freetype
[Top][All Lists]
Advanced

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

Re: [ft] How to render glyphs with baseline offset


From: Werner LEMBERG
Subject: Re: [ft] How to render glyphs with baseline offset
Date: Sat, 16 Mar 2013 08:36:06 +0100 (CET)

> However, I find the library totally NOT intuitive, since I am a C++
> developer and not very used to low level C libraries.

Suggestions for improvements of the documentation (or even patches)
are highly welcomed!

> So, now, here is my main problem at the moment: When I set the pen
> coordinates like this:
>
>   pen.x = posx*64;
>   pen.y = (height-posy)*64;
>
> where (posx, posy) are the pixel coordinates on the wxDC and height
> are the font size (in points!), the text is drawed so the leftmost
> point on the baseline of the first glyph is at (posx, posy).
> Instead, I would like it to draw the text so (posx, posy) is the
> upper-left point of the bounding box of the font face.  And rotation
> has to be around this point as well.  How can I do that?  I spent
> hours, hours and hours to make some kind of offset to pen.y, but it
> is never just right when taking different DPI's and rotation into
> account.

The only solution is to get an exact bbox of a character string is to
let FreeType compute all outlines at the given ppem value (this data
should be cached).  I strongly recommend to use a higher-level library
like Harfbuzz which does this job for you, and which also takes care
of advanced typographical stuff.

> My second question is, to render single line, rotated "rich text",
> that is text that is using different font faces (normal, italic),
> different weight (regular, bold), underline, overline, subscript and
> superscript, can I use FreeType to do this directly?  If not, I
> guess it can do the job, but I will do better (and faster) with a
> library that already supports this. So, what library is that?  It
> has to be cross-platform (Windows, Mac OS X, Linux and so on) and of
> course, well supported and easy to use.

Again: Harfbuzz.  You will be certainly delighted to hear that there
is *no* documentation yet of this library :-) However, its demo and
test programs are written in C++.


    Werner



reply via email to

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