home *** CD-ROM | disk | FTP | other *** search
- package java.awt;
-
- public class Font {
- public static final int PLAIN = 0;
- public static final int BOLD = 1;
- public static final int ITALIC = 2;
- private int pData;
- private String family;
- protected String name;
- protected int style;
- protected int size;
-
- public Font(String name, int style, int size) {
- SecurityManager.setScopePermission();
- this.family = System.getProperty("awt.font." + name.toLowerCase(), name);
- this.name = name;
- this.style = style;
- this.size = size;
- }
-
- public String getFamily() {
- return this.family;
- }
-
- public String getName() {
- return this.name;
- }
-
- public int getStyle() {
- return this.style;
- }
-
- public int getSize() {
- return this.size;
- }
-
- public boolean isPlain() {
- return this.style == 0;
- }
-
- public boolean isBold() {
- return (this.style & 1) != 0;
- }
-
- public boolean isItalic() {
- return (this.style & 2) != 0;
- }
-
- public void finalize() {
- this.dispose();
- }
-
- public synchronized native void dispose();
-
- public static Font getFont(String nm) {
- return getFont(nm, (Font)null);
- }
-
- public static Font getFont(String nm, Font font) {
- String str = System.getProperty(nm);
- if (str == null) {
- return font;
- } else {
- String fontName = str;
- int fontSize = 12;
- int fontStyle = 0;
- int i = str.indexOf(45);
- if (i >= 0) {
- fontName = str.substring(0, i);
- str = str.substring(i + 1);
- if ((i = str.indexOf(45)) >= 0) {
- if (str.startsWith("bold-")) {
- fontStyle = 1;
- } else if (str.startsWith("italic-")) {
- fontStyle = 2;
- } else if (str.startsWith("bolditalic-")) {
- fontStyle = 3;
- }
-
- str = str.substring(i + 1);
- }
-
- try {
- fontSize = Integer.valueOf(str);
- } catch (NumberFormatException var7) {
- }
- }
-
- return new Font(fontName, fontStyle, fontSize);
- }
- }
-
- public int hashCode() {
- return this.name.hashCode() ^ this.style ^ this.size;
- }
-
- public boolean equals(Object obj) {
- if (obj instanceof Font) {
- Font font = (Font)obj;
- return this.size == font.size && this.style == font.style && this.name.equals(font.name);
- } else {
- return false;
- }
- }
-
- public String toString() {
- String strStyle;
- if (this.isBold()) {
- strStyle = this.isItalic() ? "bolditalic" : "bold";
- } else {
- strStyle = this.isItalic() ? "italic" : "plain";
- }
-
- return this.getClass().getName() + "[family=" + this.family + ",name=" + this.name + ",style=" + strStyle + ",size=" + this.size + "]";
- }
- }
-