[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Freetype] aligning glyphs from different fonts
From: |
John Hunter |
Subject: |
[Freetype] aligning glyphs from different fonts |
Date: |
Sun, 22 Feb 2004 10:54:40 -0600 |
User-agent: |
Gnus/5.090013 (Oort Gnus v0.13) Emacs/21.2 (i686-pc-linux-gnu) |
I want to draw glyphs from several different font faces to a bitmap
image (sample bitmap rendering code below). I pass in x and y to the
function code below to place the glyph in the bitmap. I would like
the fonts to have a common vertical origin, so that glyphs from one
face appear to be on the same line as glyphs from the other.
Right now I am working with two font files (ftdump info below). The
font files share many of the same properties: type, direction, and EM
size. The differ, however, in their ascender, descender and
text_height, mainly in their descender and text_height. The glyphs
from the font with the large height and low descender are appearing
too low in the rendered bitmap with respect to the glyphs from the
other font. Currently, I'm passing in a fixed y and incrementing x by
advance.x; I assume I need to modify y by one of the global font
metrics.
Pointers to docs or examples appreciated.
Thanks,
John Hunter
freetype-2.1.3
sample code
error = FT_Glyph_To_Bitmap(&self->glyphs[glyph->glyph_num],
FT_RENDER_MODE_NORMAL,
0, //no additional translation
0 //don't destroy image
);
//handle error
FT_BitmapGlyph bitmap = (FT_BitmapGlyph)self->glyphs[glyph->glyph_num];
draw_bitmap( &bitmap->bitmap,
&self->image,
x + bitmap->left,
y-bitmap->top);
ftdump
hunter:~/src/ft2demos-2.1.3/bin> ./ftdump ~/src/ttf/cmmi10.ttf
There is 1 face in this file.
----- Face number: 0 -----
font name entries
family: cmmi10
style: Regular
postscript: Cmmi10
font type entries
FreeType driver: truetype
sfnt wrapped: yes
type: scalable
direction: horizontal
fixed width: no
glyph names: yes
EM size: 2048
global BBox: (-70,-512):(2146,1536)
ascent: 1444
descent: -440
text height: 2167
charmaps
0: platform: 1, encoding: 0
1: platform: 3, encoding: 1
hunter:~/src/ft2demos-2.1.3/bin> ./ftdump ~/src/ttf/cmex10.ttf
There is 1 face in this file.
----- Face number: 0 -----
font name entries
family: cmex10
style: Regular
postscript: Cmex10
font type entries
FreeType driver: truetype
sfnt wrapped: yes
type: scalable
direction: horizontal
fixed width: no
glyph names: yes
EM size: 2048
global BBox: (-49,-6062):(2978,1581)
ascent: 1581
descent: -6082
text height: 8812
charmaps
0: platform: 1, encoding: 0
1: platform: 3, encoding: 1
hunter:~/src/ft2demos-2.1.3/bin>
- [Freetype] aligning glyphs from different fonts,
John Hunter <=