Re: Comparion of LogicalFontInstance::ImplGetGlyphBoundRect() between platforms

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

 



On 16 Oct 2022, at 9:03 am, Chris Sherlock <chris.sherlock79@xxxxxxxxx> wrote:



On Sun, Oct 16, 2022 at 2:07 AM Caolán McNamara <caolanm@xxxxxxxxxx> wrote:
On Sat, 2022-10-15 at 22:13 +1100, Chris Sherlock wrote:
> So an update… after I shifted to using Liberation Sans as the font
> face and added gb_CppunitTest_use_more_fonts the only platform that
> varies is MacOS.
>
> Test name: VclLogicalFontInstanceTest::testglyphboundrect
> equality assertion failed
> - Expected: 7x9@(0,-8)
> - Actual  : 7x10@(0,-8)

And what if you use a larger font size. say font size 110 instead of
11, maybe its a hinting related thing.

Just tried, looks like it is out by 1.

Test name: VclLogicalFontInstanceTest::testglyphboundrect
equality assertion failed
- Expected: 51x82@(7,-80)
- Actual  : 51x83@(7,-80)

I’ve had another look at the code, with some help from Khaled. The issue is the way in which we do our final rounding. 

On Freetype, it uses 26.6 fixed point, and thus needs it’s own special FreeType ceil and floor functions. CoreText appears to using floating point, but the std::ceil and std::floor functions give slight different results. 

I am confused why this might be… does anyone have any ideas?

FWIW, the reasoning for using 26.6 in Freetype can be found here: https://lists.nongnu.org/archive/html/freetype/2002-09/msg00076.html

The floor and ceiling functions used are defined here:

https://gitlab.com/freetype/freetype/-/blob/master/include/freetype/internal/ftobjs.h#L91

And the control box function that gets the bounding box is FT_Glyph_Get_CBox(), which can be found here:

https://gitlab.com/freetype/freetype/-/blob/master/src/base/ftglyph.c#L733

We basically copied the ceil and floor used in Freetype in an attempt to get CoreText as close as possible to FreeType. It’s a pity it is off by 1 in many cases… would love it if something with more knowledge than me can see why this differs!

I’ve written a utility to get the bounding boxes of all the glyphs of a particular font, incidentally. It can be found here:

https://gerrit.libreoffice.org/c/core/+/141526

Chris


[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux