1,295
edits
| Line 5: | Line 5: | ||
<pre> | <pre> | ||
/** | /** | ||
* A class representing a single span of | * A class representing a single span of text with a uniform style. | ||
* It | * It treats the text is laid out along a straight horizontal line | ||
* with the glyphs oriented normally with respect to the baseline. Of course, | |||
* the text can be rotated or otherwise transformed by imposing a | |||
* transformation in the drawing context before drawing. | |||
* | |||
* When determining glyph geometry, the text should be hinted | |||
* assuming it will be drawn with the current transformation in the | |||
* referenceContext used to construct the gfxTextRun. The caller guarantees not | |||
* to change the state of referenceContext during the lifetime of the | |||
* gfxTextRun object. | |||
* The actual transformation or even context used in Draw() or AddToPath() | |||
* may be different. | |||
*/ | */ | ||
class gfxTextRun { | class gfxTextRun { | ||
// these do not copy the text. it is the caller's responsibility to keep | // these do not copy the text. it is the caller's responsibility to keep | ||
// the text alive during the lifetime of the text run. | // the text alive during the lifetime of the text run. | ||
gfxTextRun(const char* ASCII, int length, nsFontMetrics* font, PRBool RTL, nsIAtom* language); | gfxTextRun(const char* ASCII, int length, nsFontMetrics* font, PRBool RTL, nsIAtom* language, gfxContext* referenceContext); | ||
gfxTextRun(const PRUnichar* unicode, int length, nsFontMetrics* font, PRBool RTL, nsIAtom* language); | gfxTextRun(const PRUnichar* unicode, int length, nsFontMetrics* font, PRBool RTL, nsIAtom* language, gfxContext* referenceContext); | ||
enum { ClusterStart = 0x1 } CharFlags; | enum { ClusterStart = 0x1 } CharFlags; | ||
| Line 45: | Line 55: | ||
// the baseline of the visually left edge of the visually leftmost cluster. | // the baseline of the visually left edge of the visually leftmost cluster. | ||
void Draw(gfxContext* ctx, gfxPoint& pt, int pos, int len); | void Draw(gfxContext* ctx, gfxPoint& pt, int pos, int len); | ||
// The substring must not contain any partial clusters. 'pt' is the | |||
// the baseline of the visually left edge of the visually leftmost cluster. | |||
// The outlines of the characters are added to the current path. | |||
void AddToPath(gfxContext* ctx, gfxPoint& pt, int pos, int len); | |||
struct Dimensions { | struct Dimensions { | ||
// | // advance of substring start from the origin of the whole string, | ||
// always positive regardless of RTL | |||
gfxFloat xOffset; | gfxFloat xOffset; | ||
// | // advance of the substring, always positive regardless of RTL | ||
gfxFloat | gfxFloat advance; | ||
// font ascent and descent for this substring | // font ascent and descent for this substring, both always positive | ||
gfxFloat ascent, descent; | gfxFloat ascent, descent; | ||
// the bounding box of area actually rendered by the glyphs in the | // the bounding box of area actually rendered by the glyphs in the | ||
edits