On Mon, Jul 11, 2011 at 1:48 AM, Werner LEMBERG <[email protected]> wrote:

>
> > > I've been working on a bug for webkit related to an odd behavior
> > > with the Ahem font in the Qt framework.  I tracked it down to Qt
> > > either receiving incorrect descent/ascent values from
> > > FT_Size_Metrics or using the Freetype library incorrectly.
> >
> > > When using FT_Set_Char_Size(face, width, height, h_res, v_res),
> > > should face->size->metrics have the proper values for all font
> > > types afterwards or is it necessary for Qt to handle knowing
> > > truetype fonts use ((TT_Size)face->size)->root.metrics instead?
>
> BTW, right after a call to FT_Set_Char_Size, `face->size->metrics' and
> `(TT_Size)face->size)->root.metrics' point to the same object...  You
> probably mean something different?
>

My mistake, I meant ((TT_Size)face->size)->metrics has different values than
face->size->metrics.  The way it is currently, the only way to get to the
tt_size_reset values are to cast to TT_Size.  The metrics there are correct,
the root.metrics are the values before executing tt_size_reset.


>
> > > If face->size->metrics is supposed to have proper values after
> > > calling FT_Set_Char_Size, then there is a bug in either
> > > ttdriver.c or ttobjs.c.
> > >
> > > ttdriver.c line 248:
> > >     if ( FT_IS_SCALABLE( size->face ) )
> > >       error = tt_size_reset( ttsize );
> > > will need to copy ttsize->metrics over to ttsize->root.metrics
> > >
> > > or
> > >
> > > ttobjs.c line 1057:
> > >     metrics = &size->metrics;
> > > will need to be
> > >     metrics = &size->root.metrics;
> > >
> > > are some potential fixes.
>
> This is a difficult issue.  The question is what `proper values'
> actually mean.  From the documentation for FT_Size_Metrics:
>
>  Note that due to glyph hinting, these values might not be exact for
>  certain fonts.  Thus they must be treated as unreliable with an
>  error margin of at least one pixel!
>
> Normally, FreeType does grid-fitting of metrics (cf. the stuff guarded
> by the GRID_FIT_METRICS macro in ftobjs.c's
> ft_recompute_scaled_metrics) using FLOOR and CEIL if hinting is
> requested for, regardless of the font format.  For TrueType fonts,
> this gets replaced internally with ROUND if the font asks for it (in
> tt_size_reset).  This explains the one-pixel difference you experience
> sometimes.
>
> Mhmm.  Perhaps the rounding code in `tt_size_reset' should be executed
> only if GRID_FIT_METRICS is undefined?  The metrics values actually
> *are* already rounded to integers...
>
> Chia-I, can you comment also?
>
>
>    Werner
>
_______________________________________________
Freetype-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/freetype-devel

Reply via email to