From 3adcf907f0926934c74d9181be68f60c5ec43591 Mon Sep 17 00:00:00 2001 From: Peter Bernard West Date: Thu, 20 May 2004 00:07:06 +0000 Subject: [PATCH] Font testing in Java git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@197610 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/fop/render/awt/FontTest.java | 75 ++++++++++++++++++- 1 file changed, 73 insertions(+), 2 deletions(-) diff --git a/src/java/org/apache/fop/render/awt/FontTest.java b/src/java/org/apache/fop/render/awt/FontTest.java index 115acb725..a81306588 100644 --- a/src/java/org/apache/fop/render/awt/FontTest.java +++ b/src/java/org/apache/fop/render/awt/FontTest.java @@ -23,7 +23,9 @@ import java.awt.Font; import java.awt.Graphics2D; import java.awt.GraphicsEnvironment; import java.awt.font.FontRenderContext; +import java.awt.font.TextAttribute; import java.awt.image.BufferedImage; +import java.text.AttributedCharacterIterator.Attribute; import java.util.Properties; /** @@ -42,7 +44,7 @@ public class FontTest { public void setupFontInfo() { // create a temp Image to test font metrics on Properties props = System.getProperties(); - props.list(System.out); + // props.list(System.out); GraphicsEnvironment gEnv = GraphicsEnvironment.getLocalGraphicsEnvironment(); Font[] fonts = gEnv.getAllFonts(); @@ -52,8 +54,77 @@ public class FontTest { //Graphics2D g2D = fontImage.createGraphics(); Graphics2D g2D = pageSpread.createGraphics(); FontRenderContext frc = g2D.getFontRenderContext(); + for (int i = 0; i < families.length; i++) { + System.out.println(families[i]); + } + for (int i = 0; i < fonts.length; i++) { + Font f = fonts[i]; + System.out.println(f.getFontName()); + System.out.println("\tlogical:" + f.getName()); + System.out.println("\tfamily:" + f.getFamily()); + System.out.println("\tPSName:" + f.getPSName()); + System.out.println("\t" + (f.isPlain() ? "PLAIN " : " ") + + (f.isBold() ? "BOLD " : " ") + + (f.isItalic() ? "ITALIC" : " ")); + Attribute[] textAttrs = f.getAvailableAttributes(); + for (int j = 0; j < textAttrs.length; j++) { + if (textAttrs[j] instanceof TextAttribute) { + TextAttribute attr = (TextAttribute)textAttrs[j]; + if (attr == TextAttribute.BACKGROUND) { + System.out.println("\tBACKGROUND"); + } else if (attr == TextAttribute.BIDI_EMBEDDING) { + System.out.println("\tBIDI_EMBEDDING"); + } else if (attr == TextAttribute.CHAR_REPLACEMENT) { + System.out.println("\tCHAR_REPLACEMENT"); + } else if (attr == TextAttribute.FAMILY) { + System.out.println("\tFAMILY"); + } else if (attr == TextAttribute.FONT) { + System.out.println("\tFONT"); + } else if (attr == TextAttribute.FOREGROUND) { + System.out.println("\tFOREGROUND"); + } else if (attr == TextAttribute.INPUT_METHOD_HIGHLIGHT) { + System.out.println("\tINPUT_METHOD_HIGHLIGHT"); + } else if (attr == TextAttribute.INPUT_METHOD_UNDERLINE) { + System.out.println("\tINPUT_METHOD_UNDERLINE"); + } else if (attr == TextAttribute.JUSTIFICATION) { + System.out.println("\tJUSTIFICATION"); + } else if (attr == TextAttribute.NUMERIC_SHAPING) { + System.out.println("\tNUMERIC_SHAPING"); + } else if (attr == TextAttribute.POSTURE) { + System.out.println("\tPOSTURE"); + } else if (attr == TextAttribute.RUN_DIRECTION) { + System.out.println("\tRUN_DIRECTION"); + } else if (attr == TextAttribute.SIZE) { + System.out.println("\tSIZE"); + } else if (attr == TextAttribute.STRIKETHROUGH) { + System.out.println("\tSTRIKETHROUGH"); + } else if (attr == TextAttribute.SUPERSCRIPT) { + System.out.println("\tSUPERSCRIPT"); + } else if (attr == TextAttribute.SWAP_COLORS) { + System.out.println("\tSWAP_COLORS"); + } else if (attr == TextAttribute.TRANSFORM) { + System.out.println("\tTRANSFORM"); + } else if (attr == TextAttribute.UNDERLINE) { + System.out.println("\tUNDERLINE"); + } else if (attr == TextAttribute.WEIGHT) { + System.out.println("\tWEIGHT"); + } else if (attr == TextAttribute.WIDTH) { + System.out.println("\tWIDTH"); + } + } else { + Attribute attr = textAttrs[j]; + if (attr == Attribute.LANGUAGE) { + System.out.println("\tLANGUAGE"); + } else if (attr == Attribute.READING) { + System.out.println("\tREADING"); + } else if (attr == Attribute.INPUT_METHOD_SEGMENT) { + System.out.println("\tINPUT_METHOD_SEGMENT"); + } + } + } + } } - + public static void main(String[] args) { FontTest test = new FontTest(); test.setupFontInfo(); -- 2.39.5