[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ft] Loading new Face and accessing glyph metrics (performance)
From: |
Werner LEMBERG |
Subject: |
Re: [ft] Loading new Face and accessing glyph metrics (performance) |
Date: |
Sun, 22 Jul 2018 07:08:22 +0200 (CEST) |
> When accessing glyph metrics after loading a new face using
> FT_New_Face vs. FT_New_Memory_Face, I get much better performance
> from FT_New_Memory_Face which I am surprised by given at this point
> the face has been loaded. I would expect loading it the first time
> from disk is slower but afterwards, accessing other glyph metrics
> should be the same between the two.
This is not surprising at all, AFAICS. To make `FT_New_Face' fast,
FreeType only loads and parses the most necessary bits from the font
file. Everything else is lazily evaluated; data are read from disk
only when needed.
> In addition, after the face has been loaded using
> FT_New_Memory_Face, I get significant performance differences when
> accessing glyph metrics between different font files. For instance,
> getting the metrics for the letter "A" from Arial.ttf is 0.08ms
> vs. 0.018ms for Segoeui.ttf vs. 0.0035ms using Anton.ttf.
This might depend on the font's bytecode. If TrueType instructions
have to be executed to get the metrics, you'll see a slow-down.
I recommended to use a cache for glyph outlines and metrics (and small
bitmaps).
> To load the glyphs, I am using FT_LOAD_COMPUTE_METRICS which I
> presume is the most efficient option if all I need is metrics for a
> given size / glyph.
You might play around with the `ftbench' tool (from the
`freetype2-demo' bundle). If you notice strange results, please post
it here, together with the exact invocation.
> I am using FreeType version 2.8.1 right now.
The current version is 2.9.1.
Werner