Sign in to follow this  

Some questions about FreeType..

This topic is 1970 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

First:
FT_Render_Glyph(face->glyph,FT_Render_Mode::FT_RENDER_MODE_NORMAL);
After that how should I get every pixel mask as RGBA..
I realy don't know how to deal with th data with FT_Bitmap.buffer...

Next:
face->glyph->metrics.width ;
face->glyph->metrics.height;
face->glyph->metrics.horiBearingX;
face->glyph->metrics.horiAdvance;
FT_Bitmap bitmap;
bitmap.rows;
bitmap.width;

I think I've understand the member data of face->glyph->metrics;
But how should I understand bitmap.rows and the width;

Then I will express my question with a picture..[attachment=10145:GAME.png]
there are tow box ( a and b ,as you can see I write it with the mouse ) bounding the charactor "a" (ingore the "M"),wicth of the box really express the FT_Bitmap?

Thanks anyway.

Share this post


Link to post
Share on other sites
The bitmap structure is box b in your image. The following six values are needed to align and render the glyph bitmaps correctly on a horizontal baseline:[list=1]
[*]glyph->bitmap.width is the width of the glyph bitmap in pixels.
[*]glyph->bitmap.height is the height of the glyph bitmap in pixels.
[*]glyph->bitmap.pitch is the size of one scanline of the glyph bitmap in bytes.
[*]glyph->left is the x-origin of the bitmap in pixels.
[*]glyph->top is the y-origin of the bitmap in pixels.
[*]glyph->advance.x is the horizontal advance in font units.
[/list]
Point 1 and 2 is simply the size of the bitmap: loop over both width and height to access each pixel.
Point 3 is for row-alignment: each new row of the bitmap starts pitch bytes from the start of the previous row. Since each row may end with some extra bytes that are not part of the bitmap image itself, the pitch takes this into account but width does not.
Point 4 and 5 is the vertical and horizontal offsets you need to shift the bitmaps location on the screen by in order to correctly align it on the baseline. For example, a glyph like 'g' or 'j' extends below the baseline, so it has to be shifted down, you cannot align the bottom of the bitmap to the baseline in these cases.
Point 6 is determines how far along the baseline to advance the drawing position for each glyph you draw. This value is in font units and not pixels, and has to be converted to pixels. From what I remembered, "font units" was a very vague terms and could mean different things depending on the actual font you have loaded. My experience is that it's mostly a fixed point value with 6 fractional bits, so right-shift the advance.x value 6 bits to obtain a pixel value.

Last but not least, you of course need glyph->bitmap.buffer which is the pointer to the top left corner of the glyph image data. When you render with FT_RENDER_NORMAL, you get an antialiased grey scale image. Thus, each pixel consists of one byte representing the grey scale level of the pixel.

Share this post


Link to post
Share on other sites
[quote name='Brother Bob' timestamp='1342775503' post='4961236']
The bitmap structure is box b in your image. The following six values are needed to align and render the glyph bitmaps correctly on a horizontal baseline:
glyph->bitmap.width is the width of the glyph bitmap in pixels.
glyph->bitmap.height is the height of the glyph bitmap in pixels.
glyph->bitmap.pitch is the size of one scanline of the glyph bitmap in bytes.
glyph->left is the x-origin of the bitmap in pixels.
glyph->top is the y-origin of the bitmap in pixels.
glyph->advance.x is the horizontal advance in font units.
Point 1 and 2 is simply the size of the bitmap: loop over both width and height to access each pixel.
Point 3 is for row-alignment: each new row of the bitmap starts pitch bytes from the start of the previous row. Since each row may end with some extra bytes that are not part of the bitmap image itself, the pitch takes this into account but width does not.
Point 4 and 5 is the vertical and horizontal offsets you need to shift the bitmaps location on the screen by in order to correctly align it on the baseline. For example, a glyph like 'g' or 'j' extends below the baseline, so it has to be shifted down, you cannot align the bottom of the bitmap to the baseline in these cases.
Point 6 is determines how far along the baseline to advance the drawing position for each glyph you draw. This value is in font units and not pixels, and has to be converted to pixels. From what I remembered, "font units" was a very vague terms and could mean different things depending on the actual font you have loaded. My experience is that it's mostly a fixed point value with 6 fractional bits, so right-shift the advance.x value 6 bits to obtain a pixel value.

[/quote]
Thank you very much for your reply .
It's useful for me ...

Share this post


Link to post
Share on other sites

This topic is 1970 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this