1 31 package org.pdfbox.pdmodel.font; 32 33 import java.io.IOException ; 34 35 import org.pdfbox.pdmodel.common.PDRectangle; 36 37 44 public abstract class PDFontDescriptor 45 { 46 49 private static final int FLAG_FIXED_PITCH = 1; 50 53 private static final int FLAG_SERIF = 2; 54 57 private static final int FLAG_SYMBOLIC = 3; 58 61 private static final int FLAG_SCRIPT = 4; 62 65 private static final int FLAG_NON_SYMBOLIC = 6; 66 69 private static final int FLAG_ITALIC = 7; 70 73 private static final int FLAG_ALL_CAP = 17; 74 77 private static final int FLAG_SMALL_CAP = 18; 78 81 private static final int FLAG_FORCE_BOLD = 19; 82 83 84 89 public abstract String getFontName(); 90 91 96 public abstract void setFontName( String fontName ); 97 98 103 public abstract String getFontFamily(); 104 105 110 public abstract void setFontFamily( String fontFamily ); 111 112 121 public abstract String getFontStretch(); 122 123 128 public abstract void setFontStretch( String fontStretch ); 129 130 137 public abstract float getFontWeight(); 138 139 144 public abstract void setFontWeight( float fontWeight ); 145 146 151 public abstract int getFlags(); 152 153 158 public abstract void setFlags( int flags ); 159 160 165 public boolean isFixedPitch() 166 { 167 return isFlagBitOn( FLAG_FIXED_PITCH ); 168 } 169 170 175 public void setFixedPitch( boolean flag ) 176 { 177 setFlagBit( FLAG_FIXED_PITCH, flag ); 178 } 179 180 185 public boolean isSerif() 186 { 187 return isFlagBitOn( FLAG_SERIF ); 188 } 189 190 195 public void setSerif( boolean flag ) 196 { 197 setFlagBit( FLAG_SERIF, flag ); 198 } 199 200 205 public boolean isSymbolic() 206 { 207 return isFlagBitOn( FLAG_SYMBOLIC ); 208 } 209 210 215 public void setSymbolic( boolean flag ) 216 { 217 setFlagBit( FLAG_SYMBOLIC, flag ); 218 } 219 220 225 public boolean isScript() 226 { 227 return isFlagBitOn( FLAG_SCRIPT ); 228 } 229 230 235 public void setScript( boolean flag ) 236 { 237 setFlagBit( FLAG_SCRIPT, flag ); 238 } 239 240 245 public boolean isNonSymbolic() 246 { 247 return isFlagBitOn( FLAG_NON_SYMBOLIC ); 248 } 249 250 255 public void setNonSymbolic( boolean flag ) 256 { 257 setFlagBit( FLAG_NON_SYMBOLIC, flag ); 258 } 259 260 265 public boolean isItalic() 266 { 267 return isFlagBitOn( FLAG_ITALIC ); 268 } 269 270 275 public void setItalic( boolean flag ) 276 { 277 setFlagBit( FLAG_ITALIC, flag ); 278 } 279 280 285 public boolean isAllCap() 286 { 287 return isFlagBitOn( FLAG_ALL_CAP); 288 } 289 290 295 public void setAllCap( boolean flag ) 296 { 297 setFlagBit( FLAG_ALL_CAP, flag ); 298 } 299 300 305 public boolean isSmallCap() 306 { 307 return isFlagBitOn( FLAG_SMALL_CAP ); 308 } 309 310 315 public void setSmallCap( boolean flag ) 316 { 317 setFlagBit( FLAG_SMALL_CAP, flag ); 318 } 319 320 325 public boolean isForceBold() 326 { 327 return isFlagBitOn( FLAG_FORCE_BOLD ); 328 } 329 330 335 public void setForceBold( boolean flag ) 336 { 337 setFlagBit( FLAG_FORCE_BOLD, flag ); 338 } 339 340 private boolean isFlagBitOn( int bit ) 341 { 342 return (getFlags() & (1 << (bit-1))) != 0; 343 } 344 345 private void setFlagBit( int bit, boolean value ) 346 { 347 int flags = getFlags(); 348 if( value ) 349 { 350 flags = flags| (1 << (bit-1)); 351 } 352 else 353 { 354 flags = flags & (0xFFFFFFFF ^ (1 << (bit-1))); 355 } 356 setFlags( flags ); 357 } 358 359 364 public abstract PDRectangle getFontBoundingBox(); 365 366 371 public abstract void setFontBoundingBox( PDRectangle rect ); 372 373 378 public abstract float getItalicAngle(); 379 380 385 public abstract void setItalicAngle( float angle ); 386 387 392 public abstract float getAscent(); 393 394 399 public abstract void setAscent( float ascent ); 400 401 406 public abstract float getDescent(); 407 408 413 public abstract void setDescent( float descent ); 414 415 420 public abstract float getLeading(); 421 422 427 public abstract void setLeading( float leading ); 428 429 434 public abstract float getCapHeight(); 435 436 441 public abstract void setCapHeight( float capHeight ); 442 443 448 public abstract float getXHeight(); 449 450 455 public abstract void setXHeight( float xHeight ); 456 457 462 public abstract float getStemV(); 463 464 469 public abstract void setStemV( float stemV ); 470 471 476 public abstract float getStemH(); 477 478 483 public abstract void setStemH( float stemH ); 484 485 494 public abstract float getAverageWidth() throws IOException ; 495 496 501 public abstract void setAverageWidth( float averageWidth ); 502 503 508 public abstract float getMaxWidth(); 509 510 515 public abstract void setMaxWidth( float maxWidth ); 516 517 522 public abstract String getCharSet(); 523 524 529 public abstract void setCharacterSet( String charSet ); 530 } | Popular Tags |