Re: [ft] Freetype 2.4.4 -> freetype 2.4.12: FT_Get_Advance changed behaviour?

2013-06-03 Thread Gregor Mückl

On 6/3/2013 9:05 AM, Werner LEMBERG wrote:



I've reduced my code to the attached program (which is still a bit
convoluted - sorry!).  [...]


Thanks.  There was a serious bug in FT_Get_Advance which has been
fixed in version 2.4.9: According to the documentation, the returned
advance value is either in 16.16 format or in font units.  Before the
fix this was true only if it was possible to quickly retrieve the
advance value, which is not the case for hinted TT fonts.  You
probably hadn't noticed that you circumvented the bug by using the
26.6 format, together with undoing the wrong double scaling,
right? :-)

The fix is rather simple (see below) if you want to stay with
computing everything in 26.6 format.


 Werner



Thank you very much for looking into this! The suggested fix works 
nicely. I vaguely recall that I was fiddling with this scaling when I 
originally wrote this code because it was behaving wrong in *some* way. 
But I must have been very tired to not figure out that something was 
amiss here :).


I looked at the documentation for FT_Get_Advance again. I'm using 
FT_LOAD_DEFAULT as flags, but the return value is in a 16.16 scaling. 
Yet, the documentation states:


"By default, the unhinted advance is returned in font units."

To me, this reads like a (probably unwanted) contradiction to the actual 
behaviour. I suggest something like the following instead:



"The returned advance depends on whether scaling is performed (based on 
the value of flags). If scaling is performed, the advance is in 16.16 
format. Otherwise, it is in font units."


Regards,
Gregor


___
Freetype mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/freetype


Re: [ft] Freetype 2.4.4 -> freetype 2.4.12: FT_Get_Advance changed behaviour?

2013-06-03 Thread Werner LEMBERG

> I've reduced my code to the attached program (which is still a bit
> convoluted - sorry!).  [...]

Thanks.  There was a serious bug in FT_Get_Advance which has been
fixed in version 2.4.9: According to the documentation, the returned
advance value is either in 16.16 format or in font units.  Before the
fix this was true only if it was possible to quickly retrieve the
advance value, which is not the case for hinted TT fonts.  You
probably hadn't noticed that you circumvented the bug by using the
26.6 format, together with undoing the wrong double scaling,
right? :-)

The fix is rather simple (see below) if you want to stay with
computing everything in 26.6 format.


Werner


==


--- textlayouttext.cpp.orig 2013-06-03 08:59:04.0 +0200
+++ textlayouttext.cpp  2013-06-03 08:59:28.0 +0200
@@ -148,7 +148,7 @@
// get character width of current character
_TL_ActivateFontSize(glyphs[i].font,glyphs[i].size);

FT_Get_Advance(TL_Globals.fonts[glyphs[i].font].face,glyphs[i].glyph,FT_LOAD_DEFAULT,&advance);
-   
advance=(FT_Fixed)(64*advance/(float)TL_Globals.fonts[glyphs[i].font].face->size->metrics.x_scale);
+   advance>>=10;
width+=advance;
 
// check whether this is the first character in the string/line
___
Freetype mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/freetype


Re: [ft] Freetype 2.4.4 -> freetype 2.4.12: FT_Get_Advance changed behaviour?

2013-06-02 Thread Werner LEMBERG

> I've upgraded a project of mine from using freetype 2.4.4 to
> freetype 2.4.12 and now I experience totally broken text layouting
> (the layouting code is my own).  Horizontal spacings between
> characters are now either far too large or far too small, depending
> on the font.  In one case the glyph distances are at least double
> what they should be.  None of the tested fonts give anything close
> to believable reasults.  Linking against the old version of freetype
> without any further code changes fixes this issue.  [...]

Maybe a bug.  I can't see anything strange within your code.

Can you provide a minimum stand-alone example written in C which
exhibits the problem, and which I can compile and debug on my
GNU/Linux box?  If necessary, please send the offending font privately
to me.


Werner

___
Freetype mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/freetype