freetype
[Top][All Lists]
Advanced

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

[Freetype] Some probably very simple questions


From: Huw D M Davies
Subject: [Freetype] Some probably very simple questions
Date: Tue, 13 Nov 2001 12:36:51 +0000
User-agent: Mutt/1.2.5i

Hi,

Firstly thanks very much for putting so much time and energy into
developing FreeType.  It's certainly most appreciated.

I'm using FreeType to add client side font rendering to Wine
(http://www.winehq.com); at the moment I have non-rotated text working
and I must say that it looks good.  I've got a bit stuck when it comes
to rendering rotated text however and I wonder if you could help me
out.

What I have at the moment is a function that returns the bearings,
bitmap size and advance width and optionally renders the glyph bitmap
into a caller supplied buffer (actually I'm rewriting the win32 api
GetGlyphOutline).  The idea is the function gets called twice, first
to retrieve the bitmap metrics, the caller can then alloc enough
memory for the bitmap and call the function again to actually get the
bitmap.

It looks something like this.  (for monochrome bitmaps).


FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT);
width = face->glyph->metrics.width >> 6;
height = face->glyph->metrics.height >> 6;
originx = face->glyph->metrics.horiBearingX >> 6;
originy = face->glyph->metrics.horiBearingY >> 6;
advanceX = face->glyph->metrics.horiAdvance >> 6;
advanceY = 0;

pitch = (width + 31) / 32 * 4; /* Win bitmaps are dword aligned */
bytes_needed = pitch * height;

if(only_want_metrics) return width, height, origin*, advance* and bytes_needed;

ft_bitmap.width = width;
ft_bitmap.rows = height;
ft_bitmap.pitch = pitch;
ft_bitmap.pixel_mode = ft_pixel_mode_mono;
ft_bitmap.buffer = caller_supplied_buffer;

FT_Outline_Translate(&face->glyph->outline,
        - face->glyph->metrics.horiBearingX,
        - (face->glyph->metrics.horiBearingY -
                face->glyph->metrics.height));

FT_Outline_Get_Bitmap(library, &face->glyph->outline, &ft_bitmap);


Is this a sensible way to do this?  And how do I extend this to
generate rotated glyphs.  i.e How would I determine the width and
height of the required bitmap?

Thanks for any help that you can provide.

Huw.




reply via email to

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