Text¶
A Text object contains text.
- new Text()¶
Constructor method.
Create a new empty text object.
- Returns:
Text.
EXAMPLE
var text = new mupdf.Text();
Instance methods
- showGlyph(font, transform, glyph, unicode, wmode)¶
Add a glyph to the text object.
Transform is the text matrix, specifying font size and glyph location. For example:
[size,0,0,-size,x,y].Glyph and unicode may be
-1for n-to-m cluster mappings. For example, the “fi” ligature would be added in two steps: first the glyph for the ‘fi’ ligature and the unicode value for ‘f’; then glyph-1and the unicode value for ‘i’.- Arguments:
font –
Fontobject.transform –
[a,b,c,d,e,f]. The transform matrix.glyph –
Integer.unicode –
Integer.wmode –
0for horizontal writing, and1for vertical writing.
EXAMPLE
text.showGlyph(new mupdf.Font("Times-Roman"), mupdf.Matrix.identity, 21, 0x66, 0); text.showGlyph(new mupdf.Font("Times-Roman"), mupdf.Matrix.identity, -1, 0x69, 0);
- showString(font, transform, string)¶
Add a simple string to the
Textobject. Will do font substitution if the font does not have all the unicode characters required.- Arguments:
font –
Fontobject.transform –
[a,b,c,d,e,f]. The transform matrix.string – String content for
Textobject.
EXAMPLE
text.showString(new mupdf.Font("Times-Roman"), mupdf.Matrix.identity, "Hello");
- walk(textWalker)¶
Call the
showGlyphmethod on thetextWalkerobject for each glyph in the text object.- Arguments:
textWalker – The text walker object. A user definable JavaScript object which can be used to trigger your own functions on the text methods.
EXAMPLE
text.walk({ beginSpan: function (font, transform, wmode, bidilevel, markupdirection, language) { // ... do whatever ... }, showGlyph: function (font, transform, glyph, unicode, wmode, bidilevel) { // ... do whatever ... }, endSpan: function () { // ... do whatever ... }, });