?
Notes from a Medium-Sized Island [entries|archive|friends|userinfo]
Jason

[ website | My Website ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

[May. 10th, 2005|05:38 pm]
Jason
[Tags|, ]

Sort of a Flash/Fontblog entry:

I have a primitive way of getting from bdf (X11 bitmap font) to sfd (Fontforge Spline Database) now.
Here's a demo of my favorite coding font, called "codon", but no relation to tom7's font of the same name. I'd like to say I thought of the name first, but I can only honestly claim to have thought of it independently.

The script used to convert it (and from the sfd version I used fontforge to emit a truetype font) follows:

#!/usr/bin/perl

use Font::BDF;

my $f = Font::BDF->new_from_bdf(\*ARGV);
my %p = $f->get_properties;
my $ascent = $p{FONT_ASCENT};
my $descent = $p{FONT_DESCENT};
my $fontname;
if ($ARGV[0]) {
 $fontname = $ARGV[0];
 $fontname =~ s/[^A-Za-z ]//g;
}
if (!length $fontname) { $fontname = "MyFont" }
my $num_chars = $f->encoded_chars;

print <<EOF;
SplineFontDB: 1.0
FontName: $fontname
Encoding: Unicode
Ascent: $ascent
Descent: $descent
BeginChars: $num_chars $num_chars
EOF

for my $enc ($f->encoded_chars) {
my ($name, $offset) = $f->get_char_info ($enc);
my ($hoff, $voff) = @$offset;
my ($pixels) = $f->get_pixels($enc);
print <<EOF;
StartChar: $name
Encoding: $enc $enc
Width: $hoff
Flags:
Fore
EOF
for (keys %$pixels) {
my ($x, $y) =  /^(.+),(.+)$/;
my ($xp, $yp) = ($x + 1, $y + 1);
print <<EOF;
$x $y m 1
$xp $y l 1
$xp $yp l 1
$x $yp l 1
$x $y l 1
EOF
}
print <<EOF;
EndSplineSet
EndChar
EOF
}

. It is probably of no use to anyone, not least because it requires my crazy BDF libraries.
LinkReply

Comments:
[User Picture]From: rjmccall
2005-05-10 11:24 pm (UTC)
That's an intriguingly creedic font; I'm not sure how you've managed it.
(Reply) (Thread)
[User Picture]From: jcreed
2005-05-11 12:27 am (UTC)
Well, I'm very fond of the two-storey "g" and "a".
(Reply) (Parent) (Thread)