java.lang.Object
java.awt.font.GlyphVector
- 所有已实现的接口:
-
Cloneable
一个
GlyphVector对象是包含每个字形在转换坐标空间中的几何信息的字形集合,该坐标空间对应于最终显示GlyphVector的设备。
GlyphVector不会尝试解释其包含的字形序列。序列中相邻字形之间的关系仅用于确定字形在视觉坐标空间中的放置。
GlyphVector的实例是由Font创建的。
在一个可以缓存文本中间表示的文本处理应用程序中,为了在呈现过程中最快地向用户呈现字符的视觉表示,创建并缓存GlyphVector是最快的方法。
GlyphVector与一个Font关联,并且只能提供与这个Font相关的有用数据。此外,从GlyphVector获取的度量通常不是几何可伸缩的,因为像素化和间距取决于Font内的网格拟合算法。为了准确测量GlyphVector及其组成字形,必须在创建GlyphVector时指定缩放变换、抗锯齿模式和分数度量模式。这些特性可以从目标设备中派生。
对于GlyphVector中的每个字形,您可以获取:
- 字形的位置
- 与字形关联的变换
- 字形在
GlyphVector上下文中的度量。字形的度量在不同的变换、应用指定的渲染提示和GlyphVector中的特定字形实例下可能不同。
更改用于创建GlyphVector的数据不会更改GlyphVector的状态。
提供了用于调整GlyphVector中字形位置的方法。这些方法最适合于执行对齐操作以呈现字形。
提供了用于转换GlyphVector中单个字形的方法。这些方法主要用于特殊效果。
提供了返回整个GlyphVector或GlyphVector中单个字形的视觉、逻辑和像素边界的方法。
提供了返回GlyphVector的Shape以及GlyphVector中单个字形的方法。
- 参见:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int与getLayoutFlags一起使用的标志,指示此GlyphVector具有复杂的字形到字符映射(不是严格按照升序或降序匹配运行方向将字形映射到字符)。static final int与getLayoutFlags一起使用的标志,指示此GlyphVector具有位置调整。static final int与getLayoutFlags一起使用的标志,指示此GlyphVector具有每个字形的变换。static final int从getLayoutFlags获取支持的标志的掩码。static final int与getLayoutFlags一起使用的标志,指示此GlyphVector具有从右到左的运行方向。 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract booleanequals(GlyphVector set) 测试指定的GlyphVector是否与此GlyphVector完全相等。abstract FontgetFont()返回与此GlyphVector关联的Font。abstract FontRenderContext返回与此GlyphVector关联的FontRenderContext。intgetGlyphCharIndex(int glyphIndex) 返回指定字形的字符索引。int[]getGlyphCharIndices(int beginGlyphIndex, int numEntries, int[] codeReturn) 返回指定字形的字符索引。abstract intgetGlyphCode(int glyphIndex) 返回指定字形的字形代码。abstract int[]getGlyphCodes(int beginGlyphIndex, int numEntries, int[] codeReturn) 返回指定字形的字形代码数组。abstract GlyphJustificationInfogetGlyphJustificationInfo(int glyphIndex) 返回此GlyphVector中指定索引处的字形的对齐信息。abstract ShapegetGlyphLogicalBounds(int glyphIndex) 返回此GlyphVector中指定字形的逻辑边界。abstract GlyphMetricsgetGlyphMetrics(int glyphIndex) 返回此GlyphVector中指定索引处的字形的度量。abstract ShapegetGlyphOutline(int glyphIndex) 返回一个Shape,其内部对应于此GlyphVector中指定字形的视觉表示。getGlyphOutline(int glyphIndex, float x, float y) 返回一个Shape,其内部对应于此GlyphVector中指定字形的视觉表示,偏移至x,y。getGlyphPixelBounds(int index, FontRenderContext renderFRC, float x, float y) 当在具有给定FontRenderContext的Graphics中以给定位置呈现此GlyphVector时,返回索引处的字形的像素边界。abstract Point2DgetGlyphPosition(int glyphIndex) 返回指定字形相对于此GlyphVector原点的位置。abstract float[]getGlyphPositions(int beginGlyphIndex, int numEntries, float[] positionReturn) 返回指定字形的字形位置数组。abstract AffineTransformgetGlyphTransform(int glyphIndex) 返回此GlyphVector中指定字形的变换。abstract ShapegetGlyphVisualBounds(int glyphIndex) 返回GlyphVector中指定字形的视觉边界。int返回描述GlyphVector全局状态的标志。abstract Rectangle2D返回此GlyphVector的逻辑边界。abstract int返回此GlyphVector中的字形数。abstract Shape返回一个Shape,其内部对应于此GlyphVector的视觉表示。abstract ShapegetOutline(float x, float y) 返回一个Shape,其内部对应于在x,y处呈现此GlyphVector的视觉表示。getPixelBounds(FontRenderContext renderFRC, float x, float y) 返回在具有给定FontRenderContext的图形中以给定位置呈现此GlyphVector时的像素边界。abstract Rectangle2D返回此GlyphVector的视觉边界。视觉边界是此GlyphVector轮廓的边界框。abstract void为此GlyphVector中的每个字形分配默认位置。abstract voidsetGlyphPosition(int glyphIndex, Point2D newPos) 设置此GlyphVector中指定字形的位置。abstract voidsetGlyphTransform(int glyphIndex, AffineTransform newTX) 设置此GlyphVector中指定字形的变换。
-
Field Details
-
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具有位置调整。当为true时,字形位置与字形的累积默认前进不匹配(例如,如果进行了字距调整)。- 自:
- 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
- 参见:
-
-
Constructor Details
-
GlyphVector
protected GlyphVector()子类调用的构造函数。
-
-
Method Details
-
getFont
返回与此GlyphVector关联的Font。- 返回:
-
用于创建此
GlyphVector的Font。 - 参见:
-
getFontRenderContext
返回与此GlyphVector关联的FontRenderContext。- 返回:
-
用于创建此
GlyphVector的FontRenderContext。 - 参见:
-
performDefaultLayout
public abstract void performDefaultLayout()为此GlyphVector中的每个字形分配默认位置。这可能会破坏在创建此GlyphVector的初始布局期间生成的信息。 -
getNumGlyphs
public abstract int getNumGlyphs()返回此GlyphVector中的字形数。- 返回:
-
此
GlyphVector中的字形数。
-
getGlyphCode
public abstract int getGlyphCode(int glyphIndex) 返回指定字形的字形代码。此返回值对于创建此GlyphVector的Font对象之外的任何内容都是无意义的。- 参数:
-
glyphIndex- 对应于要检索其字形代码的字形的此GlyphVector中的索引。 - 返回:
-
指定
glyphIndex处字形的字形代码。 - 抛出:
-
IndexOutOfBoundsException- 如果glyphIndex小于 0 或大于等于此GlyphVector中的字形数
-
getGlyphCodes
public abstract int[] getGlyphCodes(int beginGlyphIndex, int numEntries, int[] codeReturn) 返回指定字形的字形代码数组。此返回值的内容对于创建此GlyphVector的Font以外的任何内容都是无意义的。此方法用于在处理字形代码时提供方便和性能。如果未传入数组,则会创建一个新数组。- 参数:
-
beginGlyphIndex- 开始检索字形代码的此GlyphVector中的索引 -
numEntries- 要检索的字形代码数 -
codeReturn- 接收字形代码并然后返回的数组 - 返回:
- 指定字形的字形代码数组。
- 抛出:
-
IllegalArgumentException- 如果numEntries小于 0 -
IndexOutOfBoundsException- 如果beginGlyphIndex小于 0 -
IndexOutOfBoundsException- 如果beginGlyphIndex和numEntries的总和大于此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
返回此GlyphVector的逻辑边界。在将此GlyphVector定位相对于视觉上相邻的其他GlyphVector对象时使用此方法。- 返回:
-
是此
GlyphVector的逻辑边界的Rectangle2D。
-
getVisualBounds
返回此GlyphVector的视觉边界。视觉边界是此GlyphVector轮廓的边界框。由于栅格化和像素对齐,可能导致此框不包围呈现此GlyphVector的所有受影响像素。- 返回:
-
是此
GlyphVector的边界框的Rectangle2D。
-
getPixelBounds
在给定位置的图形上下文中使用给定的FontRenderContext渲染时,返回此GlyphVector的像素边界。renderFRC 不需要与此GlyphVector的FontRenderContext相同,可以为 null。如果为 null,则使用此GlyphVector的FontRenderContext。默认实现返回视觉边界,偏移为 x、y 并四舍五入到下一个整数值(即返回一个整数矩形,包围视觉边界)并忽略 FRC。子类应该覆盖此方法。- 参数:
-
renderFRC-Graphics的FontRenderContext。 -
x- 渲染此GlyphVector的 x 坐标。 -
y- 渲染此GlyphVector的 y 坐标。 - 返回:
-
包围将受影响像素的像素的
Rectangle。 - 自:
- 1.4
-
getOutline
返回一个Shape,其内部对应于此GlyphVector的视觉表示。- 返回:
-
是此
GlyphVector的轮廓的Shape。
-
getOutline
返回一个Shape,其内部对应于在 x、y 处呈现此GlyphVector的视觉表示。- 参数:
-
x- 此GlyphVector的 X 坐标。 -
y- 此GlyphVector的 Y 坐标。 - 返回:
-
是在指定坐标处呈现此
GlyphVector的轮廓的Shape。
-
getGlyphOutline
返回一个Shape,其内部对应于此GlyphVector中指定字形的视觉表示。此方法返回的轮廓围绕每个单独字形的原点定位。- 参数:
-
glyphIndex- 这个GlyphVector中的索引 - 返回:
-
是此
GlyphVector中指定glyphIndex处字形的轮廓的Shape。 - 抛出:
-
IndexOutOfBoundsException- 如果glyphIndex小于 0 或大于等于此GlyphVector中的字形数
-
getGlyphOutline
返回一个Shape,其内部对应于此GlyphVector中指定字形的视觉表示,偏移为 x、y。此方法返回的轮廓围绕每个单独字形的原点定位。- 参数:
-
glyphIndex- 这个GlyphVector中的索引 -
x- 此GlyphVector位置的 X 坐标 -
y- 此GlyphVector位置的 Y 坐标 - 返回:
-
是在指定坐标处呈现此
GlyphVector中指定glyphIndex处字形的轮廓的Shape。 - 抛出:
-
IndexOutOfBoundsException- 如果glyphIndex小于 0 或大于等于此GlyphVector中的字形数 - 自:
- 1.4
-
getGlyphPosition
返回指定字形相对于此GlyphVector原点的位置。如果glyphIndex等于此GlyphVector中的字形数,则此方法返回最后一个字形之后的位置。此位置用于定义整个GlyphVector的前进。- 参数:
-
glyphIndex- 这个GlyphVector中的索引 - 返回:
-
是指定
glyphIndex处字形的位置的Point2D对象。 - 抛出:
-
IndexOutOfBoundsException- 如果glyphIndex小于 0 或大于等于此GlyphVector中的字形数 - 参见:
-
setGlyphPosition
设置此GlyphVector中指定字形的位置。如果glyphIndex等于此GlyphVector中的字形数,则此方法设置最后一个字形之后的位置。此位置用于定义整个GlyphVector的前进。- 参数:
-
glyphIndex- 这个GlyphVector中的索引 -
newPos- 要设置为指定glyphIndex处字形位置的Point2D - 抛出:
-
IndexOutOfBoundsException- 如果glyphIndex小于 0 或大于等于此GlyphVector中的字形数 - 参见:
-
getGlyphTransform
返回此GlyphVector中指定字形的变换。变换是相对于字形位置的。如果未应用任何特殊变换,则可以返回null。null 返回表示一个恒等变换。- 参数:
-
glyphIndex- 这个GlyphVector中的索引 - 返回:
-
一个
AffineTransform,表示指定glyphIndex处的字形的变换。 - 抛出:
-
IndexOutOfBoundsException- 如果glyphIndex小于0或大于等于此GlyphVector中的字形数 - 参见:
-
setGlyphTransform
设置此GlyphVector中指定字形的变换。变换是相对于字形位置的。对于newTX的null参数表示不对指定字形应用特殊变换。此方法可用于旋转、镜像、平移和缩放字形。添加变换可能导致性能变化。- 参数:
-
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- 接收字形位置并然后返回的数组 - 返回:
-
由
beginGlyphIndex和numEntries指定的字形位置数组 - 抛出:
-
IllegalArgumentException- 如果numEntries小于0 -
IndexOutOfBoundsException- 如果beginGlyphIndex小于0 -
IndexOutOfBoundsException- 如果beginGlyphIndex和numEntries的总和大于此GlyphVector中的字形数加一
-
getGlyphLogicalBounds
返回此GlyphVector中指定字形的逻辑边界。这些逻辑边界共有四个边缘,其中两个边缘与字形的变换下的基线平行,另外两个边缘与相邻字形共享(如果存在)。此方法对于测试指定字形、在字形的前导或尾随边缘放置插入符号以及在指定字形周围绘制高亮区域很有用。- 参数:
-
glyphIndex- 对应于要检索其逻辑边界的字形的GlyphVector中的索引 - 返回:
-
一个
Shape,表示指定glyphIndex处字形的逻辑边界 - 抛出:
-
IndexOutOfBoundsException- 如果glyphIndex小于0或大于等于此GlyphVector中的字形数 - 参见:
-
getGlyphVisualBounds
返回GlyphVector中指定字形的视觉边界。此方法返回的边界围绕每个单独字形的原点定位。- 参数:
-
glyphIndex- 对应于要检索其视觉边界的字形的GlyphVector中的索引 - 返回:
-
一个
Shape,表示指定glyphIndex处字形的视觉边界 - 抛出:
-
IndexOutOfBoundsException- 如果glyphIndex小于0或大于等于此GlyphVector中的字形数 - 参见:
-
getGlyphPixelBounds
在给定位置使用给定FontRenderContext的Graphics渲染此GlyphVector时,返回索引处字形的像素边界。renderFRC不需要与此GlyphVector的FontRenderContext相同,可以为null。如果为null,则使用此GlyphVector的FontRenderContext。默认实现返回字形的视觉边界,偏移为x,y并四舍五入为下一个整数值,并忽略FRC。子类应重写此方法。- 参数:
-
index- 字形的索引 -
renderFRC-Graphics的FontRenderContext -
x- 渲染此GlyphVector的X位置 -
y- 渲染此GlyphVector的Y位置 - 返回:
-
一个包围受影响像素的
Rectangle - 自:
- 1.4
-
getGlyphMetrics
返回此GlyphVector中指定索引处字形的度量。- 参数:
-
glyphIndex- 对应于要检索其度量的字形的GlyphVector中的索引 - 返回:
-
一个
GlyphMetrics对象,表示此GlyphVector中指定glyphIndex处字形的度量 - 抛出:
-
IndexOutOfBoundsException- 如果glyphIndex小于0或大于等于此GlyphVector中的字形数
-
getGlyphJustificationInfo
返回此GlyphVector中指定索引处字形的调整信息。- 参数:
-
glyphIndex- 对应于要检索其调整属性的字形的GlyphVector中的索引 - 返回:
-
一个
GlyphJustificationInfo对象,表示此GlyphVector中指定glyphIndex处字形的调整属性 - 抛出:
-
IndexOutOfBoundsException- 如果glyphIndex小于0或大于等于此GlyphVector中的字形数
-
equals
测试指定的GlyphVector是否与此GlyphVector完全相等。- 参数:
-
set- 要测试的指定GlyphVector - 返回:
-
如果指定的
GlyphVector等于此GlyphVector,则返回true;否则返回false
-