Mozilla2:GFXTextRun: Difference between revisions
Jump to navigation
Jump to search
| Line 12: | Line 12: | ||
// ClusterStart: character is the first character of a cluster | // ClusterStart: character is the first character of a cluster | ||
void GetCharacterFlags(int pos, int len, CharFlags* flags); | void GetCharacterFlags(int pos, int len, CharFlags* flags); | ||
void SetWordStartEnd(PRBool startsWord, PRBool endsWord); | |||
void SetLineStartEnd(PRBool startsLine, PRBool endsLine); | |||
// Set the spacing between clusters. For each character index i that is | |||
// the start of a cluster, spacingArray[i] is the amount of space to insert | |||
// before that cluster (possibly negative). For each character index i that | |||
// is not the start of a cluster, spacingArray[i] must be zero. | |||
// spacingArray[0] must be zero. | |||
void SetSpacing(gfxFloat* spacingArray); | |||
// The substring must not contain any partial clusters. 'pt' is the | |||
// the baseline of the visually left edge of the visually leftmost cluster. | |||
void Draw(gfxContext* ctx, gfxPoint& pt, int pos, int len); | |||
struct Dimensions { | struct Dimensions { | ||
gfxFloat ascent, descent, | // start of the substring relative to the origin of the whole string | ||
gfxFloat xOffset; | |||
// width of the substring; | |||
gfxFloat width; | |||
// amount by which the glyphs visually extend to the left of xOffset and | |||
// to the right of xOffset+width | |||
gfxFloat leftBearing, rightBearing; | |||
// font ascent and descent for this substring | |||
gfxFloat ascent, descent; | |||
// visual ascent and descent for this substring (area actually drawn by | |||
// glyphs --- needed for MathML I think) | |||
gfxFloat visualAscent, visualDescent; | |||
}; | }; | ||
// The substring must not contain any partial clusters | |||
Dimensions MeasureText(int pos, int len); | Dimensions MeasureText(int pos, int len); | ||
| Line 24: | Line 50: | ||
// We will usually want to call MeasureText right afterwards, | // We will usually want to call MeasureText right afterwards, | ||
// the implementor could optimize for that. | // the implementor could optimize for that. | ||
// The substring must not contain any partial clusters | |||
int GetCharsFit(int pos, int len, gfxFloat width, int breakflags); | int GetCharsFit(int pos, int len, gfxFloat width, int breakflags); | ||
// If the user clicks the mouse at point pt, | |||
int GetPositionInString(gfxPoint& pt); | int GetPositionInString(gfxPoint& pt); | ||
}; | }; | ||
Revision as of 00:12, 12 October 2005
Class gfxTextRun
class gfxTextRun {
// these do not copy the text
gfxTextRun(const char* ASCII, int length, nsIFontMetrics* font, nsIAtom* language);
gfxTextRun(const PRUnichar* unicode, int length, nsIFontMetrics* font, nsIAtom* language);
enum { ClusterStart = 0x1 } CharFlags;
// ClusterStart: character is the first character of a cluster
void GetCharacterFlags(int pos, int len, CharFlags* flags);
void SetWordStartEnd(PRBool startsWord, PRBool endsWord);
void SetLineStartEnd(PRBool startsLine, PRBool endsLine);
// Set the spacing between clusters. For each character index i that is
// the start of a cluster, spacingArray[i] is the amount of space to insert
// before that cluster (possibly negative). For each character index i that
// is not the start of a cluster, spacingArray[i] must be zero.
// spacingArray[0] must be zero.
void SetSpacing(gfxFloat* spacingArray);
// The substring must not contain any partial clusters. 'pt' is the
// the baseline of the visually left edge of the visually leftmost cluster.
void Draw(gfxContext* ctx, gfxPoint& pt, int pos, int len);
struct Dimensions {
// start of the substring relative to the origin of the whole string
gfxFloat xOffset;
// width of the substring;
gfxFloat width;
// amount by which the glyphs visually extend to the left of xOffset and
// to the right of xOffset+width
gfxFloat leftBearing, rightBearing;
// font ascent and descent for this substring
gfxFloat ascent, descent;
// visual ascent and descent for this substring (area actually drawn by
// glyphs --- needed for MathML I think)
gfxFloat visualAscent, visualDescent;
};
// The substring must not contain any partial clusters
Dimensions MeasureText(int pos, int len);
// Compute how many characters from this string starting at
// character 'pos' and up to length 'len' fit
// into the given width. 'breakflags' indicates our
// preferences about where we allow breaks.
// We will usually want to call MeasureText right afterwards,
// the implementor could optimize for that.
// The substring must not contain any partial clusters
int GetCharsFit(int pos, int len, gfxFloat width, int breakflags);
// If the user clicks the mouse at point pt,
int GetPositionInString(gfxPoint& pt);
};