Back to index

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

#include <nsFontMetricsQt.h>

Collaboration diagram for nsFontQt:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsFontQt (const nsFont &afont, nsIAtom *aLangGroup, nsIDeviceContext *acontext)
 ~nsFontQt ()
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
bool 
SupportsChar (PRUnichar c)
void RealizeFont ()

Public Attributes

QFont font
nsIDeviceContextmDeviceContext
nsCOMPtr< nsIAtommLangGroup
nscoord mLeading
nscoord mEmHeight
nscoord mEmAscent
nscoord mEmDescent
nscoord mMaxHeight
nscoord mMaxAscent
nscoord mMaxDescent
nscoord mMaxAdvance
nscoord mAveCharWidth
nscoord mXHeight
nscoord mSuperscriptOffset
nscoord mSubscriptOffset
nscoord mStrikeoutSize
nscoord mStrikeoutOffset
nscoord mUnderlineSize
nscoord mUnderlineOffset
nscoord mSpaceWidth
PRUint16 mPixelSize
PRUint16 mWeight

Detailed Description

Definition at line 73 of file nsFontMetricsQt.h.


Constructor & Destructor Documentation

nsFontQt::nsFontQt ( const nsFont afont,
nsIAtom aLangGroup,
nsIDeviceContext acontext 
)

Definition at line 66 of file nsFontMetricsQt.cpp.

{
    mLangGroup = aLangGroup;
    mDeviceContext = aContext;

    float a2d = aContext->AppUnitsToDevUnits();
    mPixelSize = NSToIntRound(a2d * aFont.size);

    if (mLangGroup) {
        nsCAutoString name("font.min-size.variable.");
        const char* langGroup = nsnull;
        mLangGroup->GetUTF8String(&langGroup);

        PRInt32 minimum = 0;
        nsresult res;
        nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID, &res);
        if (NS_SUCCEEDED(res)) {
            nsCOMPtr<nsIPrefBranch> branch;
            prefs->GetBranch(name.get(), getter_AddRefs(branch));
            branch->GetIntPref(langGroup, &minimum);
        }
        if (minimum < 0) {
            minimum = 0;
        }
        if (mPixelSize < minimum) {
            mPixelSize = minimum;
        }
    }

    font.setFamily(QString::fromUcs2(aFont.name.get()));
    font.setPixelSize(mPixelSize);
    font.setWeight(aFont.weight/10);
    font.setItalic(aFont.style != NS_FONT_STYLE_NORMAL);

    RealizeFont();
}

Here is the call graph for this function:

nsFontQt::~nsFontQt ( ) [inline]

Definition at line 77 of file nsFontMetricsQt.h.

{}

Member Function Documentation

Definition at line 103 of file nsFontMetricsQt.cpp.

{
    QFontMetrics fm(font);

    float f = mDeviceContext->DevUnitsToAppUnits();

    mMaxAscent = nscoord(fm.ascent() * f) ;
    mMaxDescent = nscoord(fm.descent() * f);
    mMaxHeight = mMaxAscent + mMaxDescent;

    mEmHeight = nscoord(fm.height() * f);
    mMaxAdvance = nscoord(fm.maxWidth() * f);

    mAveCharWidth = nscoord(fm.width(QChar('x')) * f);

    mEmAscent = mMaxAscent;
    mEmDescent = mMaxDescent;

    mXHeight = NSToCoordRound(fm.boundingRect('x').height() * f);

    mUnderlineOffset = - nscoord(fm.underlinePos() * f);

    mUnderlineSize = NSToIntRound(fm.lineWidth() * f);

    mSuperscriptOffset = mXHeight;
    mSubscriptOffset = mXHeight;

    mStrikeoutOffset = nscoord(fm.strikeOutPos() * f);
    mStrikeoutSize = mUnderlineSize;

    mLeading = nscoord(fm.leading() * f);
    mSpaceWidth = nscoord(fm.width(QChar(' ')) * f);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 80 of file nsFontMetricsQt.h.

{ return QFontMetrics(font).inFont(QChar(c)); }

Member Data Documentation

Definition at line 82 of file nsFontMetricsQt.h.

Definition at line 95 of file nsFontMetricsQt.h.

Definition at line 84 of file nsFontMetricsQt.h.

Definition at line 89 of file nsFontMetricsQt.h.

Definition at line 90 of file nsFontMetricsQt.h.

Definition at line 88 of file nsFontMetricsQt.h.

Definition at line 85 of file nsFontMetricsQt.h.

Definition at line 87 of file nsFontMetricsQt.h.

Definition at line 94 of file nsFontMetricsQt.h.

Definition at line 92 of file nsFontMetricsQt.h.

Definition at line 93 of file nsFontMetricsQt.h.

Definition at line 91 of file nsFontMetricsQt.h.

Definition at line 105 of file nsFontMetricsQt.h.

Definition at line 103 of file nsFontMetricsQt.h.

Definition at line 100 of file nsFontMetricsQt.h.

Definition at line 99 of file nsFontMetricsQt.h.

Definition at line 98 of file nsFontMetricsQt.h.

Definition at line 97 of file nsFontMetricsQt.h.

Definition at line 102 of file nsFontMetricsQt.h.

Definition at line 101 of file nsFontMetricsQt.h.

Definition at line 106 of file nsFontMetricsQt.h.

Definition at line 96 of file nsFontMetricsQt.h.


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