Last Comment Bug 95557 - Use FMGetFontFamilyTextEncoding instead of FontToScript in
: Use FMGetFontFamilyTextEncoding instead of FontToScript in
Status: RESOLVED WONTFIX
:
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
:
Mentors:
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:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments

Description 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 
http://developer.apple.com/techpubs/macosx/Carbon/text/FontManager/Font_Manager/Functions/Accessing_Fo_mily_Objects.html#//apple_ref/C/func/FMGetFontFamilyTextEncoding
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,

&myScriptCode);


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
&aFontNum)
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
all.
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 Frank Tang 2001-08-16 00:39:24 PDT
assign this bug
Comment 2 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 Frank Tang 2001-08-16 14:46:53 PDT
The following places is already outside TARGET_CARBON, so we don't need to worry 
about:

/gfx/src/mac/nsDeviceContextMac.cpp, line 887 -- ScriptCode script = 
::FontToScript(fondID);

We need to take care the following:

/gfx/src/mac/nsDeviceContextMac.cpp, line 1149 -- ScriptCode script = 
::FontToScript(fondID);
/gfx/src/mac/nsUnicodeFontMappingMac.cpp, line 117 -- ScriptCode script = 
::FontToScript(fontNum);
/gfx/src/mac/nsUnicodeMappingUtil.cpp, line 326 -- ((script < smUninterp) && 
(::FontToScript(fontID) != script)))
/gfx/src/mac/nsUnicodeRenderingToolkit.cpp, line 836 -- ScriptCode script = 
::FontToScript(fontNum);
974     ScriptCode script = ::FontToScript(fontNum);
Comment 4 Frank Tang 2001-08-21 15:39:58 PDT
mark it m94
Comment 5 Hong Kwon 2001-08-29 13:15:20 PDT
Is the 0.9.4 milestone realistic?  We are branching on Friday.
Comment 6 Frank Tang 2001-08-31 10:56:28 PDT
move to m0.9.5
Comment 7 Frank Tang 2001-10-08 10:45:39 PDT
move to m0.9.6
Comment 8 Frank Tang 2001-10-09 17:43:55 PDT
move to m97
Comment 9 nhottanscp 2001-11-20 13:48:30 PST
move to 0.9.8
Comment 10 Frank Tang 2002-01-16 17:53:16 PST
mass move unimportant m9.8 bug to m9.9 for now. 
Comment 11 Frank Tang 2002-02-12 19:56:41 PST
give this to nhotta and remove target
Comment 12 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.