Class RenderableText

  • All Implemented Interfaces:
    Cloneable, SplittableRenderNode

    public final class RenderableText
    extends RenderNode
    implements SplittableRenderNode
    The renderable text is a text chunk, enriched with layouting information, such as break opportunities, character sizes, kerning information and spacing information.

    Text is given as codepoints. Break opportunities are given as integer values, where zero forbids breaking, and higher values denote better breaks. Spacing and glyph sizes and kerning is given in micro-points; Spacing is the 'added' space between codepoints if text-justification is enabled.

    The text is computed as grapheme clusters; this means that several unicode codepoints may result in a single /virtual/ glyph/codepoint/character. (Example: 'A' + accent symbols). If the font supports Lithurges, these lithurges may also be represented as a single grapheme cluster (and thus behave unbreakable).

    Grapheme clusters with more than one unicode char have the size of that char added to the first codepoint, all subsequence codepoints of the same cluster have a size/kerning/etc of zero and are unbreakable.

    This text chunk is perfectly suitable for horizontal text, going either from left-to-right or right-to-left. (Breaking mixed text is up to the textfactory).

    Thomas Morgner
    • Method Detail

      • initialize

        protected void initialize​(GlyphList glyphs,
                                  int offset,
                                  int length,
                                  ExtendedBaselineInfo baselineInfo,
                                  int script,
                                  boolean forceLinebreak)
      • isNormalTextSpacing

        public boolean isNormalTextSpacing()
      • isForceLinebreak

        public boolean isForceLinebreak()
      • getOffset

        public int getOffset()
      • getLength

        public int getLength()
      • getRawText

        public String getRawText()
      • getBaselineInfo

        public ExtendedBaselineInfo getBaselineInfo()
        Returns the baseline info for the given node. This can be null, if the node does not have any baseline info.
      • getScript

        public int getScript()
      • getMinimumWidth

        public long getMinimumWidth()
        Description copied from interface: SplittableRenderNode
        Returns the component's minimum width.

        A layout processor can be implemented so, that it does not compute its children's positions on the spot, postponing this action until the end. However, if it finds out the component should be broken, it stops the routine. And this is the case when this method is useful, as it helps not to change the implementation of the processor. Normally each layout component knows about its bounds, hence it will not takes much effort to implement the method.

        Specified by:
        getMinimumWidth in interface SplittableRenderNode
        the minimum width of the component
      • getPreferredWidth

        public long getPreferredWidth()
      • convert

        public static long convert​(long fontMetricsValue)
      • computeMaximumTextSize

        public int computeMaximumTextSize​(long contentX2)
      • splitBy

        public RenderableText[] splitBy​(long widthOfFirst)
        Splits the component into two children. The width of first cannot exceed widthOfFirst. If the separation is impossible null is returned.

        Note, there is no guarantee that the first kid has width equal to widthOfFirst.

        Important! The separation is allowed only if .TextStyleKeys#WORDBREAK TextStyleKeys.WORDBREAK property is true

        Specified by:
        splitBy in interface SplittableRenderNode
        widthOfFirst - the maximum width of the first component
        a pair of children or null
        IllegalArgumentException - if widthOfFirst <= 0
        IllegalStateException - if widthOfFirst >= getMinimumWidth()