Back to index

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

#include <nsFontMetricsXlib.h>

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

List of all members.

Public Member Functions

 nsFontXlib ()
 nsFontXlib (nsFontXlib *)
virtual ~nsFontXlib ()
void LoadFont (void)
PRBool IsEmptyFont (XFontStruct *)
int SupportsChar (PRUnichar aChar)
virtual XFontStruct * GetXFontStruct (void)
virtual nsXFontGetXFont (void)
virtual PRBool GetXFontIs10646 (void)
virtual int GetWidth (const PRUnichar *aString, PRUint32 aLength)=0
virtual int DrawString (nsRenderingContextXlib *aContext, nsIDrawingSurfaceXlib *aSurface, nscoord aX, nscoord aY, const PRUnichar *aString, PRUint32 aLength)=0

Public Attributes

NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
nsFontMetricsXlibContext
mFontMetricsContext
PRUint16mCCMap
nsFontCharSetInfoXlibmCharSetInfo
char * mName
nsFontXlibUserDefinedmUserDefinedFont
PRUint16 mSize
PRInt16 mBaselineAdjust
PRInt16 mMaxAscent
PRInt16 mMaxDescent

Protected Attributes

XFontStruct * mFont
XFontStruct * mFontHolder
nsXFontmXFont
PRPackedBool mAlreadyCalledLoadFont

Detailed Description

Definition at line 272 of file nsFontMetricsXlib.h.


Constructor & Destructor Documentation

Definition at line 3166 of file nsFontMetricsXlib.cpp.

nsFontXlib::~nsFontXlib ( ) [virtual]

Definition at line 3171 of file nsFontMetricsXlib.cpp.

{
  MOZ_COUNT_DTOR(nsFontXlib);
  if (mXFont) {
    delete mXFont;
  }
  if (mFont 
#ifdef USE_AASB
      && (mAABaseSize==0)
#endif /* USE_AASB */
      ) {
    XFreeFont(xxlib_rgb_get_display(mFontMetricsContext->mXlibRgbHandle), mFont);
  }
  if (mCharSetInfo == mFontMetricsContext->mISO106461) {
    FreeCCMap(mCCMap);
  }
  if (mName) {
    PR_smprintf_free(mName);
  }
}

Here is the call graph for this function:


Member Function Documentation

virtual int nsFontXlib::DrawString ( nsRenderingContextXlib aContext,
nsIDrawingSurfaceXlib aSurface,
nscoord  aX,
nscoord  aY,
const PRUnichar aString,
PRUint32  aLength 
) [pure virtual]

Implemented in nsFontXlibUserDefined, nsFontXlibSubstitute, and nsFontXlibNormal.

Here is the caller graph for this function:

virtual int nsFontXlib::GetWidth ( const PRUnichar aString,
PRUint32  aLength 
) [pure virtual]

Implemented in nsFontXlibUserDefined, nsFontXlibSubstitute, and nsFontXlibNormal.

Here is the caller graph for this function:

nsXFont * nsFontXlib::GetXFont ( void  ) [virtual]

Reimplemented in nsFontXlibSubstitute.

Definition at line 3145 of file nsFontMetricsXlib.cpp.

{
  return mXFont;
}

Here is the caller graph for this function:

Reimplemented in nsFontXlibSubstitute.

Definition at line 3151 of file nsFontMetricsXlib.cpp.

Here is the caller graph for this function:

XFontStruct * nsFontXlib::GetXFontStruct ( void  ) [virtual]

Reimplemented in nsFontXlibSubstitute.

Definition at line 3139 of file nsFontMetricsXlib.cpp.

{
  return mFont;
}

Here is the caller graph for this function:

PRBool nsFontXlib::IsEmptyFont ( XFontStruct *  xFont)

Definition at line 2977 of file nsFontMetricsXlib.cpp.

{
  if (!xFont)
    return PR_TRUE;

  //
  // scan and see if we can find at least one glyph
  //
  if (xFont->per_char) {
    PRInt32 minByte1 = xFont->min_byte1;
    PRInt32 maxByte1 = xFont->max_byte1;
    PRInt32 minByte2 = xFont->min_char_or_byte2;
    PRInt32 maxByte2 = xFont->max_char_or_byte2;
    PRInt32 charsPerRow = maxByte2 - minByte2 + 1;
    for (PRInt32 row = minByte1; row <= maxByte1; row++) {
      PRInt32 offset = (((row - minByte1) * charsPerRow) - minByte2);
      for (PRInt32 cell = minByte2; cell <= maxByte2; cell++) {
        XCharStruct* bounds = &xFont->per_char[offset + cell];
        if (bounds->ascent || bounds->descent) {
          return PR_FALSE;
        }
      }
    }
  }

  return PR_TRUE;
}

Here is the caller graph for this function:

Definition at line 3006 of file nsFontMetricsXlib.cpp.

{
  if (mAlreadyCalledLoadFont)
    return;

  Display *aDisplay = xxlib_rgb_get_display(mFontMetricsContext->mXlibRgbHandle);

#ifdef USE_XPRINT
  if (mFontMetricsContext->mPrinterMode)
  {
    if (XpGetContext(aDisplay) == None)
    {
      /* applications must not make any assumptions about fonts _before_ XpSetContext() !!! */
      NS_ERROR("Obtaining font information without a valid print context (XLoadQueryFont()) _before_ XpSetContext()\n");
#ifdef DEBUG
      abort();
#else
      return;
#endif /* DEBUG */      
    }
  }
#endif /* USE_XPRINT */

  mAlreadyCalledLoadFont = PR_TRUE;

  XFontStruct *xlibFont = nsnull;

  NS_ASSERTION(!mFont, "mFont should not be loaded");
#ifdef USE_AASB
  if (mAABaseSize==0)
#endif /* USE_AASB */
  {
    NS_ASSERTION(!mFontHolder, "mFontHolder should not be loaded");
    xlibFont = ::XLoadQueryFont(aDisplay, mName);
    if(!xlibFont)
    {
#ifdef DEBUG
      printf("nsFontXlib::LoadFont(): loading of font '%s' failed\n", mName);
#endif /* DEBUG */
      return;
    }

    mXFont = new nsXFontNormal(aDisplay, xlibFont);
  }
#ifdef USE_AASB
  else {
    NS_ASSERTION(mFontHolder, "mFontHolder should be loaded");
    xlibFont = mFontHolder;
    mXFont = new nsXFontAAScaledBitmap(xxlib_rgb_get_display(mFontMetricsContext->mXlibRgbHandle),
                                       xxlib_rgb_get_screen(mFontMetricsContext->mXlibRgbHandle),
                                       xlibFont, mSize, mAABaseSize);
  }
#endif /* USE_AASB */

  NS_ASSERTION(mXFont,"failed to load mXFont");
  if (!mXFont)
    return;
  if (!mXFont->LoadFont()) {
    delete mXFont;
    mXFont = nsnull;
    return;
  }

  if (xlibFont) {
    XFontStruct* xFont = mXFont->GetXFontStruct();
    XFontStruct* xFont_with_per_char;
#ifdef USE_AASB
    if (mAABaseSize==0)
#endif /* USE_AASB */
      xFont_with_per_char = xFont;
#ifdef USE_AASB
    else
      xFont_with_per_char = mFontHolder;
#endif /* #ifdef USE_AASB */

    mMaxAscent = xFont->ascent;
    mMaxDescent = xFont->descent;

    if (mCharSetInfo == mFontMetricsContext->mISO106461) {
      mCCMap = GetMapFor10646Font(xFont_with_per_char);
      if (!mCCMap) {
        mXFont->UnloadFont();
        mXFont = nsnull;
        ::XFreeFont(aDisplay, xlibFont);
        mFontHolder = nsnull;
        return;
      }
    }

    // Redhat 6.2 Japanese has invalid jisx201 fonts
    // Solaris 2.6 has invalid cns11643 fonts for planes 4-7
    if ((mCharSetInfo == &JISX0201)
        || (mCharSetInfo == &CNS116434)
        || (mCharSetInfo == &CNS116435)
        || (mCharSetInfo == &CNS116436)
        || (mCharSetInfo == &CNS116437)
       ) {
      if (IsEmptyFont(xFont_with_per_char)) {
#ifdef NS_FONT_DEBUG_LOAD_FONT
        if (gFontDebug & NS_FONT_DEBUG_LOAD_FONT) {
          printf("\n");
          printf("***************************************\n");
          printf("invalid font \"%s\", %s %d\n", mName, __FILE__, __LINE__);
          printf("***************************************\n");
          printf("\n");
        }
#endif
        mXFont->UnloadFont();
        mXFont = nsnull;
        ::XFreeFont(aDisplay, xlibFont);
        mFontHolder = nsnull;
        return;
      }
    }
    mFont = xlibFont;

#ifdef NS_FONT_DEBUG_LOAD_FONT
    if (gFontDebug & NS_FONT_DEBUG_LOAD_FONT) {
      printf("loaded %s\n", mName);
    }
#endif

  }

#ifdef NS_FONT_DEBUG_LOAD_FONT
  else if (gFontDebug & NS_FONT_DEBUG_LOAD_FONT) {
    printf("cannot load %s\n", mName);
  }
#endif

}

Here is the call graph for this function:

Here is the caller graph for this function:

int nsFontXlib::SupportsChar ( PRUnichar  aChar) [inline]

Definition at line 285 of file nsFontMetricsXlib.h.

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

Here is the caller graph for this function:


Member Data Documentation

Definition at line 328 of file nsFontMetricsXlib.h.

Definition at line 317 of file nsFontMetricsXlib.h.

Definition at line 309 of file nsFontMetricsXlib.h.

Definition at line 310 of file nsFontMetricsXlib.h.

XFontStruct* nsFontXlib::mFont [protected]

Definition at line 325 of file nsFontMetricsXlib.h.

XFontStruct* nsFontXlib::mFontHolder [protected]

Definition at line 326 of file nsFontMetricsXlib.h.

Definition at line 280 of file nsFontMetricsXlib.h.

Definition at line 321 of file nsFontMetricsXlib.h.

Definition at line 322 of file nsFontMetricsXlib.h.

Definition at line 311 of file nsFontMetricsXlib.h.

Definition at line 313 of file nsFontMetricsXlib.h.

Definition at line 312 of file nsFontMetricsXlib.h.

Definition at line 327 of file nsFontMetricsXlib.h.


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