模块 java.desktop

类 GlyphVector

java.lang.Object
java.awt.font.GlyphVector
所有已实现的接口:
Cloneable

public abstract class GlyphVector extends Object implements Cloneable
GlyphVector 对象是一个字形集合,其中包含用于将每个字形放置在转换坐标空间中的几何信息,该坐标空间对应于最终显示 GlyphVector 的设备。

GlyphVector 不尝试对其包含的字形序列进行任何解释。顺序相邻字形之间的关系仅用于确定字形在视觉坐标空间中的位置。

GlyphVector 的实例由 Font 创建。

在可以缓存文本中间表示的文本处理应用程序中,GlyphVector 的创建和后续缓存以供在渲染期间使用是向用户呈现字符视觉表示的最快方法。

GlyphVector 仅与一个 Font 相关联,并且可以提供仅与此 Font 有关的有用数据。此外,从 GlyphVector 获得的指标通常不是几何可缩放的,因为像素化和间距取决于 Font 中的网格拟合算法。为了便于准确测量 GlyphVector 及其组成字形,您必须在创建 GlyphVector 时指定缩放变换、抗锯齿模式和分数度量模式。这些特性可以从目标设备中导出。

对于 GlyphVector 中的每个字形,您可以获得:

  • 字形的位置
  • 与字形关联的转换
  • GlyphVector 上下文中字形的度量。在不同的转换、应用程序指定的渲染提示和 GlyphVector 中字形的特定实例下,字形的度量可能不同。

改变用于创建 GlyphVector 的数据不会改变 GlyphVector 的状态。

提供了调整 GlyphVector 中字形位置的方法。这些方法最适合为字形的呈现执行对齐操作的应用程序。

提供了在 GlyphVector 中转换单个字形的方法。这些方法主要用于特殊效果。

提供了返回整个 GlyphVectorGlyphVector 中的单个字形的视觉、逻辑和像素边界的方法。

提供了为 GlyphVectorGlyphVector 中的各个字形返回 Shape 的方法。

参见:
  • 字段摘要

    字段
    修饰符和类型
    Field
    描述
    static final int
    与 getLayoutFlags 一起使用的标志,指示此 GlyphVector 具有复杂的字形到字符映射(不按照与运行方向匹配的严格升序或降序一对一地将字形映射到字符)。
    static final int
    与 getLayoutFlags 一起使用的标志,表示此 GlyphVector 具有位置调整。
    static final int
    与 getLayoutFlags 一起使用的标志,指示此 GlyphVector 具有每个字形转换。
    static final int
    来自 getLayoutFlags 的受支持标志的掩码。
    static final int
    与 getLayoutFlags 一起使用的标志,指示此 GlyphVector 具有从右到左的运行方向。
  • 构造方法总结

    构造方法
    修饰符
    构造方法
    描述
    protected
    子类调用的构造方法。
  • 方法总结

    修饰符和类型
    方法
    描述
    abstract boolean
    测试指定的 GlyphVector 是否完全等于这个 GlyphVector
    abstract Font
    返回与此 GlyphVector 关联的 Font
    返回与此 GlyphVector 关联的 FontRenderContext
    int
    getGlyphCharIndex(int glyphIndex)
    返回指定字形的字符索引。
    int[]
    getGlyphCharIndices(int beginGlyphIndex, int numEntries, int[] codeReturn)
    返回指定字形的字符索引。
    abstract int
    getGlyphCode(int glyphIndex)
    返回指定字形的字形代码。
    abstract int[]
    getGlyphCodes(int beginGlyphIndex, int numEntries, int[] codeReturn)
    返回指定字形的字形代码数组。
    getGlyphJustificationInfo(int glyphIndex)
    将指定索引处的字形的对齐信息返回到此 GlyphVector 中。
    abstract Shape
    getGlyphLogicalBounds(int glyphIndex)
    返回此 GlyphVector 中指定字形的逻辑边界。
    abstract GlyphMetrics
    getGlyphMetrics(int glyphIndex)
    将指定索引处的字形指标返回到此 GlyphVector 中。
    abstract Shape
    getGlyphOutline(int glyphIndex)
    返回一个 Shape ,其内部对应于此 GlyphVector 中指定字形的视觉表示。
    getGlyphOutline(int glyphIndex, float x, float y)
    返回一个 Shape ,其内部对应于此 GlyphVector 中指定字形的视觉表示,偏移到 x,y。
    getGlyphPixelBounds(int index, FontRenderContext renderFRC, float x, float y)
    当此 GlyphVector 在给定位置处具有给定 FontRenderContextGraphics 中呈现时,返回索引处字形的像素边界。
    abstract Point2D
    getGlyphPosition(int glyphIndex)
    返回指定字形相对于此 GlyphVector 原点的位置。
    abstract float[]
    getGlyphPositions(int beginGlyphIndex, int numEntries, float[] positionReturn)
    返回指定字形的字形位置数组。
    abstract AffineTransform
    getGlyphTransform(int glyphIndex)
    返回此 GlyphVector 中指定字形的转换。
    abstract Shape
    getGlyphVisualBounds(int glyphIndex)
    返回 GlyphVector 中指定字形的视觉边界。
    int
    返回描述 GlyphVector 全局状态的标志。
    abstract Rectangle2D
    返回此 GlyphVector 的逻辑边界。
    abstract int
    返回此 GlyphVector 中的字形数。
    abstract Shape
    返回一个 Shape ,其内部对应于此 GlyphVector 的视觉表示。
    abstract Shape
    getOutline(float x, float y)
    返回一个 Shape,其内部对应于此 GlyphVector 在 x、y 处呈现时的视觉表示。
    getPixelBounds(FontRenderContext renderFRC, float x, float y)
    返回在给定位置处具有给定 FontRenderContext 的图形中呈现时此 GlyphVector 的像素边界。
    abstract Rectangle2D
    返回此 GlyphVector 的视觉边界视觉边界是此 GlyphVector 轮廓的边界框。
    abstract void
    为这个 GlyphVector 中的每个字形分配默认位置。
    abstract void
    setGlyphPosition(int glyphIndex, Point2D newPos)
    在此 GlyphVector 中设置指定字形的位置。
    abstract void
    setGlyphTransform(int glyphIndex, AffineTransform newTX)
    在此 GlyphVector 中设置指定字形的变换。

    在类 java.lang.Object 中声明的方法

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 字段详细信息

    • FLAG_HAS_TRANSFORMS

      public static final int FLAG_HAS_TRANSFORMS
      与 getLayoutFlags 一起使用的标志,指示此 GlyphVector 具有每个字形转换。
      自从:
      1.4
      参见:
    • FLAG_HAS_POSITION_ADJUSTMENTS

      public static final int FLAG_HAS_POSITION_ADJUSTMENTS
      与 getLayoutFlags 一起使用的标志,表示此 GlyphVector 具有位置调整。当这是真的时,字形位置与字形的累积默认进步不匹配(例如,如果字距调整已经完成)。
      自从:
      1.4
      参见:
    • FLAG_RUN_RTL

      public static final int FLAG_RUN_RTL
      与 getLayoutFlags 一起使用的标志,指示此 GlyphVector 具有从右到左的运行方向。这是指字形到字符的映射,并不意味着字形的视觉位置必须按此顺序排列,尽管通常它们会如此。
      自从:
      1.4
      参见:
    • FLAG_COMPLEX_GLYPHS

      public static final int FLAG_COMPLEX_GLYPHS
      与 getLayoutFlags 一起使用的标志,指示此 GlyphVector 具有复杂的字形到字符映射(不按照与运行方向匹配的严格升序或降序一对一地将字形映射到字符)。
      自从:
      1.4
      参见:
    • FLAG_MASK

      public static final int FLAG_MASK
      来自 getLayoutFlags 的受支持标志的掩码。只应测试掩码重写的位。
      自从:
      1.4
      参见:
  • 构造方法详细信息

    • GlyphVector

      protected GlyphVector()
      子类调用的构造方法。
  • 方法详情

    • getFont

      public abstract Font  getFont()
      返回与此 GlyphVector 关联的 Font
      返回:
      Font 用于创建此 GlyphVector
      参见:
    • getFontRenderContext

      public abstract FontRenderContext  getFontRenderContext()
      返回与此 GlyphVector 关联的 FontRenderContext
      返回:
      FontRenderContext 用于创建此 GlyphVector
      参见:
    • performDefaultLayout

      public abstract void performDefaultLayout()
      为这个 GlyphVector 中的每个字形分配默认位置。这会破坏在这个 GlyphVector 初始布局期间生成的信息。
    • getNumGlyphs

      public abstract int getNumGlyphs()
      返回此 GlyphVector 中的字形数。
      返回:
      GlyphVector 中的字形数。
    • getGlyphCode

      public abstract int getGlyphCode(int glyphIndex)
      返回指定字形的字形代码。除了创建此 GlyphVectorFont 对象之外,此返回值对任何其他对象都没有意义。
      参数:
      glyphIndex - 此 GlyphVector 中的索引对应于从中检索字形代码的字形。
      返回:
      指定 glyphIndex 处字形的字形代码。
      抛出:
      IndexOutOfBoundsException - 如果 glyphIndex 小于 0 或大于或等于此 GlyphVector 中的字形数
    • getGlyphCodes

      public abstract int[] getGlyphCodes(int beginGlyphIndex, int numEntries, int[] codeReturn)
      返回指定字形的字形代码数组。除了用于创建此 GlyphVectorFont 之外,此返回值的内容对任何其他内容均无意义。在处理字形代码时,使用此方法是为了方便和提高性能。如果没有传入数组,则创建一个新数组。
      参数:
      beginGlyphIndex - 开始检索字形代码的 GlyphVector 的索引
      numEntries - 要检索的字形代码数
      codeReturn - 接收字形代码然后返回的数组
      返回:
      指定字形的字形代码数组。
      抛出:
      IllegalArgumentException - 如果 numEntries 小于 0
      IndexOutOfBoundsException - 如果 beginGlyphIndex 小于 0
      IndexOutOfBoundsException - 如果 beginGlyphIndexnumEntries 的总和大于此 GlyphVector 中的字形数
    • getGlyphCharIndex

      public int getGlyphCharIndex(int glyphIndex)
      返回指定字形的字符索引。字符索引是字形表示的第一个逻辑字符的索引。默认实现假定字形到字符的一对一、从左到右映射。
      参数:
      glyphIndex - 字形的索引
      返回:
      字形表示的第一个字符的索引
      自从:
      1.4
    • getGlyphCharIndices

      public int[] getGlyphCharIndices(int beginGlyphIndex, int numEntries, int[] codeReturn)
      返回指定字形的字符索引。字符索引是字形表示的第一个逻辑字符的索引。索引按字形顺序返回。默认实现为每个字形调用 getGlyphCharIndex,出于性能原因,子类化者可能希望重写此实现。在处理字形代码时使用此方法是为了方便和提高性能。如果没有传入数组,则创建一个新数组。
      参数:
      beginGlyphIndex - 第一个字形的索引
      numEntries - 字形索引的数量
      codeReturn - 返回字符索引的数组
      返回:
      一组字符索引,每个字形一个。
      自从:
      1.4
    • getLogicalBounds

      public abstract Rectangle2D  getLogicalBounds()
      返回此 GlyphVector 的逻辑边界。在将此 GlyphVector 与视觉上相邻的 GlyphVector 对象相关联时使用此方法。
      返回:
      一个 Rectangle2D 是这个 GlyphVector 的逻辑边界。
    • getVisualBounds

      public abstract Rectangle2D  getVisualBounds()
      返回此 GlyphVector 的视觉边界视觉边界是此 GlyphVector 轮廓的边界框。由于像素的光栅化和对齐,此框可能不会包含受渲染此 GlyphVector 影响的所有像素。
      返回:
      一个 Rectangle2D 是这个 GlyphVector 的边界框。
    • getPixelBounds

      public Rectangle  getPixelBounds(FontRenderContext  renderFRC, float x, float y)
      返回在给定位置处具有给定 FontRenderContext 的图形中呈现时此 GlyphVector 的像素边界。 renderFRC 不必与此 GlyphVectorFontRenderContext 相同,并且可以为空。如果为 null,则使用此 GlyphVectorFontRenderContext。默认实现返回视觉边界、x、y 的偏移量并四舍五入到下一个整数值(即返回一个包含视觉边界的整数矩形)并忽略 FRC。子类应该覆盖这个方法。
      参数:
      renderFRC - GraphicsFontRenderContext
      x - 渲染此 GlyphVector 的 x 坐标。
      y - 渲染此 GlyphVector 的 y 坐标。
      返回:
      a Rectangle 限制会受影响的像素。
      自从:
      1.4
    • getOutline

      public abstract Shape  getOutline()
      返回一个 Shape ,其内部对应于此 GlyphVector 的视觉表示。
      返回:
      Shape 是这个 GlyphVector 的轮廓。
    • getOutline

      public abstract Shape  getOutline(float x, float y)
      返回一个 Shape,其内部对应于此 GlyphVector 在 x、y 处呈现时的视觉表示。
      参数:
      x - 这个 GlyphVector 的 X 坐标。
      y - 这个 GlyphVector 的 Y 坐标。
      返回:
      一个 Shape 是这个 GlyphVector 在指定坐标处呈现时的轮廓。
    • getGlyphOutline

      public abstract Shape  getGlyphOutline(int glyphIndex)
      返回一个 Shape ,其内部对应于此 GlyphVector 中指定字形的视觉表示。此方法返回的轮廓位于每个单独字形的原点周围。
      参数:
      glyphIndex - 这个 GlyphVector 的索引
      返回:
      一个 Shape 是此 GlyphVector 的指定 glyphIndex 处的字形轮廓。
      抛出:
      IndexOutOfBoundsException - 如果 glyphIndex 小于 0 或大于或等于此 GlyphVector 中的字形数
    • getGlyphOutline

      public Shape  getGlyphOutline(int glyphIndex, float x, float y)
      返回一个 Shape ,其内部对应于此 GlyphVector 中指定字形的视觉表示,偏移到 x,y。此方法返回的轮廓位于每个单独字形的原点周围。
      参数:
      glyphIndex - 这个 GlyphVector 的索引
      x - 这个 GlyphVector 位置的 X 坐标
      y - 这个GlyphVector位置的Y坐标
      返回:
      一个 Shape 是在指定坐标处呈现时此 GlyphVector 的指定 glyphIndex 处的字形轮廓。
      抛出:
      IndexOutOfBoundsException - 如果 glyphIndex 小于 0 或大于或等于此 GlyphVector 中的字形数
      自从:
      1.4
    • getGlyphPosition

      public abstract Point2D  getGlyphPosition(int glyphIndex)
      返回指定字形相对于此 GlyphVector 原点的位置。如果 glyphIndex 等于此 GlyphVector 中的字形数,则此方法返回最后一个字形之后的位置。这个位置用来定义整个GlyphVector的前进。
      参数:
      glyphIndex - 这个 GlyphVector 的索引
      返回:
      一个 Point2D 对象,它是指定 glyphIndex 处字形的位置。
      抛出:
      IndexOutOfBoundsException - 如果 glyphIndex 小于 0 或大于此 GlyphVector 中的字形数
      参见:
    • setGlyphPosition

      public abstract void setGlyphPosition(int glyphIndex, Point2D  newPos)
      在此 GlyphVector 中设置指定字形的位置。如果 glyphIndex 等于此 GlyphVector 中的字形数,则此方法设置最后一个字形之后的位置。这个位置用来定义整个GlyphVector的前进。
      参数:
      glyphIndex - 这个 GlyphVector 的索引
      newPos - 将字形定位在指定的 glyphIndexPoint2D
      抛出:
      IndexOutOfBoundsException - 如果 glyphIndex 小于 0 或大于此 GlyphVector 中的字形数
      参见:
    • getGlyphTransform

      public abstract AffineTransform  getGlyphTransform(int glyphIndex)
      返回此 GlyphVector 中指定字形的转换。变换是相对于字形位置的。如果没有应用特殊变换,可以返回null。空返回表示身份转换。
      参数:
      glyphIndex - 这个 GlyphVector 的索引
      返回:
      一个 AffineTransform ,它是指定 glyphIndex 处字形的转换。
      抛出:
      IndexOutOfBoundsException - 如果 glyphIndex 小于 0 或大于或等于此 GlyphVector 中的字形数
      参见:
    • setGlyphTransform

      public abstract void setGlyphTransform(int glyphIndex, AffineTransform  newTX)
      在此 GlyphVector 中设置指定字形的变换。变换是相对于字形位置的。 newTXnull 参数表示没有对指定的字形应用特殊变换。此方法可用于旋转、镜像、平移和缩放字形。添加转换可能会导致显着的性能变化。
      参数:
      glyphIndex - 这个 GlyphVector 的索引
      newTX - glyphIndex 处字形的新变换
      抛出:
      IndexOutOfBoundsException - 如果 glyphIndex 小于 0 或大于或等于此 GlyphVector 中的字形数
      参见:
    • getLayoutFlags

      public int getLayoutFlags()
      返回描述 GlyphVector 全局状态的标志。下面未描述的标志是保留的。对于位置调整、转换、rtl 和复杂标志,默认实现返回 0(表示 false)。子类应该重写这个方法,并确保它正确地描述了 GlyphVector 并对应于相关调用的结果。
      返回:
      一个包含描述状态的标志的 int
      自从:
      1.4
      参见:
    • getGlyphPositions

      public abstract float[] getGlyphPositions(int beginGlyphIndex, int numEntries, float[] positionReturn)
      返回指定字形的字形位置数组。在处理字形位置时使用此方法是为了方便和提高性能。如果没有传入数组,则创建一个新数组。从位置零开始的偶数数组条目是编号为 beginGlyphIndex + position/2 的字形的 X 坐标。从位置一开始的奇数数组条目是编号为 beginGlyphIndex + (position-1)/2 的字形的 Y 坐标。如果 beginGlyphIndex 等于此 GlyphVector 中的字形数,则此方法获取最后一个字形之后的位置,该位置用于定义整个 GlyphVector 的前进。
      参数:
      beginGlyphIndex - 开始检索字形位置的索引
      numEntries - 要检索的字形数
      positionReturn - 接收字形位置然后返回的数组。
      返回:
      beginGlyphIndexnumEntries 指定的字形位置数组。
      抛出:
      IllegalArgumentException - 如果 numEntries 小于 0
      IndexOutOfBoundsException - 如果 beginGlyphIndex 小于 0
      IndexOutOfBoundsException - 如果 beginGlyphIndexnumEntries 的总和大于此 GlyphVector 中的字形数加一
    • getGlyphLogicalBounds

      public abstract Shape  getGlyphLogicalBounds(int glyphIndex)
      返回此 GlyphVector 中指定字形的逻辑边界。这些逻辑边界共有四个边,其中两个边平行于字形变换下的基线,另外两个边与相邻字形共享(如果它们存在)。此方法可用于指定字形的命中测试、将插入符号定位在字形的前缘或后缘,以及在指定字形周围绘制高亮区域。
      参数:
      glyphIndex - 此 GlyphVector 的索引对应于从中检索其逻辑边界的字形
      返回:
      Shape 是指定 glyphIndex 处字形的逻辑边界。
      抛出:
      IndexOutOfBoundsException - 如果 glyphIndex 小于 0 或大于或等于此 GlyphVector 中的字形数
      参见:
    • getGlyphVisualBounds

      public abstract Shape  getGlyphVisualBounds(int glyphIndex)
      返回 GlyphVector 中指定字形的视觉边界。此方法返回的边界位于每个单独字形的原点周围。
      参数:
      glyphIndex - 此 GlyphVector 的索引对应于从中检索其视觉边界的字形
      返回:
      Shape 是指定 glyphIndex 处字形的视觉边界。
      抛出:
      IndexOutOfBoundsException - 如果 glyphIndex 小于 0 或大于或等于此 GlyphVector 中的字形数
      参见:
    • getGlyphPixelBounds

      public Rectangle  getGlyphPixelBounds(int index, FontRenderContext  renderFRC, float x, float y)
      当此 GlyphVector 在给定位置处具有给定 FontRenderContextGraphics 中呈现时,返回索引处字形的像素边界。 renderFRC 不必与此 GlyphVectorFontRenderContext 相同,并且可以为空。如果为 null,则使用此 GlyphVectorFontRenderContext。默认实现返回字形的视觉边界,偏移到 x、y 并四舍五入到下一个整数值,并忽略 FRC。子类应该覆盖这个方法。
      参数:
      index - 字形的索引。
      renderFRC - GraphicsFontRenderContext
      x - 渲染此 GlyphVector 的 X 位置。
      y - 渲染此 GlyphVector 的 Y 位置。
      返回:
      a Rectangle 限制会受影响的像素。
      自从:
      1.4
    • getGlyphMetrics

      public abstract GlyphMetrics  getGlyphMetrics(int glyphIndex)
      将指定索引处的字形指标返回到此 GlyphVector 中。
      参数:
      glyphIndex - 此 GlyphVector 的索引对应于从中检索其指标的字形
      返回:
      一个 GlyphMetrics 对象,表示指定 glyphIndex 处的字形指标到此 GlyphVector 中。
      抛出:
      IndexOutOfBoundsException - 如果 glyphIndex 小于 0 或大于或等于此 GlyphVector 中的字形数
    • getGlyphJustificationInfo

      public abstract GlyphJustificationInfo  getGlyphJustificationInfo(int glyphIndex)
      将指定索引处的字形的对齐信息返回到此 GlyphVector 中。
      参数:
      glyphIndex - 此 GlyphVector 的索引对应于从中检索其对齐属性的字形
      返回:
      一个 GlyphJustificationInfo 对象,表示指定 glyphIndex 处字形的对齐属性到此 GlyphVector 中。
      抛出:
      IndexOutOfBoundsException - 如果 glyphIndex 小于 0 或大于或等于此 GlyphVector 中的字形数
    • equals

      public abstract boolean equals(GlyphVector  set)
      测试指定的 GlyphVector 是否完全等于这个 GlyphVector
      参数:
      set - 指定的 GlyphVector 进行测试
      返回:
      true 如果指定的 GlyphVector 等于这个 GlyphVectorfalse否则。