Back to index

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

#include <nsFontMetricsQt.h>

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

List of all members.

Public Member Functions

 nsFontMetricsQt ()
virtual ~nsFontMetricsQt ()
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
NS_DECL_ISUPPORTS NS_IMETHOD 
Init (const nsFont &aFont, nsIAtom *aLangGroup, nsIDeviceContext *aContext)
 Initialize the font metrics.
NS_IMETHOD Destroy ()
 Destroy this font metrics.
NS_IMETHOD GetXHeight (nscoord &aResult)
 Return the font's xheight property, scaled into app-units.
NS_IMETHOD GetSuperscriptOffset (nscoord &aResult)
 Return the font's superscript offset (the distance from the baseline to where a superscript's baseline should be placed).
NS_IMETHOD GetSubscriptOffset (nscoord &aResult)
 Return the font's subscript offset (the distance from the baseline to where a subscript's baseline should be placed).
NS_IMETHOD GetStrikeout (nscoord &aOffset, nscoord &aSize)
 Return the font's strikeout offset (the distance from the baseline to where a strikeout should be placed) and size Positive values are above the baseline, negative below.
NS_IMETHOD GetUnderline (nscoord &aOffset, nscoord &aSize)
 Return the font's underline offset (the distance from the baseline to where a underline should be placed) and size.
NS_IMETHOD GetHeight (nscoord &aHeight)
 Returns the height (in app units) of the font.
NS_IMETHOD GetNormalLineHeight (nscoord &aHeight)
 Returns the normal line height (em height + leading).
NS_IMETHOD GetLeading (nscoord &aLeading)
 Returns the amount of internal leading (in app units) for the font.
NS_IMETHOD GetEmHeight (nscoord &aHeight)
 Returns the height (in app units) of the Western font's em square.
NS_IMETHOD GetEmAscent (nscoord &aAscent)
 Returns, in app units, the ascent part of the Western font's em square.
NS_IMETHOD GetEmDescent (nscoord &aDescent)
 Returns, in app units, the descent part of the Western font's em square.
NS_IMETHOD GetMaxHeight (nscoord &aHeight)
 Returns the height (in app units) of the Western font's bounding box.
NS_IMETHOD GetMaxAscent (nscoord &aAscent)
 Returns, in app units, the maximum distance characters in this font extend above the base line.
NS_IMETHOD GetMaxDescent (nscoord &aDescent)
 Returns, in app units, the maximum distance characters in this font extend below the base line.
NS_IMETHOD GetMaxAdvance (nscoord &aAdvance)
 Returns, in app units, the maximum character advance for the font.
NS_IMETHOD GetAveCharWidth (nscoord &aAveCharWidth)
 Returns the average character width.
NS_IMETHOD GetLangGroup (nsIAtom **aLangGroup)
 Returns the language group associated with these metrics.
NS_IMETHOD GetFontHandle (nsFontHandle &aHandle)
 Returns the font handle associated with these metrics.
NS_IMETHOD GetSpaceWidth (nscoord &aSpaceWidth)
 Returns the often needed width of the space character.
virtual PRInt32 GetMaxStringLength ()
const nsFontFont ()
 Returns the font associated with these metrics.

Public Attributes

nsFontQtqFont

Protected Attributes

nsFont mFont

Detailed Description

Definition at line 111 of file nsFontMetricsQt.h.


Constructor & Destructor Documentation

Definition at line 137 of file nsFontMetricsQt.cpp.

{
    qFont = 0;
}

Definition at line 142 of file nsFontMetricsQt.cpp.

{
    NS_ASSERTION(qFont == 0, "deleting non destroyed nsFontMetricsQt");
}

Member Function Documentation

Destroy this font metrics.

This breaks the association between the font metrics and the device context.

Implements nsIFontMetrics.

Definition at line 159 of file nsFontMetricsQt.cpp.

{
    delete qFont;
    qFont = 0;
    return NS_OK;
}
const nsFont& nsIFontMetrics::Font ( ) [inline, inherited]

Returns the font associated with these metrics.

The return value is only defined after Init() has been called.

Definition at line 214 of file nsIFontMetrics.h.

{ return mFont; }

Here is the caller graph for this function:

NS_IMETHODIMP nsFontMetricsQt::GetAveCharWidth ( nscoord aAveCharWidth) [virtual]

Returns the average character width.

Implements nsIFontMetrics.

Definition at line 258 of file nsFontMetricsQt.cpp.

{
    aAveCharWidth = qFont->mAveCharWidth;
    return NS_OK;
}

Returns, in app units, the ascent part of the Western font's em square.

Implements nsIFontMetrics.

Definition at line 222 of file nsFontMetricsQt.cpp.

{
    aAscent = qFont->mEmAscent;
    return NS_OK;
}

Returns, in app units, the descent part of the Western font's em square.

Implements nsIFontMetrics.

Definition at line 228 of file nsFontMetricsQt.cpp.

{
    aDescent = qFont->mEmDescent;
    return NS_OK;
}

Returns the height (in app units) of the Western font's em square.

This is em ascent plus em descent.

Implements nsIFontMetrics.

Definition at line 216 of file nsFontMetricsQt.cpp.

{
    aHeight = qFont->mEmHeight;
    return NS_OK;
}

Returns the font handle associated with these metrics.

Implements nsIFontMetrics.

Definition at line 281 of file nsFontMetricsQt.cpp.

{
    aHandle = (nsFontHandle)qFont;
    return NS_OK;
}

Returns the height (in app units) of the font.

This is ascent plus descent plus any internal leading

This method will be removed once the callers have been moved over to the new GetEmHeight (and possibly GetMaxHeight).

Implements nsIFontMetrics.

Definition at line 198 of file nsFontMetricsQt.cpp.

{
    aHeight = qFont->mMaxHeight;
    return NS_OK;
}
NS_IMETHODIMP nsFontMetricsQt::GetLangGroup ( nsIAtom **  aLangGroup) [virtual]

Returns the language group associated with these metrics.

Implements nsIFontMetrics.

Definition at line 270 of file nsFontMetricsQt.cpp.

{
    if (!aLangGroup) {
        return NS_ERROR_NULL_POINTER;
    }
    *aLangGroup = qFont->mLangGroup;
    NS_IF_ADDREF(*aLangGroup);
    return NS_OK;
}

Returns the amount of internal leading (in app units) for the font.

This is computed as the "height - (ascent + descent)"

Implements nsIFontMetrics.

Definition at line 210 of file nsFontMetricsQt.cpp.

{
    aLeading = qFont->mLeading;
    return NS_OK;
}

Returns, in app units, the maximum character advance for the font.

Implements nsIFontMetrics.

Definition at line 252 of file nsFontMetricsQt.cpp.

{
    aAdvance = qFont->mMaxAdvance;
    return NS_OK;
}

Returns, in app units, the maximum distance characters in this font extend above the base line.

Implements nsIFontMetrics.

Definition at line 240 of file nsFontMetricsQt.cpp.

{
    aAscent = qFont->mMaxAscent;
    return NS_OK;
}

Returns, in app units, the maximum distance characters in this font extend below the base line.

Implements nsIFontMetrics.

Definition at line 246 of file nsFontMetricsQt.cpp.

{
    aDescent = qFont->mMaxDescent;
    return NS_OK;
}

Returns the height (in app units) of the Western font's bounding box.

This is max ascent plus max descent.

Implements nsIFontMetrics.

Definition at line 234 of file nsFontMetricsQt.cpp.

{
    aHeight = qFont->mMaxHeight;
    return NS_OK;
}
virtual PRInt32 nsFontMetricsQt::GetMaxStringLength ( ) [inline, virtual]

Definition at line 147 of file nsFontMetricsQt.h.

{ return PR_INT32_MAX; }

Returns the normal line height (em height + leading).

Implements nsIFontMetrics.

Definition at line 204 of file nsFontMetricsQt.cpp.

{
    aHeight = qFont->mEmHeight + qFont->mLeading;
    return NS_OK;
}
NS_IMETHODIMP nsFontMetricsQt::GetSpaceWidth ( nscoord aSpaceCharWidth) [virtual]

Returns the often needed width of the space character.

Implements nsIFontMetrics.

Definition at line 264 of file nsFontMetricsQt.cpp.

{
    aSpaceWidth = qFont->mSpaceWidth;
    return NS_OK;
}
NS_IMETHODIMP nsFontMetricsQt::GetStrikeout ( nscoord aOffset,
nscoord aSize 
) [virtual]

Return the font's strikeout offset (the distance from the baseline to where a strikeout should be placed) and size Positive values are above the baseline, negative below.

Implements nsIFontMetrics.

Definition at line 184 of file nsFontMetricsQt.cpp.

{
    aOffset = qFont->mStrikeoutOffset;
    aSize = qFont->mStrikeoutSize;
    return NS_OK;
}

Return the font's subscript offset (the distance from the baseline to where a subscript's baseline should be placed).

The value returned will be a positive value.

Implements nsIFontMetrics.

Definition at line 178 of file nsFontMetricsQt.cpp.

Return the font's superscript offset (the distance from the baseline to where a superscript's baseline should be placed).

The value returned will be a positive value.

Implements nsIFontMetrics.

Definition at line 172 of file nsFontMetricsQt.cpp.

NS_IMETHODIMP nsFontMetricsQt::GetUnderline ( nscoord aOffset,
nscoord aSize 
) [virtual]

Return the font's underline offset (the distance from the baseline to where a underline should be placed) and size.

Positive values are above the baseline, negative below.

Implements nsIFontMetrics.

Definition at line 191 of file nsFontMetricsQt.cpp.

{
    aOffset = qFont->mUnderlineOffset;
    aSize = qFont->mUnderlineSize;
    return NS_OK;
}

Return the font's xheight property, scaled into app-units.

Implements nsIFontMetrics.

Definition at line 166 of file nsFontMetricsQt.cpp.

{
    aResult = qFont->mXHeight;
    return NS_OK;
}
NS_IMETHODIMP nsFontMetricsQt::Init ( const nsFont aFont,
nsIAtom aLangGroup,
nsIDeviceContext aContext 
) [virtual]

Initialize the font metrics.

Call this after creating the font metrics. Font metrics you get from the font cache do NOT need to be initialized

See also:
nsIDeviceContext::GetMetricsFor()

Implements nsIFontMetrics.

Definition at line 149 of file nsFontMetricsQt.cpp.

{
    NS_ASSERTION(!(nsnull == aContext), "attempt to init fontmetrics with null device context");

    mFont = aFont;
    qFont = new nsFontQt(aFont, aLangGroup, aContext);
    return NS_OK;
}

Member Data Documentation

nsFont nsIFontMetrics::mFont [protected, inherited]

Definition at line 238 of file nsIFontMetrics.h.

Definition at line 149 of file nsFontMetricsQt.h.


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