BDF to Apple bitmap-only dfont, wrong line height

View: New views
7 Messages — Rating Filter:   Alert me  

BDF to Apple bitmap-only dfont, wrong line height

by Tobia Conforto :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello

I'm trying to convert my favorite Linux programming/console font (misc  
fixed 9x18) to a format usable by native OS X applications, but I'm  
running into a problem with the line height of the converted font.

I downloaded the source bdf files from the website of the original  
designer: http://www.cl.cam.ac.uk/~mgk25/ucs-fonts.html

Then I opened 9x18.bdf into Fontforge and tried a simple Generate  
Fonts, saving the font as an Apple bitmap-only .dfont file (and "No  
outline font" selected.)

The process mostly succeeded, as I can now select the font in OS X  
applications, but the line height is not right.

The original font is a monospaced 9x18 bitmap, with a line-height of  
exactly 18 pixels.  But the generated dfont seems to be rendered by  
all programs with 4px of additional ascent.  I'm not sure about the  
terminology, I mean that the 9x18 glyphs are rendered at the bottom of  
a 9x22 grid.  I checked this by looking at some inverted text in the  
terminal.

In some OS X applications, such as Terminal, I can override the line  
height.  Setting this to 0.80 masks the problem, as ceil(22 * .8) =  
18, but it doesn't help with other apps.

Does anybody have any idea about what is causing this behaviour and  
how can I fix it?


Tobia

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Fontforge-users mailing list
Fontforge-users@...
https://lists.sourceforge.net/lists/listinfo/fontforge-users

Re: BDF to Apple bitmap-only dfont, wrong line height

by Tobia Conforto :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Here's a followup:

If I open 9x18.bdf and clear (Edit/Clear) every glyph except ASCII  
(00-7f), the exported .dfont has the correct line-height (18px)

If I leave even one non-ASCII glyph (for example à, agrave), the  
exported .dfont has the wrong line-height (24px)

If I "touch" that glyph, by setting a pixel somewhere and then  
unsetting it, the .dfont is once again correct.

It would appear that in the original font all non-ASCII glyphs have  
something stuck on them (a bounding box value, or something to that  
effect?) that pushes the line-height to 24px.  It seems to me that it  
can be recomputed, and thus fixed, by simply touching the glyphs.


Any idea how can I make Fontforge recompute that value, whatever it  
is, without manually touching thousands of glyphs?


Tobia
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Fontforge-users mailing list
Fontforge-users@...
https://lists.sourceforge.net/lists/listinfo/fontforge-users

Re: BDF to Apple bitmap-only dfont, wrong line height

by Tobia Conforto :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> I'm trying to convert my favorite Linux programming/console font  
> (misc fixed 9x18) to a format usable by native OS X applications,  
> but I'm running into a problem with the line height of the converted  
> font.
>
> The original font is a monospaced 9x18 bitmap, with a line-height of  
> exactly 18 pixels.  But the generated dfont seems to be rendered by  
> all programs with 4px of additional ascent.

I tried, unsuccessfully, to get at the root of the problem by  
comparing BDF and SFD files.

After that I generated two compiled versions (Apple bitmap only dfont)  
one that works, but is a subset of Latin-1, and one that covers all  
Latin-1 codepoints but exhibits the line-height problem.

I compared the values inside the font, with the help of a hex editor  
and the TTF reference[1], but I still can't figure out what's going  
wrong.

Both files have a single bitmap stroke, 18.  Both files have a  
hori(zontal) sbitLineMetrics (in table 'bloc') with ascender=14,  
descender=-4, maxBeforeBL=14, and minAfterBL=-4.  14 minus -4 is  
clearly equal to 18, so I really can't see where the 24 line-height is  
coming from.

You can find the two compiled fonts here[2], along with my analysis of  
the 'bloc' table.

I will be grateful for any help in solving this problem, or in finding  
a workaround.


Tobia

[1] http://developer.apple.com/textfonts/TTRefMan/
[2] http://gruppo4.com/~tobia/osx-font-problem.zip

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Fontforge-users mailing list
Fontforge-users@...
https://lists.sourceforge.net/lists/listinfo/fontforge-users

Re: BDF to Apple bitmap-only dfont, wrong line height

by George Williams :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sorry to be so long in getting back to you. I'm afraid I can't be much
help.

On Wed, 2008-01-30 at 04:56, Tobia Conforto wrote:
> It would appear that in the original font all non-ASCII glyphs have  
> something stuck on them (a bounding box value, or something to that  
> effect?) that pushes the line-height to 24px.  It seems to me that it  
> can be recomputed, and thus fixed, by simply touching the glyphs.
If the bounding box is too big, then saving to a dfont will call a
routine to crop any extraneous whitespace. I can't imagine what a manual
touch would do that this would not. However...
  Doing a "Select All" in the fontview and then
  Transform -> Move 0,0 [OK]
  should mark every bitmap glyph as touched.
On Sun, 2008-02-03 at 08:34, Tobia Conforto wrote:
> Both files have a single bitmap stroke, 18.  Both files have a  
> hori(zontal) sbitLineMetrics (in table 'bloc') with ascender=14,  
> descender=-4, maxBeforeBL=14, and minAfterBL=-4.  14 minus -4 is  
> clearly equal to 18, so I really can't see where the 24 line-height is  
> coming from.
Nor can I. Apple's bitmap font format isn't really documented.

As far as I can tell, the metrics for the glyphs themselves are correct
with an 18pixel height.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Fontforge-users mailing list
Fontforge-users@...
https://lists.sourceforge.net/lists/listinfo/fontforge-users

Re: BDF to Apple bitmap-only dfont, wrong line height

by Tobia Conforto :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

George Williams wrote:
> If the bounding box is too big, then saving to a dfont will call a  
> routine to crop any extraneous whitespace. I can't imagine what a  
> manual touch would do that this would not. However... Doing a  
> "Select All" in the fontview and then Transform -> Move 0,0 [OK]  
> should mark every bitmap glyph as touched.

Alas, I was wrong. This changes nothing.
Thanks for looking into it though.

So then... what other software exists that can write Apple bitmap  
fonts?  Is there an Apple-sanctioned utility or library to do it?  Or  
is Apple reserving the right to create bitmap fonts?  I guess I'll ask  
on an Apple mailing list.


Tobia

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Fontforge-users mailing list
Fontforge-users@...
https://lists.sourceforge.net/lists/listinfo/fontforge-users

Re: BDF to Apple bitmap-only dfont, wrong line height

by George Williams :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, 2008-02-15 at 06:32, Tobia Conforto wrote:
> Alas, I was wrong. This changes nothing.
> Thanks for looking into it though.
>
> So then... what other software exists that can write Apple bitmap  
> fonts?  Is there an Apple-sanctioned utility or library to do it?  Or  
> is Apple reserving the right to create bitmap fonts?  I guess I'll ask  
> on an Apple mailing list.
Apple's bitmap only sfnts were designed for the Newton. They do WORK on
the Mac. I don't know whether there are any tools for them.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Fontforge-users mailing list
Fontforge-users@...
https://lists.sourceforge.net/lists/listinfo/fontforge-users

Re: BDF to Apple bitmap-only dfont, wrong line height

by Tobia Conforto :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

George Williams wrote:
> Apple's bitmap only sfnts were designed for the Newton. They do WORK  
> on the Mac. I don't know whether there are any tools for them.


I just tried to convert the same font with a trial version of  
BitFonter 3.0, a $500 commercial bitmap font editor, and it shows the  
same exact bug as Fontforge!

So I guess it's either a bug in OS X or a weird setting in the  
original BDF font.

The fonts are displayed the same way in both OS X 10.4 and 10.5


Tobia

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Fontforge-users mailing list
Fontforge-users@...
https://lists.sourceforge.net/lists/listinfo/fontforge-users