Mozilla2:GFXTextRun

From MozillaWiki
Revision as of 04:56, 17 March 2005 by Roc (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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);
};