1 18 package org.apache.batik.gvt.font; 19 20 import org.apache.batik.util.SVGConstants; 21 22 30 public class GVTFontFace implements SVGConstants { 31 protected String familyName; 32 protected float unitsPerEm; 33 protected String fontWeight; 34 protected String fontStyle; 35 protected String fontVariant; 36 protected String fontStretch; 37 protected float slope; 38 protected String panose1; 39 protected float ascent; 40 protected float descent; 41 protected float strikethroughPosition; 42 protected float strikethroughThickness; 43 protected float underlinePosition; 44 protected float underlineThickness; 45 protected float overlinePosition; 46 protected float overlineThickness; 47 48 51 public GVTFontFace 52 (String familyName, float unitsPerEm, String fontWeight, 53 String fontStyle, String fontVariant, String fontStretch, 54 float slope, String panose1, float ascent, float descent, 55 float strikethroughPosition, float strikethroughThickness, 56 float underlinePosition, float underlineThickness, 57 float overlinePosition, float overlineThickness) { 58 this.familyName = familyName; 59 this.unitsPerEm = unitsPerEm; 60 this.fontWeight = fontWeight; 61 this.fontStyle = fontStyle; 62 this.fontVariant = fontVariant; 63 this.fontStretch = fontStretch; 64 this.slope = slope; 65 this.panose1 = panose1; 66 this.ascent = ascent; 67 this.descent = descent; 68 this.strikethroughPosition = strikethroughPosition; 69 this.strikethroughThickness = strikethroughThickness; 70 this.underlinePosition = underlinePosition; 71 this.underlineThickness = underlineThickness; 72 this.overlinePosition = overlinePosition; 73 this.overlineThickness = overlineThickness; 74 } 75 76 80 public GVTFontFace(String familyName) { 81 this(familyName, 1000, 82 SVG_FONT_FACE_FONT_WEIGHT_DEFAULT_VALUE, 83 SVG_FONT_FACE_FONT_STYLE_DEFAULT_VALUE, 84 SVG_FONT_FACE_FONT_VARIANT_DEFAULT_VALUE, 85 SVG_FONT_FACE_FONT_STRETCH_DEFAULT_VALUE, 86 0, SVG_FONT_FACE_PANOSE_1_DEFAULT_VALUE, 87 800, 200, 300, 50, -75, 50, 800, 50); 88 } 89 90 93 public String getFamilyName() { 94 return familyName; 95 } 96 97 public boolean hasFamilyName(String family) { 98 String ffname = familyName; 99 if (ffname.length() < family.length()) { 100 return false; 101 } 102 103 ffname = ffname.toLowerCase(); 104 105 int idx = ffname.indexOf(family.toLowerCase()); 106 107 if (idx == -1) { 108 return false; 109 } 110 111 if (ffname.length() > family.length()) { 113 boolean quote = false; 114 if (idx > 0) { 115 char c = ffname.charAt(idx - 1); 116 switch (c) { 117 default: 118 return false; 119 case ' ': 120 loop: for (int i = idx - 2; i >= 0; --i) { 121 switch (ffname.charAt(i)) { 122 default: 123 return false; 124 case ' ': 125 continue; 126 case '"': 127 case '\'': 128 quote = true; 129 break loop; 130 } 131 } 132 break; 133 case '"': 134 case '\'': 135 quote = true; 136 case ',': 137 } 138 } 139 if (idx + family.length() < ffname.length()) { 140 char c = ffname.charAt(idx + family.length()); 141 switch (c) { 142 default: 143 return false; 144 case ' ': 145 loop: for (int i = idx + family.length() + 1; 146 i < ffname.length(); i++) { 147 switch (ffname.charAt(i)) { 148 default: 149 return false; 150 case ' ': 151 continue; 152 case '"': 153 case '\'': 154 if (!quote) { 155 return false; 156 } 157 break loop; 158 } 159 } 160 break; 161 case '"': 162 case '\'': 163 if (!quote) { 164 return false; 165 } 166 case ',': 167 } 168 } 169 } 170 return true; 171 } 172 173 176 public String getFontWeight() { 177 return fontWeight; 178 } 179 180 183 public String getFontStyle() { 184 return fontStyle; 185 } 186 187 190 public float getUnitsPerEm() { 191 return unitsPerEm; 192 } 193 194 198 public float getAscent() { 199 return ascent; 200 } 201 202 206 public float getDescent() { 207 return descent; 208 } 209 210 213 public float getStrikethroughPosition() { 214 return strikethroughPosition; 215 } 216 217 220 public float getStrikethroughThickness() { 221 return strikethroughThickness; 222 } 223 224 227 public float getUnderlinePosition() { 228 return underlinePosition; 229 } 230 231 234 public float getUnderlineThickness() { 235 return underlineThickness; 236 } 237 238 241 public float getOverlinePosition() { 242 return overlinePosition; 243 } 244 245 248 public float getOverlineThickness() { 249 return overlineThickness; 250 } 251 } 252 | Popular Tags |