1 7 8 22 23 package java.awt.font; 24 25 import java.awt.geom.Rectangle2D ; 26 27 90 91 public final class GlyphMetrics { 92 95 private boolean horizontal; 96 97 100 private float advanceX; 101 102 105 private float advanceY; 106 107 110 private Rectangle2D.Float bounds; 111 112 115 private byte glyphType; 116 117 121 public static final byte STANDARD = 0; 122 123 130 public static final byte LIGATURE = 1; 131 132 137 public static final byte COMBINING = 2; 138 139 147 public static final byte COMPONENT = 3; 148 149 153 public static final byte WHITESPACE = 4; 154 155 161 public GlyphMetrics(float advance, Rectangle2D bounds, byte glyphType) { 162 this.horizontal = true; 163 this.advanceX = advance; 164 this.advanceY = 0; 165 this.bounds = new Rectangle2D.Float (); 166 this.bounds.setRect(bounds); 167 this.glyphType = glyphType; 168 } 169 170 179 public GlyphMetrics(boolean horizontal, float advanceX, float advanceY, 180 Rectangle2D bounds, byte glyphType) { 181 182 this.horizontal = horizontal; 183 this.advanceX = advanceX; 184 this.advanceY = advanceY; 185 this.bounds = new Rectangle2D.Float (); 186 this.bounds.setRect(bounds); 187 this.glyphType = glyphType; 188 } 189 190 195 public float getAdvance() { 196 return horizontal ? advanceX : advanceY; 197 } 198 199 203 public float getAdvanceX() { 204 return advanceX; 205 } 206 207 211 public float getAdvanceY() { 212 return advanceY; 213 } 214 215 221 public Rectangle2D getBounds2D() { 222 return new Rectangle2D.Float (bounds.x, bounds.y, bounds.width, bounds.height); 223 } 224 225 233 public float getLSB() { 234 return horizontal ? bounds.x : bounds.y; 235 } 236 237 245 public float getRSB() { 246 return horizontal ? 247 advanceX - bounds.x - bounds.width : 248 advanceY - bounds.y - bounds.height; 249 } 250 251 255 public int getType() { 256 return glyphType; 257 } 258 259 264 public boolean isStandard() { 265 return (glyphType & 0x3) == STANDARD; 266 } 267 268 273 public boolean isLigature() { 274 return (glyphType & 0x3) == LIGATURE; 275 } 276 277 282 public boolean isCombining() { 283 return (glyphType & 0x3) == COMBINING; 284 } 285 286 291 public boolean isComponent() { 292 return (glyphType & 0x3) == COMPONENT; 293 } 294 295 300 public boolean isWhitespace() { 301 return (glyphType & 0x4) == WHITESPACE; 302 } 303 } 304 305 | Popular Tags |