KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openlaszlo > compiler > FontManager


1 /*****************************************************************************
2  * FontManager.java
3  * ****************************************************************************/

4
5 /* J_LZ_COPYRIGHT_BEGIN *******************************************************
6 * Copyright 2001-2004 Laszlo Systems, Inc. All Rights Reserved. *
7 * Use is subject to license terms. *
8 * J_LZ_COPYRIGHT_END *********************************************************/

9
10 package org.openlaszlo.compiler;
11
12 import org.openlaszlo.sc.ScriptCompiler;
13 import org.openlaszlo.server.LPS;
14 import org.openlaszlo.utils.FileUtils;
15 import org.openlaszlo.utils.ChainedException;
16 import org.openlaszlo.iv.flash.api.*;
17 import org.openlaszlo.iv.flash.api.action.*;
18 import org.openlaszlo.iv.flash.api.image.*;
19 import org.openlaszlo.iv.flash.api.sound.*;
20 import org.openlaszlo.iv.flash.api.text.*;
21 import org.openlaszlo.iv.flash.util.*;
22 import org.openlaszlo.iv.flash.cache.*;
23
24 import org.openlaszlo.compiler.CompilationEnvironment;
25
26 import org.openlaszlo.media.*;
27
28 import java.io.*;
29 import java.util.*;
30 import java.lang.Math JavaDoc;
31 import java.lang.Character JavaDoc;
32
33 // jgen 1.4
34
import java.awt.geom.Rectangle2D JavaDoc;
35
36 import org.apache.log4j.*;
37
38
39
40 public class FontManager {
41     /** Font name map */
42     private final Hashtable mFontTable = new Hashtable();
43         
44     public FontFamily getFontFamily(String JavaDoc fontName) {
45         if (fontName == null) return null;
46         return (FontFamily) mFontTable.get(fontName);
47     }
48         
49     public FontFamily getFontFamily(String JavaDoc fontName, boolean create) {
50         FontFamily family = (FontFamily) mFontTable.get(fontName);
51         if (family == null && create) {
52             family = new FontFamily();
53             mFontTable.put(fontName, family);
54         }
55         return family;
56     }
57         
58     public Enumeration getNames() {
59         return mFontTable.keys();
60     }
61
62     public boolean checkFontExists (FontInfo fontInfo) {
63         String JavaDoc fontName = fontInfo.getName();
64         int size = fontInfo.getSize();
65         int style = fontInfo.styleBits;
66         FontFamily family = getFontFamily(fontName);
67         if (family == null) {
68             return false;
69         }
70         Font font = family.getStyle(style);
71         if (font == null) {
72             return false;
73         }
74         return true;
75     }
76
77 }
78
Popular Tags