<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">On 16 Oct 2022, at 9:03 am, Chris Sherlock <<a href="mailto:chris.sherlock79@gmail.com" class="">chris.sherlock79@gmail.com</a>> wrote:<br class=""><div><blockquote type="cite" class=""><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><br class=""></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Oct 16, 2022 at 2:07 AM Caolán McNamara <<a href="mailto:caolanm@redhat.com" class="">caolanm@redhat.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Sat, 2022-10-15 at 22:13 +1100, Chris Sherlock wrote:<br class="">
> So an update… after I shifted to using Liberation Sans as the font<br class="">
> face and added gb_CppunitTest_use_more_fonts the only platform that<br class="">
> varies is MacOS.<br class="">
> <br class="">
> Test name: VclLogicalFontInstanceTest::testglyphboundrect<br class="">
> equality assertion failed<br class="">
> - Expected: 7x9@(0,-8)<br class="">
> - Actual : 7x10@(0,-8)<br class="">
<br class="">
And what if you use a larger font size. say font size 110 instead of<br class="">
11, maybe its a hinting related thing.<br class=""></blockquote><div class=""><br class=""></div><div class="">Just tried, looks like it is out by 1. <br class=""></div><div class=""><br class=""></div><div class=""><pre class="gmail-console-output">Test name: VclLogicalFontInstanceTest::testglyphboundrect
equality assertion failed
- Expected: 51x82@(7,-80)
- Actual : 51x83@(7,-80)</pre></div></div></div>
</div></blockquote><br class=""></div><div>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. </div><div><br class=""></div><div>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. </div><div><br class=""></div><div>I am confused why this might be… does anyone have any ideas?</div><div><br class=""></div><div>FWIW, the reasoning for using 26.6 in Freetype can be found here: <a href="https://lists.nongnu.org/archive/html/freetype/2002-09/msg00076.html" class="">https://lists.nongnu.org/archive/html/freetype/2002-09/msg00076.html</a></div><div><br class=""></div><div>The floor and ceiling functions used are defined here:</div><div><br class=""></div><div><a href="https://gitlab.com/freetype/freetype/-/blob/master/include/freetype/internal/ftobjs.h#L91" class="">https://gitlab.com/freetype/freetype/-/blob/master/include/freetype/internal/ftobjs.h#L91</a></div><div><br class=""></div><div>And the control box function that gets the bounding box is FT_Glyph_Get_CBox(), which can be found here:</div><div><br class=""></div><div><a href="https://gitlab.com/freetype/freetype/-/blob/master/src/base/ftglyph.c#L733" class="">https://gitlab.com/freetype/freetype/-/blob/master/src/base/ftglyph.c#L733</a></div><div><br class=""></div><div>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!</div><div><br class=""></div><div>I’ve written a utility to get the bounding boxes of all the glyphs of a particular font, incidentally. It can be found here:</div><div><br class=""></div><div><a href="https://gerrit.libreoffice.org/c/core/+/141526" class="">https://gerrit.libreoffice.org/c/core/+/141526</a></div><div><br class=""></div><div>Chris</div><br class=""></body></html>