Class PDFStyle
- java.lang.Object
-
- org.faceless.pdf2.PDFStyle
-
- All Implemented Interfaces:
Cloneable
public class PDFStyle extends Object implements 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
ExamplePDFPage. 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.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 Summary
Fields Modifier and Type Field Description static intBREAK_LEGACYA value forsetLineBreakBehaviour(int)that will use the line-breaking rules that applied in the PDF Library before release 2.22.1.static intBREAK_LINE_ANYWHEREA value forsetLineBreakBehaviour(int)that will use the line-breaking rules as described for "line-break:anywhere" in css-text-3.static intBREAK_LINE_LOOSEA value forsetLineBreakBehaviour(int)that will use the line-breaking rules as described for "line-break:loose" in css-text-3.static intBREAK_LINE_NORMALA value forsetLineBreakBehaviour(int)that will use the line-breaking rules as described for "line-break:normal" in css-text-3.static intBREAK_LINE_STRICTA value forsetLineBreakBehaviour(int)that will use the line-breaking rules as described for "line-break:strict" in css-text-3.static intBREAK_UAX14A value forsetLineBreakBehaviour(int)that will use the line-breaking rules exactly as described in UAX14static intBREAK_WORD_BREAKALLA value forsetLineBreakBehaviour(int)that will use the line-breaking rules as described for "word-break:break-all" in css-text-3.static intBREAK_WORD_KEEPALLA value forsetLineBreakBehaviour(int)that will use the line-breaking rules as described for "word-break:keep-all" in css-text-3.static intBREAK_WORD_NORMALA value forsetLineBreakBehaviour(int)that will use the line-breaking rules as described for "word-break:normal" in css-text-3.static intFONTSTYLE_FILLEDSet any text rendered in this style to be filled with the styles FillColor (the default)static intFONTSTYLE_FILLEDOUTLINESet any text rendered in this style to be filled with the styles FillColor, then to be outlined with the styles' LineColorstatic intFONTSTYLE_INVISIBLESet any text rendered in this style to be invisible.static intFONTSTYLE_OUTLINESet any text rendered in this style to be drawn as a hollow outline with the styles LineColor (the default)static charFORMRADIOBUTTONSTYLE_CHECKA value forsetFormRadioButtonStyle(char)andsetFormCheckboxStyle(char)which sets the appearance for those elements to a check mark (a tick) when selected.static charFORMRADIOBUTTONSTYLE_CIRCLEA value forsetFormRadioButtonStyle(char)andsetFormCheckboxStyle(char)which sets the appearance for those elements to a filled circle when selected.static charFORMRADIOBUTTONSTYLE_CROSSA value forsetFormRadioButtonStyle(char)andsetFormCheckboxStyle(char)which sets the appearance for those elements to a cross or "X" when selected.static charFORMRADIOBUTTONSTYLE_DIAMONDA value forsetFormRadioButtonStyle(char)andsetFormCheckboxStyle(char)which sets the appearance for those elements to a filled diamond when selected.static charFORMRADIOBUTTONSTYLE_SQUAREA value forsetFormRadioButtonStyle(char)andsetFormCheckboxStyle(char)which sets the appearance for those elements to a filled square when selected.static charFORMRADIOBUTTONSTYLE_STARA value forsetFormRadioButtonStyle(char)andsetFormCheckboxStyle(char)which sets the appearance for those elements to a filled five-pointed star when selected.static intFORMSTYLE_BEVELStyle forsetFormStyle(int)which draws an border around the field so that it looks beveled.static intFORMSTYLE_CLOUDY1Style forsetFormStyle(int)which causes the border to be "cloudy" with small curves This style only applies to someAnnotationShapeclasses andAnnotationTextstatic intFORMSTYLE_CLOUDY2Style forsetFormStyle(int)which causes the border to be "cloudy" with big curves.static intFORMSTYLE_INSETStyle forsetFormStyle(int)which draws an border around the field so that it looks inset into the page.static intFORMSTYLE_INVERTStyle forsetFormStyle(int)which causes the form element to be inverted when clickedstatic intFORMSTYLE_OUTLINEStyle forsetFormStyle(int)which causes the form element to be outlined when clickedstatic intFORMSTYLE_SOLIDStyle forsetFormStyle(int)which draws a solid border around the field (the default)static intFORMSTYLE_UNDERLINEStyle forsetFormStyle(int)which draws a single line under the fieldstatic intLINECAP_BUTTSet the end of a line to be squared off at the end.static intLINECAP_ROUNDSet the end of a line to be rounded at the end.static intLINECAP_SQUARESet the end of a line to be squared at the end.static intLINEJOIN_BEVELSets the join style of two lines so that the lines are beveled.static intLINEJOIN_MITERSets the join style of two lines so that the lines are extended so they meet at a point (like a picture frame).static intLINEJOIN_ROUNDSets 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.static PDFStyleLINKSTYLEThis style is a predefined convenience style - it can be passed intoPDFPage.beginTextLink(org.faceless.pdf2.PDFAction, org.faceless.pdf2.PDFStyle)to underline the text in the link.static intPAINTMETHOD_EVENODDA parameter tosetPaintMethod(int)to set the paint method to use the even-odd method to determine which areas are inside or outside a shape.static intPAINTMETHOD_NONZEROWINDINGA parameter tosetPaintMethod(int)to set the paint method to use the non-zero winding number method to determine which areas are inside or outside a shape.static intTEXTALIGN_BASELINESet the vertical text alignment for this style to baseline (the default).static intTEXTALIGN_BOTTOMSet the vertical text alignment for this style to bottomstatic intTEXTALIGN_CENTERSet the text alignment for this style to centeredstatic intTEXTALIGN_JUSTIFYSet the text alignment for this style to justified (the default).static intTEXTALIGN_JUSTIFY_ALLSimilar toTEXTALIGN_JUSTIFY, but will also justify the last line of a paragraph.static intTEXTALIGN_LEFTSet the text alignment for this style to left-alignedstatic intTEXTALIGN_MIDDLESet the vertical text alignment for this style to middlestatic intTEXTALIGN_RIGHTSet the text alignment for this style to right-alignedstatic intTEXTALIGN_TOPSet the vertical text alignment for this style to top
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddBackupFont(PDFFont font)Add a backup font to the current style.Objectclone()Create a duplicate of this font.PDFGlyphVectorcreateGlyphVector(String text, int offset, Locale locale, int level)Returns a PDFGlyphVector containing the glyph codes for the specified text in this style.PDFGlyphVectorcreateGlyphVector(String text, Locale locale)Returns a PDFGlyphVector containing the glyph codes for the specified text in this style.booleanequals(Object o)PDFFontgetBackupFont(int i)Get the specified backup font, as set byaddBackupFont(org.faceless.pdf2.PDFFont).StringgetBlendMode()Return the previously set blend modePaintgetFillColor()Return the fill color, as set bysetFillColor(java.awt.Paint)PDFFontgetFont()Return the font, as set bysetFont(org.faceless.pdf2.PDFFont, float)intgetFontFeature(String feature)Get the specified font feature.floatgetFontLeading()Return the text leading for this styles in points.floatgetFontSize()Return the font size of this style, as set bysetFont(org.faceless.pdf2.PDFFont, float)intgetFontStyle()Return the font style as set bysetFontStyle(int)chargetFormCheckboxStyle()Returns the checkbox style of the current style, as set bysetFormCheckboxStyle(char).intgetFormFieldOrientation()Return the form field orientation, as set bysetFormFieldOrientation(int).chargetFormRadioButtonStyle()Returns the radiobutton style of the current style, as set bysetFormRadioButtonStyle(char).intgetFormStyle()Returns the form-style of the current style, as set bysetFormStyle(int).intgetLineBreakBehaviour()Return the line-break behaviour, as set bysetLineBreakBehaviour(int)intgetLineCap()Return the line cap, as set bysetLineCap(int)PaintgetLineColor()Return the line color, as set bysetLineColor(java.awt.Paint)float[]getLineDashPattern()Return the line dash pattern, as set bysetLineDash(float, float, float).floatgetLineDashPhase()Get the "phase" part of the line dash pattern, as set bysetLineDash(float, float, float)intgetLineJoin()Return the line join, as set bysetLineJoin(int)floatgetLineJoinMiterLimit()Return the line join miter limit, as set bysetLineJoinMiterLimit(float)floatgetLineWeighting()Return the line weighting, as set bysetLineWeighting(float)OpenTypeFont.PalettegetOpenTypeFontPalette()Get the OpenTypeFont.Palette previously specified with #setOpenTypeFontPalettebooleangetOverprint()Return whether this text has the overprint flag, as set bysetOverprint(boolean)intgetTextAlign()Return the text alignment.floatgetTextBottom(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.floatgetTextIndent()Return the text indent value as set bysetTextIndent(float)floatgetTextLeft(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.floatgetTextLength(char[] c, int off, int len)Get the length of the specified string in points, using the styles font and font size.floatgetTextLength(String s)Get the length of the specified string in points, using the styles font and font size.floatgetTextLineSpacing()Return the text line spacing, as set bysetTextLineSpacing(float)floatgetTextRight(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.floatgetTextRise()Return the text rise as set bysetTextRise(float)floatgetTextStretch()Return the value of the text-stretch parameter, as set bysetTextStretch(float)booleangetTextStrikeOut()Return whether this text is struck out or not, as set bysetTextStrikeOut(boolean)floatgetTextTop(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.intgetTextUnderline()Return whether this text is underlined or not, as set bysetTextUnderline(boolean)orsetTextDoubleUnderline(boolean).floatgetTextWidths(char[] buf, int off, int len, float[] widths, float[] kerns)Deprecated.callcreateGlyphVector(java.lang.String, java.util.Locale)and retrieve this information from thereintgetTrackKerning()Return the track kerning, as set bysetTrackKerning(float)inthashCode()booleanisTextSmallCaps()Return whether this text is displayed with small-caps, as set bysetTextSmallCaps(boolean)Since 2.22 this is identical togetFontFeature("smallcaps")voidsetBlendMode(String mode)Set the "Blend Mode" of this style.voidsetFillColor(Paint paint)Set the fill color.voidsetFont(PDFFont font, float size)Set the font and font size for this style.voidsetFontFeature(String feature, boolean on)Set the specified font feature.voidsetFontFeature(String feature, int value)Set the specified font feature.voidsetFontStyle(int style)Set the font render style.voidsetFormCheckboxStyle(char style)ForFormCheckboxelements, set the type of shape to use to show the checkbox is selected.voidsetFormFieldOrientation(int rotate)Set the angle of rotation for form fields created with this style as a background style.voidsetFormRadioButtonStyle(char style)ForFormRadioButtonelements, set the type of shape to use to show the button is selected.voidsetFormStyle(int style)Sets the style of a form fields background to one ofFORMSTYLE_SOLID,FORMSTYLE_INSET,FORMSTYLE_BEVEL,FORMSTYLE_INVERT,FORMSTYLE_OUTLINEorFORMSTYLE_UNDERLINE.voidsetLineBreakBehaviour(int breakbehaviour)Set the line-break behaviour, which determines how words break at the end of the line.voidsetLineCap(int cap)Set the line cap style.voidsetLineColor(Paint paint)Set the line color.voidsetLineDash(float[] pattern, float phase)Set the line dashing pattern.voidsetLineDash(float on, float off, float phase)Set the line dashing pattern.voidsetLineJoin(int join)Set the line join style.voidsetLineJoinMiterLimit(float limit)Set the miter limit for mitered line joins.voidsetLineWeighting(float weight)Set the line weighting, for fonts and geometric shapes drawn as outlines.voidsetOpenTypeFontPalette(OpenTypeFont.Palette palette)If the font being used with this Style is an OpenTypeFont which has one or morecolor palettes, set the Palette to use.voidsetOverprint(boolean on)Cause text and objects drawn with this style to overprint.voidsetPaintMethod(int method)Set the paint method to eitherPAINTMETHOD_EVENODDorPAINTMETHOD_NONZEROWINDING(the default).voidsetStrokeAdjustment(boolean sa)Set whether this style uses Stroke AdjustmentvoidsetTextAlign(int textalign)Set the text alignment for this style.voidsetTextDoubleUnderline(boolean on)Set whether text rendered with this style is double-underlined or not.voidsetTextIndent(float indent)Set the number of points to indent the first line of any text drawn in this style.voidsetTextJustificationRatio(float i)Set the text justification ratio for a style.voidsetTextLineSpacing(float spacing)Set the spacing between lines of text.voidsetTextRise(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.voidsetTextSmallCaps(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.voidsetTextStretch(float stretch)Set how much text is stretched horizontally.voidsetTextStrikeOut(boolean on)Set whether text rendered with this style is struck-out or not.voidsetTextUnderline(boolean on)Set whether text rendered with this style is underlined or not.voidsetTrackKerning(float kern)Allows you to explicitly set the kerning between characters for a font.PDFStylesubscriptClone()Return a new style which is the "subscripted" version of the current style.PDFStylesubscriptClone(float size, float position)Return a new style which is a "subscripted" version of the current style.PDFStylesuperscriptClone()Return a new style which is the "superscripted" version of the current style.PDFStylesuperscriptClone(float size, float position)Return a new style which is a "superscripted" version of the current style.StringtoString()
-
-
-
Field Detail
-
LINKSTYLE
public static final PDFStyle LINKSTYLE
This style is a predefined convenience style - it can be passed intoPDFPage.beginTextLink(org.faceless.pdf2.PDFAction, org.faceless.pdf2.PDFStyle)to underline the text in the link.
-
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 toTEXTALIGN_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 tosetPaintMethod(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 tosetPaintMethod(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_SOLID
public static final int FORMSTYLE_SOLID
Style forsetFormStyle(int)which draws a solid border around the field (the default)- See Also:
- Constant Field Values
-
FORMSTYLE_INSET
public static final int FORMSTYLE_INSET
Style forsetFormStyle(int)which draws an border around the field so that it looks inset into the page.- See Also:
- Constant Field Values
-
FORMSTYLE_BEVEL
public static final int FORMSTYLE_BEVEL
Style forsetFormStyle(int)which draws an border around the field so that it looks beveled.- See Also:
- Constant Field Values
-
FORMSTYLE_UNDERLINE
public static final int FORMSTYLE_UNDERLINE
Style forsetFormStyle(int)which draws a single line under the field- See Also:
- Constant Field Values
-
FORMSTYLE_INVERT
public static final int FORMSTYLE_INVERT
Style forsetFormStyle(int)which causes the form element to be inverted when clicked- See Also:
- Constant Field Values
-
FORMSTYLE_OUTLINE
public static final int FORMSTYLE_OUTLINE
Style forsetFormStyle(int)which causes the form element to be outlined when clicked- See Also:
- Constant Field Values
-
FORMSTYLE_CLOUDY1
public static final int FORMSTYLE_CLOUDY1
Style forsetFormStyle(int)which causes the border to be "cloudy" with small curves This style only applies to someAnnotationShapeclasses andAnnotationText- Since:
- 2.11.17
- See Also:
- Constant Field Values
-
FORMSTYLE_CLOUDY2
public static final int FORMSTYLE_CLOUDY2
Style forsetFormStyle(int)which causes the border to be "cloudy" with big curves. This style only applies to someAnnotationShapeclasses andAnnotationText- Since:
- 2.11.17
- See Also:
- Constant Field Values
-
FORMRADIOBUTTONSTYLE_CHECK
public static final char FORMRADIOBUTTONSTYLE_CHECK
A value forsetFormRadioButtonStyle(char)andsetFormCheckboxStyle(char)which sets the appearance for those elements to a check mark (a tick) when selected. This is the default forFormCheckboxelements.- Since:
- 2.0
- See Also:
- Constant Field Values
-
FORMRADIOBUTTONSTYLE_CIRCLE
public static final char FORMRADIOBUTTONSTYLE_CIRCLE
A value forsetFormRadioButtonStyle(char)andsetFormCheckboxStyle(char)which sets the appearance for those elements to a filled circle when selected. This is default forFormRadioButtonelements.- Since:
- 2.0
- See Also:
- Constant Field Values
-
FORMRADIOBUTTONSTYLE_CROSS
public static final char FORMRADIOBUTTONSTYLE_CROSS
A value forsetFormRadioButtonStyle(char)andsetFormCheckboxStyle(char)which sets the appearance for those elements to a cross or "X" when selected.- Since:
- 2.0
- See Also:
- Constant Field Values
-
FORMRADIOBUTTONSTYLE_SQUARE
public static final char FORMRADIOBUTTONSTYLE_SQUARE
A value forsetFormRadioButtonStyle(char)andsetFormCheckboxStyle(char)which sets the appearance for those elements to a filled square when selected.- Since:
- 2.0
- See Also:
- Constant Field Values
-
FORMRADIOBUTTONSTYLE_DIAMOND
public static final char FORMRADIOBUTTONSTYLE_DIAMOND
A value forsetFormRadioButtonStyle(char)andsetFormCheckboxStyle(char)which sets the appearance for those elements to a filled diamond when selected.- Since:
- 2.0
- See Also:
- Constant Field Values
-
FORMRADIOBUTTONSTYLE_STAR
public static final char FORMRADIOBUTTONSTYLE_STAR
A value forsetFormRadioButtonStyle(char)andsetFormCheckboxStyle(char)which sets the appearance for those elements to a filled five-pointed star when selected.- Since:
- 2.0
- See Also:
- Constant Field Values
-
BREAK_LEGACY
public static final int BREAK_LEGACY
A value forsetLineBreakBehaviour(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 forsetLineBreakBehaviour(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 forsetLineBreakBehaviour(int)that will use the line-breaking rules as described for "line-break:normal" in css-text-3. This value can be combined with aBREAK_WORD_nvalue using a logical-or- Since:
- 2.22.1
-
BREAK_LINE_LOOSE
public static final int BREAK_LINE_LOOSE
A value forsetLineBreakBehaviour(int)that will use the line-breaking rules as described for "line-break:loose" in css-text-3. This value can be combined with aBREAK_WORD_nvalue using a logical-or- Since:
- 2.22.1
-
BREAK_LINE_STRICT
public static final int BREAK_LINE_STRICT
A value forsetLineBreakBehaviour(int)that will use the line-breaking rules as described for "line-break:strict" in css-text-3. This value can be combined with aBREAK_WORD_nvalue using a logical-or- Since:
- 2.22.1
-
BREAK_LINE_ANYWHERE
public static final int BREAK_LINE_ANYWHERE
A value forsetLineBreakBehaviour(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 forsetLineBreakBehaviour(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 aBREAK_LINE_nvalue using a logical-or- Since:
- 2.22.1
-
BREAK_WORD_KEEPALL
public static final int BREAK_WORD_KEEPALL
A value forsetLineBreakBehaviour(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 aBREAK_LINE_nvalue using a logical-or- Since:
- 2.22.1
-
BREAK_WORD_NORMAL
public static final int BREAK_WORD_NORMAL
A value forsetLineBreakBehaviour(int)that will use the line-breaking rules as described for "word-break:normal" in css-text-3. This value can be combined with aBREAK_LINE_nvalue 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
-
setFillColor
public void setFillColor(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
Coloras an argument, but this has been changed to its superclassPaintinstead. Although most of the time the parameter will still be a plain color, this change allows aGradientPaintto be used as well.- Parameters:
paint- the paint to use, ornullif no fill is required.- Since:
- 1.0
-
setLineColor
public void setLineColor(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 tonull(the default).- Parameters:
paint- the Color to use, ornullif 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
pathdon'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 drawoff- how many points of the line to skipphase- how far into the pattern to start- Since:
- 1.0
-
setLineDash
public void setLineDash(float[] pattern, float phase)Set the line dashing pattern. The
patternparameter 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. Thephaseparamter 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
pathdon't take effect until the path is closed.- Parameters:
pattern- the pattern of alternating on/off segments, ornullto draw solid linesphase- how far into the pattern to start- Since:
- 2.7.8
-
setFont
public void setFont(PDFFont font, float size)
Set the font and font size for this style. For styles passed in toForm.setTextStyle(org.faceless.pdf2.PDFStyle)andWidgetAnnotation.setTextStyle(org.faceless.pdf2.PDFStyle), a font size of zero means "autosize" the text. In other situatios, a zero size will cause an error when the style is used to render text.- Parameters:
font- the font to usesize- the size of the font. Must be greater than zero, except in the situation above when it may also be equal to zero.- Since:
- 1.0
-
setFontFeature
public void setFontFeature(String feature, boolean on)
Set the specified font feature. This method takes the same parameters as thePDFFont.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(String feature, int value)
Set the specified font feature. This method takes the same parameters as thePDFFont.setFeature(String,int)method, but the features will be only be applied to the font for text created with this style.- Since:
- 2.22
-
getFontFeature
public int getFontFeature(String feature)
Get the specified font feature. This method will return the value set bysetFontFeature(java.lang.String, boolean), or if not set the value ofPDFFont.getFeature(java.lang.String)for the style's font. If no font is set it will always return0- Since:
- 2.14.1 (prior to 2.22 this returned a boolean)
-
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 morecolor 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
-
setTextAlign
public void setTextAlign(int textalign)
Set the text alignment for this style. The alignment may be any one ofTEXTALIGN_LEFT,TEXTALIGN_RIGHT,TEXTALIGN_CENTERorTEXTALIGN_JUSTIFY, which control the horizontal alignment, added to any one ofTEXTALIGN_BASELINE,TEXTALIGN_TOP,TEXTALIGN_MIDDLEorTEXTALIGN_BOTTOM, which control the vertical alignment.- Parameters:
textalign- the text alignment to use for this style- Since:
- 1.0, with vertical alignment added in 1.2
-
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
-
setFontStyle
public void setFontStyle(int style)
Set the font render style. Can be one ofFONTSTYLE_FILLED(the default),FONTSTYLE_OUTLINE,FONTSTYLE_FILLEDOUTLINEorFONTSTYLE_INVISIBLE.- Since:
- 1.1
-
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 isfalse.- 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 tosetFontFeature("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.
- Parameters:
offset- the distance to raise the text above the baseline as a proportion of the font-size.- 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
-
setFormStyle
public void setFormStyle(int style)
Sets the style of a form fields background to one ofFORMSTYLE_SOLID,FORMSTYLE_INSET,FORMSTYLE_BEVEL,FORMSTYLE_INVERT,FORMSTYLE_OUTLINEorFORMSTYLE_UNDERLINE. This method can be applied to the background style passed into theForm.setBackgroundStyle(org.faceless.pdf2.PDFStyle)andWidgetAnnotation.setBackgroundStyle(org.faceless.pdf2.PDFStyle)methods, but for all other purposes (eg. setting the style of a page), this setting is ignored.- Parameters:
style- the type of background to draw the form field.- Since:
- 1.1.23
-
setFormRadioButtonStyle
public void setFormRadioButtonStyle(char style)
ForFormRadioButtonelements, set the type of shape to use to show the button is selected. The default value isFORMRADIOBUTTONSTYLE_CIRCLE, which creates round radio buttons in the traditional HTML style- Parameters:
style- one ofFORMRADIOBUTTONSTYLE_CIRCLE,FORMRADIOBUTTONSTYLE_CHECK,FORMRADIOBUTTONSTYLE_DIAMOND,FORMRADIOBUTTONSTYLE_CROSS,FORMRADIOBUTTONSTYLE_SQUAREorFORMRADIOBUTTONSTYLE_STAR- Since:
- 2.0
-
setFormCheckboxStyle
public void setFormCheckboxStyle(char style)
ForFormCheckboxelements, set the type of shape to use to show the checkbox is selected. The default value isFORMRADIOBUTTONSTYLE_CHECK, which creates checkboxes in the traditional HTML style- Parameters:
style- one ofFORMRADIOBUTTONSTYLE_CIRCLE,FORMRADIOBUTTONSTYLE_CHECK,FORMRADIOBUTTONSTYLE_DIAMOND,FORMRADIOBUTTONSTYLE_CROSS,FORMRADIOBUTTONSTYLE_SQUAREorFORMRADIOBUTTONSTYLE_STAR- Since:
- 2.0
-
setPaintMethod
public void setPaintMethod(int method)
Set the paint method to either
PAINTMETHOD_EVENODDorPAINTMETHOD_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 isLINECAP_BUTTChanges to this setting midway through a
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.pathdon't take effect until the path is closed.- Parameters:
cap- one ofLINECAP_BUTT,LINECAP_ROUNDorLINECAP_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 isLINEJOIN_MITERChanges to this setting midway through a
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.pathdon't take effect until the path is closed.- Parameters:
join- one ofLINEJOIN_MITER,LINEJOIN_ROUNDorLINEJOIN_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 bysetLineCap(int)
-
getLineJoin
public int getLineJoin()
Return the line join, as set bysetLineJoin(int)
-
getLineJoinMiterLimit
public float getLineJoinMiterLimit()
Return the line join miter limit, as set bysetLineJoinMiterLimit(float)
-
getLineColor
public Paint getLineColor()
Return the line color, as set bysetLineColor(java.awt.Paint)
-
getFillColor
public Paint getFillColor()
Return the fill color, as set bysetFillColor(java.awt.Paint)
-
getFontSize
public float getFontSize()
Return the font size of this style, as set bysetFont(org.faceless.pdf2.PDFFont, float)- Since:
- 1.0
-
getOverprint
public boolean getOverprint()
Return whether this text has the overprint flag, as set bysetOverprint(boolean)- Since:
- 2.21
-
getTextUnderline
public int getTextUnderline()
Return whether this text is underlined or not, as set bysetTextUnderline(boolean)orsetTextDoubleUnderline(boolean).- Returns:
- 0 for no underline, 1 for single underline and 2 for double underline
- Since:
- 2.21
-
getTextStrikeOut
public boolean getTextStrikeOut()
Return whether this text is struck out or not, as set bysetTextStrikeOut(boolean)- Since:
- 2.21
-
isTextSmallCaps
public boolean isTextSmallCaps()
Return whether this text is displayed with small-caps, as set bysetTextSmallCaps(boolean)Since 2.22 this is identical togetFontFeature("smallcaps")- Since:
- 2.21
-
getTextLineSpacing
public float getTextLineSpacing()
Return the text line spacing, as set bysetTextLineSpacing(float)
-
getLineWeighting
public float getLineWeighting()
Return the line weighting, as set bysetLineWeighting(float)
-
getTrackKerning
public int getTrackKerning()
Return the track kerning, as set bysetTrackKerning(float)- Since:
- 2.21
-
getTextAlign
public int getTextAlign()
Return the text alignment. This method can be used to return the alignment ofFormTextWidget 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 bysetTextIndent(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 bysetFontStyle(int)
-
getTextRise
public float getTextRise()
Return the text rise as set bysetTextRise(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 bysetTextStretch(float)- Since:
- 2.21
-
getLineDashPhase
public float getLineDashPhase()
Get the "phase" part of the line dash pattern, as set bysetLineDash(float, float, float)- Since:
- 1.1
-
getLineDashPattern
public float[] getLineDashPattern()
Return the line dash pattern, as set bysetLineDash(float, float, float). The returned value isnullif no dash pattern is in use, or an array of 1 or more positive values.- Since:
- 2.7.8
-
getFont
public PDFFont getFont()
Return the font, as set bysetFont(org.faceless.pdf2.PDFFont, float)- Since:
- 1.0
-
getBackupFont
public PDFFont getBackupFont(int i)
Get the specified backup font, as set byaddBackupFont(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
nullif no backup font exists at that index. - Since:
- 1.2
-
getFormStyle
public int getFormStyle()
Returns the form-style of the current style, as set bysetFormStyle(int).- Since:
- 1.1.23
-
getFormRadioButtonStyle
public char getFormRadioButtonStyle()
Returns the radiobutton style of the current style, as set bysetFormRadioButtonStyle(char).- Since:
- 2.0
-
getFormCheckboxStyle
public char getFormCheckboxStyle()
Returns the checkbox style of the current style, as set bysetFormCheckboxStyle(char).- Since:
- 2.0
-
getFormFieldOrientation
public int getFormFieldOrientation()
Return the form field orientation, as set bysetFormFieldOrientation(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- {link #BREAK_UAX14}, to use the rules defined in the most recent version of UAX #14
- {link #BREAK_LEGACY}, to use the legacy rules used by the PDF Library up until 2.22.1, and based on UAX#14 version 12
- {link #BREAK_WORD_NORMAL}, to use same rules as CSS word-break: normal-all
- {link #BREAK_WORD_BREAKALL}, to use same rules as CSS word-break: break-all
- {link #BREAK_WORD_KEEPALL}, to use same rules as CSS word-break: keep-all
- {link #BREAK_LINE_LOOSE}, to use same rules as CSS line-break: loose
- {link #BREAK_LINE_NORMAL}, to use same rules as CSS line-break: normal
- {link #BREAK_LINE_STRICT}, to use same rules as CSS line-break: strict
- {link #BREAK_LINE_ANYWHERE}, to use same rules as CSS line-break: anywhere
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 bysetLineBreakBehaviour(int)- Since:
- 2.22.1
-
getTextLength
public float getTextLength(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 aPDFGlyphVectorto 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(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(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(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(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.callcreateGlyphVector(java.lang.String, java.util.Locale)and retrieve this information from thereAsgetTextLength()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 useoff- the offset into that buffer to start atlen- the number of characters to processwidths- if not null, an arraylenlong which will be populated with the width of each character in pointskerns- If not null, an arraylenlong 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 togetTextLength(String)- Parameters:
c- the character buffer to useoff- the offset into that buffer to start atlen- the number of characters to process- Since:
- 1.2.1
-
clone
public Object clone()
Create a duplicate of this font. It's probably more convenient to use thePDFStyle(PDFStyle)constructor, as it will save you having to typecast the response
-
superscriptClone
public PDFStyle superscriptClone()
Return a new style which is the "superscripted" version of the current style. Callsreturn superscriptClone(font.getSubscriptSize(), font.getSuperscriptPosition())- Since:
- 1.1
-
superscriptClone
public PDFStyle superscriptClone(float size, float position)
Return a new style which is a "superscripted" version of the current style.- Parameters:
size- the multiplier to apply to the current font size, typically in the range 0.5 to 0.7position- the position above the baseline to shift the text in this font, as proportion of the size after it has been reduced. Typically in the range 0.4 to 0.75- Since:
- 2.29
- See Also:
PDFFont.getSubscriptSize(),PDFFont.getSuperscriptPosition()
-
subscriptClone
public PDFStyle subscriptClone()
Return a new style which is the "subscripted" version of the current style. Callsreturn superscriptClone(font.getSubscriptSize(), font.getSuperscriptPosition())- Since:
- 1.1
-
subscriptClone
public PDFStyle subscriptClone(float size, float position)
Return a new style which is a "subscripted" version of the current style.- Parameters:
size- the multiplier to apply to the current font size, typically about 0.6position- the position above the baseline to shift the text in this font, as proportion of the size after it has been reduced. Typically in the range 0 to -0.2 Get the recommended position of a sub-script version of this font, as a proportion of the sub-scripted font size. Value is almost always zero or negative.- Since:
- 2.29
- See Also:
PDFFont.getSubscriptSize(),PDFFont.getSubscriptPosition()
-
setBlendMode
public void setBlendMode(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 String getBlendMode()
Return the previously set blend mode
-
createGlyphVector
public PDFGlyphVector createGlyphVector(String text, Locale locale)
Returns a PDFGlyphVector containing the glyph codes for the specified text in this style. Simply returnscreateGlyphVector(text, 0, locale, 0)- Parameters:
text- the text to displaylocale- the locale of the text, or null to use the default- Since:
- 2.11.22
- See Also:
PDFGlyphVector,PDFCanvas.drawGlyphVector(org.faceless.pdf2.PDFGlyphVector, float, float)
-
createGlyphVector
public PDFGlyphVector createGlyphVector(String text, int offset, 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
PDFGlyphVectorclass 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. SeePDFGlyphVector.getTextLength()to determine how many characters were consumed.- Parameters:
text- the text to displaytext- the offset to add to any indices into that text, as returned byPDFGlyphVector.getFirstIndex(int)(0 if in doubt)locale- the locale of the text, ornullto use the defaultlevel- 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)
-
-