[ft-devel] character spacing

2011-09-18 Thread Louis Desjardins

In order to draw my text, I currently make calls to:
  
FT_Get_Char_IndexFT_Load_GlyphFT_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?
Thank-you ___
Freetype-devel mailing list
Freetype-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype-devel


Re: [ft-devel] character spacing

2011-09-18 Thread Louis Desjardins

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


Re: [ft-devel] FT_Get_Kerning returns 0

2011-09-18 Thread Werner LEMBERG

 I check if my TTF file has kerning information using FT_HAS_KERNING,
 and this returns true.  I then use: FT_Get_Kerning(face, prev, next,
 FT_KERNING_DEFAULT, delta); to determine the kerning value, but
 delta.x returns 0.  How can I debug why the kerning value is 0 even
 though FT_HAS_KERNING returns true?

Don't assume that there is a kerning value for all glyph pairs!  Use a
program like `ttx' (sourceforge.net/projects/fonttools/) to get a dump
of a TrueType font.  Then check whether there is a kerning value
between the two particular glyphs.


Werner

___
Freetype-devel mailing list
Freetype-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype-devel


Re: [ft-devel] character spacing

2011-09-18 Thread Werner LEMBERG

 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