-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAsgmTextFormatFactory.java
More file actions
48 lines (48 loc) · 1.61 KB
/
AsgmTextFormatFactory.java
File metadata and controls
48 lines (48 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package awpsoft.gamemodule;
import java.awt.Font;
import java.io.File;
public class AsgmTextFormatFactory
{
public Font createTextFormat(String nameorPath, float fontSize)
{
return createFont(nameorPath, fontSize, false, false);
}
public Font createTextFormat(String nameorPath, float fontSize, boolean bold)
{
return createFont(nameorPath, fontSize, bold, false);
}
public Font createTextFormat(String nameorPath, float fontSize, boolean bold , boolean italic)
{
return createFont(nameorPath, fontSize, bold, italic);
}
public static Font createFont(String nameorPath, float fontSize)
{
return createFont(nameorPath, fontSize, false, false);
}
public static Font createFont(String nameorPath, float fontSize, boolean bold)
{
return createFont(nameorPath, fontSize, bold, false);
}
public static Font createFont(String nameorPath, float fontSize, boolean bold , boolean italic)
{
Font f;
try
{
f = Font.createFont(0, new File(nameorPath)).deriveFont(fontSize);
}
catch(Exception ex)
{
f = Font.decode(nameorPath).deriveFont(fontSize);
}
int style = Font.PLAIN;
if(bold) style |= Font.BOLD;
if(italic) style |= Font.ITALIC;
if(style == 0) return f;
else return f.deriveFont(style);
}
public static boolean isDefaultFont(Font font)
{
return font.getFamily().equals("Dialog") || font.getName().equals("Dialog");
}
public boolean isDefaultTextFormat(Font font) {return isDefaultFont(font);}
};