[squeak-dev] Cuis font sizes
amtween at hotmail.com
Sun Aug 30 18:28:01 UTC 2009
I think the problem with the size discrepency results from the scaling factor used in TTCFont computeForm:
FreeType divides the pixel size by the units per em , but TTCFont divides by (ttcDescription ascender - ttcDescription descender).
Try making TTCFont>>computeForm: use the unitsPerEm value instead, it appears to give the correct size glyphs. i.e. ...
| ttGlyph scale |
scale := self pixelSize asFloat / ttcDescription unitsPerEm.
Scale ifNotNil: [scale := Scale * scale].
This is from the FreeType manual page http://freetype.sourceforge.net/freetype2/docs/glyphs/glyphs-2.html ...
In creating the glyph outlines, a type designer uses an imaginary square called the EM square. Typically, the EM square can be thought of as a tablet on which the characters are drawn. The square's size, i.e., the number of grid units on its sides, is very important for two reasons:
It is the reference used to scale the outlines to a given text dimension. For example, a size of 12pt at 300x300 dpi corresponds to 12*300/72 = 50 pixels. This is the size the EM square would appear on the output device if it was rendered directly. In other words, scaling from grid units to pixels uses the formula:
pixel_size = point_size * resolution / 72
pixel_coord = grid_coord * pixel_size / EM_size
Line spacing is a separate issue; it is there that the ascender, descender, and other vertical metrics become important .
> Date: Fri, 28 Aug 2009 20:22:19 -0700
> From: andreas.raab at gmx.de
> To: squeak-dev at lists.squeakfoundation.org
> Subject: [squeak-dev] Cuis font sizes
> Hi Juan -
> This is mostly to Juan but others might be able to help as well. I
> noticed that the Cuis fonts disagree in their pixel sizes significantly
> with that we get from the plain DejaVu true type fonts in Squeak. A bit
> of math reveals that at the (assumed) screen resolution of 96dpi a 12pt
> font should result in 16px high font (12*96/72 see Eqn. 3 in ). The
> corresponding Bitmap DejaVu 12pt font, however, is 19px high which would
> mean a screen resolution of 114dpi (19*72/12).
> Is this choice intentional? Unfortunately, none of the pixel sizes for
> Bitmap DejaVu correspond exactly to a point size when assuming 96dpi.
> The reason this is causing me grief is that I am trying to set up a
> mechanism for allowing people to drop the DejaVu fonts into their images
> and have any glyphs not part of the cuis fonts rendered in DejaVu
> truetype instead. I can probably get the truetype rendering to spit out
> a precise pixel size to match it but I think it'd be good if we had
> clarity on how these pixel sizes came into being.
> Any insights appreciated!
> - Andreas
>  http://www.emdpi.com/emsquare.html
View your other email accounts from your Hotmail inbox. Add them now.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Squeak-dev