1 31 package org.pdfbox.pdmodel.font; 32 33 import java.awt.Graphics ; 34 35 import org.pdfbox.cos.COSArray; 36 import org.pdfbox.cos.COSDictionary; 37 import org.pdfbox.cos.COSName; 38 import org.pdfbox.pdmodel.common.PDRectangle; 39 40 import java.io.IOException ; 41 42 48 public class PDType0Font extends PDFont 49 { 50 53 public PDType0Font() 54 { 55 super(); 56 font.setItem( COSName.SUBTYPE, COSName.getPDFName( "Type0" ) ); 57 } 58 59 64 public PDType0Font( COSDictionary fontDictionary ) 65 { 66 super( fontDictionary ); 67 } 68 69 72 public void drawString( String string, Graphics g, float fontSize, 73 float xScale, float yScale, float x, float y ) 74 { 75 throw new RuntimeException ( "Not yet implemented" ); 76 } 77 78 85 public PDRectangle getFontBoundingBox() throws IOException 86 { 87 throw new RuntimeException ( "Not yet implemented" ); 88 } 89 90 101 public float getFontWidth( byte[] c, int offset, int length ) throws IOException 102 { 103 COSArray descendantFontArray = 104 (COSArray)font.getDictionaryObject( COSName.getPDFName( "DescendantFonts" ) ); 105 106 COSDictionary descendantFontDictionary = (COSDictionary)descendantFontArray.getObject( 0 ); 107 PDFont descendentFont = PDFontFactory.createFont( descendantFontDictionary ); 108 109 return descendentFont.getFontWidth( c, offset, length ); 110 } 111 112 123 public float getFontHeight( byte[] c, int offset, int length ) throws IOException 124 { 125 COSArray descendantFontArray = 126 (COSArray)font.getDictionaryObject( COSName.getPDFName( "DescendantFonts" ) ); 127 128 COSDictionary descendantFontDictionary = (COSDictionary)descendantFontArray.getObject( 0 ); 129 PDFont descendentFont = PDFontFactory.createFont( descendantFontDictionary ); 130 131 return descendentFont.getFontHeight( c, offset, length ); 132 } 133 134 141 public float getAverageFontWidth() throws IOException 142 { 143 COSArray descendantFontArray = 144 (COSArray)font.getDictionaryObject( COSName.getPDFName( "DescendantFonts" ) ); 145 146 COSDictionary descendantFontDictionary = (COSDictionary)descendantFontArray.getObject( 0 ); 147 PDFont descendentFont = PDFontFactory.createFont( descendantFontDictionary ); 148 149 return descendentFont.getAverageFontWidth(); 150 } 151 } | Popular Tags |