[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Freetype] weird glyph width/heights
From: |
HaB JacKaL |
Subject: |
Re: [Freetype] weird glyph width/heights |
Date: |
Thu, 02 May 2002 20:12:55 -0400 |
From: David Turner <address@hidden>
Reply-To: address@hidden
To: address@hidden
Subject: Re: [Freetype] weird glyph width/heights
Date: Thu, 02 May 2002 22:29:09 +0200
Hello HaB,
nope, the bitmap's dimensions are in glyph->bitmap.width and
glyph->bitmap.rows
"glyph->bitmap_left" and "glyph->bitmap_top" correspond to the bitmap's
bearings
and are necessary to correctly place the bitmap relative to the current pen
position.
The "FreeType Glyph Conventions" has more information on the subject..
Nope, there are a few rules to follow to correctly place the bitmaps within
a text run.. Have a look at the "ftview" program and see how it renders
a single line of text (in the "Render_Text" function) for an example..
Cheers,
- David Turner
- The FreeType Project (www.freetype.org)
_______________________________________________
Well first...where can I find ftview? I did a search on my system, and I
don't have it. Does it come with Freetype?
Also...I am still getting strange values event after shifting right 6 bits.
Here is the code I'm working with. My rendering function is omitted to
conserve space:
static void setup_freetype(void)
{
// get setup for freetype
FT_Error ft_error;
ft_error = FT_Init_FreeType(&fontlib);
if(ft_error)
{
printf("Error initializing FreeType\n");
exit(1);
}
// load the font face
ft_error = FT_New_Face(fontlib,
"../fonts/tunga.ttf",
0,
&font1);
if(ft_error)
{
printf("Error loading font face\n");
}
// setting our character size to 16
FT_Set_Pixel_Sizes(font1, 0, 16);
}
static void draw_text()
{
FT_GlyphSlot slot = font1->glyph; // a small shortcut
FT_UInt glyph_index;
FT_Error ft_error;
int pen_x = 20;
int pen_y = 20;
int n;
int w;
int h;
// static unsigned char text[] = "[Space] pauses the rotation. [Esc]
quits.";
static char text[] = "blah";
for ( n = 0; n < 4; n++ )
{
// load glyph image into the slot (erase previous one)
ft_error = FT_Load_Char( font1, text[n], FT_LOAD_RENDER );
if (ft_error) continue; // ignore errors
w = (int )&slot->bitmap.width;
w = w >> 6;
h = (int )&slot->bitmap.rows;
h = h >> 6;
printf("bitmap w = %d, bitmap h = %d\n", w, h);
}
}
int main(int argc, char *argv[])
{
.... setup ...
setup_freetype();
draw_text();
}
The output I'm getting is this:
bitmap w = 2115978, bitmap h = 2115977
Either those aren't pixel values, I'm doing something horribly wrong, or
that's some HUGE text.
[:
Any ideas?
I worked thru part 1 of the tutorial. in fact, that's where a lot of this
code comes from. I am blitting to the screen via openGL, and I need the
size of the bitmap in order to do so.
Thanks!
-HaB
_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com