Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions
nsFontMetricsMac.cpp File Reference
#include "nsCarbonHelpers.h"
#include "nsFontMetricsMac.h"
#include "nsDeviceContextMac.h"
#include "nsUnicodeFontMappingMac.h"
#include "nsUnicodeMappingUtil.h"
#include "nsGfxUtils.h"
#include "nsFontUtils.h"

Go to the source code of this file.

Classes

struct  FontEnumData

Functions

static void MapGenericFamilyToFont (const nsString &aGenericFamily, nsString &aFontFace, ScriptCode aScriptCode)
static PRBool FontEnumCallback (const nsString &aFamily, PRBool aGeneric, void *aData)

Function Documentation

static PRBool FontEnumCallback ( const nsString aFamily,
PRBool  aGeneric,
void aData 
) [static]

Definition at line 199 of file nsFontMetricsMac.cpp.

{
  FontEnumData* data = (FontEnumData*)aData;
  if (aGeneric)
  {
    nsAutoString realFace;
    MapGenericFamilyToFont(aFamily, realFace, data->mScriptCode);
    data->mFaceName = realFace;
    return PR_FALSE;  // stop
  }
  else
  {
    nsAutoString realFace;
    PRBool  aliased;
    data->mContext->GetLocalFontName(aFamily, realFace, aliased);
    if (aliased || (NS_OK == data->mContext->CheckFontExistence(realFace)))
    {
       data->mFaceName = realFace;
      return PR_FALSE;  // stop
    }
  }
  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void MapGenericFamilyToFont ( const nsString aGenericFamily,
nsString aFontFace,
ScriptCode  aScriptCode 
) [static]

Definition at line 142 of file nsFontMetricsMac.cpp.

{
  // the CSS generic names (conversions from the old Mac Mozilla code for now)
  nsUnicodeMappingUtil* unicodeMappingUtil = nsUnicodeMappingUtil::GetSingleton();
  if (unicodeMappingUtil)
  {
    nsString*   foundFont = unicodeMappingUtil->GenericFontNameForScript(
          aScriptCode,
          unicodeMappingUtil->MapGenericFontNameType(aGenericFamily));
    if (foundFont)
    {
      aFontFace = *foundFont;
      return;
    }
  }
  
  NS_ASSERTION(0, "Failed to find a font");
  aFontFace.AssignLiteral("Times");
       
  /*
  // fall back onto hard-coded font names
  if (aGenericFamily.LowerCaseEqualsLiteral("serif"))
  {
    aFontFace.AssignLiteral("Times");
  }
  else if (aGenericFamily.LowerCaseEqualsLiteral("sans-serif"))
  {
    aFontFace.AssignLiteral("Helvetica");
  }
  else if (aGenericFamily.LowerCaseEqualsLiteral("cursive"))
  {
     aFontFace.AssignLiteral("Apple Chancery");
  }
  else if (aGenericFamily.LowerCaseEqualsLiteral("fantasy"))
  {
    aFontFace.AssignLiteral("Gadget");
  }
  else if (aGenericFamily.LowerCaseEqualsLiteral("monospace"))
  {
    aFontFace.AssignLiteral("Courier");
  }
  else if (aGenericFamily.LowerCaseEqualsLiteral("-moz-fixed"))
  {
    aFontFace.AssignLiteral("Courier");
  }
  */
}

Here is the call graph for this function:

Here is the caller graph for this function: