Packages

 

com.aspose.psd.fileformats.psd.layers.text

Interface ITextStyle



  • public interface ITextStyle

    Interface to work with Text Style

    Code example:

    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();
    }
    

    • Method Detail

      • getFontSize

        double getFontSize()

        Gets or sets the size of the font.

        Value: The size of the font.
      • setFontSize

        void setFontSize(double value)

        Gets or sets the size of the font.

        Value: The size of the font.
      • getFontIndex

        int getFontIndex()

        Gets the font index.

        Value: The font.
      • getAutoLeading

        boolean getAutoLeading()

        Gets or sets a value indicating whether [automatic leading].

        Value: true if [automatic leading]; otherwise, false.
      • setAutoLeading

        void setAutoLeading(boolean value)

        Gets or sets a value indicating whether [automatic leading].

        Value: true if [automatic leading]; otherwise, false.
      • getLeading

        double getLeading()

        Gets or sets the leading.

        Value: The leading.
      • setLeading

        void setLeading(double value)

        Gets or sets the leading.

        Value: The leading.
      • getTracking

        int getTracking()

        Gets or sets the tracking.

        Value: The tracking.
      • setTracking

        void setTracking(int value)

        Gets or sets the tracking.

        Value: The tracking.
      • getKerning

        int getKerning()

        Gets or sets the kerning.

        Value: The kerning between two characters.
      • setKerning

        void setKerning(int value)

        Gets or sets the kerning.

        Value: The kerning between two characters.
      • getAutoKerning

        int getAutoKerning()

        Gets or sets the auto kerning.

        Value: The auto kerning between two characters.
      • setAutoKerning

        void setAutoKerning(int value)

        Gets or sets the auto kerning.

        Value: The auto kerning between two characters.
      • getFillColor

        Color getFillColor()

        Gets or sets the color of the fill.

        Value: The color of the fill.
      • setFillColor

        void setFillColor(Color value)

        Gets or sets the color of the fill.

        Value: The color of the fill.
      • getStrokeColor

        Color getStrokeColor()

        Gets or sets the color of the stroke.

        Value: The color of the stroke.
      • setStrokeColor

        void setStrokeColor(Color value)

        Gets or sets the color of the stroke.

        Value: The color of the stroke.
      • getHindiNumbers

        boolean getHindiNumbers()

        Gets or sets a value indicating whether [hindi numbers].

        Value: true if [hindi numbers]; otherwise, false.
      • setHindiNumbers

        void setHindiNumbers(boolean value)

        Gets or sets a value indicating whether [hindi numbers].

        Value: true if [hindi numbers]; otherwise, false.
      • getFauxBold

        boolean getFauxBold()

        Gets or sets the faux bold is enabled.

      • setFauxBold

        void setFauxBold(boolean value)

        Gets or sets the faux bold is enabled.

      • getFauxItalic

        boolean getFauxItalic()

        Gets or sets the faux bold is enabled.

      • setFauxItalic

        void setFauxItalic(boolean value)

        Gets or sets the faux bold is enabled.

      • getUnderline

        boolean getUnderline()

        Gets or sets a value indicating whether [underline].

      • setUnderline

        void setUnderline(boolean value)

        Gets or sets a value indicating whether [underline].

      • getStrikethrough

        boolean getStrikethrough()

        Gets or sets a value indicating whether [strikethrough].

      • setStrikethrough

        void setStrikethrough(boolean value)

        Gets or sets a value indicating whether [strikethrough].

      • getFontBaseline

        int getFontBaseline()

        The font baseline.

      • setFontBaseline

        void setFontBaseline(int value)

        The font baseline.

      • getBaselineShift

        double getBaselineShift()

        The baseline shift.

      • setBaselineShift

        void setBaselineShift(double value)

        The baseline shift.

      • getFontCaps

        int getFontCaps()

        The font caps.

      • setFontCaps

        void setFontCaps(int value)

        The font caps.

      • getStandardLigatures

        boolean getStandardLigatures()

        The standard contextual ligatures used to connect letters together.

      • setStandardLigatures

        void setStandardLigatures(boolean value)

        The standard contextual ligatures used to connect letters together.

      • getDiscretionaryLigatures

        boolean getDiscretionaryLigatures()

        The discretionary ligatures used to connect letters, especially in script fonts.

      • setDiscretionaryLigatures

        void setDiscretionaryLigatures(boolean value)

        The discretionary ligatures used to connect letters, especially in script fonts.

      • getContextualAlternates

        boolean getContextualAlternates()

        The contextual alternates used to connect letters together.

      • setContextualAlternates

        void setContextualAlternates(boolean value)

        The contextual alternates used to connect letters together.

      • getLanguageIndex

        int getLanguageIndex()

        Gets the language index.

      • getVerticalScale

        double getVerticalScale()

        The vertical scale.

      • setVerticalScale

        void setVerticalScale(double value)

        The vertical scale.

      • getHorizontalScale

        double getHorizontalScale()

        The horizontal scale.

      • setHorizontalScale

        void setHorizontalScale(double value)

        The horizontal scale.

      • getFractions

        boolean getFractions()

        The fractions symbols can be replaced with special glyph.

      • setFractions

        void setFractions(boolean value)

        The fractions symbols can be replaced with special glyph.

      • apply

        void apply(ITextStyle style)

        Applies the specified style.

        Parameters:
        style - The style.
      • isEqual

        boolean isEqual(ITextStyle style)

        Determines whether the specified style is equal.

        Parameters:
        style - The style.
        Returns:
        true if the specified style is equal; otherwise, false.