[texworks] Mac OS TeXworks + fontconfig

Charlie Sharpsteen chuck at sharpsteen.net
Wed Jun 1 23:38:44 CEST 2011


On Mon, May 30, 2011 at 11:48 AM, Stefan Löffler <st.loeffler at gmail.com> wrote:
> Hi,
>
> On 2011-05-30 19:52, Charlie Sharpsteen wrote:
>> On Sun, May 29, 2011 at 4:25 AM, Jonathan Kew <jfkthame at googlemail.com> wrote:
>>> Maybe we could enhance the code to try both ZapfDingbats and ZapfDingbatsITC?
>> I replaced the declaration of `myName` at the beginning of
>> `GlobalParams::loadPlatformFont`:
>>
>>     char * myName = copyString(fontName);
>>
>> With:
>>
>>     char *myName;
>>     if ( strcmp((const char*) fontName, "ZapfDingbats") == 0 ) {
>>       myName = copyString("ZapfDingbatsITC");
>>     } else {
>>       myName = copyString(fontName);
>>     }
>
> Crude, but for debugging purposes effective (though ultimately, we
> should probably try "ZapfDingbats" first; who knows if that isn't
> available on some systems, or if Apple changes it in the future...).

I cleaned the implementation up a little bit by placing the
substitution inside the first `while` loop along with the other tricks
that get tried if `ATSFontFindFromPostScriptName` returns
`kATSUInvalidFontID`:

    https://github.com/Sharpie/TeXworks/commit/037a148


>> Lookup font: ZapfDingbatsITC
>>    ATSFontFindFromPostScriptName found fontRef
>>    found 'glyf' table
>>    found in file: /System/Library/Fonts/ZapfDingbats.ttf
>> Bogus memory allocation size
>
> Strange. My guess would be that the .ttf has some problems, but we'll see.
> Can you check (by adding "std:cerr <<" lines which of the lines
> following the "found in file" message succeed? If it runs until the
> "return gTrue;", the problem is (hopefully) not in our patch. Otherwise,
> we know where to start digging.
>
> HTH
> Stefan

I also bumped up the debugging verbosity a bit and extended the
messages to the `getDisplayFont` method which is what calls
`loadPlatformFont`---this includes messages that get printed every
time the variable `myName` is altered so that it is different than
what was copied from `fontName`.  The results were interesting:

Lookup font: Times-Roman
Loading font.
   ATSFontFindFromPostScriptName found fontRef
   found 'glyf' table
   no TTF file found, checking for .dfont
   ATSFontGetTableDirectory succeeded
   font converted to /tmp/Lgp7uLyf.ttf
   returning temporary TTF file.
Finished getDisplayFont.

Lookup font: Times-Bold
Loading font.
   ATSFontFindFromPostScriptName found fontRef
   found 'glyf' table
   no TTF file found, checking for .dfont
   ATSFontGetTableDirectory succeeded
   font converted to /tmp/WhxA2P62.ttf
   returning temporary TTF file.
Finished getDisplayFont.

Lookup font: Times-Italic
Loading font.
   ATSFontFindFromPostScriptName found fontRef
   found 'glyf' table
   no TTF file found, checking for .dfont
   ATSFontGetTableDirectory succeeded
   font converted to /tmp/tTwspGOu.ttf
   returning temporary TTF file.
Finished getDisplayFont.

Lookup font: Times-BoldItalic
Loading font.
   ATSFontFindFromPostScriptName found fontRef
   found 'glyf' table
   no TTF file found, checking for .dfont
   ATSFontGetTableDirectory succeeded
   font converted to /tmp/7vtq0Lms.ttf
   returning temporary TTF file.
Finished getDisplayFont.

Lookup font: Helvetica
Loading font.
   ATSFontFindFromPostScriptName found fontRef
   found 'glyf' table
   no TTF file found, checking for .dfont
   ATSFontGetTableDirectory succeeded
   font converted to /tmp/YstMMD3G.ttf
   returning temporary TTF file.
Finished getDisplayFont.

Lookup font: Helvetica-Bold
Loading font.
   ATSFontFindFromPostScriptName found fontRef
   found 'glyf' table
   no TTF file found, checking for .dfont
   ATSFontGetTableDirectory succeeded
   font converted to /tmp/bYuUncqC.ttf
   returning temporary TTF file.
Finished getDisplayFont.

Lookup font: Helvetica-Oblique
Loading font.
   ATSFontFindFromPostScriptName found fontRef
   found 'glyf' table
   no TTF file found, checking for .dfont
   ATSFontGetTableDirectory succeeded
   font converted to /tmp/G1HQTZHK.ttf
   returning temporary TTF file.
Finished getDisplayFont.

Lookup font: Helvetica-BoldOblique
Loading font.
   ATSFontFindFromPostScriptName found fontRef
   found 'glyf' table
   no TTF file found, checking for .dfont
   ATSFontGetTableDirectory succeeded
   font converted to /tmp/Bn1ZK7yN.ttf
   returning temporary TTF file.
Finished getDisplayFont.

Lookup font: Courier
Loading font.
   ATSFontFindFromPostScriptName found fontRef
   found 'glyf' table
   no TTF file found, checking for .dfont
   ATSFontGetTableDirectory succeeded
   font converted to /tmp/w2aox6iO.ttf
   returning temporary TTF file.
Finished getDisplayFont.

Lookup font: Courier-Bold
Loading font.
   ATSFontFindFromPostScriptName found fontRef
   found 'glyf' table
   no TTF file found, checking for .dfont
   ATSFontGetTableDirectory succeeded
   font converted to /tmp/Esqo3EQX.ttf
   returning temporary TTF file.
Finished getDisplayFont.

Lookup font: Courier-Oblique
Loading font.
   ATSFontFindFromPostScriptName found fontRef
   found 'glyf' table
   no TTF file found, checking for .dfont
   ATSFontGetTableDirectory succeeded
   font converted to /tmp/935QMecc.ttf
   returning temporary TTF file.
Finished getDisplayFont.

Lookup font: Courier-BoldOblique
Loading font.
   ATSFontFindFromPostScriptName found fontRef
   found 'glyf' table
   no TTF file found, checking for .dfont
   ATSFontGetTableDirectory succeeded
   font converted to /tmp/yGgX6wZZ.ttf
   returning temporary TTF file.
Finished getDisplayFont.

Lookup font: Symbol
Loading font.
   ATSFontFindFromPostScriptName found fontRef
   found 'glyf' table
   found in file: /System/Library/Fonts/Symbol.ttf
   returning TTF file.
Finished getDisplayFont.

Lookup font: ZapfDingbats
Loading font.
   Substituting ZapfDingbatsITC for ZapfDingbats.
   ATSFontFindFromPostScriptName found fontRef
   found 'glyf' table
   found in file: /System/Library/Fonts/ZapfDingbats.ttf
   returning TTF file.
Finished getDisplayFont.

Lookup font: Times-Roman
Finished getDisplayFont.

Lookup font: Times-Bold
Finished getDisplayFont.

Lookup font: Times-Italic
Finished getDisplayFont.

Lookup font: Times-BoldItalic
Finished getDisplayFont.

Lookup font: Helvetica
Finished getDisplayFont.

Lookup font: Helvetica-Bold
Finished getDisplayFont.

Lookup font: Helvetica-Oblique
Finished getDisplayFont.

Lookup font: Helvetica-BoldOblique
Finished getDisplayFont.

Lookup font: Courier
Finished getDisplayFont.

Lookup font: Courier-Bold
Finished getDisplayFont.

Lookup font: Courier-Oblique
Finished getDisplayFont.

Lookup font: Courier-BoldOblique
Finished getDisplayFont.

Lookup font: Symbol
Finished getDisplayFont.

Lookup font: ZapfDingbats
Finished getDisplayFont.

Bogus memory allocation size
Bogus memory allocation size
Bogus memory allocation size
Bogus memory allocation size
Bogus memory allocation size
Bogus memory allocation size
Bogus memory allocation size
Bogus memory allocation size


ZapfDingbats is the only font for which `loadPlatformFont` has to
alter the `fontName` in order for `ATSFontFindFromPostScriptName` to
get a match. It looks like whatever is happening to produce the memory
errors is happening outside of `GlobalParamsMac.cc`, but may be
influenced by the substitution that occurs within `loadPlatformFont`.

-Charlie



More information about the texworks mailing list