Class PDFStyle

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class PDFStyle
    extends java.lang.Object
    implements java.lang.Cloneable

    A PDFStyle controls the colors, font and many other aspects of the actual display of elements on a PDF page. It's conceptually similar to a CSS style used with HTML markup.

    The idea behind the PDFStyle class is that you create a style and then apply it to the PDFPage. This means you can switch from one style to another with a single command, and switch back just as easily. It makes defining a consistant "feel" to your document much easier than it would if you had to set the font and color separately.

    Example
       import java.awt.Color;
    
       // Create a new style "normal": 12pt black Times-Roman, with
       // line-spacing of 1.5
       PDFStyle normal = new PDFStyle();
       normal.setFont(new StandardFont(StandardFont.TIMES), 12);
       normal.setFillColor(Color.black);
       normal.setTextLineSpacing(1.5);
    
       // Create a new varient of "normal": 12pt red Times-Italic with
       // the same line-spacing
       PDFStyle italic = new PDFStyle(normal);
       italic.setFont(new StandardFont(StandardFont.TIMESITALIC), 12);
       italic.setFillColor(Color.red);
    
       // Create a style to draw a box around the text in green, with a
       // line width of 2 points
       PDFStyle boxstyle = new PDFStyle();
       boxstyle.setLineColor(Color.green);
       boxstyle.setLineWeighting(2);
    
       // Now use these styles in a document
       PDF p = new PDF();
       PDFPage page = p.newPage(PDF.PAGESIZE_A4);
       page.setStyle(normal);
       page.drawText("This is in 12pt black Times Roman", 100, 100);
       page.setStyle(italic);
       page.drawText("This is in 12pt red Times Italic", 100, 120);
    
       // Draw a box around them in green
       page.setStyle(boxstyle);
       page.drawRectangle(90,90, 200, 40);
     

    This shows several useful aspects of styles:

    • Styles can easily be extended by using the PDFStyle(PDFStyle) constructor
    • Not all the aspects of a style need to be set
    • Styles can be given meaningful names
    Since:
    1.0
    • Field Detail

      • TEXTALIGN_LEFT

        public static final int TEXTALIGN_LEFT
        Set the text alignment for this style to left-aligned
        See Also:
        Constant Field Values
      • TEXTALIGN_RIGHT

        public static final int TEXTALIGN_RIGHT
        Set the text alignment for this style to right-aligned
        See Also:
        Constant Field Values
      • TEXTALIGN_CENTER

        public static final int TEXTALIGN_CENTER
        Set the text alignment for this style to centered
        See Also:
        Constant Field Values
      • TEXTALIGN_JUSTIFY

        public static final int TEXTALIGN_JUSTIFY
        Set the text alignment for this style to justified (the default). Justification is only useful when text is written within a paragraph. When a single element of text is drawn, the effect is the same as left-alignment.
        See Also:
        Constant Field Values
      • TEXTALIGN_JUSTIFY_ALL

        public static final int TEXTALIGN_JUSTIFY_ALL
        Similar to TEXTALIGN_JUSTIFY, but will also justify the last line of a paragraph.
        Since:
        2.2.1
        See Also:
        Constant Field Values
      • TEXTALIGN_BASELINE

        public static final int TEXTALIGN_BASELINE
        Set the vertical text alignment for this style to baseline (the default).
        See Also:
        Constant Field Values
      • TEXTALIGN_TOP

        public static final int TEXTALIGN_TOP
        Set the vertical text alignment for this style to top
        See Also:
        Constant Field Values
      • TEXTALIGN_MIDDLE

        public static final int TEXTALIGN_MIDDLE
        Set the vertical text alignment for this style to middle
        See Also:
        Constant Field Values
      • TEXTALIGN_BOTTOM

        public static final int TEXTALIGN_BOTTOM
        Set the vertical text alignment for this style to bottom
        See Also:
        Constant Field Values
      • LINECAP_BUTT

        public static final int LINECAP_BUTT
        Set the end of a line to be squared off at the end. There is no projection beyond the end of the path. This is the default
        See Also:
        Constant Field Values
      • LINECAP_ROUND

        public static final int LINECAP_ROUND
        Set the end of a line to be rounded at the end. Effectively draws a circle with a diameter of the line width at the end of each line.
        See Also:
        Constant Field Values
      • LINECAP_SQUARE

        public static final int LINECAP_SQUARE
        Set the end of a line to be squared at the end. Effectively extends each line by half the linewidth.
        See Also:
        Constant Field Values
      • LINEJOIN_MITER

        public static final int LINEJOIN_MITER
        Sets the join style of two lines so that the lines are extended so they meet at a point (like a picture frame). For extremely sharp angles, this will automatically be converted to a LINEJOIN_BEVEL. This is the default.
        See Also:
        Constant Field Values
      • LINEJOIN_ROUND

        public static final int LINEJOIN_ROUND
        Sets the join style of two lines so that the lines are rounded, equivalent to drawing a circle with a diameter of the linewidth where the lines meet.
        See Also:
        Constant Field Values
      • LINEJOIN_BEVEL

        public static final int LINEJOIN_BEVEL
        Sets the join style of two lines so that the lines are beveled. The two lines are drawn with LINECAP_BUTT ends, and the notch between the two segments is filled in with a triangle.
        See Also:
        Constant Field Values
      • FONTSTYLE_FILLED

        public static final int FONTSTYLE_FILLED
        Set any text rendered in this style to be filled with the styles FillColor (the default)
        See Also:
        Constant Field Values
      • FONTSTYLE_OUTLINE

        public static final int FONTSTYLE_OUTLINE
        Set any text rendered in this style to be drawn as a hollow outline with the styles LineColor (the default)
        See Also:
        Constant Field Values
      • FONTSTYLE_FILLEDOUTLINE

        public static final int FONTSTYLE_FILLEDOUTLINE
        Set any text rendered in this style to be filled with the styles FillColor, then to be outlined with the styles' LineColor
        See Also:
        Constant Field Values
      • FONTSTYLE_INVISIBLE

        public static final int FONTSTYLE_INVISIBLE
        Set any text rendered in this style to be invisible. This becomes useful in applications like OCR, where the original scanned image is displayed on the screen and invisible text written above it, allowing the text to be cut and pasted.
        See Also:
        Constant Field Values
      • PAINTMETHOD_NONZEROWINDING

        public static final int PAINTMETHOD_NONZEROWINDING
        A parameter to setPaintMethod(int) to set the paint method to use the non-zero winding number method to determine which areas are inside or outside a shape. This is the default.
        See Also:
        Constant Field Values
      • PAINTMETHOD_EVENODD

        public static final int PAINTMETHOD_EVENODD
        A parameter to setPaintMethod(int) to set the paint method to use the even-odd method to determine which areas are inside or outside a shape.
        See Also:
        Constant Field Values
      • FORMSTYLE_INSET

        public static final int FORMSTYLE_INSET
        Style for setFormStyle(int) which draws an border around the field so that it looks inset into the page.
        See Also:
        Constant Field Values
      • BREAK_LEGACY

        public static final int BREAK_LEGACY
        A value for setLineBreakBehaviour(int) that will use the line-breaking rules that applied in the PDF Library before release 2.22.1. These rules were as defined in UAX#13 version 12.
      • BREAK_UAX14

        public static final int BREAK_UAX14
        A value for setLineBreakBehaviour(int) that will use the line-breaking rules exactly as described in UAX14
        Since:
        2.22.1
      • BREAK_LINE_NORMAL

        public static final int BREAK_LINE_NORMAL
        A value for setLineBreakBehaviour(int) that will use the line-breaking rules as described for "line-break:normal" in css-text-3. This value can be combined with a BREAK_WORD_n value using a logical-or
        Since:
        2.22.1
      • BREAK_LINE_LOOSE

        public static final int BREAK_LINE_LOOSE
        A value for setLineBreakBehaviour(int) that will use the line-breaking rules as described for "line-break:loose" in css-text-3. This value can be combined with a BREAK_WORD_n value using a logical-or
        Since:
        2.22.1
      • BREAK_LINE_STRICT

        public static final int BREAK_LINE_STRICT
        A value for setLineBreakBehaviour(int) that will use the line-breaking rules as described for "line-break:strict" in css-text-3. This value can be combined with a BREAK_WORD_n value using a logical-or
        Since:
        2.22.1
      • BREAK_LINE_ANYWHERE

        public static final int BREAK_LINE_ANYWHERE
        A value for setLineBreakBehaviour(int) that will use the line-breaking rules as described for "line-break:anywhere" in css-text-3. It will allow a breakpoint between any two glyphs.
        Since:
        2.22.1
      • BREAK_WORD_BREAKALL

        public static final int BREAK_WORD_BREAKALL
        A value for setLineBreakBehaviour(int) that will use the line-breaking rules as described for "word-break:break-all" in css-text-3. This value can be combined with a BREAK_LINE_n value using a logical-or
        Since:
        2.22.1
      • BREAK_WORD_KEEPALL

        public static final int BREAK_WORD_KEEPALL
        A value for setLineBreakBehaviour(int) that will use the line-breaking rules as described for "word-break:keep-all" in css-text-3. This value can be combined with a BREAK_LINE_n value using a logical-or
        Since:
        2.22.1
      • BREAK_WORD_NORMAL

        public static final int BREAK_WORD_NORMAL
        A value for setLineBreakBehaviour(int) that will use the line-breaking rules as described for "word-break:normal" in css-text-3. This value can be combined with a BREAK_LINE_n value using a logical-or
        Since:
        2.22.1
    • Constructor Detail

      • PDFStyle

        public PDFStyle()
        Create a new PDFStyle using the default settings. No fill color, line color or font is specified
      • PDFStyle

        public PDFStyle​(PDFStyle style)
        Create a new style which is a clone of the specified style
        Since:
        2.0
    • Method Detail

      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • setFillColor

        public void setFillColor​(java.awt.Paint paint)

        Set the fill color. For text, this is the color of the text. For geometric shapes, this is paint to fill those shapes with. To draw only outlines, set it to null (the default).

        Prior to release 1.2, this method took a Color as an argument, but this has been changed to its superclass Paint instead. Although most of the time the parameter will still be a plain color, this change allows a GradientPaint to be used as well.

        Parameters:
        paint - the paint to use, or null if no fill is required.
        Since:
        1.0
      • setLineColor

        public void setLineColor​(java.awt.Paint paint)
        Set the line color. For text, this is the color of the outline of the text. For geometric shapes, this is color to draw the outlines of those shapes. If no outline is required, set it to null (the default).
        Parameters:
        paint - the Color to use, or null if no outline is required.
        Since:
        1.0
      • setLineWeighting

        public void setLineWeighting​(float weight)
        Set the line weighting, for fonts and geometric shapes drawn as outlines. The minimum possible value is zero, which indicates to the PDF renderer to use the thinest line possible. On high-resolution devices this will become nearly invisible, and because of its device-dependent nature a value of 0 is not recommended.

        Changes to this setting midway through a path don't take effect until the path is closed.

        Parameters:
        weight - the thickness of the line in points, or 0 for "as thin as possible"
        Since:
        1.0
      • setLineDash

        public void setLineDash​(float on,
                                float off,
                                float phase)

        Set the line dashing pattern. Since 2.7.8 this method simply calls setLineDash(new float[] { on, off }, phase).

        Parameters:
        on - how many points of the line to draw
        off - how many points of the line to skip
        phase - how far into the pattern to start
        Since:
        1.0
      • setLineDash

        public void setLineDash​(float[] pattern,
                                float phase)

        Set the line dashing pattern. The pattern parameter is an array of 1 or more float values that are > 0, which define the length in points of the alternating "on" and "off" segments of any lines drawn with this style. The phase paramter determines how far into this pattern to start.

        To draw solid lines, the first parameter should be null.

        Changes to this setting midway through a path don't take effect until the path is closed.

        Parameters:
        pattern - the pattern of alternating on/off segments, or null to draw solid lines
        phase - how far into the pattern to start
        Since:
        2.7.8
      • setFontFeature

        public void setFontFeature​(java.lang.String feature,
                                   boolean on)
        Set the specified font feature. This method takes the same parameters as the PDFFont.setFeature(String,boolean) method, but the features will be only be applied to the font for text created with this style.
        Since:
        2.14.1
      • setFontFeature

        public void setFontFeature​(java.lang.String feature,
                                   int value)
        Set the specified font feature. This method takes the same parameters as the PDFFont.setFeature(String,int) method, but the features will be only be applied to the font for text created with this style.
        Since:
        2.22
      • getOpenTypeFontPalette

        public OpenTypeFont.Palette getOpenTypeFontPalette()
        Get the OpenTypeFont.Palette previously specified with #setOpenTypeFontPalette
        Since:
        2.24.1
      • setOpenTypeFontPalette

        public void setOpenTypeFontPalette​(OpenTypeFont.Palette palette)
        If the font being used with this Style is an OpenTypeFont which has one or more color palettes, set the Palette to use. Any text created with that font will use the specified palette, provided the "color" feature is also set. Note it is possible to set a custom palette not retrieved from the font, provided it has the correct number of entries. If no palette is specified, the first palette from the font will be used (this is the default).
        Parameters:
        palette - the color palette to use when rendering the font
        Since:
        2.24.1
      • setTextLineSpacing

        public void setTextLineSpacing​(float spacing)

        Set the spacing between lines of text. The paramater is a multiple of the default spacing between lines for this font (as determined by the PDFFont.getDefaultLeading() method). This allows individual fonts to set their preferred line spacing more accurately.

        The default value is 1, for single-spaced text. A value of 1.5 sets line-and-a-half spacing, a value of 2 gives double spacing, and so on.

        Parameters:
        spacing - the spacing between lines
        Since:
        1.0
      • setTextIndent

        public void setTextIndent​(float indent)

        Set the number of points to indent the first line of any text drawn in this style. Positive values result in the first line being indented to the right, negative values in the first line being indented to the left (this is reversed for RTL scripts)

        Note that mixing styles with different text-indent levels on the first line of text in a paragraph will result in unpredictable results.

        Since:
        1.1.21
      • setTextJustificationRatio

        public void setTextJustificationRatio​(float i)
        Set the text justification ratio for a style. When a line of text is padded to justify it against two margins, there is always the the option of extending the space between each character, extending the space between each word, or a combination of the two. The "justification ratio" determines how much to apply to each. A ratio of 0 means "only extend the spaces between words", a ratio of 1 means "only extend the spaces between letters". The default is 0.5.
        Since:
        1.0
      • setOverprint

        public void setOverprint​(boolean on)
        Cause text and objects drawn with this style to overprint. Has no effect unless the fill and/or line color are CMYK or Spot colors. The default is false.
        Since:
        2.10
      • setTextUnderline

        public void setTextUnderline​(boolean on)
        Set whether text rendered with this style is underlined or not. The exact position and width of the underlining is font specific. The default is false.
        Since:
        1.1
      • setTextDoubleUnderline

        public void setTextDoubleUnderline​(boolean on)
        Set whether text rendered with this style is double-underlined or not. The exact position and width of the underlining is font specific. The default is false.
        Since:
        2.11.12
      • setTextStrikeOut

        public void setTextStrikeOut​(boolean on)
        Set whether text rendered with this style is struck-out or not. The default is false.
        Since:
        1.1
      • setTextSmallCaps

        public void setTextSmallCaps​(boolean on)
        Set whether text in this style is displayed with "small-caps" - ie. all lower case letters are displayed as upper-case but at 80% of the original font-size. The default is false. Since 2.22 this is identical to setFontFeature("smallcaps")
        Since:
        2.5
      • setTrackKerning

        public void setTrackKerning​(float kern)

        Allows you to explicitly set the kerning between characters for a font. This method may be called as many times as necessary - between each character if required - to set the kerning distance between characters for all future text rendered in this style ("characters" in this context includes spaces). This "track kerning" is used as well as the standard "pair-wise" kerning, as returned by PDFFont.getKerning(char, char).

        If text-alignment is set to TEXTALIGN_JUSTIFY, kerning (both track and pairwise) is scaled up or down depending on the justification required.

        Parameters:
        kern - the space to place between each character in millipoints (thousandths of a point) if this font was rendered one point high. May be positive, which moves the characters apart, or negative to move them closer together.
        Since:
        1.1.14
        See Also:
        PDFFont.getKerning(char, char)
      • setTextRise

        public void setTextRise​(float offset)

        Set the text vertical offset - the distance between the standard baseline and the basline for this style, as a proportion of the font size. This is mainly used for superscripting or subscripting. text.

        As an example, if you wanted to create a line of text that was 6 points high and 6 points above the standard baseline, set the font size to 6 and the TextRise() to 1. (1x6 = 6 points above the baseline). To place the same text 3 points below the baseline, set the offset to -0.5.

        Since:
        1.1
      • addBackupFont

        public void addBackupFont​(PDFFont font)
        Add a backup font to the current style. Backup fonts are used when the standard font doesn't have a character defined - for example, creating a style with the "Times Roman" font and then adding a backup font of "Symbol" would allow text to be written in both English and Greek without changing styles. As many backup fonts as are required may be added.
        Parameters:
        font - the font to add as a backup for the current style.
        Since:
        1.2
      • setPaintMethod

        public void setPaintMethod​(int method)

        Set the paint method to either PAINTMETHOD_EVENODD or PAINTMETHOD_NONZEROWINDING (the default). The paint method determines which area of a self-intersecting polygon is filled. If your polygons aren't self-intersecting, it has no effect.

        This setting is very obscure and is really only here for completeness. For a full discussion of the difference see the PDF Reference manual version 1.4, page 169.

        Since:
        1.1.5
      • setLineCap

        public void setLineCap​(int cap)
        Set the line cap style. Line caps are the shape of the end of the line - normally not noticable unless you're drawing very thick lines or are zoomed in a long way. The default is LINECAP_BUTT

        Changes to this setting midway through a path don't take effect until the path is closed.

        This setting is very obscure and is really only here for completeness. For a full discussion of the difference see the PDF Reference manual version 1.4, page 153.
        Parameters:
        cap - one of LINECAP_BUTT, LINECAP_ROUND or LINECAP_SQUARE
        Since:
        1.0
      • setLineJoin

        public void setLineJoin​(int join)
        Set the line join style. Line caps are the shape of the join between two line segments - normally not noticable unless you're drawing very thick lines or are zoomed in a long way. The default is LINEJOIN_MITER

        Changes to this setting midway through a path don't take effect until the path is closed.

        This setting is very obscure and is really only here for completeness. For a full discussion of the difference see the PDF Reference manual version 1.4, page 153.
        Parameters:
        join - one of LINEJOIN_MITER, LINEJOIN_ROUND or LINEJOIN_BEVEL.
        Since:
        1.0
      • setLineJoinMiterLimit

        public void setLineJoinMiterLimit​(float limit)
        Set the miter limit for mitered line joins. The default is 10.
        Since:
        2.23.1
      • getLineCap

        public int getLineCap()
        Return the line cap, as set by setLineCap(int)
      • getLineJoin

        public int getLineJoin()
        Return the line join, as set by setLineJoin(int)
      • getOverprint

        public boolean getOverprint()
        Return whether this text has the overprint flag, as set by setOverprint(boolean)
        Since:
        2.21
      • getTextUnderline

        public int getTextUnderline()
        Return whether this text is underlined or not, as set by setTextUnderline(boolean)
        Since:
        2.21
      • getTextStrikeOut

        public boolean getTextStrikeOut()
        Return whether this text is struck out or not, as set by setTextStrikeOut(boolean)
        Since:
        2.21
      • getTrackKerning

        public int getTrackKerning()
        Return the track kerning, as set by setTrackKerning(float)
        Since:
        2.21
      • getTextAlign

        public int getTextAlign()
        Return the text alignment. This method can be used to return the alignment of FormText Widget annotations. It can not be used to determine the alignment of text extracted from the body of the PDF - alignment is not a concept used by PDF except in form fields.
        Since:
        2.6.5
      • getTextIndent

        public float getTextIndent()
        Return the text indent value as set by setTextIndent(float)
        Since:
        1.1.21
      • getFontLeading

        public float getFontLeading()
        Return the text leading for this styles in points. The leading is the distance between the baseline of two successive lines of text, and is defined as:
        getFontSize() * font.getDefaultLeading() * getTextLineSpacing()
        Since:
        1.0
      • getFontStyle

        public int getFontStyle()
        Return the font style as set by setFontStyle(int)
      • getTextRise

        public float getTextRise()
        Return the text rise as set by setTextRise(float)
        Since:
        2.21
      • setTextStretch

        public void setTextStretch​(float stretch)
        Set how much text is stretched horizontally. By default the text has a horizontal stretch factor of 1.0, but this can be increased (to widen the text) or reduced to narrow it. The supplied value must be greater than zero.
        Parameters:
        stretch - the text stretch factor. Must be > 0.
        Since:
        2.0.3
      • getTextStretch

        public float getTextStretch()
        Return the value of the text-stretch parameter, as set by setTextStretch(float)
        Since:
        2.21
      • getLineDashPattern

        public float[] getLineDashPattern()
        Return the line dash pattern, as set by setLineDash(float, float, float). The returned value is null if no dash pattern is in use, or an array of 1 or more positive values.
        Since:
        2.7.8
      • getBackupFont

        public PDFFont getBackupFont​(int i)
        Get the specified backup font, as set by addBackupFont(org.faceless.pdf2.PDFFont). The argument to this method determines which backup font to return - zero for the first, one for the second and so on.
        Parameters:
        i - the backup font to return
        Returns:
        the specified backup font, or null if no backup font exists at that index.
        Since:
        1.2
      • getFormStyle

        public int getFormStyle()
        Returns the form-style of the current style, as set by setFormStyle(int).
        Since:
        1.1.23
      • getFormRadioButtonStyle

        public char getFormRadioButtonStyle()
        Returns the radiobutton style of the current style, as set by setFormRadioButtonStyle(char).
        Since:
        2.0
      • getFormCheckboxStyle

        public char getFormCheckboxStyle()
        Returns the checkbox style of the current style, as set by setFormCheckboxStyle(char).
        Since:
        2.0
      • getFormFieldOrientation

        public int getFormFieldOrientation()
        Return the form field orientation, as set by setFormFieldOrientation(int). Returned value will be one of 0, 90, 180 or 270.
        Since:
        2.7.7
      • setStrokeAdjustment

        public void setStrokeAdjustment​(boolean sa)
        Set whether this style uses Stroke Adjustment
      • setFormFieldOrientation

        public void setFormFieldOrientation​(int rotate)
        Set the angle of rotation for form fields created with this style as a background style.
        Parameters:
        rotate - the form rotation - one of 0 (the default), 90, 180 or 270.
        Since:
        2.7.7
      • setLineBreakBehaviour

        public void setLineBreakBehaviour​(int breakbehaviour)
        Set the line-break behaviour, which determines how words break at the end of the line. Valid values are It is possible to mix BREAK_WORD_X and BREAK_LINE_X values with a logical-or, eg
         style.setLineBreakBehaviour(PDFStyle.BREAK_LINE_NORMAL | PDFStyle.BREAK_WORD_NORMAL)
         
        Since:
        2.22.1
      • getLineBreakBehaviour

        public int getLineBreakBehaviour()
        Return the line-break behaviour, as set by setLineBreakBehaviour(int)
        Since:
        2.22.1
      • getTextLength

        public float getTextLength​(java.lang.String s)
        Get the length of the specified string in points, using the styles font and font size. The line of text must not contain any newlines. Note this is a legacy method; for styles containing no backup fonts, it is faster to use a PDFGlyphVector to measure and display text.
        Parameters:
        s - the String to measure the length of
        Returns:
        the length of the string in points if drawn in this style
      • getTextLeft

        public float getTextLeft​(java.lang.String s)
        Get the left-most X co-ordinate of the specified string in points if it was rendered at (0,0), using the styles font and font size. The line of text must not contain any newlines. This method takes track-kerning into account.
        Returns:
        the left edge of the string in points if drawn in this style
      • getTextRight

        public float getTextRight​(java.lang.String s)
        Get the right-most X co-ordinate of the specified string in points if it was rendered at (0,0), using the styles font and font size. The line of text must not contain any newlines. This method takes track-kerning into account.
        Returns:
        the right edge of the string in points if drawn in this style
      • getTextTop

        public float getTextTop​(java.lang.String s)
        Get the top-most Y co-ordinate of the specified string in points if it was rendered at (0,0), using the styles font and font size. The line of text must not contain any newlines.
        Returns:
        the top edge of the string in points if drawn in this style
      • getTextBottom

        public float getTextBottom​(java.lang.String s)
        Get the bottom-most Y co-ordinate of the specified string in points if it was rendered at (0,0), using the styles font and font size. The line of text must not contain any newlines.
        Returns:
        the bottom edge of the string in points if drawn in this style
      • getTextWidths

        @Deprecated
        public float getTextWidths​(char[] buf,
                                   int off,
                                   int len,
                                   float[] widths,
                                   float[] kerns)
        Deprecated.
        call createGlyphVector(java.lang.String, java.util.Locale) and retrieve this information from there
        As getTextLength() but sets the width of each character in the specified arrays; a very low level routine unlikely to be used by many, but useful for calculating break points for advanced layout engines like the Report Generator.
        Parameters:
        buf - the character buffer to use
        off - the offset into that buffer to start at
        len - the number of characters to process
        widths - if not null, an array len long which will be populated with the width of each character in points
        kerns - If not null, an array len long which will be populated with the kerning values after each character, in points. Negative values move the next character closer, positive moves them further away.
        Returns:
        the total width of the text, as from getTextLength()
        Since:
        2.6
      • getTextLength

        public float getTextLength​(char[] c,
                                   int off,
                                   int len)
        Get the length of the specified string in points, using the styles font and font size. Identical to getTextLength(String)
        Parameters:
        c - the character buffer to use
        off - the offset into that buffer to start at
        len - the number of characters to process
        Since:
        1.2.1
      • clone

        public java.lang.Object clone()
        Create a duplicate of this font. It's probably more convenient to use the PDFStyle(PDFStyle) constructor, as it will save you having to typecast the response
        Overrides:
        clone in class java.lang.Object
      • superscriptClone

        public PDFStyle superscriptClone()
        Return a new style which is the "superscripted" version of the current style.
        Since:
        1.1
      • subscriptClone

        public PDFStyle subscriptClone()
        Return a new style which is the "subscripted" version of the current style.
        Since:
        1.1
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • setBlendMode

        public void setBlendMode​(java.lang.String mode)
        Set the "Blend Mode" of this style. The mode may be one of "Normal", "Multiply", "Screen", "Overlay", "Darken", "Lighten", "ColorDodge", "ColorBurn", "HardLight", "SoftLight", "Difference", "Exclusion", "Hue", "Color", "Saturation" or "Luminosity". Blend modes may not work in all situations.
        Since:
        2.11.7
      • getBlendMode

        public java.lang.String getBlendMode()
        Return the previously set blend mode
      • createGlyphVector

        public PDFGlyphVector createGlyphVector​(java.lang.String text,
                                                int offset,
                                                java.util.Locale locale,
                                                int level)

        Returns a PDFGlyphVector containing the glyph codes for the specified text in this style. This can then be drawn directly to a PDFCanvas. See the PDFGlyphVector class for an example.

        Note that the returned PDFGlyphVector may not represent the complete String: the returned item will contain as many characters as can be displayed in this font, which may be the same as text.length(), or empty if none of the characters are available in the font. See PDFGlyphVector.getTextLength() to determine how many characters were consumed.

        Parameters:
        text - the text to display
        text - the offset to add to any indices into that text, as returned by PDFGlyphVector.getFirstIndex(int) (0 if in doubt)
        locale - the locale of the text, or null to use the default
        level - the level in the Unicode bidirectional algorithm for this glyph vector, or 0 if it doesn't apply.
        See Also:
        PDFGlyphVector, PDFCanvas.drawGlyphVector(org.faceless.pdf2.PDFGlyphVector, float, float)