TOpenFontSpec Class Reference

#include <openfont.h>

Link against: fntstr.lib

class TOpenFontSpec : public TOpenFontFaceAttribBase

Inherits from

Public Member Enumerations
enumanonymous { EAlgorithmicBold, EDropShadow, EOutline }
Public Member Functions
TOpenFontSpec()
TOpenFontSpec(const TFontSpec &)
TInt ApplyRatio(TInt &, TInt, TInt)
TInt ApplyRatio(TInt32 &, TInt, TInt)
TGlyphBitmapType BitmapType()
IMPORT_C voidCompensateForAspectRatio(TInt, TInt)
IMPORT_C voidCompensateForAspectRatio(const MGraphicsDeviceMap &)
TUint32 Effects()
IMPORT_C voidGetTFontSpec(TFontSpec &)
TInt Height()
TBool IsCompensationForAspectRatioNeeded(TInt, TInt)
IMPORT_C TBoolIsEffectOn(FontEffect::TEffect)
TFontPrintPosition PrintPosition()
IMPORT_C TIntScriptTypeForMetrics()
IMPORT_C voidSetAttrib(const TOpenFontFaceAttribBase &)
voidSetBitmapType(TGlyphBitmapType)
voidSetEffects(TUint32)
IMPORT_C voidSetEffects(FontEffect::TEffect, TBool)
voidSetHeight(TInt)
IMPORT_C voidSetScriptTypeForMetrics(TLanguage)
voidSetSlantFactor(TInt32)
voidSetWidthFactor(TInt32)
TInt32 SlantFactor()
TInt32 WidthFactor()
TBool operator!=(const TOpenFontSpec &)
IMPORT_C voidoperator=(const TFontSpec &)
TBool operator==(const TOpenFontSpec &)
Inherited Attributes
TOpenFontFaceAttribBase::iCoverage
TOpenFontFaceAttribBase::iName
TOpenFontFaceAttribBase::iReserved
TOpenFontFaceAttribBase::iStyle
Inherited Enumerations
TOpenFontFaceAttribBase:@46
TOpenFontFaceAttribBase:@47
TOpenFontFaceAttribBase:@48
TOpenFontFaceAttribBase:@49
TOpenFontFaceAttribBase:@57
TOpenFontFaceAttribBase:@58
TOpenFontFaceAttribBase:@59
TOpenFontFaceAttribBase:@60
Inherited Functions
TOpenFontFaceAttribBase::Coverage()const
TOpenFontFaceAttribBase::HasCJK()const
TOpenFontFaceAttribBase::HasCyrillic()const
TOpenFontFaceAttribBase::HasGreek()const
TOpenFontFaceAttribBase::HasHangul()const
TOpenFontFaceAttribBase::HasKana()const
TOpenFontFaceAttribBase::HasLatin()const
TOpenFontFaceAttribBase::IsBold()const
TOpenFontFaceAttribBase::IsItalic()const
TOpenFontFaceAttribBase::IsMonoWidth()const
TOpenFontFaceAttribBase::IsSerif()const
TOpenFontFaceAttribBase::IsSymbol()const
TOpenFontFaceAttribBase::Name()const
TOpenFontFaceAttribBase::SetBold(TBool)
TOpenFontFaceAttribBase::SetCoverage(TUint,TUint,TUint,TUint)
TOpenFontFaceAttribBase::SetItalic(TBool)
TOpenFontFaceAttribBase::SetMonoWidth(TBool)
TOpenFontFaceAttribBase::SetName(const TDesC &)
TOpenFontFaceAttribBase::SetSerif(TBool)
TOpenFontFaceAttribBase::TOpenFontFaceAttribBase()
TOpenFontFaceAttribBase::operator==(const TOpenFontFaceAttribBase &)const

Detailed Description

Font specification allowing more attributes to be specified than TFontSpec.

In addition to the attributes specified by TFontSpec, this font specification allows stretching and slanting in the x dimension, and other algorithmic effects. This is used to correct for non-square pixels, and to allow algorithmic slanting and bold. The width factor and slant factor transform any point (x,y) to (x iWidthFactor + y * iSlantFactor,y). The width and slant factors are 16.16 fixed-point numbers.

The font specification also provides access to information about the scripts which are supported by the font. This information is not always reliable, because it may be incorrectly specified, or not specified at all, by some font manufacturers.

Member Enumeration Documentation

Enum anonymous

Algorithmic effects flags.

These can be combined using an OR operation.

WARNING: Enum for internal and partner use ONLY. Compatibility is not guaranteed in future releases.

DeprecatedUse FontEffect::TEffect instead.

EnumeratorValueDescription
EAlgorithmicBold1

Font is algorithmic bold.

EDropShadow2

Font has a drop shadow.

EOutline4

Font is an outline font.

Constructor & Destructor Documentation

TOpenFontSpec ( )

IMPORT_CTOpenFontSpec()

Default C++ constructor setting height to 16 pixels or twips, width factor to 1 (65536 in 16.16 format), slant factor to 0 (no slant), effects to ENone, symbol to 0 (assuming EScriptNone = 0), print position to EPrintPosNormal.

TOpenFontSpec ( const TFontSpec & )

IMPORT_CTOpenFontSpec(const TFontSpec &aFontSpec)

C++ constructor taking a reference to a TFontSpec.

This object's members are initialised from the values of the aFontSpec parameter.

ParameterDescription
aFontSpecThe font specification used to initialise this font specification.

Member Function Documentation

ApplyRatio ( TInt &, TInt, TInt )

TInt ApplyRatio(TInt &aValue,
TIntaNumerator,
TIntaDenominator
)[static]

Multiplies aValue by aNumerator/aDenominator but using TInt64's to avoid any overflows. Returns ETrue if the final result has an overflow.

ApplyRatio ( TInt32 &, TInt, TInt )

TInt ApplyRatio(TInt32 &aValue,
TIntaNumerator,
TIntaDenominator
)[static]

Same as above function but this takes a TInt32 not a TInt

BitmapType ( )

TGlyphBitmapType BitmapType()const [inline]

Gets the anti-aliasing setting for the font, as set by SetBitmapType().

Returns: Indicates whether or not the font should be drawn using anti-aliasing.

CompensateForAspectRatio ( TInt, TInt )

IMPORT_C voidCompensateForAspectRatio(TIntaPixelWidth,
TIntaPixelHeight
)

Adjust the width factor and slant factor to suit a pixel aspect ratio.

ParameterDescription
aPixelWidthThe pixel width, in the same units as aPixelHeight.
aPixelHeightThe pixel height, in the same units as aPixelWidth.

CompensateForAspectRatio ( const MGraphicsDeviceMap & )

IMPORT_C voidCompensateForAspectRatio(const MGraphicsDeviceMap &aMap)

Adjust the width factor and slant factor to suit a pixel aspect ratio stored in a MGraphicsDeviceMap derived object.

ParameterDescription
aMapThe MGraphicsDeviceMap defining the pixel aspect ratio.

Effects ( )

TUint32 Effects()const [inline]

Gets the font effects flags. Because the flags encoded in the Effects are anonymous, the return value should only be tested for the specific bits that are of interest, and never tested as a whole.

See also: TOpenFontSpec::SetEffects()

Returns: The font effects flags.

GetTFontSpec ( TFontSpec & )

IMPORT_C voidGetTFontSpec(TFontSpec &aFontSpec)const

Gets the TFontSpec corresponding to this Open Font System font specification.

ParameterDescription
aFontSpecOn return, contains the TFontSpec corresponding to this font specification.

Height ( )

TInt Height()const [inline]

Gets the height of the font.

See also: SetHeight()

Returns: The height of the font, in pixels or twips.

IsCompensationForAspectRatioNeeded ( TInt, TInt )

TBool IsCompensationForAspectRatioNeeded(TIntaPixelWidth,
TIntaPixelHeight
)[static]

The pixel width and height are used to derive a ratio, and so can be in any units. Aspect ratios differing by less than 1/1000 are treated as 1:1.

IsEffectOn ( FontEffect::TEffect )

IMPORT_C TBoolIsEffectOn(FontEffect::TEffectaEffect)const

Checks if a font effect is on.

See also: TOpenFontSpec::SetEffects()

ParameterDescription
aEffectThe font effect to be checked.

Returns: True represents the specified font effect is on, otherwise off.

PrintPosition ( )

TFontPrintPosition PrintPosition()const [inline]

Gets the print position.

Returns: The print position.

ScriptTypeForMetrics ( )

IMPORT_C TIntScriptTypeForMetrics()const

Gets the script which the font metrics calculation will be based on.

Returns: The script.

SetAttrib ( const TOpenFontFaceAttribBase & )

IMPORT_C voidSetAttrib(const TOpenFontFaceAttribBase &aAttrib)

Sets the font attributes.

ParameterDescription
aAttribThe font attributes.

SetBitmapType ( TGlyphBitmapType )

voidSetBitmapType(TGlyphBitmapTypeaBitmapType)[inline]

Sets whether the font should be drawn using anti-aliasing. If set, this value overrides the default setting (set by CFbsTypefaceStore::SetDefaultBitmapType()) for this font.

Anti-aliasing can only be used for scalable fonts. There is currently no anti-aliasing support for bitmapped fonts.

ParameterDescription
aBitmapTypeIndicates whether or not the font should be drawn using anti-aliasing.

SetEffects ( TUint32 )

voidSetEffects(TUint32aEffects)[inline]

Sets the font effects flags. Prior to calling this routine, the value from Effects() should be read, and its flags modified as required, before passing them back in.

See also: TOpenFontSpec::Effects()

SetEffects ( FontEffect::TEffect, TBool )

IMPORT_C voidSetEffects(FontEffect::TEffectaEffect,
TBoolaOn
)

Sets a font effect to the given state.

See also: TOpenFontSpec::IsEffectOn()

ParameterDescription
aEffectThe font effect to be set.
aOnTrue represents on, otherwise off.

SetHeight ( TInt )

voidSetHeight(TIntaHeight)[inline]

Sets the font's height.

See also: Height()

ParameterDescription
aHeightThe font's height, in pixels or twips.

SetScriptTypeForMetrics ( TLanguage )

IMPORT_C voidSetScriptTypeForMetrics(TLanguageaLanguage)

Specifies the script which font metrics calculation will be based on.

ParameterDescription
aLanguageThe language used to derive the required script.

SetSlantFactor ( TInt32 )

voidSetSlantFactor(TInt32aSlantFactor)[inline]

Sets the algorithmic slant factor.

Note: The slant factor is used to create an italic effect for characters which do not have an italic glyph in the typeface. When slanting is active, pixel x co-ordinates are shifted by a factor relative to the y co-ordinate (i.e. x = x + y x slant factor).

The slant factor is a 32 bit, 16.16 fixed-point number. This means that the first 16 bits are treated as a whole number, and the second 16 as the fractional part. e.g. if aSlantFactor=0, there is no slant. If aSlantFactor=65536 this is equivalent to an integer slant value of 1, which causes a 45 degree slant on the character.

See also: SlantFactor()

ParameterDescription
aSlantFactorThe slant factor as a 16.16 fixed-point number.

SetWidthFactor ( TInt32 )

voidSetWidthFactor(TInt32aWidthFactor)[inline]

Sets the algorithmic width factor.

The width factor is multiplied by the pixel's x position to get the new position, causing characters to become wider or narrower. A width factor of 1 (65536 in 16.16 fixed-point number format) should be used if the character width is not to be changed.

See also: WidthFactor()

ParameterDescription
aWidthFactorThe algorithmic width factor as a 16.16 fixed-point number.

SlantFactor ( )

TInt32 SlantFactor()const [inline]

Gets the algorithmic slant factor.

See also: SetSlantFactor()

Returns: The algorithmic slant factor as a 16.16 fixed-point number.

WidthFactor ( )

TInt32 WidthFactor()const [inline]

Gets the algorithmic width factor.

See also: SetWidthFactor()

Returns: The algorithmic width factor as a 16.16 fixed-point number.

operator!= ( const TOpenFontSpec & )

TBool operator!=(const TOpenFontSpec &aOpenFontSpec)const

operator= ( const TFontSpec & )

IMPORT_C voidoperator=(const TFontSpec &aFontSpec)

Assignment operator.

ParameterDescription
aFontSpecThe old-style font specification to copy into this font specification.

operator== ( const TOpenFontSpec & )

TBool operator==(const TOpenFontSpec &aFontSpec)const [inline]

Compares this and another open font specification. Compares all the properties of the two fonts.

ParameterDescription
aFontSpecThe open font specification to compare with this one.

Returns: ETrue if all values are equal, EFalse if not.