Logo Search packages:      
Sourcecode: xulrunner-1.9 version File versions

gfxTextRun Class Reference

#include <gfxFont.h>

Inheritance diagram for gfxTextRun:


List of all members.

Detailed Description

gfxTextRun is an abstraction for drawing and measuring substrings of a run of text. It stores runs of positioned glyph data, each run having a single gfxFont. The glyphs are associated with a string of source text, and the gfxTextRun APIs take parameters that are offsets into that source text.

gfxTextRuns are not refcounted. They should be deleted when no longer required.

gfxTextRuns are mostly immutable. The only things that can change are inter-cluster spacing and line break placement. Spacing is always obtained lazily by methods that need it, it is not cached. Line breaks are stored persistently (insofar as they affect the shaping of glyphs; gfxTextRun does not actually do anything to explicitly account for line breaks). Initially there are no line breaks. The textrun can record line breaks before or after any given cluster. (Line breaks specified inside clusters are ignored.)

It is important that zero-length substrings are handled correctly. This will be on the test!

gfxTextRun stores a list of zero or more glyphs for each character. For each glyph we store the glyph ID, the advance, and possibly an xoffset and yoffset. The idea is that a string is rendered by a loop that draws each glyph at its designated offset from the current point, then advances the current point by the glyph's advance in the direction of the textrun (LTR or RTL). Each glyph advance is always rounded to the nearest appunit; this ensures consistent results when dividing the text in a textrun into multiple text frames (frame boundaries are always aligned to appunits). We optimize for the case where a character has a single glyph and zero xoffset and yoffset, and the glyph ID and advance are in a reasonable range so we can pack all necessary data into 32 bits.

gfxTextRun methods that measure or draw substrings will associate all the glyphs in a cluster with the first character of the cluster; if that character is in the substring, the glyphs will be measured or drawn, otherwise they won't.

Definition at line 694 of file gfxFont.h.

Public Types

typedef gfxFont::RunMetrics Metrics

Public Member Functions

nsresult AddGlyphRun (gfxFont *aFont, PRUint32 aStartCharIndex, PRBool aForceNewRun=PR_FALSE)
void AdjustAdvancesForSyntheticBold (PRUint32 aStart, PRUint32 aLength)
PRUint32 BreakAndMeasureText (PRUint32 aStart, PRUint32 aMaxLength, PRBool aLineBreakBefore, gfxFloat aWidth, PropertyProvider *aProvider, PRBool aSuppressInitialBreak, gfxFloat *aTrimWhitespace, Metrics *aMetrics, PRBool aTightBoundingBox, gfxContext *aRefContextForTightBoundingBox, PRBool *aUsedHyphenation, PRUint32 *aLastBreak)
PRBool CanBreakLineBefore (PRUint32 aPos)
void ClearFlagBits (PRUint32 aFlags)
virtual gfxTextRunClone (const gfxTextRunFactory::Parameters *aParams, const void *aText, PRUint32 aLength, gfxFontGroup *aFontGroup, PRUint32 aFlags)
virtual void CopyGlyphDataFrom (gfxTextRun *aSource, PRUint32 aStart, PRUint32 aLength, PRUint32 aDest, PRBool aStealData)
PRUint32 CountMissingGlyphs ()
void Draw (gfxContext *aContext, gfxPoint aPt, PRUint32 aStart, PRUint32 aLength, const gfxRect *aDirtyRect, PropertyProvider *aProvider, gfxFloat *aAdvanceWidth)
void DrawToPath (gfxContext *aContext, gfxPoint aPt, PRUint32 aStart, PRUint32 aLength, PropertyProvider *aBreakProvider, gfxFloat *aAdvanceWidth)
void FetchGlyphExtents (gfxContext *aRefContext)
PRUint32 FindFirstGlyphRunContaining (PRUint32 aOffset)
gfxFloat GetAdvanceWidth (PRUint32 aStart, PRUint32 aLength, PropertyProvider *aProvider)
PRUint32 GetAppUnitsPerDevUnit () const
const PRUnichar GetChar (PRUint32 i) const
const CompressedGlyphGetCharacterGlyphs ()
const DetailedGlyphGetDetailedGlyphs (PRUint32 aCharIndex)
gfxFloat GetDirection () const
nsExpirationStateGetExpirationState ()
PRUint32 GetFlags () const
gfxFontGroup * GetFontGroup () const
const GlyphRun * GetGlyphRuns (PRUint32 *aNumGlyphRuns)
PRUint32 GetHashCode () const
PRUint32 GetLength ()
const gfxSkipCharsGetSkipChars () const
const PRUint8 * GetText8Bit () const
const void * GetTextAt (PRUint32 aIndex)
const PRUnichar * GetTextUnicode () const
void * GetUserData () const
PRBool HasDetailedGlyphs ()
PRBool IsClusterStart (PRUint32 aPos)
PRBool IsLigatureGroupStart (PRUint32 aPos)
PRBool IsRightToLeft () const
Metrics MeasureText (PRUint32 aStart, PRUint32 aLength, PRBool aTightBoundingBox, gfxContext *aRefContextForTightBoundingBox, PropertyProvider *aProvider)
void operator delete (void *aPtr)
void RecordSurrogates (const PRUnichar *aString)
void ResetGlyphRuns ()
void SetContext (gfxContext *aContext)
void SetFlagBits (PRUint32 aFlags)
void SetGlyphs (PRUint32 aCharIndex, CompressedGlyph aGlyph, const DetailedGlyph *aGlyphs)
void SetHashCode (PRUint32 aHash)
virtual PRBool SetLineBreaks (PRUint32 aStart, PRUint32 aLength, PRBool aLineBreakBefore, PRBool aLineBreakAfter, gfxFloat *aAdvanceWidthDelta, gfxContext *aRefContext)
void SetMissingGlyph (PRUint32 aCharIndex, PRUint32 aUnicodeChar)
virtual PRBool SetPotentialLineBreaks (PRUint32 aStart, PRUint32 aLength, PRPackedBool *aBreakBefore, gfxContext *aRefContext)
void SetSimpleGlyph (PRUint32 aCharIndex, CompressedGlyph aGlyph)
void SetSpaceGlyph (gfxFont *aFont, gfxContext *aContext, PRUint32 aCharIndex)
void SetUserData (void *aUserData)
void SortGlyphRuns ()

Static Public Member Functions

static gfxTextRunCreate (const gfxTextRunFactory::Parameters *aParams, const void *aText, PRUint32 aLength, gfxFontGroup *aFontGroup, PRUint32 aFlags)

Protected Member Functions

 gfxTextRun (const gfxTextRunFactory::Parameters *aParams, const void *aText, PRUint32 aLength, gfxFontGroup *aFontGroup, PRUint32 aFlags, PRUint32 aObjectSize)
void * operator new (size_t aSize, PRUint32 aLength, PRUint32 aFlags)

Private Member Functions

void AccumulateMetricsForRun (gfxFont *aFont, PRUint32 aStart, PRUint32 aEnd, PRBool aTight, gfxContext *aRefContext, PropertyProvider *aProvider, PRUint32 aSpacingStart, PRUint32 aSpacingEnd, Metrics *aMetrics)
void AccumulatePartialLigatureMetrics (gfxFont *aFont, PRUint32 aStart, PRUint32 aEnd, PRBool aTight, gfxContext *aRefContext, PropertyProvider *aProvider, Metrics *aMetrics)
DetailedGlyphAllocateDetailedGlyphs (PRUint32 aCharIndex, PRUint32 aCount)
LigatureData ComputeLigatureData (PRUint32 aPartStart, PRUint32 aPartEnd, PropertyProvider *aProvider)
gfxFloat ComputePartialLigatureWidth (PRUint32 aPartStart, PRUint32 aPartEnd, PropertyProvider *aProvider)
void DrawGlyphs (gfxFont *aFont, gfxContext *aContext, PRBool aDrawToPath, gfxPoint *aPt, PRUint32 aStart, PRUint32 aEnd, PropertyProvider *aProvider, PRUint32 aSpacingStart, PRUint32 aSpacingEnd)
void DrawPartialLigature (gfxFont *aFont, gfxContext *aCtx, PRUint32 aStart, PRUint32 aEnd, const gfxRect *aDirtyRect, gfxPoint *aPt, PropertyProvider *aProvider)
PRBool GetAdjustedSpacingArray (PRUint32 aStart, PRUint32 aEnd, PropertyProvider *aProvider, PRUint32 aSpacingStart, PRUint32 aSpacingEnd, nsTArray< PropertyProvider::Spacing > *aSpacing)
gfxFloat GetPartialLigatureWidth (PRUint32 aStart, PRUint32 aEnd, PropertyProvider *aProvider)
void ShrinkToLigatureBoundaries (PRUint32 *aStart, PRUint32 *aEnd)

Private Attributes

PRUint32 mAppUnitsPerDevUnit
PRUint32 mCharacterCount
nsAutoArrayPtr< nsAutoArrayPtr
< DetailedGlyph > > 
nsExpirationState mExpirationState
PRUint32 mFlags
gfxFontGroup * mFontGroup
nsAutoTArray< GlyphRun, 1 > mGlyphRuns
PRUint32 mHashCode
gfxSkipChars mSkipChars
union {
   const PRUnichar *   mDouble
   const PRUint8 *   mSingle
void * mUserData


class FontSelector
class GlyphRunIterator


class  CompressedGlyph
struct  DetailedGlyph
struct  GlyphRun
class  GlyphRunIterator
class  GlyphRunOffsetComparator
struct  LigatureData
class  PropertyProvider

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

Generated by  Doxygen 1.6.0   Back to index