1 19 20 package jxl.write; 21 22 import jxl.write.biff.WritableFontRecord; 23 24 import jxl.format.Font; 25 import jxl.format.Colour; 26 import jxl.format.UnderlineStyle; 27 import jxl.format.ScriptStyle; 28 29 33 public class WritableFont extends WritableFontRecord 34 { 35 38 public static class FontName 39 { 40 43 String name; 44 45 50 FontName(String s) 51 { 52 name = s; 53 } 54 } 55 56 59 static class BoldStyle 60 { 61 64 public int value; 65 66 71 BoldStyle(int val) 72 { 73 value = val; 74 } 75 } 76 77 81 public static final FontName ARIAL = new FontName("Arial"); 82 86 public static final FontName TIMES = new FontName("Times New Roman"); 87 91 public static final FontName COURIER = new FontName("Courier New"); 92 96 public static final FontName TAHOMA = new FontName("Tahoma"); 97 98 100 103 public static final BoldStyle NO_BOLD = new BoldStyle(0x190); 104 107 public static final BoldStyle BOLD = new BoldStyle(0x2bc); 108 109 112 public static final int DEFAULT_POINT_SIZE = 10; 113 114 120 public WritableFont(FontName fn) 121 { 122 this(fn, 123 DEFAULT_POINT_SIZE, 124 NO_BOLD, 125 false, 126 UnderlineStyle.NO_UNDERLINE, 127 Colour.BLACK, 128 ScriptStyle.NORMAL_SCRIPT); 129 } 130 131 136 public WritableFont(Font f) 137 { 138 super(f); 139 } 140 141 148 public WritableFont(FontName fn, int ps) 149 { 150 this(fn, ps, NO_BOLD, false, 151 UnderlineStyle.NO_UNDERLINE, 152 Colour.BLACK, 153 ScriptStyle.NORMAL_SCRIPT); 154 } 155 156 163 public WritableFont(FontName fn, int ps, BoldStyle bs) 164 { 165 this(fn, ps, bs, false, 166 UnderlineStyle.NO_UNDERLINE, 167 Colour.BLACK, 168 ScriptStyle.NORMAL_SCRIPT); 169 } 170 171 180 public WritableFont(FontName fn, int ps, BoldStyle bs, boolean italic) 181 { 182 this(fn, ps, bs, italic, 183 UnderlineStyle.NO_UNDERLINE, 184 Colour.BLACK, 185 ScriptStyle.NORMAL_SCRIPT); 186 } 187 188 198 public WritableFont(FontName fn, 199 int ps, 200 BoldStyle bs, 201 boolean it, 202 UnderlineStyle us) 203 { 204 this(fn, ps, bs, it, us, Colour.BLACK, ScriptStyle.NORMAL_SCRIPT); 205 } 206 207 208 219 public WritableFont(FontName fn, 220 int ps, 221 BoldStyle bs, 222 boolean it, 223 UnderlineStyle us, 224 Colour c) 225 { 226 this(fn, ps, bs, it, us, c, ScriptStyle.NORMAL_SCRIPT); 227 } 228 229 230 243 public WritableFont(FontName fn, 244 int ps, 245 BoldStyle bs, 246 boolean it, 247 UnderlineStyle us, 248 Colour c, 249 ScriptStyle ss) 250 { 251 super(fn.name, ps, bs.value, it, 252 us.getValue(), 253 c.getValue(), ss.getValue()); 254 } 255 256 262 public void setPointSize(int pointSize) throws WriteException 263 { 264 super.setPointSize(pointSize); 265 } 266 267 273 public void setBoldStyle(BoldStyle boldStyle) throws WriteException 274 { 275 super.setBoldStyle(boldStyle.value); 276 } 277 278 285 public void setItalic(boolean italic) throws WriteException 286 { 287 super.setItalic(italic); 288 } 289 290 297 public void setUnderlineStyle(UnderlineStyle us) throws WriteException 298 { 299 super.setUnderlineStyle(us.getValue()); 300 } 301 302 309 public void setColour(Colour colour) throws WriteException 310 { 311 super.setColour(colour.getValue()); 312 } 313 314 321 public void setScriptStyle(ScriptStyle scriptStyle) throws WriteException 322 { 323 super.setScriptStyle(scriptStyle.getValue()); 324 } 325 326 334 public static FontName createFont(String fontName) 335 { 336 return new FontName(fontName); 337 } 338 339 } 340 341 | Popular Tags |