freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ft-devel] Arial/Times ldot hinting


From: Nigel Tao
Subject: [ft-devel] Arial/Times ldot hinting
Date: Fri, 6 Dec 2013 09:53:12 +1100

I'm working on a Freetype port to the Go programming language. One of
my compatibility tests compares my output (at the glyph point level,
not of rasterized pixels) of hinted glyphs with C Freetype's. I note
that on Arial_Bold.ttf glyph #274 "ldot", C Freetype's hinted output
looks off to me. This is a trivial glyph: the first screenshot
attached shows that it is composed of two rectangles, each of four
points. My C Freetype program [0] to print the glyph points says for
Arial_Bold glyph #274 at 11 ppem:

-1 0 1, -1 512 1, 127 512 1, 127 0 1, 192 256 1, 192 384 1, 320 384 1, 320 256 1

The way to read it this output is that there are 8 glyph points. Each
triple is (x y o) where x and y are obviously the co-ordinates and o
is whether the point is on or off the curve. The 'ldot' glyph is a
composite glyph, obviously composing an 'l' and a 'dot'. Note that the
first four points (the 'l' in 'ldot') are 'off-grid' by -1 in the x
direction, in that their x co-ordinates are not a perfect multiple of
64. The 'dot' part is 'on-grid'.

Times New Roman glyph #274 "ldot" at 13 ppem is similarly off by -3,
although that's not as trivially obvious just from the print-out:

125 576 1, 125 128 1, 125 96 0, 136 75 0, 158 64 0, 189 64 1, 189 0 1,
-3 0 1, -3 64 1, 27 64 0, 49 74 0, 61 96 0, 61 128 1, 61 384 1, 61 426
0, 55 445 0, 42 454 0, 32 454 1, 21 454 0, 4 448 1, -3 512 1, 107 576
1, 224 320 1, 237 320 0, 256 301 0, 256 288 1, 256 275 0, 237 256 0,
224 256 1, 211 256 0, 192 275 0, 192 288 1, 192 301 0, 211 320 0

The second and especially the third screenshots attached should give
visual confirmation that the 'l' part of the 'ldot' is off-grid.

I don't know if the patch below to the C Freetype code matches e.g.
Microsoft's hinting code, but it does change these two 'ldot' hinted
glyphs to snap to the grid. Furthermore, it changes no other hinted or
unhinted glyphs out of my test set:

Adobe Source Sans Pro Bold Italic at 10 ppem
Adobe Source Sans Pro Regular at 14 ppem
Arial Bold at 11 ppem
Comic Sans at 10 ppem
DejaVu Sans Oblique at 17 ppem
Droid Sans Japanese at 9 ppem
Times New Roman at 13 ppem

What are freetype-devel's thoughts?

========
$ git diff
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index 2c2bea5..de40cfb 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -760,7 +760,10 @@
     origin = zone->cur[zone->n_points - 4].x;
     origin = FT_PIX_ROUND( origin ) - origin;
     if ( origin )
-      translate_array( zone->n_points, zone->cur, origin, 0 );
+      translate_array(
+        is_composite ? 4 : zone->n_points,
+        zone->cur + (is_composite ? (zone->n_points - 4) : 0),
+        origin, 0 );

 #ifdef TT_USE_BYTECODE_INTERPRETER
     /* save original point position in org */
========

[0] 
https://code.google.com/p/freetype-go/source/browse/cmd/print-glyph-points/main.c

Attachment: ldot-arial-bold-11.png
Description: PNG image

Attachment: ldot-times-13.png
Description: PNG image

Attachment: ldot-times-13-zoom.png
Description: PNG image

Attachment: ttgload.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]