freetype
[Top][All Lists]
Advanced

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

Re: [Freetype] Anyone else using FreeType on MacOS? Found a bug...


From: Paul Miller
Subject: Re: [Freetype] Anyone else using FreeType on MacOS? Found a bug...
Date: Thu, 25 Oct 2001 09:29:31 -0500

I found a bug in how the Mac-specific FOND code accesses the appropriate sfnt resource - with the existing code there is no way to specify one of the alternate faces (ie. Bold, Italic). I'm wondering where to send my changes.
I was just looking at this code last night, Paul, and I believe that the way you specify the face is via the face_index.

How about if you send me your patches, which I'll included in my version, and then send the whole thing to Tom to check in??

Hi Leonard,

The problem is the face_index is never passed down to the parse_fond() function which determines which sfnt to use. It always picks the "first" sfnt.

New bit of parse_fond:

  static void
  parse_fond( char*   fond_data,
              short*  have_sfnt,
              short*  sfnt_id,
              Str255  lwfn_file_name,
              short face_index )
  {
    AsscEntry*  assoc;
    AsscEntry*  base_assoc;
    FamRec*     fond;

    *sfnt_id          = 0;
    *have_sfnt        = 0;
    lwfn_file_name[0] = 0;

    fond = (FamRec*)fond_data;
    assoc = (AsscEntry*)( fond_data + sizeof ( FamRec ) + 2 );
    base_assoc = assoc;
    assoc += face_index;        /* NEW - add on the face_index! */

/* if the face at this index is not scalable, fall back to the first one (old behavior) */
    if ( assoc->fontSize == 0 )
    {
      *have_sfnt = 1;
      *sfnt_id = assoc->fontID;
    }
    else if (base_assoc->fontSize == 0)
    {
      *have_sfnt = 1;
      *sfnt_id = base_assoc->fontID;
    }


And then in FT_New_Face_From_FONT...

    HLock( fond );
    parse_fond( *fond, &have_sfnt, &sfnt_id, lwfn_file_name, face_index );
    HUnlock( fond );


Note that face_index should be in the index taking into account scalable fonts only. Some fonts, like Times, have some non-scalable bitmap sfnts first, but when iterating over the faces in Times, face_index should only be incremented when a scalable face is discovered.

I also have some code that goes from a font name (like "Times New Roman Bold Italic") to the appropriate FOND and face_index, if you are interested.

Note: I'm not really a "mac guy", so some of this could be wrong. But it's certainly working for me!


--
Paul T. Miller | VP of Engineering, Profound Effects, Inc. | http://www.profoundeffects.com




reply via email to

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