1
4
5 import org.aswing.ASTextFormat;
6 import org.aswing.utils.HashMap;
7
8
12 class org.aswing.ASFont{
13
14
17 public static var DEFAULT_NAME:String = "Arial";
18 public static var DEFAULT_SIZE:Number = 12;
19
20
21
24 private var fontName:String;
25 private var fontSize:Number;
26
27
30 private var fontBold:Boolean;
31 private var fontItalic:Boolean;
32 private var fontUnderline:Boolean;
33
34 private var embedFonts:Boolean;
35
36
37
41 public function ASFont(_name:String , _size:Number , _bold:Boolean , _italic:Boolean , _underline:Boolean, _embedFonts:Boolean){
42 this.setName(_name);
43 this.setSize(_size);
44 this.setBold(_bold);
45 this.setItalic(_italic);
46 this.setUnderline(_underline);
47 this.setEmbedFonts(_embedFonts);
48 }
49
50 public static function getASFont(_name:String , _size:Number):ASFont{
51 return new ASFont(_name , _size , false , false , false, false);
52 }
53
54 public static function getASFontFromASTextFormat(ASTF:ASTextFormat):ASFont{
55 return ASTF.getASFont();
56 }
57
58
59
60 private function setName(_name:String):Void{
61 if(_name == null){
62 this.fontName = ASFont.DEFAULT_NAME;
63 }else{
64 this.fontName = _name;
65 }
66 }
67
68 public function getName():String{
69 return this.fontName;
70 }
71
72 private function setSize(_size:Number):Void{
73 if(_size == null){
74 this.fontSize = ASFont.DEFAULT_SIZE;
75 }else{
76 this.fontSize = _size;
77 }
78 }
79
80 public function getSize():Number{
81 return this.fontSize;
82 }
83
84 private function setBold(_bold:Boolean):Void{
85 this.fontBold = _bold;
86 if(this.fontBold == null){
87 this.fontBold = false;
88 }
89 }
90
91 public function getBold():Boolean{
92 return this.fontBold;
93 }
94
95 private function setItalic(_italic:Boolean):Void{
96 this.fontItalic = _italic;
97 if(this.fontItalic == null){
98 this.fontItalic = false;
99 }
100 }
101
102 public function getItalic():Boolean{
103 return this.fontItalic;
104 }
105
106 private function setUnderline(_underline:Boolean):Void{
107 this.fontUnderline = _underline;
108 if(this.fontUnderline == null){
109 this.fontUnderline = false;
110 }
111 }
112
113 public function getUnderline():Boolean{
114 return this.fontUnderline;
115 }
116
117 public function setEmbedFonts(b:Boolean):Void{
118 if(b == undefined) b = false;
119 embedFonts = b;
120 }
121
122 public function getEmbedFonts():Boolean{
123 return embedFonts;
124 }
125
126
129 public function getFeatures():HashMap{
130 var features:HashMap = new HashMap();
131 features.put("bold" , this.getBold());
132 features.put("italic" , this.getItalic());
133 features.put("underline" , this.getUnderline());
134 features.put("embedFonts" , this.getEmbedFonts());
135 return features;
136 }
137
138 public function getASTextFormat():ASTextFormat{
139 var ASTF:ASTextFormat = ASTextFormat.getEmptyASTextFormat();
140 ASTF.setASFont(this);
141 return ASTF;
142 }
143
144 public function toString():String{
145 return "ASFont[name:" + fontName
146 + ", size:" + fontSize
147 + ", bold:" + fontBold
148 + ", italic:" + fontItalic
149 + ", underline:" + fontUnderline
150 + ", embedFonts:" + embedFonts + "]";
151 }
152
153 }
154