1 4 5 9 10 package org.openlaszlo.compiler; 11 12 import org.openlaszlo.iv.flash.api.text.*; 13 14 import java.awt.geom.Rectangle2D ; 15 16 21 final class FontFamily { 22 23 private Rectangle2D [] boundsPlain = null; 24 private Rectangle2D [] boundsBold = null; 25 private Rectangle2D [] boundsItalic = null; 26 private Rectangle2D [] boundsBitalic = null; 27 28 public FontFamily() { 29 plain = null; 30 bold = null; 31 italic = null; 32 bitalic = null; 33 } 34 37 public FontFamily(Font plain, Font bold, Font italic, Font bitalic) { 38 this.plain = plain; 39 this.bold = bold; 40 this.italic = italic; 41 this.bitalic = bitalic; 42 } 43 44 47 public Font getStyle(int style) { 48 switch (style) { 49 case FontInfo.PLAIN: 50 return plain; 51 case FontInfo.BOLD: 52 return bold; 53 case FontInfo.ITALIC: 54 return italic; 55 case FontInfo.BOLDITALIC: 56 return bitalic; 57 default: 58 throw new CompilationError("Unknown style " + style); 59 } 60 } 61 62 private String getBookRecommendations() { 63 return "http://www.wetmachine.com/books.html"; 64 } 65 66 69 public Rectangle2D [] getBounds(int style) { 70 switch (style) { 71 case FontInfo.PLAIN: 72 if (plain != null && boundsPlain == null) { 73 boundsPlain = plain.getGlyphBounds(); 74 } 75 return boundsPlain; 76 case FontInfo.BOLD: 77 if (bold != null && boundsBold == null) { 78 boundsBold = bold.getGlyphBounds(); 79 } 80 return boundsBold; 81 case FontInfo.ITALIC: 82 if (italic != null && boundsItalic == null) { 83 boundsItalic = italic.getGlyphBounds(); 84 } 85 return boundsItalic; 86 case FontInfo.BOLDITALIC: 87 if (bitalic != null && boundsBitalic == null) { 88 boundsBitalic = bitalic.getGlyphBounds(); 89 } 90 return boundsBitalic; 91 default: 92 throw new CompilationError("Unknown style " + style); 93 } 94 } 95 96 97 public Font plain = null; 98 99 public Font bold = null; 100 101 public Font italic = null; 102 103 public Font bitalic = null; 104 } 105 | Popular Tags |