Mozilla2:GFXTextRun

Revision as of 04:59, 17 March 2005 by Roc (talk | contribs)

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