compositeglyph.java
来自「纯java操作系统jnode,安装简单和操作简单的个人使用的Java操作系统」· Java 代码 · 共 83 行
JAVA
83 行
/*
* $Id: CompositeGlyph.java,v 1.1 2003/11/25 11:51:38 epr Exp $
*/
package org.jnode.awt.font.truetype;
import java.awt.geom.AffineTransform;
import java.awt.geom.GeneralPath;
import java.io.IOException;
public class CompositeGlyph extends Glyph {
private static final int ARGS_WORDS = 0;
private static final int ARGS_XY = 1;
private static final int SCALE = 3;
private static final int XY_SCALE = 6;
private static final int TWO_BY_TWO = 7;
private static final int MORE_COMPONENTS = 5;
private GeneralPath shape;
private int noComponents;
private final TTFGlyphTable table;
public CompositeGlyph(TTFGlyphTable table) {
this.table = table;
}
public String getType() {
return "Composite Glyph";
}
public GeneralPath getShape() {
return shape;
}
public void read(TTFInput ttf) throws IOException {
super.read(ttf);
shape = new GeneralPath();
noComponents = 0;
boolean more = true;
while (more) {
noComponents++;
ttf.readUShortFlags();
more = ttf.flagBit(MORE_COMPONENTS);
int glyphIndex = ttf.readUShort();
int arg1, arg2;
if (ttf.flagBit(ARGS_WORDS)) {
arg1 = ttf.readShort();
arg2 = ttf.readShort();
} else {
arg1 = ttf.readChar();
arg2 = ttf.readChar();
}
AffineTransform t = new AffineTransform();
if (ttf.flagBit(ARGS_XY)) {
t.translate(arg1, arg2);
} else {
System.err.println("TTFGlyfTable: ARGS_ARE_POINTS not implemented.");
}
if (ttf.flagBit(SCALE)) {
double scale = ttf.readF2Dot14();
t.scale(scale, scale);
} else if (ttf.flagBit(XY_SCALE)) {
double scaleX = ttf.readF2Dot14();
double scaleY = ttf.readF2Dot14();
t.scale(scaleX, scaleY);
} else if (ttf.flagBit(TWO_BY_TWO)) {
System.err.println("TTFGlyfTable: WE_HAVE_A_TWO_BY_TWO not implemented.");
}
GeneralPath appendGlyph = (GeneralPath) table.getGlyph(glyphIndex).getShape().clone();
appendGlyph.transform(t);
shape.append(appendGlyph, false);
}
}
public String toString() {
return super.toString() + ", " + noComponents + " components";
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?