1 17 18 19 20 package org.apache.fop.fonts; 21 22 import org.apache.avalon.framework.ValuedEnum; 23 24 27 public class FontType extends ValuedEnum { 28 29 32 public static final FontType OTHER = new FontType("Other", 0); 33 36 public static final FontType TYPE0 = new FontType("Type0", 1); 37 40 public static final FontType TYPE1 = new FontType("Type1", 2); 41 44 public static final FontType MMTYPE1 = new FontType("MMType1", 3); 45 48 public static final FontType TYPE3 = new FontType("Type3", 4); 49 52 public static final FontType TRUETYPE = new FontType("TrueType", 5); 53 54 55 58 protected FontType(String name, int value) { 59 super(name, value); 60 } 61 62 63 68 public static FontType byName(String name) { 69 if (name.equalsIgnoreCase(FontType.OTHER.getName())) { 70 return FontType.OTHER; 71 } else if (name.equalsIgnoreCase(FontType.TYPE0.getName())) { 72 return FontType.TYPE0; 73 } else if (name.equalsIgnoreCase(FontType.TYPE1.getName())) { 74 return FontType.TYPE1; 75 } else if (name.equalsIgnoreCase(FontType.MMTYPE1.getName())) { 76 return FontType.MMTYPE1; 77 } else if (name.equalsIgnoreCase(FontType.TYPE3.getName())) { 78 return FontType.TYPE3; 79 } else if (name.equalsIgnoreCase(FontType.TRUETYPE.getName())) { 80 return FontType.TRUETYPE; 81 } else { 82 throw new IllegalArgumentException ("Invalid font type: " + name); 83 } 84 } 85 86 87 92 public static FontType byValue(int value) { 93 if (value == FontType.OTHER.getValue()) { 94 return FontType.OTHER; 95 } else if (value == FontType.TYPE0.getValue()) { 96 return FontType.TYPE0; 97 } else if (value == FontType.TYPE1.getValue()) { 98 return FontType.TYPE1; 99 } else if (value == FontType.MMTYPE1.getValue()) { 100 return FontType.MMTYPE1; 101 } else if (value == FontType.TYPE3.getValue()) { 102 return FontType.TYPE3; 103 } else if (value == FontType.TRUETYPE.getValue()) { 104 return FontType.TRUETYPE; 105 } else { 106 throw new IllegalArgumentException ("Invalid font type: " + value); 107 } 108 } 109 110 } 111 | Popular Tags |