Back to index

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

#include <nsFontMetricsPS.h>

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

List of all members.

Public Member Functions

 nsFontMetricsPS ()
 
See documentation in nsFontMetricsPS.h 2/26/99 dwc
virtual ~nsFontMetricsPS ()
 
See documentation in nsFontMetricsPS.h 2/26/99 dwc
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
NS_DECL_ISUPPORTS NS_IMETHOD 
Init (const nsFont &aFont, nsIAtom *aLangGroup, nsIDeviceContext *aContext)
 
See documentation in nsFontMetricsPS.h 2/26/99 dwc
NS_IMETHOD Destroy ()
 Destroy this font metrics.
NS_IMETHOD GetXHeight (nscoord &aResult)
 
See documentation in nsFontMetricsPS.h 2/26/99 dwc
NS_IMETHOD GetSuperscriptOffset (nscoord &aResult)
 
See documentation in nsFontMetricsPS.h 2/26/99 dwc
NS_IMETHOD GetSubscriptOffset (nscoord &aResult)
 
See documentation in nsFontMetricsPS.h 2/26/99 dwc
NS_IMETHOD GetStrikeout (nscoord &aOffset, nscoord &aSize)
 
See documentation in nsFontMetricsPS.h 2/26/99 dwc
NS_IMETHOD GetUnderline (nscoord &aOffset, nscoord &aSize)
 
See documentation in nsFontMetricsPS.h 2/26/99 dwc
NS_IMETHOD GetHeight (nscoord &aHeight)
 
See documentation in nsFontMetricsPS.h 2/26/99 dwc
NS_IMETHOD GetNormalLineHeight (nscoord &aHeight)
 
See documentation in nsFontMetricsPS.h
NS_IMETHOD GetLeading (nscoord &aLeading)
 
See documentation in nsFontMetricsPS.h 2/26/99 dwc
NS_IMETHOD GetEmHeight (nscoord &aHeight)
 
See documentation in nsFontMetricsPS.h
NS_IMETHOD GetEmAscent (nscoord &aAscent)
 
See documentation in nsFontMetricsPS.h
NS_IMETHOD GetEmDescent (nscoord &aDescent)
 
See documentation in nsFontMetricsPS.h
NS_IMETHOD GetMaxHeight (nscoord &aHeight)
 
See documentation in nsFontMetricsPS.h
NS_IMETHOD GetMaxAscent (nscoord &aAscent)
 
See documentation in nsFontMetricsPS.h 2/26/99 dwc
NS_IMETHOD GetMaxDescent (nscoord &aDescent)
 
See documentation in nsFontMetricsPS.h 2/26/99 dwc
NS_IMETHOD GetMaxAdvance (nscoord &aAdvance)
 
See documentation in nsFontMetricsPS.h 2/26/99 dwc
NS_IMETHOD GetAveCharWidth (nscoord &aAveCharWidth)
 Returns the average character width.
NS_IMETHOD GetSpaceWidth (nscoord &aAveCharWidth)
 
See documentation in nsFontMetricsPS.h 2/26/99 dwc
NS_IMETHOD GetLangGroup (nsIAtom **aLangGroup)
 Returns the language group associated with these metrics.
NS_IMETHOD GetFontHandle (nsFontHandle &aHandle)
 
See documentation in nsFontMetricsPS.h 2/26/99 dwc
NS_IMETHOD GetStringWidth (const char *String, nscoord &aWidth, nscoord aLength)
 
See documentation in nsFontMetricsPS.h 2/26/99 dwc
NS_IMETHOD GetStringWidth (const PRUnichar *aString, nscoord &aWidth, nscoord aLength)
 
See documentation in nsFontMetricsPS.h 2/26/99 dwc
void SetXHeight (nscoord aXHeight)
void SetSuperscriptOffset (nscoord aSuperscriptOffset)
void SetSubscriptOffset (nscoord aSubscriptOffset)
void SetStrikeout (nscoord aOffset, nscoord aSize)
void SetUnderline (nscoord aOffset, nscoord aSize)
void SetHeight (nscoord aHeight)
void SetLeading (nscoord aLeading)
void SetAscent (nscoord aAscent)
void SetDescent (nscoord aDescent)
void SetEmHeight (nscoord aEmHeight)
void SetEmAscent (nscoord aEmAscent)
void SetEmDescent (nscoord aEmDescent)
void SetMaxHeight (nscoord aMaxHeight)
void SetMaxAscent (nscoord aMaxAscent)
void SetMaxDescent (nscoord aMaxDescent)
void SetMaxAdvance (nscoord aMaxAdvance)
void SetAveCharWidth (nscoord aAveCharWidth)
void SetSpaceWidth (nscoord aSpaceWidth)
nsDeviceContextPSGetDeviceContext ()
nsVoidArrayGetFontsPS ()
nsHashtable * GetFontsAlreadyLoadedList ()
int GetFontPSState ()
void IncrementFontPSState ()
const nsFontFont ()
 Returns the font associated with these metrics.

Protected Member Functions

void RealizeFont ()
 
See documentation in nsFontMetricsPS.h 2/26/99 dwc

Protected Attributes

nsDeviceContextPSmDeviceContext
nscoord mHeight
nscoord mAscent
nscoord mDescent
nscoord mLeading
nscoord mEmHeight
nscoord mEmAscent
nscoord mEmDescent
nscoord mMaxHeight
nscoord mMaxAscent
nscoord mMaxDescent
nscoord mMaxAdvance
nscoord mXHeight
nscoord mSuperscriptOffset
nscoord mSubscriptOffset
nscoord mStrikeoutSize
nscoord mStrikeoutOffset
nscoord mUnderlineSize
nscoord mUnderlineOffset
nscoord mSpaceWidth
nscoord mAveCharWidth
nsVoidArraymFontsPS
nsHashtable * mFontsAlreadyLoaded
int mFontPSState
nsFont mFont

Private Attributes

nsCOMPtr< nsIAtommLangGroup

Detailed Description

Definition at line 75 of file nsFontMetricsPS.h.


Constructor & Destructor Documentation


See documentation in nsFontMetricsPS.h 2/26/99 dwc

Definition at line 89 of file nsFontMetricsPS.cpp.

{
}


See documentation in nsFontMetricsPS.h 2/26/99 dwc

Definition at line 97 of file nsFontMetricsPS.cpp.

{
  if (mFontsPS) {
    int i;
    for (i=0; i<mFontsPS->Count(); i++) {
      fontps *fontPS = (fontps *)mFontsPS->ElementAt(i);
      if (!fontPS)
        continue;
      if (fontPS->fontps)
        delete fontPS->fontps;
#ifdef MOZ_ENABLE_XFT
      if (fontPS->entry)
        delete fontPS->entry;
      if (fontPS->charset)
        FcCharSetDestroy(fontPS->charset);
#else
#ifdef MOZ_ENABLE_FREETYPE2
      NS_IF_RELEASE(fontPS->entry);
      if (fontPS->ccmap)
        FreeCCMap(fontPS->ccmap);
#endif
#endif
      delete fontPS;
    }
    delete mFontsPS;
  }

  if (mFontsAlreadyLoaded) {
    delete mFontsAlreadyLoaded;
  }

  if (mDeviceContext) {
    // Notify our device context that owns us so that it can update its font cache
    mDeviceContext->FontMetricsDeleted(this);
    mDeviceContext = nsnull;
  }
}

Here is the call graph for this function:


Member Function Documentation

Destroy this font metrics.

This breaks the association between the font metrics and the device context.

Implements nsIFontMetrics.

Definition at line 166 of file nsFontMetricsPS.cpp.

{
  mDeviceContext = nsnull;
  return NS_OK;
}
const nsFont& nsIFontMetrics::Font ( ) [inline, inherited]

Returns the font associated with these metrics.

The return value is only defined after Init() has been called.

Definition at line 214 of file nsIFontMetrics.h.

{ return mFont; }

Here is the caller graph for this function:

NS_IMETHODIMP nsFontMetricsPS::GetAveCharWidth ( nscoord aAveCharWidth) [virtual]

Returns the average character width.

Implements nsIFontMetrics.

Definition at line 358 of file nsFontMetricsPS.cpp.

{
  aAveCharWidth = mAveCharWidth;
  return NS_OK;
}

Definition at line 131 of file nsFontMetricsPS.h.

{ return mDeviceContext; }

Here is the caller graph for this function:


See documentation in nsFontMetricsPS.h

Implements nsIFontMetrics.

Definition at line 298 of file nsFontMetricsPS.cpp.

{
  aAscent = mEmAscent;
  return NS_OK;
}


See documentation in nsFontMetricsPS.h

Implements nsIFontMetrics.

Definition at line 308 of file nsFontMetricsPS.cpp.

{
  aDescent = mEmDescent;
  return NS_OK;
}


See documentation in nsFontMetricsPS.h

Implements nsIFontMetrics.

Definition at line 288 of file nsFontMetricsPS.cpp.

{
  aHeight = mEmHeight;
  return NS_OK;
}


See documentation in nsFontMetricsPS.h 2/26/99 dwc

Implements nsIFontMetrics.

Definition at line 393 of file nsFontMetricsPS.cpp.

{

  return NS_OK;
}

Definition at line 134 of file nsFontMetricsPS.h.

{ return mFontPSState; };
nsHashtable* nsFontMetricsPS::GetFontsAlreadyLoadedList ( ) [inline]

Definition at line 133 of file nsFontMetricsPS.h.

Definition at line 132 of file nsFontMetricsPS.h.

{ return mFontsPS; };

Here is the caller graph for this function:


See documentation in nsFontMetricsPS.h 2/26/99 dwc

Implements nsIFontMetrics.

Definition at line 257 of file nsFontMetricsPS.cpp.

{
  aHeight = mHeight;
  return NS_OK;
}

Here is the caller graph for this function:

NS_IMETHODIMP nsFontMetricsPS::GetLangGroup ( nsIAtom **  aLangGroup) [virtual]

Returns the language group associated with these metrics.

Implements nsIFontMetrics.

Definition at line 376 of file nsFontMetricsPS.cpp.

{
  if (!aLangGroup) {
    return NS_ERROR_NULL_POINTER;
  }

  *aLangGroup = mLangGroup;
  NS_IF_ADDREF(*aLangGroup);

  return NS_OK;
}


See documentation in nsFontMetricsPS.h 2/26/99 dwc

Implements nsIFontMetrics.

Definition at line 278 of file nsFontMetricsPS.cpp.

{
  aLeading = mLeading;
  return NS_OK;
}


See documentation in nsFontMetricsPS.h 2/26/99 dwc

Implements nsIFontMetrics.

Definition at line 351 of file nsFontMetricsPS.cpp.

{
  aAdvance = mMaxAdvance;
  return NS_OK;
}


See documentation in nsFontMetricsPS.h 2/26/99 dwc

Implements nsIFontMetrics.

Definition at line 329 of file nsFontMetricsPS.cpp.

{
  aAscent = mMaxAscent;
  return NS_OK;
}

Here is the caller graph for this function:


See documentation in nsFontMetricsPS.h 2/26/99 dwc

Implements nsIFontMetrics.

Definition at line 340 of file nsFontMetricsPS.cpp.

{
  aDescent = mMaxDescent;
  return NS_OK;
}

Here is the caller graph for this function:


See documentation in nsFontMetricsPS.h

Implements nsIFontMetrics.

Definition at line 318 of file nsFontMetricsPS.cpp.

{
  aHeight = mMaxHeight;
  return NS_OK;
}


See documentation in nsFontMetricsPS.h

Implements nsIFontMetrics.

Definition at line 267 of file nsFontMetricsPS.cpp.

{
  aHeight = mEmHeight + mLeading;
  return NS_OK;
}
NS_IMETHODIMP nsFontMetricsPS::GetSpaceWidth ( nscoord aAveCharWidth) [virtual]


See documentation in nsFontMetricsPS.h 2/26/99 dwc

Implements nsIFontMetrics.

Definition at line 369 of file nsFontMetricsPS.cpp.

{
  aSpaceWidth = mSpaceWidth;
  return NS_OK;
}
NS_IMETHODIMP nsFontMetricsPS::GetStrikeout ( nscoord aOffset,
nscoord aSize 
) [virtual]


See documentation in nsFontMetricsPS.h 2/26/99 dwc

Implements nsIFontMetrics.

Definition at line 233 of file nsFontMetricsPS.cpp.

{
  aOffset = mStrikeoutOffset;
  aSize = mStrikeoutSize;
  return NS_OK;
}
NS_IMETHODIMP nsFontMetricsPS::GetStringWidth ( const char *  String,
nscoord aWidth,
nscoord  aLength 
)


See documentation in nsFontMetricsPS.h 2/26/99 dwc

Definition at line 404 of file nsFontMetricsPS.cpp.

{
  aWidth = 0;
  if (aLength == 0)
    return NS_OK;
  nsFontPS* fontPS = nsFontPS::FindFont(aString[0], mFont, this);
  NS_ENSURE_TRUE(fontPS, NS_ERROR_FAILURE);

  nscoord i, start = 0;
  for (i=0; i<aLength; i++) {
    nsFontPS* fontThisChar = nsFontPS::FindFont(aString[i], mFont, this);
    NS_ASSERTION(fontThisChar,"failed to find a font");
    NS_ENSURE_TRUE(fontThisChar, NS_ERROR_FAILURE);
    if (fontThisChar != fontPS) {
      // measure text up to this point
      aWidth += fontPS->GetWidth(aString+start, i-start);
      start = i;
      fontPS = fontThisChar;
    }
  }
  // measure the last part
  if (aLength-start)
      aWidth += fontPS->GetWidth(aString+start, aLength-start);

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsFontMetricsPS::GetStringWidth ( const PRUnichar aString,
nscoord aWidth,
nscoord  aLength 
)


See documentation in nsFontMetricsPS.h 2/26/99 dwc

Definition at line 437 of file nsFontMetricsPS.cpp.

{
  aWidth = 0;
  if (aLength == 0)
    return NS_OK;
  nsFontPS* fontPS = nsFontPS::FindFont(aString[0], mFont, this);
  NS_ENSURE_TRUE(fontPS, NS_ERROR_FAILURE);

  nscoord i, start = 0;
  for (i=0; i<aLength; i++) {
    nsFontPS* fontThisChar = nsFontPS::FindFont(aString[i], mFont, this);
    NS_ASSERTION(fontThisChar,"failed to find a font");
    NS_ENSURE_TRUE(fontThisChar, NS_ERROR_FAILURE);
    if (fontThisChar != fontPS) {
      // measure text up to this point
      aWidth += fontPS->GetWidth(aString+start, i-start);
      start = i;
      fontPS = fontThisChar;
    }
  }
  // measure the last part
  if (aLength-start)
      aWidth += fontPS->GetWidth(aString+start, aLength-start);

  return NS_OK;
}

Here is the call graph for this function:


See documentation in nsFontMetricsPS.h 2/26/99 dwc

Implements nsIFontMetrics.

Definition at line 222 of file nsFontMetricsPS.cpp.


See documentation in nsFontMetricsPS.h 2/26/99 dwc

Implements nsIFontMetrics.

Definition at line 211 of file nsFontMetricsPS.cpp.

NS_IMETHODIMP nsFontMetricsPS::GetUnderline ( nscoord aOffset,
nscoord aSize 
) [virtual]


See documentation in nsFontMetricsPS.h 2/26/99 dwc

Implements nsIFontMetrics.

Definition at line 245 of file nsFontMetricsPS.cpp.

{
  aOffset = mUnderlineOffset;
  aSize = mUnderlineSize;
  return NS_OK;
}


See documentation in nsFontMetricsPS.h 2/26/99 dwc

Implements nsIFontMetrics.

Definition at line 200 of file nsFontMetricsPS.cpp.

{
  aResult = mXHeight;
  return NS_OK;
}

Definition at line 135 of file nsFontMetricsPS.h.

{ mFontPSState++; };
NS_IMETHODIMP nsFontMetricsPS::Init ( const nsFont aFont,
nsIAtom aLangGroup,
nsIDeviceContext aContext 
) [virtual]


See documentation in nsFontMetricsPS.h 2/26/99 dwc

Implements nsIFontMetrics.

Definition at line 142 of file nsFontMetricsPS.cpp.

{
  mLangGroup = aLangGroup;

  mFont = aFont;

  //don't addref this to avoid circular refs
  mDeviceContext = (nsDeviceContextPS *)aContext;

  mFontsPS = new nsVoidArray();
  NS_ENSURE_TRUE(mFontsPS, NS_ERROR_OUT_OF_MEMORY);
  mFontsAlreadyLoaded = new nsHashtable();
  NS_ENSURE_TRUE(mFontsAlreadyLoaded, NS_ERROR_OUT_OF_MEMORY);

  // make sure we have at least one font
  nsFontPS *fontPS = nsFontPS::FindFont('a', aFont, this);
  NS_ENSURE_TRUE(fontPS, NS_ERROR_FAILURE);

  RealizeFont();
  return NS_OK;
}

Here is the call graph for this function:


See documentation in nsFontMetricsPS.h 2/26/99 dwc

Definition at line 178 of file nsFontMetricsPS.cpp.

{
  if (mDeviceContext) {
    float dev2app;
    dev2app = mDeviceContext->DevUnitsToAppUnits();
    fontps *font = (fontps*)mFontsPS->ElementAt(0);
#if defined(MOZ_ENABLE_FREETYPE2) || defined(MOZ_ENABLE_XFT)
    NS_ASSERTION(font && font->entry, "no font available");
    if (font && !font->fontps && font->entry)
      font->fontps = CreateFontPS(font->entry, mFont, this);
#endif
    NS_ASSERTION(font && font->fontps, "no font available");
    if (font && font->fontps)
      font->fontps->RealizeFont(this, dev2app);
  }
}

Here is the call graph for this function:

void nsFontMetricsPS::SetAscent ( nscoord  aAscent) [inline]

Definition at line 119 of file nsFontMetricsPS.h.

{ mAscent = aAscent; };

Here is the caller graph for this function:

void nsFontMetricsPS::SetAveCharWidth ( nscoord  aAveCharWidth) [inline]

Definition at line 128 of file nsFontMetricsPS.h.

{ mAveCharWidth = aAveCharWidth; };

Here is the caller graph for this function:

void nsFontMetricsPS::SetDescent ( nscoord  aDescent) [inline]

Definition at line 120 of file nsFontMetricsPS.h.

{ mDescent = aDescent; };

Here is the caller graph for this function:

void nsFontMetricsPS::SetEmAscent ( nscoord  aEmAscent) [inline]

Definition at line 122 of file nsFontMetricsPS.h.

{ mEmAscent = aEmAscent; };

Here is the caller graph for this function:

void nsFontMetricsPS::SetEmDescent ( nscoord  aEmDescent) [inline]

Definition at line 123 of file nsFontMetricsPS.h.

{ mEmDescent = aEmDescent; };

Here is the caller graph for this function:

void nsFontMetricsPS::SetEmHeight ( nscoord  aEmHeight) [inline]

Definition at line 121 of file nsFontMetricsPS.h.

{ mEmHeight = aEmHeight; };

Here is the caller graph for this function:

void nsFontMetricsPS::SetHeight ( nscoord  aHeight) [inline]

Definition at line 117 of file nsFontMetricsPS.h.

{ mHeight = aHeight; };

Here is the caller graph for this function:

void nsFontMetricsPS::SetLeading ( nscoord  aLeading) [inline]

Definition at line 118 of file nsFontMetricsPS.h.

{ mLeading = aLeading; };

Here is the caller graph for this function:

void nsFontMetricsPS::SetMaxAdvance ( nscoord  aMaxAdvance) [inline]

Definition at line 127 of file nsFontMetricsPS.h.

{ mMaxAdvance = aMaxAdvance; };

Here is the caller graph for this function:

void nsFontMetricsPS::SetMaxAscent ( nscoord  aMaxAscent) [inline]

Definition at line 125 of file nsFontMetricsPS.h.

{ mMaxAscent = aMaxAscent; };

Here is the caller graph for this function:

void nsFontMetricsPS::SetMaxDescent ( nscoord  aMaxDescent) [inline]

Definition at line 126 of file nsFontMetricsPS.h.

{ mMaxDescent = aMaxDescent; };

Here is the caller graph for this function:

void nsFontMetricsPS::SetMaxHeight ( nscoord  aMaxHeight) [inline]

Definition at line 124 of file nsFontMetricsPS.h.

{ mMaxHeight = aMaxHeight; };

Here is the caller graph for this function:

void nsFontMetricsPS::SetSpaceWidth ( nscoord  aSpaceWidth) [inline]

Definition at line 129 of file nsFontMetricsPS.h.

{ mSpaceWidth = aSpaceWidth; };

Here is the caller graph for this function:

void nsFontMetricsPS::SetStrikeout ( nscoord  aOffset,
nscoord  aSize 
) [inline]

Definition at line 115 of file nsFontMetricsPS.h.

Here is the caller graph for this function:

void nsFontMetricsPS::SetSubscriptOffset ( nscoord  aSubscriptOffset) [inline]

Definition at line 114 of file nsFontMetricsPS.h.

{ mSubscriptOffset = aSubscriptOffset; };

Here is the caller graph for this function:

void nsFontMetricsPS::SetSuperscriptOffset ( nscoord  aSuperscriptOffset) [inline]

Definition at line 113 of file nsFontMetricsPS.h.

{ mSuperscriptOffset = aSuperscriptOffset; };

Here is the caller graph for this function:

void nsFontMetricsPS::SetUnderline ( nscoord  aOffset,
nscoord  aSize 
) [inline]

Definition at line 116 of file nsFontMetricsPS.h.

Here is the caller graph for this function:

void nsFontMetricsPS::SetXHeight ( nscoord  aXHeight) [inline]

Definition at line 112 of file nsFontMetricsPS.h.

{ mXHeight = aXHeight; };

Here is the caller graph for this function:


Member Data Documentation

Definition at line 156 of file nsFontMetricsPS.h.

Definition at line 174 of file nsFontMetricsPS.h.

Definition at line 157 of file nsFontMetricsPS.h.

Definition at line 154 of file nsFontMetricsPS.h.

Definition at line 160 of file nsFontMetricsPS.h.

Definition at line 161 of file nsFontMetricsPS.h.

Definition at line 159 of file nsFontMetricsPS.h.

nsFont nsIFontMetrics::mFont [protected, inherited]

Definition at line 238 of file nsIFontMetrics.h.

Definition at line 178 of file nsFontMetricsPS.h.

nsHashtable* nsFontMetricsPS::mFontsAlreadyLoaded [protected]

Definition at line 177 of file nsFontMetricsPS.h.

Definition at line 176 of file nsFontMetricsPS.h.

Definition at line 155 of file nsFontMetricsPS.h.

Definition at line 135 of file nsFontMetricsPS.h.

Definition at line 158 of file nsFontMetricsPS.h.

Definition at line 165 of file nsFontMetricsPS.h.

Definition at line 163 of file nsFontMetricsPS.h.

Definition at line 164 of file nsFontMetricsPS.h.

Definition at line 162 of file nsFontMetricsPS.h.

Definition at line 173 of file nsFontMetricsPS.h.

Definition at line 170 of file nsFontMetricsPS.h.

Definition at line 169 of file nsFontMetricsPS.h.

Definition at line 168 of file nsFontMetricsPS.h.

Definition at line 167 of file nsFontMetricsPS.h.

Definition at line 172 of file nsFontMetricsPS.h.

Definition at line 171 of file nsFontMetricsPS.h.

Definition at line 166 of file nsFontMetricsPS.h.


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