Back to index

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

#include <nsFontMetricsOS2.h>

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

List of all members.

Public Member Functions

 nsFontOS2FT (void)
virtual ~nsFontOS2FT (void)
virtual PRBool HasGlyph (HPS aPS, PRUint32 aChar)
virtual PRInt32 GetWidth (HPS aPS, const PRUnichar *aString, PRUint32 aLength)
virtual void DrawString (HPS aPS, nsDrawingSurfaceOS2 *aSurface, PRInt32 aX, PRInt32 aY, const PRUnichar *aString, PRUint32 aLength)
PRBool IsSymbolFont ()
void SelectIntoPS (HPS hps, long lcid)
virtual PRInt32 GetWidth (HPS aPS, const char *aString, PRUint32 aLength)
virtual void DrawString (HPS aPS, nsDrawingSurfaceOS2 *aSurface, PRInt32 aX, PRInt32 aY, const char *aString, PRUint32 aLength, INT *aDx0)

Public Attributes

FATTRS mFattrs
SIZEF mCharbox
ULONG mHashMe
nscoord mMaxAscent
nscoord mMaxDescent
int mConvertCodePage
PRUint32mHaveCheckedCharMap
PRUint32mRepresentableCharMap

Static Public Attributes

static Ft2FontSupportsUnicodeChar1 pfnFt2FontSupportsUnicodeChar1 = NULL
static Ft2QueryTextBoxW pfnFt2QueryTextBoxW = NULL
static Ft2CharStringPosAtW pfnFt2CharStringPosAtW = NULL

Detailed Description

Definition at line 407 of file nsFontMetricsOS2.h.


Constructor & Destructor Documentation

Definition at line 2367 of file nsFontMetricsOS2.cpp.

                             : nsFontOS2()
{
  mFattrs.usCodePage = 1208;
#ifdef DEBUG_FONT_STRUCT_ALLOCS
  mRefCount++;
  printf("+++ nsFontOS2FT total = %d\n", mRefCount);
#endif
}

Definition at line 2376 of file nsFontMetricsOS2.cpp.

{
#ifdef DEBUG_FONT_STRUCT_ALLOCS
  mRefCount--;
  printf("--- nsFontOS2FT total = %d\n", mRefCount);
#endif
}

Member Function Documentation

void nsFontOS2::DrawString ( HPS  aPS,
nsDrawingSurfaceOS2 aSurface,
PRInt32  aX,
PRInt32  aY,
const char *  aString,
PRUint32  aLength,
INT aDx0 
) [virtual, inherited]

Definition at line 1925 of file nsFontMetricsOS2.cpp.

{
  POINTL ptl = { aX, aY };
  aSurface->NS2PM(&ptl, 1);
  ExtTextOut(aPS, ptl.x, ptl.y, 0, NULL, aString, aLength, aDx0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsFontOS2FT::DrawString ( HPS  aPS,
nsDrawingSurfaceOS2 aSurface,
PRInt32  aX,
PRInt32  aY,
const PRUnichar aString,
PRUint32  aLength 
) [virtual]

Reimplemented from nsFontOS2.

Definition at line 2464 of file nsFontMetricsOS2.cpp.

{
  USHORT rc;
  POINTL ptl = { aX, aY };
  aSurface->NS2PM(&ptl, 1);

  if (!IsSymbolFont()) {
#ifdef USE_EXPANDED_FREETYPE_FUNCS
    rc = pfnFt2CharStringPosAtW(aPS, &ptl, NULL, 0, aLength,
                                (LPWSTR)aString, NULL, NULL);

#ifdef DEBUG
    if (rc == GPI_ERROR) {
      // We only expect Ft2CharStringPosAtW() to fail with
      // PMERR_FUNCTION_NOT_SUPPORTED.  If it fails with any other error, then
      // print out a warning message
      USHORT errorCode = ERRORIDERROR (::WinGetLastError(0));
      if (errorCode != PMERR_FUNCTION_NOT_SUPPORTED) {
        printf("GFX_Err: pfnFt2CharStringPosAtW = 0x%X, 0x%X (%s - %s,  line %d)\n",
               rc, errorCode, __FILE__, __FUNCTION__, __LINE__);
      }
    }
#endif /* debug */

    // Sometimes, Ft2CharStringPosAtW will fail with GPI_ERROR (WinGetLastError
    // will return PMERR_FUNCTION_NOT_SUPPORTED), particularly when printing
    // (this function is not supported when printing). So if it fails, fall back
    // to the straight GPI call case.
    if (rc == GPI_ERROR)
#endif /* use_expanded_freetype_funcs */
    {
      NS_ConvertUCS2toUTF8 str(Substring(aString, aString + aLength));
      ExtTextOut(aPS, ptl.x, ptl.y, 0, NULL, (const char*)str.get(),
                 str.Length(), NULL);
    }
  } else {
    nsAutoCharBuffer buffer;
    PRInt32 destLength = aLength;
    WideCharToMultiByte(1252, aString, aLength, buffer, destLength);
    ExtTextOut(aPS, ptl.x, ptl.y, 0, NULL, buffer.get(), destLength, NULL);
  }
}

Here is the call graph for this function:

PRInt32 nsFontOS2::GetWidth ( HPS  aPS,
const char *  aString,
PRUint32  aLength 
) [virtual, inherited]

Definition at line 1904 of file nsFontMetricsOS2.cpp.

{
  SIZEL size;
  GetTextExtentPoint32(aPS, aString, aLength, &size);
  return size.cx;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsFontOS2FT::GetWidth ( HPS  aPS,
const PRUnichar aString,
PRUint32  aLength 
) [virtual]

Reimplemented from nsFontOS2.

Definition at line 2414 of file nsFontMetricsOS2.cpp.

{
  USHORT rc;
  SIZEL size;

  if (!IsSymbolFont()) {
#ifdef USE_EXPANDED_FREETYPE_FUNCS
    POINTL ptls[5];
    rc = pfnFt2QueryTextBoxW(aPS, aLength, (LPWSTR)aString, 5, ptls);
    size.cx = ptls[TXTBOX_CONCAT].x;
    
#ifdef DEBUG
    if (rc == FALSE) {
      // We only expect Ft2QueryTextBoxW() to fail with
      // PMERR_FUNCTION_NOT_SUPPORTED.  If it fails with any other error, then
      // print out a warning message
      USHORT errorCode = ERRORIDERROR (::WinGetLastError(0));
      if (errorCode != PMERR_FUNCTION_NOT_SUPPORTED) {
        printf("GFX_Err: pfnFt2QueryTextBoxW = 0x%X, 0x%X (%s - %s,  line %d)\n",
               rc, errorCode, __FILE__, __FUNCTION__, __LINE__);
      }
    }
#endif /* debug */

    // Sometimes, Ft2QueryTextBoxW will fail with FALSE (WinGetLastError
    // will return PMERR_FUNCTION_NOT_SUPPORTED), particularly when printing
    // (this function is not supported when printing). So if it fails, fall back
    // to the straight GPI call case.
    if (rc == FALSE)
#endif /* use_expanded_freetype_funcs */
    {
      NS_ConvertUCS2toUTF8 str(Substring(aString, aString + aLength));
      rc = GetTextExtentPoint32(aPS, (const char*)str.get(), str.Length(),
                                &size);
    }
  } else {
    nsAutoCharBuffer buffer;
    PRInt32 destLength = aLength;
    WideCharToMultiByte(1252, aString, aLength, buffer, destLength);
    rc = GetTextExtentPoint32(aPS, buffer.get(), destLength, &size);
  }

  if (rc == TRUE) {
    return size.cx;
  } else {
    return 0;
  }
}

Here is the call graph for this function:

PRBool nsFontOS2FT::HasGlyph ( HPS  aPS,
PRUint32  aChar 
) [virtual]

Reimplemented from nsFontOS2.

Definition at line 2385 of file nsFontMetricsOS2.cpp.

{
#ifdef PERF_HASGLYPH_CHAR_MAP
  if (IS_IN_BMP(aChar) && IS_REPRESENTABLE(mHaveCheckedCharMap, aChar)) {
    // we have already checked this char for this font
    return IS_REPRESENTABLE(mRepresentableCharMap, aChar);
  } else
#endif
  {
    // If not in Plane 0, OS/2 can't render it.
    if (!IS_IN_BMP(aChar)) {
      return PR_FALSE;
    }

    PRBool rc = pfnFt2FontSupportsUnicodeChar1(0, &mFattrs, PR_TRUE, aChar);

#ifdef PERF_HASGLYPH_CHAR_MAP
    // set that we have checked this char
    SET_REPRESENTABLE(mHaveCheckedCharMap, aChar);
    if (rc) {
      SET_REPRESENTABLE(mRepresentableCharMap, aChar);
    }
#endif

    return rc;
  }
}

Here is the caller graph for this function:

Definition at line 422 of file nsFontMetricsOS2.h.

{ return mFattrs.usCodePage == 65400; };

Here is the caller graph for this function:

void nsFontOS2::SelectIntoPS ( HPS  hps,
long  lcid 
) [inline, inherited]

Definition at line 1897 of file nsFontMetricsOS2.cpp.

{
   GFX (::GpiSetCharSet(aPS, aLcid), FALSE);
   GFX (::GpiSetCharBox(aPS, &mCharbox), FALSE);
}

Here is the caller graph for this function:


Member Data Documentation

SIZEF nsFontOS2::mCharbox [inherited]

Definition at line 176 of file nsFontMetricsOS2.h.

Definition at line 180 of file nsFontMetricsOS2.h.

FATTRS nsFontOS2::mFattrs [inherited]

Definition at line 175 of file nsFontMetricsOS2.h.

Definition at line 177 of file nsFontMetricsOS2.h.

Definition at line 186 of file nsFontMetricsOS2.h.

Definition at line 178 of file nsFontMetricsOS2.h.

Definition at line 179 of file nsFontMetricsOS2.h.

Reimplemented in nsFontOS2Substitute.

Definition at line 187 of file nsFontMetricsOS2.h.

Ft2CharStringPosAtW nsFontOS2FT::pfnFt2CharStringPosAtW = NULL [static]

Definition at line 427 of file nsFontMetricsOS2.h.

Ft2FontSupportsUnicodeChar1 nsFontOS2FT::pfnFt2FontSupportsUnicodeChar1 = NULL [static]

Definition at line 422 of file nsFontMetricsOS2.h.

Ft2QueryTextBoxW nsFontOS2FT::pfnFt2QueryTextBoxW = NULL [static]

Definition at line 426 of file nsFontMetricsOS2.h.


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