1 31 package org.pdfbox.util.operator; 32 33 import java.util.List ; 34 35 import org.pdfbox.cos.COSName; 36 import org.pdfbox.cos.COSNumber; 37 import org.pdfbox.pdmodel.font.PDFont; 38 import org.pdfbox.util.PDFOperator; 39 40 import java.io.IOException ; 41 42 52 53 public class SetTextFont extends OperatorProcessor 54 { 55 61 public void process(PDFOperator operator, List arguments) throws IOException 62 { 63 if( arguments.size() >= 2 ) 67 { 68 COSName fontName = (COSName)arguments.get( 0 ); 70 float fontSize = ((COSNumber)arguments.get( 1 ) ).floatValue(); 71 context.getGraphicsState().getTextState().setFontSize( fontSize ); 72 73 context.getGraphicsState().getTextState().setFont( (PDFont)context.getFonts().get( fontName.getName() ) ); 81 if( context.getGraphicsState().getTextState().getFont() == null ) 82 { 83 throw new IOException ( "Error: Could not find font(" + fontName + ") in map=" + context.getFonts() ); 84 } 85 } 86 } 87 88 } 89 | Popular Tags |