Back to index

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

#include <nsFontMetricsPS.h>

Inheritance diagram for nsFontPSAFM:
Inheritance graph
[legend]
Collaboration diagram for nsFontPSAFM:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsFontPSAFM (const nsFont &aFont, nsAFMObject *aAFMInfo, PRInt16 aFontIndex, nsFontMetricsPS *aFontMetrics)
virtual ~nsFontPSAFM ()
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
nscoord 
GetWidth (const char *aString, PRUint32 aLength)
nscoord GetWidth (const PRUnichar *aString, PRUint32 aLength)
nscoord DrawString (nsRenderingContextPS *aContext, nscoord aX, nscoord aY, const char *aString, PRUint32 aLength)
nscoord DrawString (nsRenderingContextPS *aContext, nscoord aX, nscoord aY, const PRUnichar *aString, PRUint32 aLength)
nsresult RealizeFont (nsFontMetricsPS *aFontMetrics, float dev2app)
nsresult SetupFont (nsRenderingContextPS *aContext)
PRInt32 SupportsChar (PRUnichar aChar)

Static Public Member Functions

static nsFontPSFindFont (const nsFont &aFont, nsFontMetricsPS *aFontMetrics)
static
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
nsFontPS
FindFont (char aChar, const nsFont &aFont, nsFontMetricsPS *aFontMetrics)
static nsFontPSFindFont (PRUnichar aChar, const nsFont &aFont, nsFontMetricsPS *aFontMetrics)

Public Attributes

nsAFMObjectmAFMInfo
PRInt16 mFontIndex
nsString mFamilyName

Protected Attributes

nsFontmFont
PRUint16mCCMap
nsFontMetricsPSmFontMetrics

Detailed Description

Definition at line 224 of file nsFontMetricsPS.h.


Constructor & Destructor Documentation

nsFontPSAFM::nsFontPSAFM ( const nsFont aFont,
nsAFMObject aAFMInfo,
PRInt16  aFontIndex,
nsFontMetricsPS aFontMetrics 
)

Definition at line 564 of file nsFontMetricsPS.cpp.

                                                                           :
nsFontPS(aFont, aFontMetrics), mAFMInfo(aAFMInfo), mFontIndex(fontIndex)
{
  if (!(mFont && mAFMInfo)) return;
  AppendASCIItoUTF16(mAFMInfo->mPSFontInfo->mFamilyName, mFamilyName);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 572 of file nsFontMetricsPS.cpp.

{
  if (mAFMInfo) {
    delete mAFMInfo;
    mAFMInfo = nsnull;
  }
}

Member Function Documentation

nscoord nsFontPSAFM::DrawString ( nsRenderingContextPS aContext,
nscoord  aX,
nscoord  aY,
const char *  aString,
PRUint32  aLength 
) [virtual]

Implements nsFontPS.

Definition at line 601 of file nsFontMetricsPS.cpp.

{
  NS_ENSURE_TRUE(aContext, 0);
  nsPostScriptObj* psObj = aContext->GetPostScriptObj();
  NS_ENSURE_TRUE(psObj, 0);

  psObj->moveto(aX, aY);
  psObj->show(aString, aLength, "");
  return GetWidth(aString, aLength);
}

Here is the call graph for this function:

nscoord nsFontPSAFM::DrawString ( nsRenderingContextPS aContext,
nscoord  aX,
nscoord  aY,
const PRUnichar aString,
PRUint32  aLength 
) [virtual]

Implements nsFontPS.

Definition at line 615 of file nsFontMetricsPS.cpp.

{
  NS_ENSURE_TRUE(aContext, 0);
  nsPostScriptObj* psObj = aContext->GetPostScriptObj();
  NS_ENSURE_TRUE(psObj, 0);

  psObj->moveto(aX, aY);
  psObj->show(aString, aLength, "", 0);
  return GetWidth(aString, aLength);
}

Here is the call graph for this function:

nsFontPS * nsFontPS::FindFont ( char  aChar,
const nsFont aFont,
nsFontMetricsPS aFontMetrics 
) [static, inherited]

Definition at line 465 of file nsFontMetricsPS.cpp.

{
  PRUnichar uc = (unsigned char)aChar;
  return FindFont(uc, aFont, aFontMetrics);
}

Here is the caller graph for this function:

nsFontPS * nsFontPS::FindFont ( PRUnichar  aChar,
const nsFont aFont,
nsFontMetricsPS aFontMetrics 
) [static, inherited]

Definition at line 474 of file nsFontMetricsPS.cpp.

{
  nsFontPS* fontPS;

#if defined(MOZ_ENABLE_FREETYPE2) || defined(MOZ_ENABLE_XFT)
  nsDeviceContextPS* dc = aFontMetrics->GetDeviceContext();
  NS_ENSURE_TRUE(dc, nsnull);
  if (dc->mFTPEnable) {
#ifdef MOZ_ENABLE_XFT
    fontPS = nsFontPSXft::FindFont(aChar, aFont, aFontMetrics);
#else
    fontPS = nsFontPSFreeType::FindFont(aChar, aFont, aFontMetrics);
#endif
    if (fontPS)
      return fontPS;
  }
#endif

  /* Find in afm font */
  if (aFontMetrics->GetFontsPS()->Count() > 0) {
    fontps *fps = (fontps*)aFontMetrics->GetFontsPS()->ElementAt(0);
    NS_ENSURE_TRUE(fps, nsnull);
    fontPS = fps->fontps;
  }
  else {
    fontPS = nsFontPSAFM::FindFont(aFont, aFontMetrics);
    fontps *fps = new fontps;
    NS_ENSURE_TRUE(fps, nsnull);
    fps->fontps = fontPS;
#if defined(MOZ_ENABLE_XFT) || defined(MOZ_ENABLE_FREETYPE2) 
    fps->entry  = nsnull;
#ifdef MOZ_ENABLE_XFT
    fps->charset = nsnull;
#else
    fps->ccmap  = nsnull;
#endif
#endif
    aFontMetrics->GetFontsPS()->AppendElement(fps);
  }
  return fontPS;
}

Here is the call graph for this function:

nsFontPS * nsFontPSAFM::FindFont ( const nsFont aFont,
nsFontMetricsPS aFontMetrics 
) [static]

Definition at line 540 of file nsFontMetricsPS.cpp.

{
  nsAFMObject* afmInfo = new nsAFMObject();
  if (!afmInfo) return nsnull;
  afmInfo->Init(aFont.size);

  PRInt16 fontIndex = afmInfo->CheckBasicFonts(aFont, PR_TRUE);
  if (fontIndex < 0) {
    if (!(afmInfo->AFM_ReadFile(aFont))) {
      fontIndex = afmInfo->CheckBasicFonts(aFont, PR_FALSE);
      if (fontIndex < 0) {
        fontIndex = afmInfo->CreateSubstituteFont(aFont);
      }
    }
  }

  nsFontPSAFM* fontPSAFM = nsnull;
  if (fontIndex < 0)
    delete afmInfo;
  else
    fontPSAFM = new nsFontPSAFM(aFont, afmInfo, fontIndex, aFontMetrics);
  return fontPSAFM;
}

Here is the call graph for this function:

nscoord nsFontPSAFM::GetWidth ( const char *  aString,
PRUint32  aLength 
) [virtual]

Implements nsFontPS.

Definition at line 581 of file nsFontMetricsPS.cpp.

{
  nscoord width = 0;
  if (mAFMInfo) {
    mAFMInfo->GetStringWidth(aString, width, aLength);
  }
  return width;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nscoord nsFontPSAFM::GetWidth ( const PRUnichar aString,
PRUint32  aLength 
) [virtual]

Implements nsFontPS.

Definition at line 591 of file nsFontMetricsPS.cpp.

{
  nscoord width = 0;
  if (mAFMInfo) {
    mAFMInfo->GetStringWidth(aString, width, aLength);
  }
  return width;
}

Here is the call graph for this function:

nsresult nsFontPSAFM::RealizeFont ( nsFontMetricsPS aFontMetrics,
float  dev2app 
) [virtual]

Implements nsFontPS.

Definition at line 629 of file nsFontMetricsPS.cpp.

{
  NS_ENSURE_ARG_POINTER(aFontMetrics);

  float fontSize;
  float offset;

  nscoord onePixel = NSToCoordRound(1 * dev2app);

  // convert the font size which is in twips to points
  fontSize = mFont->size / TWIPS_PER_POINT_FLOAT;

  offset = NSFloatPointsToTwips(fontSize * mAFMInfo->mPSFontInfo->mXHeight) / 1000.0f;
  nscoord xHeight = NSToCoordRound(offset);
  aFontMetrics->SetXHeight(xHeight);
  aFontMetrics->SetSuperscriptOffset(xHeight);
  aFontMetrics->SetSubscriptOffset(xHeight);
  aFontMetrics->SetStrikeout((nscoord)(xHeight / 2), onePixel);

  offset = NSFloatPointsToTwips(fontSize * mAFMInfo->mPSFontInfo->mUnderlinePosition) / 1000.0f;
  aFontMetrics->SetUnderline(NSToCoordRound(offset), onePixel);

  nscoord size = NSToCoordRound(fontSize * dev2app);
  aFontMetrics->SetHeight(size);
  aFontMetrics->SetEmHeight(size);
  aFontMetrics->SetMaxAdvance(size);
  aFontMetrics->SetMaxHeight(size);

  offset = NSFloatPointsToTwips(fontSize * mAFMInfo->mPSFontInfo->mAscender) / 1000.0f;
  nscoord ascent = NSToCoordRound(offset);
  aFontMetrics->SetAscent(ascent);
  aFontMetrics->SetEmAscent(ascent);
  aFontMetrics->SetMaxAscent(ascent);

  offset = NSFloatPointsToTwips(fontSize * mAFMInfo->mPSFontInfo->mDescender) / 1000.0f;
  nscoord descent = -(NSToCoordRound(offset));
  aFontMetrics->SetDescent(descent);
  aFontMetrics->SetEmDescent(descent);
  aFontMetrics->SetMaxDescent(descent);

  aFontMetrics->SetLeading(0);

  nscoord spaceWidth = GetWidth(" ", 1);
  aFontMetrics->SetSpaceWidth(spaceWidth);

  nscoord aveCharWidth = GetWidth("x", 1);
  aFontMetrics->SetAveCharWidth(aveCharWidth);

  return NS_OK;
}

Here is the call graph for this function:

Implements nsFontPS.

Definition at line 681 of file nsFontMetricsPS.cpp.

{
  NS_ENSURE_TRUE(aContext && mFontMetrics, 0);
  nsPostScriptObj* psObj = aContext->GetPostScriptObj();
  NS_ENSURE_TRUE(psObj, 0);

  nscoord fontHeight = 0;
  mFontMetrics->GetHeight(fontHeight);

  psObj->setscriptfont(mFontIndex, mFamilyName,
                       fontHeight, mFont->style, mFont->variant,
                       mFont->weight, mFont->decorations);
  return NS_OK;
}

Here is the call graph for this function:

PRInt32 nsFontPS::SupportsChar ( PRUnichar  aChar) [inline, inherited]

Definition at line 193 of file nsFontMetricsPS.h.

    { return mCCMap && CCMAP_HAS_CHAR(mCCMap, aChar); };

Member Data Documentation

Definition at line 256 of file nsFontMetricsPS.h.

PRUint16* nsFontPS::mCCMap [protected, inherited]

Definition at line 220 of file nsFontMetricsPS.h.

Definition at line 258 of file nsFontMetricsPS.h.

nsFont* nsFontPS::mFont [protected, inherited]

Definition at line 219 of file nsFontMetricsPS.h.

Definition at line 257 of file nsFontMetricsPS.h.

nsFontMetricsPS* nsFontPS::mFontMetrics [protected, inherited]

Definition at line 221 of file nsFontMetricsPS.h.


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