Class ArtWord

All Implemented Interfaces:
Drawer, ElementSplit, RenderPrepare

public class ArtWord extends CanvasBase
艺术字元素 本元素在Span元素的效果上增加了艺术字常见效果,,比如斜体,文字左右拉伸,文字垂直拉伸
Since:
2024/6/12
Author:
韩兴元
  • Constructor Details

  • Method Details

    • getColor

      public int[] getColor()
    • setColor

      public ArtWord setColor(int[] rgb)
      设置字体颜色
      Parameters:
      rgb - 颜色值
      Returns:
      this
    • setColor

      public ArtWord setColor(int r, int g, int b)
      设置字体颜色
      Parameters:
      r - 红
      g - 绿
      b - 懒
      Returns:
      this
    • setColor

      public ArtWord setColor(String color)
      设置字体颜色
      Parameters:
      color - 16进制颜色,如#FFFFFF
      Returns:
      this
    • length

      public int length()
      Returns:
      字符数量
    • getFont

      public Font getFont()
    • setFont

      public ArtWord setFont(Font font)
    • getFontSize

      public Double getFontSize()
    • setFontSize

      public ArtWord setFontSize(Double fontSize)
    • getLetterSpacing

      public Double getLetterSpacing()
    • setLetterSpacing

      public ArtWord setLetterSpacing(Double letterSpacing)
    • isBold

      public boolean isBold()
    • setBold

      public ArtWord setBold(boolean bold)
      设置是否加粗

      若需要更加细致的控制,可以使用 setWeight(Weight)

      Parameters:
      bold - 是否加粗
      Returns:
      this
    • getWeight

      public org.ofdrw.core.text.text.Weight getWeight()
      获取字体粗细
      Returns:
      字体粗细,可能为null。
    • setWeight

      public ArtWord setWeight(org.ofdrw.core.text.text.Weight weight)
      设置字体粗细
      Parameters:
      weight - 字体粗细
      Returns:
      this
    • isItalic

      public boolean isItalic()
    • setItalic

      public ArtWord setItalic(boolean italic)
    • isUnderline

      public boolean isUnderline()
    • setUnderline

      public ArtWord setUnderline(boolean underline)
      设置 下划线
      Parameters:
      underline - 是否启用下划线
      Returns:
      this
    • setUnderline

      public ArtWord setUnderline(boolean underline, double offset, double width)
      设置下划线
      Parameters:
      underline - 是否启用下划线
      offset - 下划线与文字的偏移量,可以为负值,默认值为1.2,单位毫米。
      width - 下划线线宽,默认为0,为0时默认为字体大小的0.05倍。
      Returns:
      this
    • getText

      public String getText()
    • setText

      public ArtWord setText(String text)
    • getOffsetY

      public double getOffsetY()
    • setOffsetY

      public void setOffsetY(double offsetY)
    • getOffsetX

      public double getOffsetX()
    • setOffsetX

      public void setOffsetX(double offsetX)
    • getVerticalInclination

      public double getVerticalInclination()
    • setVerticalInclination

      public void setVerticalInclination(double verticalInclination)
    • getHorizontalInclination

      public double getHorizontalInclination()
    • setHorizontalInclination

      public void setHorizontalInclination(double horizontalInclination)
    • getVerticalScaling

      public double getVerticalScaling()
    • setVerticalScaling

      public void setVerticalScaling(double verticalScaling)
    • getHorizontalScaling

      public double getHorizontalScaling()
    • setHorizontalScaling

      public void setHorizontalScaling(double horizontalScaling)
    • getTextAlign

      public TextAlign getTextAlign()
    • setTextAlign

      public void setTextAlign(TextAlign textAlign)
    • getUnderlineOffset

      public double getUnderlineOffset()
      获取下划线与文字的偏移量
      Returns:
      下划线与文字的偏移量,单位毫米
    • getUnderlineWidth

      public double getUnderlineWidth()
      获取下划线宽度
      Returns:
      下划线宽度, 0表示保持默认,默认为字体大小的0.05倍,单位毫米
    • getTextLayoutAlign

      public TextAlign getTextLayoutAlign()
    • setTextLayoutAlign

      public void setTextLayoutAlign(TextAlign textLayoutAlign)
    • clone

      public ArtWord clone()
      Description copied from class: Div
      克隆Div
      Overrides:
      clone in class Div<Canvas>
      Returns:
      一模一样的全新Div对象
    • draw

      public void draw(DrawContext ctx) throws IOException
      Description copied from interface: Drawer
      绘制
      Parameters:
      ctx - 绘制上下文
      Throws:
      IOException - 图片读取过程中IO异常