freetype
[Top][All Lists]
Advanced

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

Re: [ft] The fastest way to query size of a rendered bitmap


From: Daniel Plakhotich
Subject: Re: [ft] The fastest way to query size of a rendered bitmap
Date: Mon, 20 Nov 2017 14:28:21 +0200

Here is a small test program:
  https://gist.github.com/danpla/35292c7c54fc1217b81219aa442dcc37

Note that it works in two passes, which is necessary to reproduce the
issue when the size of a bitmap is bigger than cbox/bbox.
That issue also depends on the order of FT_Get_Char_Index() and/or
FT_Render_Glyph(). Unlike this test example, which renders glyphs
sequentially, my program packs cboxes first, and therefore renders
glyphs random order. As a result, giving the same range of code points
(from 1 to 0x10ffff), it reports the error for just for U+07ED,
U+07F2, U+07F3, and U+07F8.

With DejaVuSans.ttf v2.37, it gives the following output:

FreeType 2.5.2
Loading DejaVuSans.ttf at 100 pt
Checking cbox vs bbox
U+0238 bbox > cbox: {94, 77} > {89, 77}
U+035A bbox > cbox: {40, 22} > {36, 22}
U+03D1 bbox > cbox: {50, 79} > {50, 77}
U+0533 bbox > cbox: {71, 75} > {69, 75}
U+053A bbox > cbox: {71, 75} > {69, 75}
U+0540 bbox > cbox: {67, 76} > {61, 76}
U+0541 bbox > cbox: {61, 79} > {61, 78}
U+0551 bbox > cbox: {61, 79} > {61, 77}
U+0563 bbox > cbox: {61, 77} > {60, 77}
U+0566 bbox > cbox: {61, 77} > {60, 77}
U+056A bbox > cbox: {60, 79} > {60, 78}
U+056E bbox > cbox: {51, 79} > {51, 78}
U+05DB bbox > cbox: {46, 55} > {43, 55}
U+07C9 bbox > cbox: {52, 75} > {48, 75}
U+07D0 bbox > cbox: {50, 91} > {50, 75}
U+07E2 bbox > cbox: {51, 73} > {49, 73}
U+07E6 bbox > cbox: {52, 73} > {50, 73}
U+20A0 bbox > cbox: {83, 73} > {80, 73}
U+22B6 bbox > cbox: {100, 29} > {90, 29}
U+22B7 bbox > cbox: {100, 29} > {90, 29}
U+22B8 bbox > cbox: {81, 29} > {75, 29}
U+2422 bbox > cbox: {70, 78} > {66, 78}
U+25D0 bbox > cbox: {79, 78} > {77, 78}
U+25D1 bbox > cbox: {117, 78} > {77, 78}
U+25D5 bbox > cbox: {115, 80} > {77, 78}
U+25E6 bbox > cbox: {30, 31} > {30, 30}
U+25F4 bbox > cbox: {79, 78} > {77, 78}
U+25F5 bbox > cbox: {79, 78} > {77, 78}
U+2668 bbox > cbox: {70, 112} > {70, 74}
U+2686 bbox > cbox: {74, 145} > {74, 74}
U+2687 bbox > cbox: {74, 145} > {74, 74}
U+2688 bbox > cbox: {158, 145} > {74, 74}
U+2689 bbox > cbox: {76, 145} > {74, 74}
U+2747 bbox > cbox: {69, 85} > {69, 77}
U+279C bbox > cbox: {74, 52} > {72, 52}
U+2C70 bbox > cbox: {70, 77} > {64, 77}
U+2C7A bbox > cbox: {51, 61} > {51, 58}
U+A757 bbox > cbox: {63, 77} > {59, 77}
U+FB3B bbox > cbox: {46, 55} > {43, 55}
U+FB4D bbox > cbox: {44, 70} > {43, 70}
U+10308 bbox > cbox: {78, 79} > {77, 77}
U+1030F bbox > cbox: {155, 163} > {77, 77}
U+10312 bbox > cbox: {46, 76} > {45, 75}
U+1031A bbox > cbox: {39, 81} > {39, 73}

Checking bitmap vs cbox
U+00E6 bitmap > cbox: {88, 58} > {87, 58}
U+01C0 bitmap > cbox: {10, 97} > {9, 97}
U+01C1 bitmap > cbox: {30, 97} > {29, 97}
U+01C2 bitmap > cbox: {44, 97} > {43, 97}
U+01E3 bitmap > cbox: {88, 76} > {87, 76}
U+01FD bitmap > cbox: {88, 81} > {87, 81}
U+0223 bitmap > cbox: {51, 64} > {49, 64}
U+0239 bitmap > cbox: {89, 78} > {88, 78}
U+028F bitmap > cbox: {50, 55} > {49, 55}
U+0294 bitmap > cbox: {41, 76} > {40, 76}
U+0295 bitmap > cbox: {41, 76} > {40, 76}
U+0296 bitmap > cbox: {41, 75} > {40, 75}
U+02A1 bitmap > cbox: {41, 76} > {40, 76}
U+02A2 bitmap > cbox: {41, 76} > {40, 76}
U+03C9 bitmap > cbox: {70, 55} > {69, 55}
U+03CE bitmap > cbox: {70, 81} > {69, 81}
U+03D6 bitmap > cbox: {76, 57} > {75, 57}
U+03E3 bitmap > cbox: {71, 76} > {70, 76}
U+03E4 bitmap > cbox: {61, 95} > {60, 95}
U+0461 bitmap > cbox: {70, 55} > {69, 55}
U+047F bitmap > cbox: {70, 74} > {69, 74}
U+04AF bitmap > cbox: {54, 76} > {53, 76}
U+04D5 bitmap > cbox: {88, 58} > {87, 58}
U+05D0 bitmap > cbox: {49, 55} > {46, 55}
U+05D2 bitmap > cbox: {35, 55} > {34, 55}
U+05DC bitmap > cbox: {46, 73} > {43, 73}
U+05E5 bitmap > cbox: {45, 76} > {44, 76}
U+05E6 bitmap > cbox: {46, 55} > {44, 55}
U+05E7 bitmap > cbox: {55, 76} > {52, 76}
U+07ED bitmap > cbox: {10, 10} > {9, 9}
U+07F2 bitmap > cbox: {10, 10} > {9, 9}
U+07F3 bitmap > cbox: {29, 10} > {28, 9}
U+07F8 bitmap > cbox: {46, 50} > {45, 49}
U+07F9 bitmap > cbox: {46, 49} > {45, 49}
U+0EB0 bitmap > cbox: {56, 58} > {55, 60}
U+0EB1 bitmap > cbox: {56, 25} > {55, 27}
U+1F60 bitmap > cbox: {70, 80} > {69, 80}
U+1F61 bitmap > cbox: {70, 80} > {69, 80}
U+1F62 bitmap > cbox: {70, 81} > {69, 81}
U+1F63 bitmap > cbox: {70, 81} > {69, 81}
U+1F64 bitmap > cbox: {70, 81} > {69, 81}
U+1F65 bitmap > cbox: {70, 81} > {69, 81}
U+1F66 bitmap > cbox: {70, 94} > {69, 94}
U+1F67 bitmap > cbox: {70, 94} > {69, 94}
U+1F7C bitmap > cbox: {70, 81} > {69, 81}
U+1F7D bitmap > cbox: {70, 81} > {69, 81}
U+1FA0 bitmap > cbox: {70, 100} > {69, 100}
U+1FA1 bitmap > cbox: {70, 100} > {69, 100}
U+1FA2 bitmap > cbox: {70, 101} > {69, 101}
U+1FA3 bitmap > cbox: {70, 101} > {69, 101}
U+1FA4 bitmap > cbox: {70, 101} > {69, 101}
U+1FA5 bitmap > cbox: {70, 101} > {69, 101}
U+1FA6 bitmap > cbox: {70, 114} > {69, 114}
U+1FA7 bitmap > cbox: {70, 114} > {69, 114}
U+1FF2 bitmap > cbox: {70, 101} > {69, 101}
U+1FF3 bitmap > cbox: {70, 75} > {69, 75}
U+1FF4 bitmap > cbox: {70, 101} > {69, 101}
U+1FF6 bitmap > cbox: {70, 79} > {69, 79}
U+1FF7 bitmap > cbox: {70, 99} > {69, 99}
U+2375 bitmap > cbox: {70, 55} > {69, 55}

On Mon, Nov 20, 2017 at 8:54 AM, Werner LEMBERG <address@hidden> wrote:
>
>> It seems like even FT_Outline_Get_CBox() results in smaller sizes
>> when a font is opened at really big size (I tested with 100 pt at 72
>> dpi).  The bigger size, the bigger difference is, so it's not
>> possible to fix the issue by just adding 2-3 px just in case.
>>
>> Unfortunately, manual grid fitting is not a solution to my problem.
>
> C code please C code please C code please C code please :-)
>
>
>     Werner



reply via email to

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