Class FontSetting

java.lang.Object
org.ofdrw.layout.element.canvas.FontSetting
All Implemented Interfaces:
Cloneable, TextFontInfo

public class FontSetting extends Object implements Cloneable, TextFontInfo
字体设置
Since:
2020-05-06 18:21:02
Author:
权观宇
  • Constructor Details

    • FontSetting

      public FontSetting(double fontSize, Font fontObj)
  • Method Details

    • getInstance

      public static FontSetting getInstance()
      简化构造提供默认的字体配置

      字体类型为宋体

      Returns:
      字体配置
    • getInstance

      public static FontSetting getInstance(double fontSize)
      简化构造提供可选的字体配置

      字体类型为宋体

      Parameters:
      fontSize - 字体大小,单位:毫米(mm)
      Returns:
      字体配置
    • getTextAlign

      public TextAlign getTextAlign()
      获取文本对齐方式
      Returns:
      文本对齐方式
    • setTextAlign

      public FontSetting setTextAlign(TextAlign textAlign)
      设置文本对齐方式
      Parameters:
      textAlign - 文本对齐方式
      Returns:
      this
    • getFont

      public Font getFont()
      获取文字对象
      Specified by:
      getFont in interface TextFontInfo
      Returns:
      文字对象
    • setFont

      public FontSetting setFont(Font fontObj)
      设置文字对象
      Parameters:
      fontObj - 文字对象
      Returns:
      this
    • getFontSize

      public Double getFontSize()
      获取文字字号
      Specified by:
      getFontSize in interface TextFontInfo
      Returns:
      字号(单位毫米)
    • setFontSize

      public FontSetting setFontSize(double fontSize)
      设置文字字号
      Parameters:
      fontSize - 字号(单位毫米)
      Returns:
      this
    • isItalic

      public boolean isItalic()
      字体是否为斜体
      Returns:
      true - 斜体
    • setItalic

      public FontSetting setItalic(boolean italic)
      设置字体是否为斜体
      Parameters:
      italic - true - 斜体;false - 非斜体
      Returns:
      this
    • setBold

      public FontSetting setBold()
      设置字体为加粗格式

      宽度:800

      Returns:
      this
    • getFontWeight

      public Integer getFontWeight()
      获取字体宽度
      Returns:
      字体宽度
    • getCharDirection

      public int getCharDirection()
      获取字符方向
      Returns:
      字符方向
    • setCharDirection

      public FontSetting setCharDirection(int charDirection)
      设置字符方向
      Parameters:
      charDirection - 字符方向(charDirection) 允许值:0、90、180、270
      Returns:
      this
    • getReadDirection

      public int getReadDirection()
      获取阅读方向
      Returns:
      阅读方向
    • getLetterSpacing

      public Double getLetterSpacing()
      获取字间距
      Specified by:
      getLetterSpacing in interface TextFontInfo
      Returns:
      字间距,单位毫米mm,默认值0
    • setLetterSpacing

      public FontSetting setLetterSpacing(double letterSpacing)
      设置字间距

      如果字间距小于0,那么将会自动修正为0

      Parameters:
      letterSpacing - 字间距,单位毫米mm
      Returns:
      this
    • setReadDirection

      public FontSetting setReadDirection(int readDirection)
      设置阅读方向
      Parameters:
      readDirection - 设置阅读方向(charDirection) 允许值:0、90、180、270
      Returns:
      this
    • setFontWeight

      public FontSetting setFontWeight(Integer fontWeight)
      设置字体宽度
      Parameters:
      fontWeight - 字体宽度,可选值:100、200、300、400、500、600、700、800、900
      Returns:
      this
    • charWidth

      public Double charWidth(char c)
      字符宽度
      Parameters:
      c - 字符
      Returns:
      宽度单位毫米
    • box

      public Rectangle2D box(char c)
      返回文字所占空间
      Parameters:
      c - 文字
      Returns:
      文字所占空间
    • clone

      public FontSetting clone()
      Overrides:
      clone in class Object