Last Comment Bug 95557 - Use FMGetFontFamilyTextEncoding instead of FontToScript in
: Use FMGetFontFamilyTextEncoding instead of FontToScript in
Product: Core
Classification: Components
Component: Internationalization (show other bugs)
: Trunk
: PowerPC Mac OS X
P3 normal with 1 vote (vote)
: ---
Assigned To: nhottanscp
: Yuying Long
: Makoto Kato [:m_kato]
Depends on:
Blocks: 103669 120401
  Show dependency treegraph
Reported: 2001-08-16 00:38 PDT by Frank Tang
Modified: 2014-04-26 03:07 PDT (History)
7 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Description User image Frank Tang 2001-08-16 00:38:08 PDT
in EnumerateFont  ( gfx/src/mac/nsDeviceContextMac.cpp ), we use FontToScript to
decide the lang group of a font. According to
we should use FMGetFontFamilyTextEncoding  instead to decide a font. 

OSStatus FMGetFontFamilyTextEncoding (
    FMFontFamily inFontFamily, 
    TextEncoding oTextEncoding
This function is a replacement for the Script Manager function FontToScript. You
should use the function FMGetFontFamilyTextEncoding instead of the function
FontToScript to assure your application supports font formats other than the
resource fork TrueType and PostScript Type 1 fonts. Unlike the FontToScript 
function, the state of the font force flag is ignored and the script system of
the font family is not mapped to the zero even if it is disabled in the current
application process.

Once you have obtained the text encoding, you can use Text Encoding Converter
Manager function RevertTextEncodingToScriptInfo to extract the script as follows:

status = FMGetFontFamilyTextEncoding (myFontFamily, &myTextEncoding);

status = RevertTextEncodingToScriptInfo (myTextEncoding,


Notice that in  nsDeviceContextMac :: InitFontInfoList() , the classic build said 

short fondID;
 gFontInfoList->Put(&key, (void*)fondID);
and later on in 
932 bool nsDeviceContextMac :: GetMacFontNumber(const nsString& aFontName, short
933 {
934 //¥TODO?: Maybe we shouldn't call that function so often. If nsFont could
store the
935 //        fontNum, nsFontMetricsMac::SetFont() wouldn't need to call this at
936 InitFontInfoList();
937 FontNameKey key(aFontName);
938 aFontNum = (short)gFontInfoList->Get(&key);
939 return (aFontNum != 0) && (kFontIDSymbol != aFontNum);
940 }

1141 EnumerateFont(nsHashKey *aKey, void *aData, void* closure)
1142 1143 {
1144 EnumerateFontInfo* info = (EnumerateFontInfo*) closure;
1145 PRUnichar** array = info->mArray;
1146 int j = info->mCount;
1147 1148 short fondID = (short) aData;
1149 ScriptCode script = ::FontToScript(fondID);

Both place cast the value of the gFontInfoList hash to a FontID, but since in
the carbon build nsDeviceContextMac :: InitFontInfoList():

 FMFontFamily fontFamily;
gFontInfoList->Put(&key, (void*)fontFamily);

we should cast them to a FMFontFamily in these two places and do proper processing.
Comment 1 User image Frank Tang 2001-08-16 00:39:24 PDT
assign this bug
Comment 2 User image Frank Tang 2001-08-16 14:35:13 PDT
It's not too bad
typedef SInt16                          FMFontFamily;

so we probably dont' need to change the data type from Short to FMFontFamily now.
Comment 3 User image Frank Tang 2001-08-16 14:46:53 PDT
The following places is already outside TARGET_CARBON, so we don't need to worry 

/gfx/src/mac/nsDeviceContextMac.cpp, line 887 -- ScriptCode script = 

We need to take care the following:

/gfx/src/mac/nsDeviceContextMac.cpp, line 1149 -- ScriptCode script = 
/gfx/src/mac/nsUnicodeFontMappingMac.cpp, line 117 -- ScriptCode script = 
/gfx/src/mac/nsUnicodeMappingUtil.cpp, line 326 -- ((script < smUninterp) && 
(::FontToScript(fontID) != script)))
/gfx/src/mac/nsUnicodeRenderingToolkit.cpp, line 836 -- ScriptCode script = 
974     ScriptCode script = ::FontToScript(fontNum);
Comment 4 User image Frank Tang 2001-08-21 15:39:58 PDT
mark it m94
Comment 5 User image Hong Kwon 2001-08-29 13:15:20 PDT
Is the 0.9.4 milestone realistic?  We are branching on Friday.
Comment 6 User image Frank Tang 2001-08-31 10:56:28 PDT
move to m0.9.5
Comment 7 User image Frank Tang 2001-10-08 10:45:39 PDT
move to m0.9.6
Comment 8 User image Frank Tang 2001-10-09 17:43:55 PDT
move to m97
Comment 9 User image nhottanscp 2001-11-20 13:48:30 PST
move to 0.9.8
Comment 10 User image Frank Tang 2002-01-16 17:53:16 PST
mass move unimportant m9.8 bug to m9.9 for now. 
Comment 11 User image Frank Tang 2002-02-12 19:56:41 PST
give this to nhotta and remove target
Comment 12 User image Mano (::mano, needinfo? for any questions; not reading general bugmail) 2004-08-09 20:12:44 PDT
1. FMGetFontFamilyTextEncoding is broken on Mac OS X (eg. returns smKorean for
windows Arial)
2. Scripts or "font encodings" are no longer exists (again: OS X).

As a result of (2), we started to remove FontToScript and
FMGetFontFamilyTextEncoding calls (see bug 120401).

Note You need to log in before you can comment on or make changes to this bug.