Back to index

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

List of all members.

Public Member Functions

 nsFontXftCustom (FcPattern *aPattern, FcPattern *aFontName, nsFontXftInfo *aFontInfo)
virtual ~nsFontXftCustom ()
virtual PRBool HasChar (PRUint32 aChar)
virtual FT_UInt CharToGlyphIndex (FcChar32 aChar)
virtual nsresult GetTextExtents32 (const FcChar32 *aString, PRUint32 aLen, XGlyphInfo &aGlyphInfo)
virtual nsresult DrawStringSpec (FcChar32 *aString, PRUint32 aLen, void *aData)
 nsFontXftCustom (FcPattern *aPattern, FcPattern *aFontName, nsFontXftInfo *aFontInfo)
virtual ~nsFontXftCustom ()
virtual PRBool HasChar (PRUint32 aChar)
virtual FT_UInt CharToGlyphIndex (FcChar32 aChar)
virtual nsresult GetTextExtents32 (const FcChar32 *aString, PRUint32 aLen, XGlyphInfo &aGlyphInfo)
virtual nsresult DrawStringSpec (FcChar32 *aString, PRUint32 aLen, void *aData)
XftFont * GetXftFont (void)
XftFont * GetXftFont (void)
gint GetWidth32 (const FcChar32 *aString, PRUint32 aLen)
gint GetWidth32 (const FcChar32 *aString, PRUint32 aLen)
PRInt16 GetMaxAscent (void)
PRInt16 GetMaxAscent (void)
PRInt16 GetMaxDescent (void)
PRInt16 GetMaxDescent (void)

Public Attributes

XftFont * mXftFont
FcPattern * mPattern
FcPattern * mFontName
FcCharSet * mCharset

Private Member Functions

nsresult SetFT_FaceCharmap (void)
nsresult SetFT_FaceCharmap (void)

Private Attributes

nsFontXftInfomFontInfo
FT_Face mFT_Face

Detailed Description

Definition at line 143 of file nsFontMetricsXft.cpp.


Constructor & Destructor Documentation

nsFontXftCustom::nsFontXftCustom ( FcPattern *  aPattern,
FcPattern *  aFontName,
nsFontXftInfo aFontInfo 
) [inline]

Definition at line 145 of file nsFontMetricsXft.cpp.

      : nsFontXft(aPattern, aFontName)
      , mFontInfo(aFontInfo)
      , mFT_Face(nsnull)
    { }

Definition at line 2019 of file nsFontMetricsXft.cpp.

{
    if (mXftFont && mFT_Face)
       XftUnlockFace(mXftFont);
}
nsFontXftCustom::nsFontXftCustom ( FcPattern *  aPattern,
FcPattern *  aFontName,
nsFontXftInfo aFontInfo 
) [inline]

Definition at line 145 of file nsFontMetricsXft.cpp.

      : nsFontXft(aPattern, aFontName)
      , mFontInfo(aFontInfo)
      , mFT_Face(nsnull)
    { }
virtual nsFontXftCustom::~nsFontXftCustom ( ) [virtual]

Member Function Documentation

FT_UInt nsFontXftCustom::CharToGlyphIndex ( FcChar32  aChar) [virtual]

Reimplemented from nsFontXft.

Definition at line 2075 of file nsFontMetricsXft.cpp.

{
    if (mFontInfo->mFontType == eFontTypeCustomWide)
        return XftCharIndex(GDK_DISPLAY(), mXftFont, aChar);
    else
        return FT_Get_Char_Index(mFT_Face, aChar);
}
virtual FT_UInt nsFontXftCustom::CharToGlyphIndex ( FcChar32  aChar) [virtual]

Reimplemented from nsFontXft.

nsresult nsFontXftCustom::DrawStringSpec ( FcChar32 *  aString,
PRUint32  aLen,
void aData 
) [virtual]

Reimplemented from nsFontXft.

Definition at line 2086 of file nsFontMetricsXft.cpp.

{
    NS_PRECONDITION(mXftFont, "FindFont should not return bad fonts");

    nsresult rv = NS_OK;
    nsAutoFcChar32Buffer buffer;
    PRUint32 destLen = aLen;
    PRBool isWide = (mFontInfo->mFontType == eFontTypeCustomWide); 

    rv = ConvertUCS4ToCustom(aString, aLen, destLen, mFontInfo->mConverter, 
                             isWide, buffer);
    NS_ENSURE_SUCCESS(rv, rv);

    if (!isWide) {
        // For some narrow fonts(Mathematica, Symbol, and MTExtra),  
        // what we get back  after the conversion  is in the encoding 
        // of a specific  FT_Charmap (Apple Roman) instead of Unicode 
        // so that we  can't call XftCharIndex() which regards input 
        // as a Unicode codepoint. Instead, we have to directly invoke 
        // FT_Get_Char_Index() with FT_Face corresponding to XftFont 
        // after setting FT_Charmap to the cmap of our choice(Apple Roman).
        rv = SetFT_FaceCharmap();
        NS_ENSURE_SUCCESS(rv, rv);
    }

    FcChar32 *str = buffer.get();

    return nsFontXft::DrawStringSpec(str, destLen, aData);
}

Here is the call graph for this function:

virtual nsresult nsFontXftCustom::DrawStringSpec ( FcChar32 *  aString,
PRUint32  aLen,
void aData 
) [virtual]

Reimplemented from nsFontXft.

Definition at line 1944 of file nsFontMetricsXft.cpp.

{
    NS_PRECONDITION(mXftFont, "FindFont should not return bad fonts");

    return mXftFont->ascent;
}

Here is the caller graph for this function:

Definition at line 1952 of file nsFontMetricsXft.cpp.

{
    NS_PRECONDITION(mXftFont, "FindFont should not return bad fonts");
    return mXftFont->descent;
}

Here is the caller graph for this function:

nsresult nsFontXftCustom::GetTextExtents32 ( const FcChar32 *  aString,
PRUint32  aLen,
XGlyphInfo &  aGlyphInfo 
) [virtual]

Reimplemented from nsFontXft.

Definition at line 2028 of file nsFontMetricsXft.cpp.

{
    NS_PRECONDITION(mXftFont, "FindFont should not return bad fonts");

    nsAutoFcChar32Buffer buffer;
    nsresult rv;
    PRUint32 destLen = aLen;
    PRBool isWide = (mFontInfo->mFontType == eFontTypeCustomWide); 

    // we won't use this again. it's safe to cast away const.
    rv = ConvertUCS4ToCustom(NS_CONST_CAST(FcChar32 *, aString), 
                             aLen, destLen, mFontInfo->mConverter,
                             isWide, buffer);
    NS_ENSURE_SUCCESS(rv, rv);
      
    FcChar32 *str = buffer.get();

    // short cut for the common case
    if (isWide) { 
        XftTextExtents32(GDK_DISPLAY(), mXftFont, str, destLen, &aGlyphInfo);
        return NS_OK;
    }

    // If FT_SelectCharMap succeeds for MacRoman or Unicode,
    // use glyph indices directly for 'narrow' custom encoded fonts.
    rv = SetFT_FaceCharmap();
    NS_ENSURE_SUCCESS(rv, rv);

    // replace chars with glyphs in place. 
    for (PRUint32 i = 0; i < destLen; i++) {
        str[i] = FT_Get_Char_Index (mFT_Face, FT_ULong(str[i]));
    }

    XftGlyphExtents(GDK_DISPLAY(), mXftFont, str, destLen, &aGlyphInfo);
        
    return NS_OK;
}

Here is the call graph for this function:

virtual nsresult nsFontXftCustom::GetTextExtents32 ( const FcChar32 *  aString,
PRUint32  aLen,
XGlyphInfo &  aGlyphInfo 
) [virtual]

Reimplemented from nsFontXft.

gint nsFontXft::GetWidth32 ( const FcChar32 *  aString,
PRUint32  aLen 
) [inherited]

Definition at line 1914 of file nsFontMetricsXft.cpp.

{
    XGlyphInfo glyphInfo;
    GetTextExtents32(aString, aLen, glyphInfo);

    return glyphInfo.xOff;
}

Here is the call graph for this function:

Here is the caller graph for this function:

gint nsFontXft::GetWidth32 ( const FcChar32 *  aString,
PRUint32  aLen 
) [inherited]
XftFont* nsFontXft::GetXftFont ( void  ) [inherited]
XftFont * nsFontXft::GetXftFont ( void  ) [inherited]

Definition at line 1871 of file nsFontMetricsXft.cpp.

{
    if (!mXftFont) {
        FcPattern *pat = FcFontRenderPrepare(0, mPattern, mFontName);
        if (!pat)
            return nsnull;

        // bug 196312 : work around problem with CJK bi-width fonts
        // and fontconfig prior to 2.2. CJK bi-width fonts are regarded
        // as genuinely monospace by fontconfig that  sets FC_SPACING
        // to FC_MONOSPACE, which makes Xft drawing/measuring routines
        // use the global advance width (the width of double width glyphs 
        // and twice the width of single width glyphs) even for single width
        // characters (e.g. Latin letters and digits). This results in
        // spaced-out ('s p a c e d - o u t') rendering. By deleting
        // FC_SPACING here, we're emulating the behavior of fontconfig 2.2 or 
        // later that does not set FC_SPACING for any font.
        if (FcGetVersion() < 20300)
            FcPatternDel(pat, FC_SPACING);

        mXftFont = XftFontOpenPattern(GDK_DISPLAY(), pat);
        if (!mXftFont)
            FcPatternDestroy(pat);
    }

    return mXftFont;
}

Here is the caller graph for this function:

Implements nsFontXft.

Definition at line 2068 of file nsFontMetricsXft.cpp.

{
    return (mFontInfo->mCCMap &&
            CCMAP_HAS_CHAR_EXT(mFontInfo->mCCMap, aChar)); 
}
virtual PRBool nsFontXftCustom::HasChar ( PRUint32  aChar) [virtual]

Implements nsFontXft.

Definition at line 2118 of file nsFontMetricsXft.cpp.

{
    NS_PRECONDITION(mXftFont, "FindFont should not return bad fonts");

    if (mFT_Face)
        return NS_OK;

    mFT_Face = XftLockFace(mXftFont);

    NS_ENSURE_TRUE(mFT_Face != nsnull, NS_ERROR_UNEXPECTED);

    // Select FT_Encoding to use for custom narrow fonts in 
    // glyph index look-up with FT_Get_Char_Index succeeds.
        
    if (FT_Select_Charmap (mFT_Face, mFontInfo->mFT_Encoding))
        return NS_ERROR_UNEXPECTED;

    return NS_OK;
}

Here is the caller graph for this function:


Member Data Documentation

FcCharSet * nsFontXft::mCharset [inherited]

Definition at line 115 of file nsFontMetricsXft.cpp.

Definition at line 163 of file nsFontMetricsXft.cpp.

FcPattern * nsFontXft::mFontName [inherited]

Definition at line 114 of file nsFontMetricsXft.cpp.

Definition at line 167 of file nsFontMetricsXft.cpp.

FcPattern * nsFontXft::mPattern [inherited]

Definition at line 113 of file nsFontMetricsXft.cpp.

XftFont * nsFontXft::mXftFont [inherited]

Definition at line 112 of file nsFontMetricsXft.cpp.


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