public interface ITextStyle
Interface to work with Text Style
An example of applying different text styles to a single text layer of a PSD file. It modifies the text style of an existing text layer and adds to one a few new text portions styled differently then saves a changed copy of the document as a new PSD file.
String inPsdFilePath = "text212.psd"; String outPsdFilePath = "Output_text212.psd"; // Load a PSD file containing predefined text layers PsdImage psdImage = (PsdImage)Image.load(inPsdFilePath); try { // Obtain a text container of a first layer TextLayer textLayer = (TextLayer)psdImage.getLayers()[1]; IText textData = textLayer.getTextData(); // Define a default text style ITextStyle defaultStyle = textData.producePortion().getStyle(); defaultStyle.setFillColor(Color.getDimGray()); defaultStyle.setFontSize(51); // Define a default text paragraph ITextParagraph defaultParagraph = textData.producePortion().getParagraph(); // Style an existing text portion textData.getItems()[1].getStyle().setStrikethrough(true); // Create a few new text portions with default styling ITextPortion[] newTextPortions = textData.producePortions(new String[] { "E=mc", "2\r", "Bold", "Italic\r", "Lowercasetext" }, defaultStyle, defaultParagraph); // Style the text portions differently newTextPortions[0].getStyle().setUnderline(true); // edit text style of "E=mc" newTextPortions[1].getStyle().setFontBaseline(FontBaseline.Superscript); // edit text style of "2\r" newTextPortions[2].getStyle().setFauxBold(true); // edit text style of "Bold" newTextPortions[3].getStyle().setFauxItalic(true); // edit text style of "Italic\r" newTextPortions[3].getStyle().setBaselineShift(-25); // edit text style of "Italic\r" newTextPortions[4].getStyle().setFontCaps(FontCaps.SmallCaps); // edit text style of "Lowercasetext" // Bind the text portions to the text layer for (ITextPortion newTextPortion : newTextPortions) { textData.addPortion(newTextPortion); } // Apply changes defined in the text portions to the text layer textData.updateLayerData(); // Save a copy of loaded PSD file including the changes on the specified path psdImage.save(outPsdFilePath); } finally { psdImage.dispose(); }
Modifier and Type | Method and Description |
---|---|
void |
apply(ITextStyle style)
Applies the specified style.
|
int |
getAutoKerning()
Gets or sets the auto kerning.
|
boolean |
getAutoLeading()
Gets or sets a value indicating whether [automatic leading].
|
double |
getBaselineShift()
The baseline shift.
|
boolean |
getContextualAlternates()
The contextual alternates used to connect letters together.
|
boolean |
getDiscretionaryLigatures()
The discretionary ligatures used to connect letters, especially in script fonts.
|
boolean |
getFauxBold()
Gets or sets the faux bold is enabled.
|
boolean |
getFauxItalic()
Gets or sets the faux bold is enabled.
|
Color |
getFillColor()
Gets or sets the color of the fill.
|
int |
getFontBaseline()
The font baseline.
|
int |
getFontCaps()
The font caps.
|
int |
getFontIndex()
Gets the font index.
|
double |
getFontSize()
Gets or sets the size of the font.
|
boolean |
getFractions()
The fractions symbols can be replaced with special glyph.
|
boolean |
getHindiNumbers()
Gets or sets a value indicating whether [hindi numbers].
|
double |
getHorizontalScale()
The horizontal scale.
|
int |
getKerning()
Gets or sets the kerning.
|
int |
getLanguageIndex()
Gets the language index.
|
double |
getLeading()
Gets or sets the leading.
|
boolean |
getStandardLigatures()
The standard contextual ligatures used to connect letters together.
|
boolean |
getStrikethrough()
Gets or sets a value indicating whether [strikethrough].
|
Color |
getStrokeColor()
Gets or sets the color of the stroke.
|
int |
getTracking()
Gets or sets the tracking.
|
boolean |
getUnderline()
Gets or sets a value indicating whether [underline].
|
double |
getVerticalScale()
The vertical scale.
|
boolean |
isEqual(ITextStyle style)
Determines whether the specified style is equal.
|
void |
setAutoKerning(int value)
Gets or sets the auto kerning.
|
void |
setAutoLeading(boolean value)
Gets or sets a value indicating whether [automatic leading].
|
void |
setBaselineShift(double value)
The baseline shift.
|
void |
setContextualAlternates(boolean value)
The contextual alternates used to connect letters together.
|
void |
setDiscretionaryLigatures(boolean value)
The discretionary ligatures used to connect letters, especially in script fonts.
|
void |
setFauxBold(boolean value)
Gets or sets the faux bold is enabled.
|
void |
setFauxItalic(boolean value)
Gets or sets the faux bold is enabled.
|
void |
setFillColor(Color value)
Gets or sets the color of the fill.
|
void |
setFontBaseline(int value)
The font baseline.
|
void |
setFontCaps(int value)
The font caps.
|
void |
setFontSize(double value)
Gets or sets the size of the font.
|
void |
setFractions(boolean value)
The fractions symbols can be replaced with special glyph.
|
void |
setHindiNumbers(boolean value)
Gets or sets a value indicating whether [hindi numbers].
|
void |
setHorizontalScale(double value)
The horizontal scale.
|
void |
setKerning(int value)
Gets or sets the kerning.
|
void |
setLeading(double value)
Gets or sets the leading.
|
void |
setStandardLigatures(boolean value)
The standard contextual ligatures used to connect letters together.
|
void |
setStrikethrough(boolean value)
Gets or sets a value indicating whether [strikethrough].
|
void |
setStrokeColor(Color value)
Gets or sets the color of the stroke.
|
void |
setTracking(int value)
Gets or sets the tracking.
|
void |
setUnderline(boolean value)
Gets or sets a value indicating whether [underline].
|
void |
setVerticalScale(double value)
The vertical scale.
|
double getFontSize()
Gets or sets the size of the font.
Value: The size of the font.void setFontSize(double value)
Gets or sets the size of the font.
Value: The size of the font.int getFontIndex()
Gets the font index.
Value: The font.boolean getAutoLeading()
Gets or sets a value indicating whether [automatic leading].
Value:true
if [automatic leading]; otherwise, false
.void setAutoLeading(boolean value)
Gets or sets a value indicating whether [automatic leading].
Value:true
if [automatic leading]; otherwise, false
.double getLeading()
Gets or sets the leading.
Value: The leading.void setLeading(double value)
Gets or sets the leading.
Value: The leading.int getTracking()
Gets or sets the tracking.
Value: The tracking.void setTracking(int value)
Gets or sets the tracking.
Value: The tracking.int getKerning()
Gets or sets the kerning.
Value: The kerning between two characters.void setKerning(int value)
Gets or sets the kerning.
Value: The kerning between two characters.int getAutoKerning()
Gets or sets the auto kerning.
Value: The auto kerning between two characters.void setAutoKerning(int value)
Gets or sets the auto kerning.
Value: The auto kerning between two characters.Color getFillColor()
Gets or sets the color of the fill.
Value: The color of the fill.void setFillColor(Color value)
Gets or sets the color of the fill.
Value: The color of the fill.Color getStrokeColor()
Gets or sets the color of the stroke.
Value: The color of the stroke.void setStrokeColor(Color value)
Gets or sets the color of the stroke.
Value: The color of the stroke.boolean getHindiNumbers()
Gets or sets a value indicating whether [hindi numbers].
Value:true
if [hindi numbers]; otherwise, false
.void setHindiNumbers(boolean value)
Gets or sets a value indicating whether [hindi numbers].
Value:true
if [hindi numbers]; otherwise, false
.boolean getFauxBold()
Gets or sets the faux bold is enabled.
void setFauxBold(boolean value)
Gets or sets the faux bold is enabled.
boolean getFauxItalic()
Gets or sets the faux bold is enabled.
void setFauxItalic(boolean value)
Gets or sets the faux bold is enabled.
boolean getUnderline()
Gets or sets a value indicating whether [underline].
void setUnderline(boolean value)
Gets or sets a value indicating whether [underline].
boolean getStrikethrough()
Gets or sets a value indicating whether [strikethrough].
void setStrikethrough(boolean value)
Gets or sets a value indicating whether [strikethrough].
int getFontBaseline()
The font baseline.
void setFontBaseline(int value)
The font baseline.
double getBaselineShift()
The baseline shift.
void setBaselineShift(double value)
The baseline shift.
int getFontCaps()
The font caps.
void setFontCaps(int value)
The font caps.
boolean getStandardLigatures()
The standard contextual ligatures used to connect letters together.
void setStandardLigatures(boolean value)
The standard contextual ligatures used to connect letters together.
boolean getDiscretionaryLigatures()
The discretionary ligatures used to connect letters, especially in script fonts.
void setDiscretionaryLigatures(boolean value)
The discretionary ligatures used to connect letters, especially in script fonts.
boolean getContextualAlternates()
The contextual alternates used to connect letters together.
void setContextualAlternates(boolean value)
The contextual alternates used to connect letters together.
int getLanguageIndex()
Gets the language index.
double getVerticalScale()
The vertical scale.
void setVerticalScale(double value)
The vertical scale.
double getHorizontalScale()
The horizontal scale.
void setHorizontalScale(double value)
The horizontal scale.
boolean getFractions()
The fractions symbols can be replaced with special glyph.
void setFractions(boolean value)
The fractions symbols can be replaced with special glyph.
void apply(ITextStyle style)
Applies the specified style.
style
- The style.boolean isEqual(ITextStyle style)
Determines whether the specified style is equal.
style
- The style.true
if the specified style is equal; otherwise, false
.