[Top][All Lists]

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

Re: Initial pen position in freetype?

From: Derek Nylen
Subject: Re: Initial pen position in freetype?
Date: Tue, 21 Jul 2020 10:13:10 -0700

The way I approached this is:

1) The “pen” starts at 0,0

2) Spin through the text, collecting a list of glyphs and glyph metrics - you 
can do any fancy layout you want here

3) Spin through the glyphs, get their bounding boxes, and calculate the bounds 
of the whole text, and thus the size of the necessary image

4) Spin through the glyphs again and raster them to the image.

The main thing to note is that the coordinate system of the glyphs is not the 
same as the coordinate system of the image. The origin and xMin + yMax of the 
combined bounding box gives you the offset needed to translate between the two.

Hope that helps.

— Derek

> On Jul 21, 2020, at 1:47 AM, Andrew Tomazos <> wrote:
> On Tue, Jul 21, 2020 at 6:14 PM Lawrence D'Oliveiro <>
> wrote:
>> On Tue, 21 Jul 2020 17:48:38 +1000, Andrew Tomazos wrote:
>>> In FreeType Glyph Conventions / V it says:
>>> <quote>
>>> Writing simple text strings
>>> ...
>> All I can say is, don’t do that. Use FreeType for what it’s good at:
>> imaging individual glyphs, and giving you information about
>> associated character mappings, metrics etc. For anything more than
> that, use a proper graphics library. I have used Cairo a lot for its
>> useful 2D graphics capabilities and basic text rendering. For more
>> advanced text layout (OpenType font features and bidirectional text),
>> HarfBuzz and FreeBidi are handy additions to the mix.
> Thanks for your advice, but it doesn't answer my question.  Please review
> my initial post.  What combination of metrics should be used to set the
> initial pen position appropriately?  ie How far below and to the right of
> the upper left corner of a text box should the origin of the first
> character be?  See
> for a
> reference about glyph metrics.  An answer to my question would involve a
> pair of integer expressions in terms of the members of FT_FaceRec and/or
> FT_GlyphRec.

reply via email to

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