home *** CD-ROM | disk | FTP | other *** search
- package java.awt;
-
- import java.awt.peer.FontPeer;
- import java.io.IOException;
- import java.io.ObjectInputStream;
- import java.io.ObjectOutputStream;
- import java.io.Serializable;
-
- public class Font implements Serializable {
- public static final int PLAIN = 0;
- public static final int BOLD = 1;
- public static final int ITALIC = 2;
- private transient int pData;
- private transient String family;
- protected String name;
- protected int style;
- protected int size;
- transient FontPeer peer;
- private static final long serialVersionUID = -4206021311591459213L;
- private int fontSerializedDataVersion = 1;
-
- public FontPeer getPeer() {
- return this.peer;
- }
-
- private void initializeFont() {
- this.family = System.getProperty("awt.font." + this.name.toLowerCase(), this.name);
- this.peer = Toolkit.getDefaultToolkit().getFontPeer(this.name, this.style);
- }
-
- public Font(String var1, int var2, int var3) {
- this.name = var1;
- this.style = var2;
- this.size = var3;
- this.initializeFont();
- }
-
- 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 static Font getFont(String var0) {
- return getFont(var0, (Font)null);
- }
-
- public static Font decode(String var0) {
- String var1 = var0;
- int var2 = 12;
- byte var3 = 0;
- int var4 = var0.indexOf(45);
- if (var4 >= 0) {
- var1 = var0.substring(0, var4);
- var0 = var0.substring(var4 + 1);
- if ((var4 = var0.indexOf(45)) >= 0) {
- if (var0.startsWith("bold-")) {
- var3 = 1;
- } else if (var0.startsWith("italic-")) {
- var3 = 2;
- } else if (var0.startsWith("bolditalic-")) {
- var3 = 3;
- }
-
- var0 = var0.substring(var4 + 1);
- }
-
- try {
- var2 = Integer.valueOf(var0);
- } catch (NumberFormatException var5) {
- }
- }
-
- return new Font(var1, var3, var2);
- }
-
- public static Font getFont(String var0, Font var1) {
- String var2 = System.getProperty(var0);
- return var2 == null ? var1 : decode(var2);
- }
-
- public int hashCode() {
- return this.name.hashCode() ^ this.style ^ this.size;
- }
-
- public boolean equals(Object var1) {
- if (var1 instanceof Font) {
- Font var2 = (Font)var1;
- return this.size == var2.size && this.style == var2.style && this.name.equals(var2.name);
- } else {
- return false;
- }
- }
-
- public String toString() {
- String var1;
- if (this.isBold()) {
- var1 = this.isItalic() ? "bolditalic" : "bold";
- } else {
- var1 = this.isItalic() ? "italic" : "plain";
- }
-
- return this.getClass().getName() + "[family=" + this.family + ",name=" + this.name + ",style=" + var1 + ",size=" + this.size + "]";
- }
-
- private void writeObject(ObjectOutputStream var1) throws ClassNotFoundException, IOException {
- var1.defaultWriteObject();
- }
-
- private void readObject(ObjectInputStream var1) throws ClassNotFoundException, IOException {
- var1.defaultReadObject();
- this.initializeFont();
- }
- }
-