SkTypeface Class Reference

#include <SkTypeface.h>

Inherits SkRefCnt.

Collaboration diagram for SkTypeface:
Collaboration graph
[legend]

List of all members.

Public Types

enum  Style { kNormal = 0, kBold = 0x01, kItalic = 0x02, kBoldItalic = 0x03 }

Public Member Functions

Style style () const
bool isBold () const
bool isItalic () const
uint32_t uniqueID () const
void serialize (SkWStream *) const

Static Public Member Functions

static uint32_t UniqueID (const SkTypeface *face)
static bool Equal (const SkTypeface *facea, const SkTypeface *faceb)
static SkTypefaceCreateFromName (const char familyName[], Style style)
static SkTypefaceCreateFromTypeface (const SkTypeface *family, Style s)
static SkTypefaceCreateFromFile (const char path[])
static SkTypefaceCreateFromStream (SkStream *stream)
static SkTypefaceDeserialize (SkStream *)

Protected Member Functions

 SkTypeface (Style style, uint32_t uniqueID)

Detailed Description

The SkTypeface class specifies the typeface and intrinsic style of a font. This is used in the paint, along with optionally algorithmic settings like textSize, textSkewX, textScaleX, kFakeBoldText_Mask, to specify how text appears when drawn (and measured).

Typeface objects are immutable, and so they can be shared between threads.

Definition at line 34 of file SkTypeface.h.


Member Enumeration Documentation

Style specifies the intrinsic style attributes of a given typeface

Enumerator:
kNormal 
kBold 
kItalic 
kBoldItalic 

Definition at line 38 of file SkTypeface.h.


Constructor & Destructor Documentation

SkTypeface::SkTypeface ( Style  style,
uint32_t  uniqueID 
) [inline, protected]

uniqueID must be unique (please!) and non-zero

Definition at line 124 of file SkTypeface.h.


Member Function Documentation

static SkTypeface* SkTypeface::CreateFromFile ( const char  path[]  )  [static]

Return a new typeface given a file. If the file does not exist, or is not a valid font file, returns null.

static SkTypeface* SkTypeface::CreateFromName ( const char  familyName[],
Style  style 
) [static]

Return a new reference to the typeface that most closely matches the requested familyName and style. Pass null as the familyName to return the default font for the requested style. Will never return null

Parameters:
familyName May be NULL. The name of the font family.
style The style (normal, bold, italic) of the typeface.
Returns:
reference to the closest-matching typeface. Call must call unref() when they are done.
static SkTypeface* SkTypeface::CreateFromStream ( SkStream stream  )  [static]

Return a new typeface given a stream. If the stream is not a valid font file, returns null. Ownership of the stream is transferred, so the caller must not reference it again.

static SkTypeface* SkTypeface::CreateFromTypeface ( const SkTypeface family,
Style  s 
) [static]

Return a new reference to the typeface that most closely matches the requested typeface and specified Style. Use this call if you want to pick a new style from the same family of the existing typeface. If family is NULL, this selects from the default font's family.

Parameters:
family May be NULL. The name of the existing type face.
s The style (normal, bold, italic) of the type face.
Returns:
reference to the closest-matching typeface. Call must call unref() when they are done.
static SkTypeface* SkTypeface::Deserialize ( SkStream  )  [static]

Given the data previously written by serialize(), return a new instance to a typeface referring to the same font. If that font is not available, return null. If an instance is returned, the caller is responsible for calling unref() when they are done with it.

static bool SkTypeface::Equal ( const SkTypeface facea,
const SkTypeface faceb 
) [static]

Returns true if the two typefaces reference the same underlying font, handling either being null (treating null as the default font)

bool SkTypeface::isBold (  )  const [inline]

Returns true if getStyle() has the kBold bit set.

Definition at line 53 of file SkTypeface.h.

bool SkTypeface::isItalic (  )  const [inline]

Returns true if getStyle() has the kItalic bit set.

Definition at line 57 of file SkTypeface.h.

void SkTypeface::serialize ( SkWStream  )  const

Write a unique signature to a stream, sufficient to reconstruct a typeface referencing the same font when Deserialize is called.

Style SkTypeface::style (  )  const [inline]

Returns the typeface's intrinsic style attributes

Definition at line 49 of file SkTypeface.h.

static uint32_t SkTypeface::UniqueID ( const SkTypeface face  )  [static]

Return the uniqueID for the specified typeface. If the face is null, resolve it to the default font and return its uniqueID. Will never return 0.

uint32_t SkTypeface::uniqueID (  )  const [inline]

Return a 32bit value for this typeface, unique for the underlying font data. Will never return 0.

Definition at line 62 of file SkTypeface.h.


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

Generated on Tue Oct 20 11:03:42 2009 for Skia by  doxygen 1.6.1