Class TextGlyphRun
- java.lang.Object
-
- com.adobe.xfa.text.TextGlyphRun
-
public class TextGlyphRun extends java.lang.Object
The run is the basic building block of text layout.A run is sequence of glyphs that share common attributes and don't require any special inter-glyph positioning. A run can be either horizontal or vertical. Horizontal runs are used for Latin, Middle-Eastern and certain Asian scripts. The implicit rendering order of a horizontal run is always left-to-right (LTR), even it contains glyphs based on right-to-left (RTL) characters. Vertical runs are used for CJK text in vertical format.
-
-
Constructor Summary
Constructors Constructor Description TextGlyphRun()
Default constructor.TextGlyphRun(TextGlyphRun oSource)
Copy constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCharGlyphs(java.lang.String sCharGlyphs)
void
addGlyph(int nAdd)
Add a single glyph to the run.void
copyFrom(TextGlyphRun oSource)
Assignment operator.TextAttr
getAttr()
Return the text attributes that apply to this run.int
getGlyph(int nIndex)
Extract one glyph from the run, by index.int
getGlyphCount()
Return the number of glyphs currently in the run.int
getGlyphOrientation()
Query the glyph orientation for this run.CoordPair
getPosition()
Obtain the runs position.CoordPair
getShift()
Obtain the run's shift.boolean
isCharRun()
Query whether this run represents Unicode characters or glyph IDs.boolean
isRTL()
Query whether this run represents RTL glyphs.boolean
isShifted()
Convenience method to query whether the run has any shift.void
setAttr(TextAttr oAttr)
/** Set the attributes to be used for this run.void
setAttrRef(TextAttr poAttr)
Set the attributes to be used for this run, via a reference-counted attribute object.void
setCharRun(boolean bCharRun)
Tells the glyph run whether its 32-bit values represent Unicode characters or glyph IDs.void
setGlyphOrientation(int eGlyphOrientation)
Set the glyph orientation for this run.void
setRTL(boolean bRTL)
Tells the glyph run whether it represents right-to-left (RTL) glyphs.void
setShift(CoordPair oShift)
Specify a shift for the run.
-
-
-
Constructor Detail
-
TextGlyphRun
public TextGlyphRun()
Default constructor.The run is initially empty of glyphs and has a null attribute pointer. Its position and shift are both set to (0,0).
-
TextGlyphRun
public TextGlyphRun(TextGlyphRun oSource)
Copy constructor.Create a new glyph run, copying the contents of the given source run. Note that copying the run's attributes means adding a reference to the shared attribute object.
- Parameters:
oSource
- - Source run object to copy.
-
-
Method Detail
-
setAttr
public void setAttr(TextAttr oAttr)
/** Set the attributes to be used for this run.All text attributes can be specified through a single TextAttr object. This object represents a possibly sparse collection of attributes. Please see the description of the TextAttr class for more information.
- Parameters:
oAttr
- - Attribute set to use for this run. Any omitted attributes will be inherited from the previous run. If attributes are missing on the first run, TextAttr defaults will be used. The run will cache a copy of the attribute object; the caller can delete or modify the original after the method returns.
-
setAttrRef
public void setAttrRef(TextAttr poAttr)
Set the attributes to be used for this run, via a reference-counted attribute object.Please see method SetAttr() for more information on attributes.
- Parameters:
poAttr
- - Attribute set to use for this run. Unlike method SetAttr(), this method does not make a copy. Instead, the given attribute object is assumed to be reference counted. After the call, the run will have added its own reference to the object. This allows the caller to create a common attribute instance to be shared by several runs.
-
getAttr
public TextAttr getAttr()
Return the text attributes that apply to this run.- Returns:
- Text attributes for the run; null if attributes have never been set. Note that the return value uses the text attribute reference counting model. If the client chooses to hang on to the return pointer, it must add a reference.
-
setShift
public void setShift(CoordPair oShift)
Specify a shift for the run.A shift occurs if the run doesnt start at the end point of the previous run. This could be the result of either a baseline shift, a horizontal shift such as kerning adjustment, or both. There is no need to set the shift for the first run of a line if that run starts at the left endpoint of the line's baseline.
A horizontal shift implicitly cascades through subsequent runs. In other words, if a run is shifted left due to kerning, the next run would normally start at the end point of the shifted run. There would be no need to explicitly declare a shift on subsequent runs. Indeed, if the next run did declare a shift, the shift would compound.
On the other hand, vertical shifts must be re-asserted on each run. If a run is shifted away from its baseline, the next run will revert to the baseline if it doesn't declare its own vertical shift.
- Parameters:
oShift
- - Shift to apply to this run.
-
getShift
public CoordPair getShift()
Obtain the run's shift.- Returns:
- Shift that applies to this run.
-
isShifted
public boolean isShifted()
Convenience method to query whether the run has any shift.- Returns:
- True if the run has an X and/or Y shift; false if no shift.
-
getPosition
public CoordPair getPosition()
Obtain the runs position.This call makes sense only after formatting. It returns the position--relative to the left endpoint of the lines baseline--of the run.
- Returns:
- Run's position.
-
addGlyph
public void addGlyph(int nAdd)
Add a single glyph to the run.- Parameters:
nAdd
- - Glyph ID to add to the run.
-
addCharGlyphs
public void addCharGlyphs(java.lang.String sCharGlyphs)
-
getGlyphCount
public int getGlyphCount()
Return the number of glyphs currently in the run.- Returns:
- Number of glyphs currently in the run.
-
getGlyph
public int getGlyph(int nIndex)
Extract one glyph from the run, by index.- Parameters:
nIndex
- - Index of the desired glyph. Index numbers start at zero. Unpredictable results will occur if the index is out of range.- Returns:
- Glyph ID at the specified index.
-
setCharRun
public void setCharRun(boolean bCharRun)
Tells the glyph run whether its 32-bit values represent Unicode characters or glyph IDs.- Parameters:
bCharRun
- - True if this run represents Unicode characters; false if it represents glyph IDs. If the client never sets this flag, it defaults to false.
-
isCharRun
public boolean isCharRun()
Query whether this run represents Unicode characters or glyph IDs.- Returns:
- True if the run represents Unicode characters; false if it represents glyph IDs.
-
setRTL
public void setRTL(boolean bRTL)
Tells the glyph run whether it represents right-to-left (RTL) glyphs.AXTE needs to know glyph direction when resolving ambiguous caret positions in bidirectional text. Unfortunately it cannot glean such direction from the mappings alone; the application must provide glyph direction independently of the mappings.
- Parameters:
bRTL
- - True if this run represents RTL glyphs; false if it represents left-to-right (LTR) glyphs. If the client never sets this flag, it defaults to false.
-
isRTL
public boolean isRTL()
Query whether this run represents RTL glyphs.- Returns:
- True if the run represents RTL glyphs; false if it represents LTR glyphs.
-
setGlyphOrientation
public void setGlyphOrientation(int eGlyphOrientation)
Set the glyph orientation for this run.- Parameters:
eGlyphOrientation
- - New glyph orientation to use.
-
getGlyphOrientation
public int getGlyphOrientation()
Query the glyph orientation for this run.- Returns:
- Glyph orientation currently in effect.
-
copyFrom
public void copyFrom(TextGlyphRun oSource)
Assignment operator.Copies all contents of the given source run. Note that copying the run's attributes means adding a reference to the shared attribute object.
- Parameters:
oSource
- - Source run object to copy.
-
-