1 31 package org.pdfbox.pdmodel.font; 32 33 import org.pdfbox.cos.COSArray; 34 import org.pdfbox.cos.COSBase; 35 import org.pdfbox.cos.COSDictionary; 36 import org.pdfbox.cos.COSName; 37 import org.pdfbox.cos.COSString; 38 import org.pdfbox.cos.COSStream; 39 40 import org.pdfbox.pdmodel.common.COSObjectable; 41 import org.pdfbox.pdmodel.common.PDRectangle; 42 import org.pdfbox.pdmodel.common.PDStream; 43 44 51 public class PDFontDescriptorDictionary extends PDFontDescriptor implements COSObjectable 52 { 53 private COSDictionary dic; 54 55 58 public PDFontDescriptorDictionary() 59 { 60 dic = new COSDictionary(); 61 dic.setName( "Type", "FontDescriptor" ); 62 } 63 64 69 public PDFontDescriptorDictionary( COSDictionary desc ) 70 { 71 dic = desc; 72 } 73 74 79 public COSDictionary getCOSDictionary() 80 { 81 return dic; 82 } 83 84 89 public COSBase getCOSObject() 90 { 91 return dic; 92 } 93 94 99 public String getFontName() 100 { 101 String retval = null; 102 COSName name = (COSName)dic.getDictionaryObject( COSName.getPDFName( "FontName" ) ); 103 if( name != null ) 104 { 105 retval = name.getName(); 106 } 107 return retval; 108 } 109 110 115 public void setFontName( String fontName ) 116 { 117 COSName name = null; 118 if( fontName != null ) 119 { 120 name = COSName.getPDFName( fontName ); 121 } 122 dic.setItem( COSName.getPDFName( "FontName" ), name ); 123 } 124 125 130 public String getFontFamily() 131 { 132 String retval = null; 133 COSString name = (COSString)dic.getDictionaryObject( COSName.getPDFName( "FontFamily" ) ); 134 if( name != null ) 135 { 136 retval = name.getString(); 137 } 138 return retval; 139 } 140 141 146 public void setFontFamily( String fontFamily ) 147 { 148 COSString name = null; 149 if( fontFamily != null ) 150 { 151 name = new COSString( fontFamily ); 152 } 153 dic.setItem( COSName.getPDFName( "FontFamily" ), name ); 154 } 155 156 163 public float getFontWeight() 164 { 165 return dic.getFloat( "FontWeight",0 ); 166 } 167 168 173 public void setFontWeight( float fontWeight ) 174 { 175 dic.setFloat( "FontWeight", fontWeight ); 176 } 177 178 187 public String getFontStretch() 188 { 189 String retval = null; 190 COSName name = (COSName)dic.getDictionaryObject( COSName.getPDFName( "FontStretch" ) ); 191 if( name != null ) 192 { 193 retval = name.getName(); 194 } 195 return retval; 196 } 197 198 203 public void setFontStretch( String fontStretch ) 204 { 205 COSName name = null; 206 if( fontStretch != null ) 207 { 208 name = COSName.getPDFName( fontStretch ); 209 } 210 dic.setItem( COSName.getPDFName( "FontStretch" ), name ); 211 } 212 213 218 public int getFlags() 219 { 220 return dic.getInt( "Flags", 0 ); 221 } 222 223 228 public void setFlags( int flags ) 229 { 230 dic.setInt( "Flags", flags ); 231 } 232 233 238 public PDRectangle getFontBoundingBox() 239 { 240 COSArray rect = (COSArray)dic.getDictionaryObject( COSName.getPDFName( "FontBBox" ) ); 241 PDRectangle retval = null; 242 if( rect != null ) 243 { 244 retval = new PDRectangle( rect ); 245 } 246 return retval; 247 } 248 249 254 public void setFontBoundingBox( PDRectangle rect ) 255 { 256 COSArray array = null; 257 if( rect != null ) 258 { 259 array = rect.getCOSArray(); 260 } 261 dic.setItem( COSName.getPDFName( "FontBBox" ), array ); 262 } 263 264 269 public float getItalicAngle() 270 { 271 return dic.getFloat( "ItalicAngle", 0 ); 272 } 273 274 279 public void setItalicAngle( float angle ) 280 { 281 dic.setFloat( "ItalicAngle", angle ); 282 } 283 284 289 public float getAscent() 290 { 291 return dic.getFloat( "Ascent", 0 ); 292 } 293 294 299 public void setAscent( float ascent ) 300 { 301 dic.setFloat( "Ascent", ascent ); 302 } 303 304 309 public float getDescent() 310 { 311 return dic.getFloat( "Descent", 0 ); 312 } 313 314 319 public void setDescent( float descent ) 320 { 321 dic.setFloat( "Descent", descent ); 322 } 323 324 329 public float getLeading() 330 { 331 return dic.getFloat( "Leading", 0 ); 332 } 333 334 339 public void setLeading( float leading ) 340 { 341 dic.setFloat( "Leading", leading ); 342 } 343 344 349 public float getCapHeight() 350 { 351 return dic.getFloat( "CapHeight", 0 ); 352 } 353 354 359 public void setCapHeight( float capHeight ) 360 { 361 dic.setFloat( "CapHeight", capHeight ); 362 } 363 364 369 public float getXHeight() 370 { 371 return dic.getFloat( "XHeight", 0 ); 372 } 373 374 379 public void setXHeight( float xHeight ) 380 { 381 dic.setFloat( "XHeight", xHeight ); 382 } 383 384 389 public float getStemV() 390 { 391 return dic.getFloat( "StemV", 0 ); 392 } 393 394 399 public void setStemV( float stemV ) 400 { 401 dic.setFloat( "StemV", stemV ); 402 } 403 404 409 public float getStemH() 410 { 411 return dic.getFloat( "StemH", 0 ); 412 } 413 414 419 public void setStemH( float stemH ) 420 { 421 dic.setFloat( "StemH", stemH ); 422 } 423 424 429 public float getAverageWidth() 430 { 431 return dic.getFloat( "AvgWidth", 0 ); 432 } 433 434 439 public void setAverageWidth( float averageWidth ) 440 { 441 dic.setFloat( "AvgWidth", averageWidth ); 442 } 443 444 449 public float getMaxWidth() 450 { 451 return dic.getFloat( "MaxWidth", 0 ); 452 } 453 454 459 public void setMaxWidth( float maxWidth ) 460 { 461 dic.setFloat( "MaxWidth", maxWidth ); 462 } 463 464 469 public float getMissingWidth() 470 { 471 return dic.getFloat( "MissingWidth", 0 ); 472 } 473 474 479 public void setMissingWidth( float missingWidth ) 480 { 481 dic.setFloat( "MissingWidth", missingWidth ); 482 } 483 484 489 public String getCharSet() 490 { 491 String retval = null; 492 COSString name = (COSString)dic.getDictionaryObject( COSName.getPDFName( "CharSet" ) ); 493 if( name != null ) 494 { 495 retval = name.getString(); 496 } 497 return retval; 498 } 499 500 505 public void setCharacterSet( String charSet ) 506 { 507 COSString name = null; 508 if( charSet != null ) 509 { 510 name = new COSString( charSet ); 511 } 512 dic.setItem( COSName.getPDFName( "CharSet" ), name ); 513 } 514 515 520 public PDStream getFontFile() 521 { 522 PDStream retval = null; 523 COSStream stream = (COSStream)dic.getDictionaryObject( "FontFile" ); 524 if( stream != null ) 525 { 526 retval = new PDStream( stream ); 527 } 528 return retval; 529 } 530 531 536 public void setFontFile( PDStream type1Stream ) 537 { 538 dic.setItem( "FontFile", type1Stream ); 539 } 540 541 546 public PDStream getFontFile2() 547 { 548 PDStream retval = null; 549 COSStream stream = (COSStream)dic.getDictionaryObject( "FontFile2" ); 550 if( stream != null ) 551 { 552 retval = new PDStream( stream ); 553 } 554 return retval; 555 } 556 557 562 public void setFontFile2( PDStream ttfStream ) 563 { 564 dic.setItem( "FontFile2", ttfStream ); 565 } 566 567 572 public PDStream getFontFile3() 573 { 574 PDStream retval = null; 575 COSStream stream = (COSStream)dic.getDictionaryObject( "FontFile3" ); 576 if( stream != null ) 577 { 578 retval = new PDStream( stream ); 579 } 580 return retval; 581 } 582 583 588 public void setFontFile3( PDStream stream ) 589 { 590 dic.setItem( "FontFile3", stream ); 591 } 592 } | Popular Tags |