freetype
[Top][All Lists]
Advanced

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

[ft] FreeType glyph sizing trouble


From: stoneMcClane
Subject: [ft] FreeType glyph sizing trouble
Date: Thu, 3 Mar 2011 13:42:18 +0100

Hi,

I have previously rendered font glyphs extracted from an SWF file in a program of mine, now I wanted to integrate FreeType as an alternative to directly load fonts from TTF files.
Sadly I've got some trouble when it comes to correctly scaling & aligning the parsed glyphs...

This is what some sample text looks like when being parsed from SWF (top) vs. FreeType (bottom): http://imgur.com/djfGL

As you can see the FeeType text is a good bit bigger than the SWF one (it's the very same font though).
SWF does define its glyphs in a 1024 x 1024 EM square, what I'm very unsure about is how I'd set the FreeType scaling to match this EM square constraints.

This is my FreeType code so far...

FT_Outline_Funcs outline_funcs = { moveTo, lineTo, conicTo, cubicTo, 0, 0 }; // what should I be doing to get the correct scaling here ? Should I use one of the other FT_Request/Size methods instead ? FT_Set_Pixel_Sizes(face, 1000, 1000); mEmSize = face->units_per_EM; FontResource* font = new FontResource(face->family_name); font->setName(face->family_name); font->setAscender(face->ascender / mEmSize); font->setDescender(face->descender / mEmSize); font->setLeading((face->ascender - face->descender - face->units_per_EM) / mEmSize); uint glyph_idx = 0; for(uint i=32; i<127; ++i) { mCurrentGlyph = new GlyphResource(font); uint glyph_index = FT_Get_Char_Index(face, i); error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT); error = FT_Outline_Decompose(&face->glyph->outline, &outline_funcs, this); mCurrentGlyph->setIndex(glyph_idx); mCurrentGlyph->setAdvance(face->glyph->advance.x / mEmSize); mCurrentGlyph->setCode(i); font->addGlyph(mCurrentGlyph); ++glyph_idx; }

The 1000 at FT_Set_Pixel_Sizes that I used is just a random value since I recognized that I have to set some kind of size before I can actually load glyphs.
How would I set the correct size to get the exact same glyphs that I get from SWF (which uses the mentioned 1024 EM square) ???

Many thanks for any help,
Wolfgang Steiner

reply via email to

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