Jason (jcreed) wrote,
Jason
jcreed

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.
Tags: flash, fonts
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 2 comments