freetype
[Top][All Lists]
Advanced

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

Re: Initial pen position in freetype?


From: Andrew Tomazos
Subject: Re: Initial pen position in freetype?
Date: Tue, 4 Aug 2020 14:52:59 +1000

On Fri, Jul 31, 2020 at 3:20 PM Werner LEMBERG <wl@gnu.org> wrote:

>
> > For the record I ended up using as initial pen position:
> >
> >   pen.x = 0;
> >   pen.y = -face->size->metrics.ascender;
> >
> > This seems to be the appropriate minimal border to the topleft of the
> > origin of the first glyph.
>
> This is a good start for many cases, but it won't work in general.
> Let's assume that the upper left corner of your canvas is (x,y) =
> (0,0).  If I understand you correctly you want a solution that ensures
> that no ink is spilled in the range y < 0.


Not quite, no.  It's ok if there is some bleed (or clipping) of the glyphs
in some cases, this can be handled as appropriate when blitting the glyph
bitmap to the surface.  What I want is the framing of the text to be as the
font designer intended.  .ascender above the top baseline and .descender
below the bottom baseline looks right to me so far for all the fonts I've
checked.

I've also observed that FT_Load_Glyph(FT_LOAD_DEFAULT) seems to take about
80% as long as FT_Load_Glyph(FT_LOAD_RENDER) for small scales (EM:
10-20px), consequently making one pass of the glyphs calling
FT_Load_Glyph(FT_LOAD_DEFAULT) for layout and then another pass calling
FT_Load_Glyph(FT_LOAD_RENDER) takes almost twice as long as making a
singular pass calling FT_Load_Glyph(FT_LOAD_RENDER) once per glyph.  Unless
I am missing some faster way of loading the glyphs on the first layout pass?

I'm not sure I fully understand what FT_Load_Glyph(FT_LOAD_DEFAULT) is
doing under the hood that it takes almost the same amount of time
as FT_Load_Glyph(FT_LOAD_RENDER) - my profiling tools say something about
"TT_RunIns" - is that something to do with walking the font outline?  Is
there some way I can just get face->glyph->advance calculated without doing
any of the other work FT_Load_Glyph(FT_LOAD_DEFAULT) does?  advance is all
I need on a layout pass.


reply via email to

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