freetype
[Top][All Lists]
Advanced

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

Re: [ft] How to decide whether a binary is Type1 or TTF?


From: mpsuzuki
Subject: Re: [ft] How to decide whether a binary is Type1 or TTF?
Date: Fri, 13 Jan 2006 10:29:30 +0900

Hi

On Wed, 11 Jan 2006 21:13:25 +0100
Zoltan Boszormenyi <address@hidden> wrote:
>I am trying to extend RLIB/RPDF (http://rlib.sicompos.com) so it can 
>embed fonts.
>I already read the font image into a memory buffer, with the help of 
>GNOME-VFS,
>from the "fonts:///" URI, so I know only the font symbolic name, but not the
>exact file name. How can I deduce the font type from only the binary 
>data using FreeType2?
>I am on Fedora Core 3, it only has FreeType2-2.1.9.

I have no time to give concrete example, sorry.

The easiest way might be using following 2 functions
(for loaded face) defined in include/freetype/freetype.h.

FT_IS_SCALABLE( face )  - check if it's outline (both of TrueType & Type1)
FT_IS_SFNT( face )      - check if it's in TrueType file format

In most case, you can use them aslike:

        if ( !FT_IS_SCALABLE( face ) )
        {
            /* bitmap font */
        }
        else
        {
            if ( FT_IS_SFNT( face ) )
            {
                /* TrueType font handling */
            }
            else
            {
                /* PostScript font handling */
            }
        }

There are several points that we have to care.

1. some *.ttf have bitmap data but no outline data.
   FT_IS_SFNT() is true, but FT_IS_SCALABLE() is false.
   for such TTF, fonts://... path looks very correct,
   but they cannot be embedded.

2. there are sfnt-housed PS font and CFF OpenType.

   sfnt-housed PS font is a old PS font designed for
   MacOS. It stores Type1 font in "typ1" table of
   TrueType file format. Therefore, if we use only
   2 functions in above, such font is mistaken as
   usual TrueType font. If you're working for Windows
   or UNIX, possibly this font format may be exceptional.

   CFF OpenType is new. It stores CFF PostScript
   font in "CFF " table of TrueType file format.
   The confusion is same with sfnt-housed PS font.

3. how about Type11, Type42?

   it's very difficult to find Type11, Type42 font as
   isolated file, but when we parse PS/PDF document,
   such font "object" may appear in buffer, and fontforge
   can generate such font as isolated file. if we use only
   2 functions in above, Type42 and Type11 are mistaken
   as usual PS font.

Regards,
mpsuzuki




reply via email to

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