You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by pb...@apache.org on 2004/05/20 02:07:06 UTC

cvs commit: xml-fop/src/java/org/apache/fop/render/awt FontTest.java

pbwest      2004/05/19 17:07:06

  Modified:    src/java/org/apache/fop/render/awt Tag:
                        FOP_0-20-0_Alt-Design FontTest.java
  Log:
  Font testing in Java
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.3   +75 -4     xml-fop/src/java/org/apache/fop/render/awt/Attic/FontTest.java
  
  Index: FontTest.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/awt/Attic/FontTest.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- FontTest.java	18 May 2004 23:05:26 -0000	1.1.2.2
  +++ FontTest.java	20 May 2004 00:07:06 -0000	1.1.2.3
  @@ -23,7 +23,9 @@
   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 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 @@
         //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();
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org