Re: [ft] diff Pixel height
So,You mean irrespective of what ever we do...the BBox is Always negative. For this glyph, yes. In your previous reply you said, the only way to get the exact metrics is to render _all_ glyphs. Sorry for being ambiguous. It either means: . To get the smallest global bounding box of a font you have to render all glyphs of a font or . To get the smallest bounding box of a glyph string you have to render all glyphs of the string. Reason is, Output from my program will be used by another tool, which doesnt understand the hinting process. So if i would like to provide the exact metrics of a glyph. How can i do? As I told you already multiple times: You have to render the glyphs to get exact bounding boxes, regardless whether you use hinting or not. Werner ___ Freetype mailing list Freetype@nongnu.org http://lists.nongnu.org/mailman/listinfo/freetype
Re: [ft] diff Pixel height
Hi Werner, i tried like below: error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_HINTING); Family name of the font is --- Arial Style name of the font is --- Regular bbox = [-1 0 9 9] *Xmin is still negative. * Can you please provide me syntax if i am doing wrong in setting the flags.How can i do if i want a MONOCHROME,RENDERED and NO_HINTING glyph metrics? Thanksregards Sam On Thu, Feb 18, 2010 at 5:23 PM, Werner LEMBERG w...@gnu.org wrote: I mean, If i would like to verify NO_HINTING option and see whether i get real Metrics of the Glyph, how can i do? You can load a glyph with the no-hinting flag set, then doing the same again without that flag. Note that there is perhaps a misunderstanding: Hinting instructions move points to improve the shape for a given pixel size; this often changes the BBox. However, even if you use the unhinted outline of a glyph, you have to rasterize it to get the *exact* dimensions in pixels. In other words: Regardless whether hinting is active or not, the real BBox of a glyph rasterized at a certain pixel size can only be determined after a glyph has been rendered. Or to say it again in a different formulation: The BBox and CBox functions provided by FreeType are by their very nature of limited use if you need a *smallest* BBox at a given pixel size. Werner ___ Freetype mailing list Freetype@nongnu.org http://lists.nongnu.org/mailman/listinfo/freetype
Re: [ft] diff Pixel height
error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_HINTING); Family name of the font is --- Arial Style name of the font is --- Regular bbox = [-1 0 9 9] *Xmin is still negative. Yes! I told you in a previous mail that the unhinted coordinate of the leftmost pixel is NEGATIVE! FreeType always rounds to the extreme, thus you get -1 and not 0. Can you please provide me syntax if i am doing wrong in setting the flags. How can i do if i want a MONOCHROME, RENDERED and NO_HINTING glyph metrics? You mean glyph dimensions (the BBox), right? Glyph metrics is the advance width, for example, and this is independent from the outline. Again: The only way to get an exact BBox for a given DPI is to render the glyph! Werner ___ Freetype mailing list Freetype@nongnu.org http://lists.nongnu.org/mailman/listinfo/freetype
Re: [ft] diff Pixel height
Thanks for the reply. So,You mean irrespective of what ever we do...the BBox is Always negative. In your previous reply you said, the only way to get the exact metrics is to render _all_ glyphs. Can you please give me some syntax how to load glyph to get exact metrics. Reason is,Output from my program will be used by another tool,which doesnt understand the hinting process.So if i would like to provide the exact metrics of a glyph.How can i do? Regards, Sam On Mon, Feb 22, 2010 at 12:29 PM, Werner LEMBERG w...@gnu.org wrote: error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_HINTING); Family name of the font is --- Arial Style name of the font is --- Regular bbox = [-1 0 9 9] *Xmin is still negative. Yes! I told you in a previous mail that the unhinted coordinate of the leftmost pixel is NEGATIVE! FreeType always rounds to the extreme, thus you get -1 and not 0. Can you please provide me syntax if i am doing wrong in setting the flags. How can i do if i want a MONOCHROME, RENDERED and NO_HINTING glyph metrics? You mean glyph dimensions (the BBox), right? Glyph metrics is the advance width, for example, and this is independent from the outline. Again: The only way to get an exact BBox for a given DPI is to render the glyph! Werner ___ Freetype mailing list Freetype@nongnu.org http://lists.nongnu.org/mailman/listinfo/freetype
Re: [ft] diff Pixel height
Thanks Werner.Hats-off for remembering!! Where can find about definition of hinted fonts?What it means? How does it vary in freetype for HINT and NO_HINT? Also,When i was looking for hinted in FT_Load_Glyph i found , For *no_hinting *we can use FT_LOAD_NO_SCALE flag I tried using something like below, FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_HINTING|FT_LOAD_RENDER|FT_LOAD_MONOCHROME); But still i am getting xmin for A as -1. If i would like to check no_hinting option,how can i do it? Thanks, Sam On Tue, Feb 16, 2010 at 5:39 PM, Werner LEMBERG w...@gnu.org wrote: Samaram, I've now found some time to answer this your question: I am using Arial.ttf file [at 12px/72dpi], [...] I am getting x min for few characters as -1 [after a call to compute the CBox]. Is it correct? Yes. Have a look at the attached image, from a debugging session with FontForge. It shows the outline of glyph `A' from arial.ttf at 12px with 72dpi, after hinting has been applied. The hinting engine moves point 0 to the left so that it eventually gets a negative x value. After rounding, this becomes -1. Similarly, point 3 gets moved to the right, causing the xmax value to be 8. In other words, the CBox of the hinted glyph `A' is two pixels wider than necessary. Always bear in mind the following warning from the description of the `bbox' field in FT_FaceRec: Note that the bounding box might be off by (at least) one pixel for hinted fonts. See @FT_Size_Metrics for further discussion. In the description of FT_Size_Metrics: [...] Indeed, the only way to get the exact metrics is to render _all_ glyphs. As this would be a definite performance hit, it is up to client applications to perform such computations. Werner ___ Freetype mailing list Freetype@nongnu.org http://lists.nongnu.org/mailman/listinfo/freetype ___ Freetype mailing list Freetype@nongnu.org http://lists.nongnu.org/mailman/listinfo/freetype
Re: [ft] diff Pixel height
Where can find about definition of hinted fonts? What it means? Read the OpenType specification. How does it vary in freetype for HINT and NO_HINT? Well, if you set the no-hint flag, no hinting gets applied. However, you have to understand the concept of hinting first... I tried using something like below, FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_HINTING|FT_LOAD_RENDER|FT_LOAD_MONOCHROME); But still i am getting xmin for A as -1. Yes. The unhinted coordinate of the leftmost point in font units is (-3,0); this inevitably causes xmin of the CBox to be a negative value, regardless of the used resolution. If i would like to check no_hinting option,how can i do it? Check? What do you mean? Werner ___ Freetype mailing list Freetype@nongnu.org http://lists.nongnu.org/mailman/listinfo/freetype
Re: [ft] diff Pixel height
*error = FT_Set_Char_Size( face,10*64,0,72,0 ); /*The pen position in 26.6 cartesian space coordinates; */ pen.x = 0; pen.y = 0; FT_Set_Transform(face,0,pen); glyph_index = FT_Get_Char_Index( face,text[n] ); //printf( Glyph_Index = %.2x\n,glyph_index); error = FT_Load_Glyph( face, glyph_index, FT_LOAD_RENDER|FT_LOAD_MONOCHROME); error = FT_Get_Glyph (face-glyph, glyph); FT_Glyph_Get_CBox(glyph, FT_GLYPH_BBOX_PIXELS, bbox); fprintf( stderr, bbox = [%ld %ld %ld %ld] \n, bbox.xMin, bbox.yMin, bbox.xMax, bbox.yMax );* Arial.ttf,72dpi and any point you can use either 10,11,12,14 etc. Thanks Werner On Mon, Feb 8, 2010 at 11:11 AM, Werner LEMBERG w...@gnu.org wrote: I am using Arial.ttf file, If i use pen.x and pen.y = 0, I am getting x min for few characters as -1. Is it correct? I will check. Which dpi and pt values are you using? Werner ___ Freetype mailing list Freetype@nongnu.org http://lists.nongnu.org/mailman/listinfo/freetype
Re: [ft] diff Pixel height
Thank You Werner. I tried as you said CBox to get the actual dimensions of the Glyph. FT_Glyph_Get_CBox(glyph, *FT_GLYPH_BBOX_PIXELS*, bbox); fprintf( stderr, bbox = [%ld %ld %ld %ld]\n, bbox.xMin, bbox.yMin, bbox.xMax, bbox.yMax ); I got the follwoing for Glyph g and Glyph a respectivelly. bbox = [0 3 12 14] .... .*** ..*. ...***...**. ..***.** ..**.*** .**..*...*** .**..**. .***.... .*.. ...* bbox = [0 2 10 14] ...**. ..***. .. ** ...***.*** ...**..*** .. .. .***...**. .****. **.**. .. Where in in Set_Char_size i gave character size as 12.I thought i will be getting the height of 12 pixels irrespective of the character. Also,dont know why am i getting just a empty row at the end of glyph A and one column for glyph G at the beginning? Does it too corresponds to the glyph's bit map buffer ? Could you please explain me if my understanding is wrong? Thanks a lot... -Sam On Sat, Jan 30, 2010 at 2:13 PM, Werner LEMBERG w...@gnu.org wrote: I am setting my glyph size as 10,on 72dpi. I assumed i will be getting a glyph height of 10 pixels, But it is not? Correct. If you specify a glyph size of 10 pixels you can expect that it (more or less) harmonizes with other fonts rendered at a size of 10 pixels. It is completely unrelated to the actual size of the glyphs. To get the real glyph dimensions, compute the glyph's CBox (which should be sufficient in most situations). Werner ___ Freetype mailing list Freetype@nongnu.org http://lists.nongnu.org/mailman/listinfo/freetype
Re: [ft] diff Pixel height
I am setting my glyph size as 10,on 72dpi. I assumed i will be getting a glyph height of 10 pixels, But it is not? Correct. If you specify a glyph size of 10 pixels you can expect that it (more or less) harmonizes with other fonts rendered at a size of 10 pixels. It is completely unrelated to the actual size of the glyphs. To get the real glyph dimensions, compute the glyph's CBox (which should be sufficient in most situations). Werner ___ Freetype mailing list Freetype@nongnu.org http://lists.nongnu.org/mailman/listinfo/freetype