freetype
[Top][All Lists]
Advanced

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

[ft] How to render glyphs with baseline offset


From: pvh1987
Subject: [ft] How to render glyphs with baseline offset
Date: Fri, 15 Mar 2013 10:12:02 -0700 (PDT)

Since the support for text drawing is very limited in a wxWidgets Device
Context (simple pixel-based drawing area), I need to use another library to
render the text. I stumbled across FreeType, which seem to be the leading
open-source font rendering engine. However, I find the library totally NOT
intuitive, since I am a C++ developer and not very used to low level C
libraries.

I want to render some kind of single line, rotated "rich text" onto the
wxWidgets Device Context. So, I followed the tutorial at
http://www.freetype.org/freetype2/docs/tutorial/step1.html and I am now at
"c. More advanced rendering". I somehow managed to make my own
"my_draw_bitmap" function that actually works - it took me very long to do
and as with the rest of the tutorial, there is a whole lot of "guessing" in
order to make things work. However, finally it works! It will draw rotated
text as well - I am impressed.

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.

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.

Thanks in advance :-)
-- 
View this message in context: 
http://old.nabble.com/How-to-render-glyphs-with-baseline-offset-tp35179767p35179767.html
Sent from the Freetype - User mailing list archive at Nabble.com.




reply via email to

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