freetype
[Top][All Lists]
Advanced

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

[ft] How to get Horizontal Advance on Stroked Glyph


From: johnpf74
Subject: [ft] How to get Horizontal Advance on Stroked Glyph
Date: Thu, 17 May 2012 23:21:02 -0700 (PDT)

Hello, 

I am trying to get the advance amount for a stroked glyph. I cannot find it
anywhere in the documentation. I have a code snippet below. Basically when I
do the algorithm, the advance amount is not accounting for the width of the
outline, so the next character's outline overlaps the previous character.

Any suggestions?

Thanks,
John

// set the stroker with a 3 pixel stroke
FT_Stroker_Set(stroker,
                static_cast< FT_Fixed >( 3 * 0x40),
                FT_STROKER_LINECAP_ROUND,
                FT_STROKER_LINEJOIN_ROUND,
                0);
                
FT_Glyph outlineGlyph = NULL;

// Load the glyph
FT_UInt glyphIndex = FT_Get_Char_Index( *face, chr ); 
FT_Load_Glyph( *face, glyphIndex, FT_LOAD_NO_BITMAP );
FT_Get_Glyph( (*face)->glyph, &outlineGlyph );

// stroke it
FT_Glyph_Stroke( &outlineGlyph, stroker, false );

// copy to bitmap
FT_Glyph_To_Bitmap( &outlineGlyph, FT_RENDER_MODE_NORMAL, NULL, true );
FT_BitmapGlyph outlineBitmap = (FT_BitmapGlyph)outlineGlyph;

// get metrics - chrDef is my own struct where I am storing per character
metrics
chrDef->m_bearingX = (*face)->glyph->metrics.horiBearingX >> 6;
chrDef->m_bearingY = (*face)->glyph->metrics.horiBearingY >> 6;

// ???? this advance does not account for extra width of outline in advance
chrDef->m_advance = (*face)->glyph->metrics.horiAdvance >> 6;
// I also tried this and got similar results
//chrDef->m_advance = outlineGlyph->advance.x >> 16;

FT_Glyph interiorGlyph = NULL;
FT_Load_Glyph( *face, glyphIndex, FT_LOAD_NO_BITMAP );
FT_Get_Glyph( (*face)->glyph, &interiorGlyph );
FT_Glyph_To_Bitmap( &interiorGlyph, FT_RENDER_MODE_NORMAL, NULL, true );


-- 
View this message in context: 
http://old.nabble.com/How-to-get-Horizontal-Advance-on-Stroked-Glyph-tp33868633p33868633.html
Sent from the Freetype - User mailing list archive at Nabble.com.




reply via email to

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