package sun.font;
import java.awt.Font;
import java.awt.font.FontRenderContext;
import java.awt.geom.AffineTransform;
import java.awt.geom.GeneralPath;;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
public final class CFont extends PhysicalFont {
StrikeMetrics getFontMetrics(long pScalerContext) {
throw new InternalError("Not implemented");
}
float getGlyphAdvance(long pScalerContext, int glyphCode) {
throw new InternalError("Not implemented");
}
void getGlyphMetrics(long pScalerContext, int glyphCode,
Point2D.Float metrics) {
throw new InternalError("Not implemented");
}
long getGlyphImage(long pScalerContext, int glyphCode) {
throw new InternalError("Not implemented");
}
Rectangle2D.Float getGlyphOutlineBounds(long pScalerContext,
int glyphCode) {
throw new InternalError("Not implemented");
}
GeneralPath getGlyphOutline(long pScalerContext, int glyphCode,
float x, float y) {
throw new InternalError("Not implemented");
}
GeneralPath getGlyphVectorOutline(long pScalerContext,
int[] glyphs, int numGlyphs,
float x, float y) {
throw new InternalError("Not implemented");
}
private static native long createNativeFont(final String nativeFontName,
final int style,
final boolean isFakeItalic);
private static native void disposeNativeFont(final long nativeFontPtr);
private boolean isFakeItalic;
private String nativeFontName;
private long nativeFontPtr;
public CFont(String name) {
this(name, name);
}
public CFont(String name, String inFamilyName) {
handle = new Font2DHandle(this);
fullName = name;
familyName = inFamilyName;
nativeFontName = inFamilyName;
setStyle();
}
public CFont(CFont other, String logicalFamilyName) {
handle = new Font2DHandle(this);
fullName = logicalFamilyName;
familyName = logicalFamilyName;
nativeFontName = other.nativeFontName;
style = other.style;
isFakeItalic = other.isFakeItalic;
}
public CFont createItalicVariant() {
CFont font = new CFont(this, familyName);
font.fullName =
fullName + (style == Font.BOLD ? "" : "-") + "Italic-Derived";
font.style |= Font.ITALIC;
font.isFakeItalic = true;
return font;
}
protected synchronized long getNativeFontPtr() {
if (nativeFontPtr == 0L) {
nativeFontPtr = createNativeFont(nativeFontName, style, isFakeItalic);
}
return nativeFontPtr;
}
protected synchronized void finalize() {
if (nativeFontPtr != 0) {
disposeNativeFont(nativeFontPtr);
}
nativeFontPtr = 0;
}
protected CharToGlyphMapper getMapper() {
if (mapper == null) {
mapper = new CCharToGlyphMapper(this);
}
return mapper;
}
protected FontStrike createStrike(FontStrikeDesc desc) {
if (isFakeItalic) {
desc = new FontStrikeDesc(desc);
desc.glyphTx.concatenate(AffineTransform.getShearInstance(-0.2, 0));
}
return new CStrike(this, desc);
}
private static FontRenderContext DEFAULT_FRC =
new FontRenderContext(null, false, false);
public FontStrike getStrike(final Font font) {
return getStrike(font, DEFAULT_FRC);
}
public String toString() {
return "CFont { fullName: " + fullName +
", familyName: " + familyName + ", style: " + style +
" } aka: " + super.toString();
}
}