Back to index

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

#include <nsFontMetricsGTK.h>

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

List of all members.

Public Member Functions

 nsFontGTK ()
 nsFontGTK (nsFontGTK *)
virtual ~nsFontGTK ()
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
void 
LoadFont (void)
PRBool IsEmptyFont (XFontStruct *)
int SupportsChar (PRUint32 aChar)
virtual GdkFont * GetGDKFont (void)
virtual nsXFontGetXFont (void)
virtual PRBool GetXFontIs10646 (void)
virtual PRBool IsFreeTypeFont (void)
virtual gint GetWidth (const PRUnichar *aString, PRUint32 aLength)=0
virtual gint DrawString (nsRenderingContextGTK *aContext, nsDrawingSurfaceGTK *aSurface, nscoord aX, nscoord aY, const PRUnichar *aString, PRUint32 aLength)=0

Public Attributes

PRUint16mCCMap
nsFontCharSetInfomCharSetInfo
char * mName
nsFontGTKUserDefinedmUserDefinedFont
PRUint16 mSize
PRUint16 mAABaseSize
PRInt16 mBaselineAdjust
PRInt16 mMaxAscent
PRInt16 mMaxDescent

Protected Attributes

GdkFont * mFont
GdkFont * mFontHolder
nsXFontmXFont
PRBool mAlreadyCalledLoadFont

Detailed Description

Definition at line 162 of file nsFontMetricsGTK.h.


Constructor & Destructor Documentation

Definition at line 2804 of file nsFontMetricsGTK.cpp.

nsFontGTK::~nsFontGTK ( ) [virtual]

Definition at line 2809 of file nsFontMetricsGTK.cpp.

{
  MOZ_COUNT_DTOR(nsFontGTK);
  if (mXFont) {
    delete mXFont;
  }
  if (mFont && (mAABaseSize==0)) {
    gdk_font_unref(mFont);
  }
  if (mCharSetInfo == &ISO106461) {
    FreeCCMap(mCCMap);
  }
  if (mName) {
    PR_smprintf_free(mName);
  }
}

Here is the call graph for this function:


Member Function Documentation

virtual gint nsFontGTK::DrawString ( nsRenderingContextGTK aContext,
nsDrawingSurfaceGTK aSurface,
nscoord  aX,
nscoord  aY,
const PRUnichar aString,
PRUint32  aLength 
) [pure virtual]

Implemented in nsFontGTKUserDefined, nsFontGTKSubstitute, and nsFontGTKNormal.

Here is the caller graph for this function:

GdkFont * nsFontGTK::GetGDKFont ( void  ) [virtual]

Reimplemented in nsFontGTKSubstitute.

Definition at line 2779 of file nsFontMetricsGTK.cpp.

{
  return mFont;
}

Here is the caller graph for this function:

virtual gint nsFontGTK::GetWidth ( const PRUnichar aString,
PRUint32  aLength 
) [pure virtual]

Implemented in nsFontGTKUserDefined, nsFontGTKSubstitute, and nsFontGTKNormal.

Here is the caller graph for this function:

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

Reimplemented in nsFontGTKSubstitute.

Definition at line 2785 of file nsFontMetricsGTK.cpp.

{
  return mXFont;
}

Here is the caller graph for this function:

Reimplemented in nsFontGTKSubstitute.

Definition at line 2791 of file nsFontMetricsGTK.cpp.

{
  return ((PRBool) (mCharSetInfo == &ISO106461));
}

Here is the caller graph for this function:

PRBool nsFontGTK::IsEmptyFont ( XFontStruct *  xFont)

Definition at line 2645 of file nsFontMetricsGTK.cpp.

{

  //
  // 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 2797 of file nsFontMetricsGTK.cpp.

{
  return PR_FALSE;
}

Here is the caller graph for this function:

Definition at line 2672 of file nsFontMetricsGTK.cpp.

{
  if (mAlreadyCalledLoadFont) {
    return;
  }

  mAlreadyCalledLoadFont = PR_TRUE;
  GdkFont* gdkFont;
  NS_ASSERTION(!mFont, "mFont should not be loaded");
  if (mAABaseSize==0) {
    NS_ASSERTION(!mFontHolder, "mFontHolder should not be loaded");
    gdk_error_trap_push();
    gdkFont = ::gdk_font_load(mName);
    gdk_error_trap_pop();
    if (!gdkFont)
      return;
    mXFont = new nsXFontNormal(gdkFont);
  }
  else {
    NS_ASSERTION(mFontHolder, "mFontHolder should be loaded");
    gdkFont = mFontHolder;
    mXFont = new nsXFontAAScaledBitmap(GDK_DISPLAY(),
                                       DefaultScreen(GDK_DISPLAY()),
                                       gdkFont, mSize, mAABaseSize);
  }

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

  if (gdkFont) {
    XFontStruct* xFont = mXFont->GetXFontStruct();
    XFontStruct* xFont_with_per_char;
    if (mAABaseSize==0)
      xFont_with_per_char = xFont;
    else
      xFont_with_per_char = (XFontStruct *)GDK_FONT_XFONT(mFontHolder);

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

    if (mCharSetInfo == &ISO106461) {
      mCCMap = GetMapFor10646Font(xFont_with_per_char);
      if (!mCCMap) {
        mXFont->UnloadFont();
        mXFont = nsnull;
        ::gdk_font_unref(gdkFont);
        mFontHolder = nsnull;
        return;
      }
    }

//
// since we are very close to a release point
// limit the risk of this fix 
// please remove soon
//
// 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;
      ::gdk_font_unref(gdkFont);
      mFontHolder = nsnull;
      return;
    }
}
    mFont = gdkFont;

#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 nsFontGTK::SupportsChar ( PRUint32  aChar) [inline]

Definition at line 173 of file nsFontMetricsGTK.h.

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

Here is the caller graph for this function:


Member Data Documentation

Definition at line 200 of file nsFontMetricsGTK.h.

Definition at line 212 of file nsFontMetricsGTK.h.

Definition at line 201 of file nsFontMetricsGTK.h.

Definition at line 195 of file nsFontMetricsGTK.h.

Definition at line 196 of file nsFontMetricsGTK.h.

GdkFont* nsFontGTK::mFont [protected]

Definition at line 209 of file nsFontMetricsGTK.h.

GdkFont* nsFontGTK::mFontHolder [protected]

Definition at line 210 of file nsFontMetricsGTK.h.

Definition at line 205 of file nsFontMetricsGTK.h.

Definition at line 206 of file nsFontMetricsGTK.h.

Definition at line 197 of file nsFontMetricsGTK.h.

Definition at line 199 of file nsFontMetricsGTK.h.

Definition at line 198 of file nsFontMetricsGTK.h.

nsXFont* nsFontGTK::mXFont [protected]

Definition at line 211 of file nsFontMetricsGTK.h.


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