1 50 51 package com.lowagie.text; 52 53 import java.awt.Color ; 54 import java.util.Properties ; 55 import java.util.Set ; 56 57 import com.lowagie.text.pdf.BaseFont; 58 59 66 67 public class FontFactory { 68 69 70 public static final String COURIER = BaseFont.COURIER; 71 72 73 public static final String COURIER_BOLD = BaseFont.COURIER_BOLD; 74 75 76 public static final String COURIER_OBLIQUE = BaseFont.COURIER_OBLIQUE; 77 78 79 public static final String COURIER_BOLDOBLIQUE = BaseFont.COURIER_BOLDOBLIQUE; 80 81 82 public static final String HELVETICA = BaseFont.HELVETICA; 83 84 85 public static final String HELVETICA_BOLD = BaseFont.HELVETICA_BOLD; 86 87 88 public static final String HELVETICA_OBLIQUE = BaseFont.HELVETICA_OBLIQUE; 89 90 91 public static final String HELVETICA_BOLDOBLIQUE = BaseFont.HELVETICA_BOLDOBLIQUE; 92 93 94 public static final String SYMBOL = BaseFont.SYMBOL; 95 96 97 public static final String TIMES = "Times"; 98 99 100 public static final String TIMES_ROMAN = BaseFont.TIMES_ROMAN; 101 102 103 public static final String TIMES_BOLD = BaseFont.TIMES_BOLD; 104 105 106 public static final String TIMES_ITALIC = BaseFont.TIMES_ITALIC; 107 108 109 public static final String TIMES_BOLDITALIC = BaseFont.TIMES_BOLDITALIC; 110 111 112 public static final String ZAPFDINGBATS = BaseFont.ZAPFDINGBATS; 113 114 private static FontFactoryImp fontImp = new FontFactoryImp(); 115 116 117 public static String defaultEncoding = BaseFont.WINANSI; 118 119 120 public static boolean defaultEmbedding = BaseFont.NOT_EMBEDDED; 121 122 123 private FontFactory() { 124 } 125 126 137 138 public static Font getFont(String fontname, String encoding, boolean embedded, float size, int style, Color color) { 139 return fontImp.getFont(fontname, encoding, embedded, size, style, color); 140 } 141 142 155 156 public static Font getFont(String fontname, String encoding, boolean embedded, float size, int style, Color color, boolean cached) { 157 return fontImp.getFont(fontname, encoding, embedded, size, style, color, cached); 158 } 159 160 166 167 public static Font getFont(Properties attributes) { 168 fontImp.defaultEmbedding = defaultEmbedding; 169 fontImp.defaultEncoding = defaultEncoding; 170 return fontImp.getFont(attributes); 171 } 172 173 183 184 public static Font getFont(String fontname, String encoding, boolean embedded, float size, int style) { 185 return getFont(fontname, encoding, embedded, size, style, null); 186 } 187 188 197 198 public static Font getFont(String fontname, String encoding, boolean embedded, float size) { 199 return getFont(fontname, encoding, embedded, size, Font.UNDEFINED, null); 200 } 201 202 210 211 public static Font getFont(String fontname, String encoding, boolean embedded) { 212 return getFont(fontname, encoding, embedded, Font.UNDEFINED, Font.UNDEFINED, null); 213 } 214 215 225 226 public static Font getFont(String fontname, String encoding, float size, int style, Color color) { 227 return getFont(fontname, encoding, defaultEmbedding, size, style, color); 228 } 229 230 239 240 public static Font getFont(String fontname, String encoding, float size, int style) { 241 return getFont(fontname, encoding, defaultEmbedding, size, style, null); 242 } 243 244 252 253 public static Font getFont(String fontname, String encoding, float size) { 254 return getFont(fontname, encoding, defaultEmbedding, size, Font.UNDEFINED, null); 255 } 256 257 264 265 public static Font getFont(String fontname, String encoding) { 266 return getFont(fontname, encoding, defaultEmbedding, Font.UNDEFINED, Font.UNDEFINED, null); 267 } 268 269 278 279 public static Font getFont(String fontname, float size, int style, Color color) { 280 return getFont(fontname, defaultEncoding, defaultEmbedding, size, style, color); 281 } 282 283 291 292 public static Font getFont(String fontname, float size, int style) { 293 return getFont(fontname, defaultEncoding, defaultEmbedding, size, style, null); 294 } 295 296 303 304 public static Font getFont(String fontname, float size) { 305 return getFont(fontname, defaultEncoding, defaultEmbedding, size, Font.UNDEFINED, null); 306 } 307 308 314 315 public static Font getFont(String fontname) { 316 return getFont(fontname, defaultEncoding, defaultEmbedding, Font.UNDEFINED, Font.UNDEFINED, null); 317 } 318 319 325 public void registerFamily(String familyName, String fullName, String path) { 326 fontImp.registerFamily(familyName, fullName, path); 327 } 328 329 334 335 public static void register(String path) { 336 register(path, null); 337 } 338 339 345 346 public static void register(String path, String alias) { 347 fontImp.register(path, alias); 348 } 349 350 354 public static int registerDirectory(String dir) { 355 return fontImp.registerDirectory(dir); 356 } 357 358 362 public static int registerDirectories() { 363 return fontImp.registerDirectories(); 364 } 365 366 370 371 public static Set getRegisteredFonts() { 372 return fontImp.getRegisteredFonts(); 373 } 374 375 379 380 public static Set getRegisteredFamilies() { 381 return fontImp.getRegisteredFamilies(); 382 } 383 384 389 390 public static boolean contains(String fontname) { 391 return fontImp.isRegistered(fontname); 392 } 393 394 400 401 public static boolean isRegistered(String fontname) { 402 return fontImp.isRegistered(fontname); 403 } 404 405 409 public static FontFactoryImp getFontImp() { 410 return fontImp; 411 } 412 413 417 public static void setFontImp(FontFactoryImp fontImp) { 418 if (fontImp == null) 419 throw new NullPointerException ("FontFactoryImp cannot be null."); 420 FontFactory.fontImp = fontImp; 421 } 422 } | Popular Tags |