Re: [ft-devel] character spacing
On 09/19/11 01:21, Louis Desjardins wrote: Also - as I have already invested much time in Freetype I no longer have time to integrate a different library such as Pango - is there somewhere I can obtain freely distributable TTF files that contains kerning information that can be handled by Freetype? I'm guessing that you don't want kerning. You want the glyph advance widths. I'm just guessing that you are stacking bitmaps next to eachother, using the bitmap width as the advance vector. That's wrong. When saving the bitmaps, also save face-glyph-advance.x. behdad Thank-you! -- From: lost_bits1...@hotmail.ca To: w...@gnu.org CC: freetype-devel@nongnu.org Subject: RE: [ft-devel] character spacing Date: Sun, 18 Sep 2011 22:15:58 -0700 Thanks for your reply - Note, however, that today many fonts contain kerning in the GPOS table which is not handled by FreeType. Instead, you have to use a higher-level library like Pango or ICU. FT_HAS_KERNING will return true for these types of fonts? When I call, FT_Get_Kerning, the akerning value always gets set to (0,0), which from the sample code on freetype.org, looks like is an error. Could this indicate that the kerning information is in the 'GPOS' table? How can I know for sure, or is there a way to debug this? Thank-you again! Date: Mon, 19 Sep 2011 07:10:24 +0200 To: lost_bits1...@hotmail.ca CC: freetype-devel@nongnu.org Subject: Re: [ft-devel] character spacing From: w...@gnu.org In order to draw my text, I currently make calls to: FT_Get_Char_Index FT_Load_Glyph FT_Render_Glyph and then I store the bitmap of each ascii character to memory, so that once I actually render the character, I can simply call on the stored bitmap. The problem is that the character spacing is not correct. It looks like I need to use FT_Get_Kerning to correct this, however from the examples I've seen, it looks like I need to call this before FT_Load_Glyph, i.e. at the time when I am storing each of my characters. However, I have no idea what strings will be rendered, until runtime, so I don't know the 'left_glyph' and 'right_glyph' parameters in FT_Get_Kerning beforehand. Is there a way to make use of FT_Get_Kerning while drawing my bitmap (after I've already loaded the glyph and retrieved its bitmap), in order to achieve proper character spacing at runtime? Have a look at the ftstring demo program to see how simple kerning works. You can call `FT_Get_Kerning' whenever you want; it is completely unrelated to `FT_Render_Glyph'. Note, however, that today many fonts contain kerning in the GPOS table which is not handled by FreeType. Instead, you have to use a higher-level library like Pango or ICU. Werner ___ Freetype-devel mailing list Freetype-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/freetype-devel ___ Freetype-devel mailing list Freetype-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/freetype-devel
Re: [ft-devel] character spacing
Thanks! Well when I perform this search, no 'GPOS' text is found, but I do find the text 'kern' - so at least Freetype can handle this file. I also tried the tool ttx as you suggested - thanks for this tip! Indeed it turns out that the 'kern' table does not have any of the pairs I was looking for (which I thought was very surprising). When I do enter a glyph indices for pairs that I do actually see in the kern table, then FT_Get_Kerning does return a value. My original problem persists though and there is too much spacing between certain characters, such as F and a, and between 1 and almost any other number. Is this not something that should be dealt with by the kerning table, or do I now need to look for a different font? Thank-you again!LD Date: Mon, 19 Sep 2011 07:27:04 +0200 To: lost_bits1...@hotmail.ca CC: freetype-devel@nongnu.org Subject: Re: [ft-devel] character spacing From: w...@gnu.org Also - as I have already invested much time in Freetype I no longer have time to integrate a different library such as Pango - is there somewhere I can obtain freely distributable TTF files that contains kerning information that can be handled by Freetype? If a font doesn't contain a `GPOS' table and only `kern', you are on the safe side. This inspection can be done even manually; just search for `GPOS' inside the font (rather at the beginning, within the first few kBytes). Werner ___ Freetype-devel mailing list Freetype-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/freetype-devel
Re: [ft-devel] character spacing
Thank-you for your reply, actually I do save face-glyph-advance.x, and when it comes time to render this is what I am using. Unfortunately the spacing does not look right still. Date: Mon, 19 Sep 2011 09:20:46 -0400 From: beh...@behdad.org To: lost_bits1...@hotmail.ca CC: w...@gnu.org; freetype-devel@nongnu.org Subject: Re: [ft-devel] character spacing On 09/19/11 01:21, Louis Desjardins wrote: Also - as I have already invested much time in Freetype I no longer have time to integrate a different library such as Pango - is there somewhere I can obtain freely distributable TTF files that contains kerning information that can be handled by Freetype? I'm guessing that you don't want kerning. You want the glyph advance widths. I'm just guessing that you are stacking bitmaps next to eachother, using the bitmap width as the advance vector. That's wrong. When saving the bitmaps, also save face-glyph-advance.x. behdad Thank-you! -- From: lost_bits1...@hotmail.ca To: w...@gnu.org CC: freetype-devel@nongnu.org Subject: RE: [ft-devel] character spacing Date: Sun, 18 Sep 2011 22:15:58 -0700 Thanks for your reply - Note, however, that today many fonts contain kerning in the GPOS table which is not handled by FreeType. Instead, you have to use a higher-level library like Pango or ICU. FT_HAS_KERNING will return true for these types of fonts? When I call, FT_Get_Kerning, the akerning value always gets set to (0,0), which from the sample code on freetype.org, looks like is an error. Could this indicate that the kerning information is in the 'GPOS' table? How can I know for sure, or is there a way to debug this? Thank-you again! Date: Mon, 19 Sep 2011 07:10:24 +0200 To: lost_bits1...@hotmail.ca CC: freetype-devel@nongnu.org Subject: Re: [ft-devel] character spacing From: w...@gnu.org In order to draw my text, I currently make calls to: FT_Get_Char_Index FT_Load_Glyph FT_Render_Glyph and then I store the bitmap of each ascii character to memory, so that once I actually render the character, I can simply call on the stored bitmap. The problem is that the character spacing is not correct. It looks like I need to use FT_Get_Kerning to correct this, however from the examples I've seen, it looks like I need to call this before FT_Load_Glyph, i.e. at the time when I am storing each of my characters. However, I have no idea what strings will be rendered, until runtime, so I don't know the 'left_glyph' and 'right_glyph' parameters in FT_Get_Kerning beforehand. Is there a way to make use of FT_Get_Kerning while drawing my bitmap (after I've already loaded the glyph and retrieved its bitmap), in order to achieve proper character spacing at runtime? Have a look at the ftstring demo program to see how simple kerning works. You can call `FT_Get_Kerning' whenever you want; it is completely unrelated to `FT_Render_Glyph'. Note, however, that today many fonts contain kerning in the GPOS table which is not handled by FreeType. Instead, you have to use a higher-level library like Pango or ICU. Werner ___ Freetype-devel mailing list Freetype-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/freetype-devel ___ Freetype-devel mailing list Freetype-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/freetype-devel
Re: [ft-devel] character spacing
My original problem persists though and there is too much spacing between certain characters, such as F and a, and between 1 and almost any other number. Is this not something that should be dealt with by the kerning table, or do I now need to look for a different font? I think that your problem is not related to kerning at all. Do you use sub-pixel positioning? Perhaps it really helps if you compare your code to one of the ftdemo programs. Besides that, I'm running out of ideas. Werner ___ Freetype-devel mailing list Freetype-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/freetype-devel
Re: [ft-devel] character spacing
LD == Louis Desjardins lost_bits1...@hotmail.ca writes: LD between 1 and almost any other number Most fonts have ascii digits (and some other glyphs often used with them) designed to be monowidth, even when the rest of the font is proportional. This is to ensure that columns of digits line up well. Some fonts – Adobe’s more complete families are among the examples – contain (opentype) features which enable proportional digits. In opentype, those features would be in the GSUB table. ttx decodes GSUB well enough that it should be easy to understand. -JimC -- James Cloos cl...@jhcloos.com OpenPGP: 1024D/ED7DAEA6 ___ Freetype-devel mailing list Freetype-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/freetype-devel