Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes
nsFontSubset Class Reference
Inheritance diagram for nsFontSubset:
Inheritance graph
[legend]
Collaboration diagram for nsFontSubset:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsFontSubset ()
virtual ~nsFontSubset ()
virtual PRInt32 GetWidth (HDC aDC, const PRUnichar *aString, PRUint32 aLength)
virtual void DrawString (HDC aDC, PRInt32 aX, PRInt32 aY, const PRUnichar *aString, PRUint32 aLength)
int Load (HDC aDC, nsFontMetricsWinA *aFontMetricsWin, nsFontWinA *aFont)
virtual void Convert (const PRUnichar *aString, PRUint32 aLength, nsAutoCharBuffer &aResult, PRUint32 *aResultLength)
virtual PRInt32 GetWidth (HDC aDC, const char *aString, PRUint32 aLength)
virtual void DrawString (HDC aDC, PRInt32 aX, PRInt32 aY, const char *aString, PRUint32 aLength, INT *aDx0)
virtual PRBool HasGlyph (PRUint32 ch)
PRBool FillClipRect (PRInt32 aX, PRInt32 aY, UINT aLength, UINT uOptions, RECT &clipRect)

Public Attributes

BYTE mCharset
PRUint16 mCodePage
char mName [LF_FACESIZE]
HFONT mFont
PRUint16mCCMap
nscoord mMaxAscent
nscoord mMaxDescent
LONG mOverhangCorrection
LONG mMaxCharWidthMetric
LONG mMaxHeightMetric
BYTE mPitchAndFamily

Detailed Description

Definition at line 294 of file nsFontMetricsWin.cpp.


Constructor & Destructor Documentation

Definition at line 4816 of file nsFontMetricsWin.cpp.

Definition at line 4821 of file nsFontMetricsWin.cpp.

{
}

Member Function Documentation

void nsFontSubset::Convert ( const PRUnichar aString,
PRUint32  aLength,
nsAutoCharBuffer aResult,
PRUint32 aResultLength 
) [virtual]

Reimplemented in nsFontSubsetSubstitute.

Definition at line 4826 of file nsFontMetricsWin.cpp.

{
  *aResultLength = 0;
  // Get the number of bytes needed for the conversion
  int nb = WideCharToMultiByte(mCodePage, 0, aString, aLength,
                               nsnull, 0, nsnull, nsnull);

  if (!nb || !aResult.EnsureElemCapacity(nb)) return;
  char* buf = aResult.get();
  // Convert the Unicode string to ANSI
  *aResultLength = WideCharToMultiByte(mCodePage, 0, aString, aLength,
                                       buf, nb, nsnull, nsnull);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsFontWin::DrawString ( HDC  aDC,
PRInt32  aX,
PRInt32  aY,
const char *  aString,
PRUint32  aLength,
INT aDx0 
) [virtual, inherited]

Definition at line 4300 of file nsFontMetricsWin.cpp.

{
  NS_ExtTextOutA(aDC, this, aX, aY, 0, NULL, aString, aLength, lpDx);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsFontSubset::DrawString ( HDC  aDC,
PRInt32  aX,
PRInt32  aY,
const PRUnichar aString,
PRUint32  aLength 
) [virtual]

Implements nsFontWin.

Reimplemented in nsFontSubsetSubstitute.

Definition at line 4856 of file nsFontMetricsWin.cpp.

{
  nsAutoCharBuffer buffer;
  Convert(aString, aLength, buffer, &aLength);
  if (aLength) {
    NS_ExtTextOutA(aDC, this, aX, aY, 0, NULL, buffer.get(), aLength, NULL);
  }
}

Here is the call graph for this function:

PRBool nsFontWin::FillClipRect ( PRInt32  aX,
PRInt32  aY,
UINT  aLength,
UINT  uOptions,
RECT &  clipRect 
) [inherited]

Definition at line 4259 of file nsFontMetricsWin.cpp.

{
  if (!(uOptions & (ETO_CLIPPED | ETO_OPAQUE)) &&
      mOverhangCorrection > 0 && !(mPitchAndFamily & TMPF_FIXED_PITCH)) {
    // bug 52596 - although the clipping rectangle is said to be optional, we
    // have to use a clipping rectange to work around a GDI bug on
    // Win9X-Japanese that causes the text to be truncated incorrectly.
    clipRect.top = aY - mMaxHeightMetric;
    clipRect.bottom = aY + mMaxHeightMetric;
    clipRect.left = aX;
    clipRect.right = aX + mMaxCharWidthMetric * aLength;
    return PR_TRUE;
  }
  return PR_FALSE;
}

Here is the caller graph for this function:

PRInt32 nsFontWin::GetWidth ( HDC  aDC,
const char *  aString,
PRUint32  aLength 
) [virtual, inherited]

Definition at line 4250 of file nsFontMetricsWin.cpp.

{
  SIZE size;
  ::GetTextExtentPoint32(aDC, aString, aLength, &size);
  size.cx -= mOverhangCorrection;
  return size.cx;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRInt32 nsFontSubset::GetWidth ( HDC  aDC,
const PRUnichar aString,
PRUint32  aLength 
) [virtual]

Implements nsFontWin.

Reimplemented in nsFontSubsetSubstitute.

Definition at line 4842 of file nsFontMetricsWin.cpp.

{
  nsAutoCharBuffer buffer;
  Convert(aString, aLength, buffer, &aLength);
  if (aLength) {
    SIZE size;
    ::GetTextExtentPoint32A(aDC, buffer.get(), aLength, &size);
    size.cx -= mOverhangCorrection;
    return size.cx;
  }
  return 0;
}

Here is the call graph for this function:

virtual PRBool nsFontWin::HasGlyph ( PRUint32  ch) [inline, virtual, inherited]

Reimplemented in nsFontWinSubstituteA, and nsFontWinSubstitute.

Definition at line 113 of file nsFontMetricsWin.h.

Here is the caller graph for this function:

int nsFontSubset::Load ( HDC  aDC,
nsFontMetricsWinA aFontMetricsWin,
nsFontWinA aFont 
)

Definition at line 5174 of file nsFontMetricsWin.cpp.

{
  LOGFONT* logFont = &aFont->mLogFont;
  logFont->lfCharSet = mCharset;
  // create a font handle without filling & overwriting what is in logFont
  HFONT hfont = (aFontMetricsWinA->Font().sizeAdjust <= 0) 
    ? ::CreateFontIndirect(logFont)
    : aFontMetricsWinA->CreateFontAdjustHandle(aDC, logFont);
  if (hfont) {
    int i = gCharsetToIndex[mCharset];
    if (!gCharsetInfo[i].mCCMap)
      gCharsetInfo[i].mCCMap = gCharsetInfo[i].GenerateMap(&gCharsetInfo[i]);
    if (!gCharsetInfo[i].mCCMap) {
      ::DeleteObject(hfont);
      return 0;
    }
    mCCMap = gCharsetInfo[i].mCCMap;
    mCodePage = gCharsetInfo[i].mCodePage;
    mFont = hfont;

    //XXX can we safely assume the same metrics for all subsets and remove this?
    HFONT oldFont = (HFONT)::SelectObject(aDC, (HGDIOBJ)hfont);
    aFontMetricsWinA->InitMetricsFor(aDC, this);
    ::SelectObject(aDC, (HGDIOBJ)oldFont);

    return 1;
  }
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 133 of file nsFontMetricsWin.h.

Definition at line 321 of file nsFontMetricsWin.cpp.

Definition at line 322 of file nsFontMetricsWin.cpp.

HFONT nsFontWin::mFont [inherited]

Definition at line 132 of file nsFontMetricsWin.h.

Definition at line 138 of file nsFontMetricsWin.h.

Definition at line 143 of file nsFontMetricsWin.h.

Definition at line 139 of file nsFontMetricsWin.h.

Definition at line 144 of file nsFontMetricsWin.h.

char nsFontWin::mName[LF_FACESIZE] [inherited]

Definition at line 113 of file nsFontMetricsWin.h.

Definition at line 142 of file nsFontMetricsWin.h.

Definition at line 145 of file nsFontMetricsWin.h.


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