Jump to content

  • Log In with Google      Sign In   
  • Create Account


Some questions about FreeType..


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 FireInDark   Members   -  Reputation: 148

Like
0Likes
Like

Posted 20 July 2012 - 02:11 AM

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..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.

Sponsor:

#2 Brother Bob   Moderators   -  Reputation: 8053

Like
2Likes
Like

Posted 20 July 2012 - 03:11 AM

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.

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.

#3 FireInDark   Members   -  Reputation: 148

Like
0Likes
Like

Posted 21 July 2012 - 09:48 PM

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.

Thank you very much for your reply .
It's useful for me ...




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS