0

I abandoned my efforts to rasterize TTF on my own since I don't want to do hinting, so I turned to Windows's method... And I think I found a bug.

I used Windows's DrawText function and in the left column are GLYPHMETRICS structures loaded with GetGlyphOutline:

    SetRect(&rect, 10,0,5,5);
    SetTextColor(glyph_hdc, RGB(255,0,0));
    DrawText(glyph_hdc, TEXT("A"), -1,&rect, DT_NOCLIP);
    ...
    SetRect(&rect, 70,0,5,5);
    SetTextColor(glyph_hdc, RGB(255,0,0));
    DrawText(glyph_hdc, TEXT("!"), -1,&rect, DT_NOCLIP);


GetGlyphOutlineA(glyph_hdc, ascii_code, GGO_BITMAP, &glyph_metric_A, 10000, win_bitmap, &m2);

I used gray 2x1 rectangles in Adobe Illustrator to measure distances... enter image description here

I hope that the picture illustrates well the apparent bug: The BlackBoxX and BlackBoxY should be enclosing the glyph. Do you think that this is an internal bug? Do you know how to correct for this? It seems like the black box does not account for hinting.

8
  • remember to take glyph lsb (found in hmtx) and rsb (effectively quad size - glyph maxx) into consideration. Nov 12, 2019 at 18:30
  • How is it relevant? gmBlackBoxX: The width of the smallest rectangle that completely encloses the glyph (its black box). (msdn docs) Nov 12, 2019 at 18:32
  • fair point. Looking at industry-standard code that works with this (e.g. Cairo's chromium.googlesource.com/chromiumos/third_party/cairo/+/master/…), is scaling relevant to you? Nov 12, 2019 at 18:38
  • Practically, I don't think it ever matters since you probably only care about the two coordinate systems (blue and red dots) + the advancement... The widths of glyphs are bounded so you can use the max value. It might matter if you want to pack the glyphs close together.. personally, I'm not planning on that so... Nov 12, 2019 at 18:43
  • When it comes to scaling, I don't know what you mean... I only found out from here that the glyph height is a slave of the cell height, because of the hinting process. Nov 12, 2019 at 18:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.