Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | Static Private Attributes
nsUnicodeFontMappingMac Class Reference

#include <nsUnicodeFontMappingMac.h>

Collaboration diagram for nsUnicodeFontMappingMac:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsUnicodeFontMappingMac (nsFont *aFont, nsIDeviceContext *aDeviceContext, const nsString &aLangGroup, const nsString &aLANG)
 ~nsUnicodeFontMappingMac ()
short GetFontID (PRUnichar aChar)
const short * GetScriptFallbackFonts ()
PRBool Equals (const nsUnicodeFontMappingMac &anther)
PRBool ConvertUnicodeToGlyphs (short aFontNum, const PRUnichar *aString, ByteCount aStringLength, char *aBuffer, ByteCount aBufferLength, ByteCount &oActualLength, ByteCount &oBytesRead, OptionBits opts)

Static Public Member Functions

static PRBool FontEnumCallback (const nsString &aFamily, PRBool aGeneric, void *aData)

Protected Member Functions

PRBool ScriptMapInitComplete ()
void InitByFontFamily (nsFont *aFont, nsIDeviceContext *aDeviceContext)
void InitByLANG (const nsString &aLANG)
void InitByLangGroup (const nsString &aLangGroup)
void InitDefaultScriptFonts ()
void processOneLangRegion (const char *aLanguage, const char *aRegion)
nsUnicodeBlock GetBlock (PRUnichar aChar)

Private Attributes

PRInt8 mPrivBlockToScript [kUnicodeBlockVarScriptMax]
short mScriptFallbackFontIDs [smPseudoTotalScripts]
nsAutoVoidArray mFontList

Static Private Attributes

static nsUnicodeMappingUtilgUtil = nsnull

Detailed Description

Definition at line 53 of file nsUnicodeFontMappingMac.h.


Constructor & Destructor Documentation

nsUnicodeFontMappingMac::nsUnicodeFontMappingMac ( nsFont aFont,
nsIDeviceContext aDeviceContext,
const nsString aLangGroup,
const nsString aLANG 
)

Definition at line 452 of file nsUnicodeFontMappingMac.cpp.

Here is the call graph for this function:

Definition at line 471 of file nsUnicodeFontMappingMac.cpp.


Member Function Documentation

PRBool nsUnicodeFontMappingMac::ConvertUnicodeToGlyphs ( short  aFontNum,
const PRUnichar aString,
ByteCount  aStringLength,
char *  aBuffer,
ByteCount  aBufferLength,
ByteCount &  oActualLength,
ByteCount &  oBytesRead,
OptionBits  opts 
)

Definition at line 274 of file nsUnicodeFontMappingMac.cpp.

{
    for(PRInt32 i = 0; i < mFontList.Count(); i++)
    {
        nsUnicodeFontMappingEntry* entry = (nsUnicodeFontMappingEntry*) mFontList[i];
        if(aFontNum == entry->GetFontNum())
            return entry->Convert(aString, aStringLength, aBuffer, aBufferLength,
                oActualLength, oBytesRead, opts);
    }
    return PR_FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 481 of file nsUnicodeFontMappingMac.cpp.

{
       PRUint32 i;
       if(&aMap != this) {
              for( i=0; i < smPseudoTotalScripts; i++)
              {
                     if(mScriptFallbackFontIDs[i] != aMap.mScriptFallbackFontIDs[i])
                            return PR_FALSE;
              }
              for( i=0; i < kUnicodeBlockVarScriptMax; i++)
              {
                     if(mPrivBlockToScript[i] != aMap.mPrivBlockToScript[i])
                            return PR_FALSE;
              }
       }
       return PR_TRUE;
}
PRBool nsUnicodeFontMappingMac::FontEnumCallback ( const nsString aFamily,
PRBool  aGeneric,
void aData 
) [static]

Definition at line 205 of file nsUnicodeFontMappingMac.cpp.

{
  MyFontEnumData* data = (MyFontEnumData*)aData;
  nsUnicodeMappingUtil * info = nsUnicodeMappingUtil::GetSingleton();
  NS_PRECONDITION(info != nsnull, "out of memory");
  if (aGeneric)
  {
       if(nsnull == info)
              return PR_FALSE;
    nsGenericFontNameType type = info->MapGenericFontNameType(aFamily);

       if( type != kUknownGenericFontName) {
           for(ScriptCode script = 0; script < 32 ; script++)
              {
                     const nsString* fontName =  info->GenericFontNameForScript(script,type);
                     if(nsnull != fontName) {
                         short fontNum;
                            nsDeviceContextMac::GetMacFontNumber(*fontName, fontNum);

        if(0 != fontNum)
        {
            nsUnicodeFontMappingEntry* entry = new nsUnicodeFontMappingEntry(nsnull, nsnull, fontNum, script);
            if (entry)
                data->mFontMapping->mFontList.AppendElement(entry);

            if (BAD_FONT_NUM == data->mFontMapping->mScriptFallbackFontIDs[ script ])
              data->mFontMapping->mScriptFallbackFontIDs[ script ] = fontNum;
            // since this is a generic font name, it won't impact the order of script we used
        }
                     }
              }
       }
  }
  else
  {
    nsAutoString realFace;
    PRBool  aliased;
    data->mContext->GetLocalFontName(aFamily, realFace, aliased);
    if (aliased || (NS_OK == data->mContext->CheckFontExistence(realFace)))
    {
           short fontNum;
              nsDeviceContextMac::GetMacFontNumber(realFace, fontNum);
              
              if(0 != fontNum) {
            nsCOMPtr<nsIUnicodeEncoder> converter;
            PRUint16 *ccmap = nsnull;

            // if this fails, aConverter & aCCMap will be nsnull
            nsMacUnicodeFontInfo::GetConverterAndCCMap(realFace, getter_AddRefs(converter), &ccmap);

            ScriptCode script = (converter ? BAD_SCRIPT : ::FontToScript(fontNum));

            nsUnicodeFontMappingEntry* entry = new nsUnicodeFontMappingEntry(converter, ccmap, fontNum, script);
            if(entry)
                data->mFontMapping->mFontList.AppendElement(entry);
            
            // only fill in this information for non-symbolic fonts
            if(!converter)
            {    
                if(BAD_FONT_NUM == data->mFontMapping->mScriptFallbackFontIDs[ script ]) 
                    data->mFontMapping->mScriptFallbackFontIDs[ script ] = fontNum;
                FillVarBlockToScript( script, data->mFontMapping->mPrivBlockToScript);
            }
              }
       }
  }
  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 702 of file nsUnicodeFontMappingMac.cpp.

{
   return (*(gAllGetBlock[(aChar >> 12)]))(aChar);
}

Here is the caller graph for this function:

Definition at line 501 of file nsUnicodeFontMappingMac.cpp.

                                                        {
    // initialize to bogus values
    short firstSymbolicFont = BAD_FONT_NUM, firstNonSymbolicFont = BAD_FONT_NUM;
    PRInt32 firstSymbolicFontIndex = -1;
    
    // Trap invisible chars
    if (CCMAP_HAS_CHAR_EXT(gIgnorableCCMapExt, aChar)) {
      return IGNORABLE_FONT_NUM;
    }

    // find the first symbolic font that has a glyph for aChar
    // and if there is one, remember it's index in the font list
    for(PRInt32 i = 0; i < mFontList.Count(); i++)
    {
        nsUnicodeFontMappingEntry* entry = (nsUnicodeFontMappingEntry*) mFontList[i];
        PRUint16 *ccmap = entry->GetCCMap();
        if(ccmap && CCMAP_HAS_CHAR(ccmap, aChar))
        {
            firstSymbolicFontIndex = i;
            firstSymbolicFont = entry->GetFontNum();
            break;
        }
    }

    // find the first non-symbolic font that has a glyph for aChar
       nsUnicodeBlock block = GetBlock(aChar);
       if(block < kUnicodeBlockFixedScriptMax) 
       {
              firstNonSymbolicFont = mScriptFallbackFontIDs[gUtil->BlockToScript(block)];
              
              // if there was no symbolic font we don't need to loop through the list again
        if(firstSymbolicFont == BAD_FONT_NUM)
            return firstNonSymbolicFont;
        
        // find the index of the first non symbolic font in the list and return the 
        // first font (symbolic or non symbolic) in the list that has a glyph for this char
        for(PRInt32 i = 0; i < mFontList.Count(); i++)
        {
            nsUnicodeFontMappingEntry* entry = (nsUnicodeFontMappingEntry*) mFontList[i];
            if(entry->GetFontNum() == firstNonSymbolicFont)
            {
                return (firstSymbolicFontIndex < i ? firstSymbolicFont : firstNonSymbolicFont);
            }
        }
        return firstNonSymbolicFont;
       }
       
    return (firstSymbolicFont != BAD_FONT_NUM ? firstSymbolicFont : 
              mScriptFallbackFontIDs[ mPrivBlockToScript[ block - kUnicodeBlockFixedScriptMax] ]);
}

Here is the call graph for this function:

Definition at line 60 of file nsUnicodeFontMappingMac.h.

Here is the caller graph for this function:

void nsUnicodeFontMappingMac::InitByFontFamily ( nsFont aFont,
nsIDeviceContext aDeviceContext 
) [protected]

Definition at line 295 of file nsUnicodeFontMappingMac.cpp.

{
    MyFontEnumData fontData(aDeviceContext, this);
    aFont->EnumerateFamilies(nsUnicodeFontMappingMac::FontEnumCallback, &fontData);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 344 of file nsUnicodeFontMappingMac.cpp.

{
       // do not countinue if there are no difference to look at the lang tag
       if( ScriptMapInitComplete() )
              return;
       const PRUnichar *p = aLANG.get();
       PRUint32 len = aLANG.Length();
       char language[3];
       char region[3];
       language[2] = region[2]= '\0';;
       language[0]= language[1] = region[0]= region[1] = ' ';
       PRUint32 state = 0;
       
       for(PRUint32 i = 0; (state != -1) && (i < len); i++, p++)
       {
              switch (state) {
                     case 0:
                            if(( ka <= *p) && (*p <= kz )) {
                                   language[state++] = (char)*p;
                            } else if( kSpace == *p) {
                                   state = 0;
                            } else {
                                   state = -1;
                            }
                            break;
                     case 1:
                            if(( ka <= *p) && (*p <= kz )) {
                                   language[state++] = (char)*p;
                            } else {
                                   state = -1;
                            }
                            break;
                     case 2:
                            if(kComma == *p) {
                                   processOneLangRegion(language, region);
                                   return;
                            } else if(kUnderline == *p) {
                                   state = 3;
                            } else {
                                   state = -1;
                            }
                            break;
                     case 3:
                     case 4:
                            if(( kA <= *p) && (*p <= kZ )) {
                                   region[state - 3] = (char)*p;
                                   state++;
                            } else {
                                   state = -1;
                            }
                            break;
                     case 5:
                            if(kComma == *p) {
                                   processOneLangRegion(language, region);
                                   return;
                            } else {
                                   state = -1;
                            }
                            break;
              };
       }
       if((2 == state) || (5 == state)) {
              processOneLangRegion(language, region);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 410 of file nsUnicodeFontMappingMac.cpp.

{
       // do not continue if there are no difference to look at the document Charset
       if( ScriptMapInitComplete() )
              return;
       if(aLangGroup.LowerCaseEqualsLiteral("x-western"))
       {
              FillVarBlockToScript(smRoman, mPrivBlockToScript);             
       } else if(aLangGroup.LowerCaseEqualsLiteral("zh-cn"))
       {
              FillVarBlockToScript(smSimpChinese, mPrivBlockToScript);
       } else if(aLangGroup.LowerCaseEqualsLiteral("ko"))
       {
              FillVarBlockToScript(smKorean, mPrivBlockToScript);
       } else if(aLangGroup.LowerCaseEqualsLiteral("zh-tw") ||
              aLangGroup.LowerCaseEqualsLiteral("zh-hk"))
       {
              FillVarBlockToScript(smTradChinese, mPrivBlockToScript);
       } else if(aLangGroup.LowerCaseEqualsLiteral("ja"))
       {
              FillVarBlockToScript(smJapanese, mPrivBlockToScript);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 435 of file nsUnicodeFontMappingMac.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void nsUnicodeFontMappingMac::processOneLangRegion ( const char *  aLanguage,
const char *  aRegion 
) [protected]

Definition at line 302 of file nsUnicodeFontMappingMac.cpp.

{
       if ((! nsCRT::strcmp(aLanguage,"zh")) &&
           ((! nsCRT::strcmp(aRegion,"TW")) || (! nsCRT::strcmp(aRegion,"HK"))))
       {
              FillVarBlockToScript(smTradChinese, mPrivBlockToScript);
       } 
       else if(! nsCRT::strcmp(aLanguage,"zh"))
       {
              FillVarBlockToScript(smSimpChinese, mPrivBlockToScript);
       } 
       else if(! nsCRT::strcmp(aLanguage,"ko"))
       {
              FillVarBlockToScript(smKorean, mPrivBlockToScript);
       }
       else if(! nsCRT::strcmp(aLanguage,"ja"))
       {
              FillVarBlockToScript(smJapanese, mPrivBlockToScript);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 323 of file nsUnicodeFontMappingMac.cpp.

Here is the caller graph for this function:


Member Data Documentation

Definition at line 85 of file nsUnicodeFontMappingMac.h.

nsAutoVoidArray nsUnicodeFontMappingMac::mFontList [private]

Definition at line 83 of file nsUnicodeFontMappingMac.h.

Definition at line 81 of file nsUnicodeFontMappingMac.h.

Definition at line 82 of file nsUnicodeFontMappingMac.h.


The documentation for this class was generated from the following files: