freetype
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ft] Space versus no glyph


From: mpsuzuki
Subject: Re: [ft] Space versus no glyph
Date: Tue, 10 May 2005 11:18:45 +0900

Hi

On Tue, 10 May 2005 08:49:29 +1000
"Ross Crawford" <address@hidden> wrote:

>I created a small font that just contains space, digits 0-9, and caps A-Z. 
>It is being used as the default font in my program. I want the space to just 
>increase the advance, but all undefined characters to generate a warning for 
>the user and not generate anything. However I can't seem to find how to tell 
>the difference between a char not existing in the charmap, and char 32 
>(which has no glyph associated with it).

If your font uses cmap format 0, it has complete 1:1 map between charcode
(0x00 - 0xFF) and glyphID, and it does not use any fallbacking rule for
undefined charcode (because all charcode must be mapped). But, if glyphID
is resolved but no glyph data could not be loaded, no-space problem can
arise.

>FT_Load_Char() does not return an error for the non-existant chars, and 
>FT_Get_Char_Index() returns 0 for space as well as the non-existant ones. Is 
>there a way I can check the charmap directly to determine whether or not a 
>given char is mapped?

To check font file itself (not tracing the FreeType mechanism),
please get perl module Font-TTF in some CPAN archive, and check the
manual page for Font::TTF::Cmap. The perl module can load and print
cmap for human, like this (this is tool for 16bit cmap, not suitable
for your purpose, but I expect you can know how to use it):

# ----------------------------------------------------------------
#!/usr/local/bin/perl
use Font::TTF::Font;
$f = Font::TTF::Font->open($ARGV[0]) or die "Specify a TrueType font file.\n";
$f->{'cmap'}->read();
$cmap = $f->{'cmap'};
$tbl = $cmap->find_ms();
print "0 0\n";
for ($u = 0; $u < 65556; $u++) {
  $gid = $cmap->ms_lookup($u);
  printf "<%04x> -> GID %d\n", $u, $gid if defined($gid);
}
$f->DESTROY; # forces close of $in and maybe memory reclaim!
# ----------------------------------------------------------------

Regards,
mpsuzuki




reply via email to

[Prev in Thread] Current Thread [Next in Thread]