Mozilla2:GFXTextRun: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 7: | Line 7: | ||
void SetFont(nsFont* font, nsIAtom* language); | void SetFont(nsFont* font, nsIAtom* language); | ||
enum { ClusterStart = 0x1 } CharFlags; | enum { ClusterStart = 0x1 } CharFlags; | ||
// ClusterStart: character is the first character of a cluster/glyph | // ClusterStart: character is the first character of a cluster/glyph | ||
void GetCharacterFlags(int pos, int len, CharFlags* flags); | void GetCharacterFlags(int pos, int len, CharFlags* flags); | ||
struct Dimensions { | struct Dimensions { | ||
double ascent, descent, width, leftBearing, rightBearing; | double ascent, descent, width, leftBearing, rightBearing; | ||
}; | }; | ||
Dimensions MeasureText(int pos, int len); | Dimensions MeasureText(int pos, int len); | ||
// Compute how many characters from this string starting at | // Compute how many characters from this string starting at | ||
// character 'pos' and up to length 'len' fit | // character 'pos' and up to length 'len' fit | ||
| Line 24: | Line 24: | ||
// the implementor could optimize for that. | // the implementor could optimize for that. | ||
int GetCharsFit(int pos, int len, double width, int breakflags); | int GetCharsFit(int pos, int len, double width, int breakflags); | ||
int GetPositionInString(Point pt); | int GetPositionInString(Point pt); | ||
}; | }; | ||
For Graphics we can have something like this | |||
// Assumes that the whole TextRun is to be drawn at the current | |||
// position, and renders a substring of it. | |||
DrawString(TextRun text, int pos, int len); | |||
Revision as of 04:59, 17 March 2005
For text we can have something like this.
class TextRun {
// these do not copy the text
TextRun(const char* ASCII, int length);
TextRun(const PRUnichar* unicode, int length);
void SetFont(nsFont* font, nsIAtom* language);
enum { ClusterStart = 0x1 } CharFlags;
// ClusterStart: character is the first character of a cluster/glyph
void GetCharacterFlags(int pos, int len, CharFlags* flags);
struct Dimensions {
double ascent, descent, width, leftBearing, rightBearing;
};
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.
int GetCharsFit(int pos, int len, double width, int breakflags);
int GetPositionInString(Point pt);
};
For Graphics we can have something like this
// Assumes that the whole TextRun is to be drawn at the current // position, and renders a substring of it. DrawString(TextRun text, int pos, int len);