Mozilla2:GFXTextRun: Difference between revisions

Jump to navigation Jump to search
Line 4: Line 4:


<pre>
<pre>
/**
* A class representing a single span of styled text.
* It assumes that the text is laid out along a straight line with the glyphs
* oriented normally with respect to the baseline.
*
*/
class gfxTextRun {
class gfxTextRun {
   // these do not copy the text
   // these do not copy the text
Line 13: Line 19:
   void GetCharacterFlags(int pos, int len, CharFlags* flags);
   void GetCharacterFlags(int pos, int len, CharFlags* flags);


  // Set whether or not this text run starts/ends a word
   void SetWordStartEnd(PRBool startsWord, PRBool endsWord);
   void SetWordStartEnd(PRBool startsWord, PRBool endsWord);
  // Set whether or not this text run starts/ends a line
   void SetLineStartEnd(PRBool startsLine, PRBool endsLine);
   void SetLineStartEnd(PRBool startsLine, PRBool endsLine);


Line 32: Line 40:
     // width of the substring;
     // width of the substring;
     gfxFloat width;
     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
     // font ascent and descent for this substring
     gfxFloat ascent, descent;
     gfxFloat ascent, descent;
     // visual ascent and descent for this substring (area actually drawn by
     // the bounding box of area actually rendered by the glyphs in the
     // glyphs --- needed for MathML I think)
     // substring, relative to the origin of the whole string; if this can't
     gfxFloat visualAscent, visualDescent;
     // be accurately determined, then at least this must contain the true
    // bounding box
    gfxRect boundingBox;
   };
   };
   // The substring must not contain any partial clusters
   // The substring must not contain any partial clusters
Line 46: Line 53:
   // 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
   // into the given width. 'breakflags' indicates our
   // into the given width. A break is allowed before character i
   // preferences about where we allow breaks.
   // wherever breaks[i] is nonzero, i.e., if the result of GetCharsFit
  // is i then breaks[i] is nonzero.
   // 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
   // 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, PRUint8* breaks);


   // If the user clicks the mouse at point pt,  
   // Return the index of the character selected if the user clicks the
   int GetPositionInString(gfxPoint& pt);
  // mouse at point pt. If the point is exactly between two characters,
  // if preferLeft is true then return the character visually to the left
  // (as if pt.x had been smaller) if there is one, otherwise return the
  // character visually to the right. If the point is before the start of
  // the string, return -1. If the point is beyond the end of the string,
  // return the full string length.
   int GetPositionInString(gfxPoint& pt, PRBool preferLeft);
};
};
</pre>
</pre>


See [[Gecko2:NewTextAPI]]
See [[Gecko2:NewTextAPI]]
1,295

edits

Navigation menu