1 17 18 19 20 package org.apache.fop.fonts.type1; 21 22 import java.io.IOException ; 23 import java.io.InputStream ; 24 25 import org.apache.fop.fonts.CustomFont; 26 import org.apache.fop.fonts.FontLoader; 27 import org.apache.fop.fonts.FontResolver; 28 import org.apache.fop.fonts.FontType; 29 import org.apache.fop.fonts.SingleByteFont; 30 31 34 public class Type1FontLoader extends FontLoader { 35 36 private String fontFileURI; 37 private PFMFile pfm; 38 private SingleByteFont singleFont; 39 private CustomFont returnFont; 40 private FontResolver resolver; 41 42 49 public Type1FontLoader(String fontFileURI, InputStream in, FontResolver resolver) 50 throws IOException { 51 this.fontFileURI = fontFileURI; 52 this.resolver = resolver; 53 54 pfm = new PFMFile(); 55 pfm.load(in); 56 singleFont = new SingleByteFont(); 57 singleFont.setFontType(FontType.TYPE1); 58 singleFont.setResolver(this.resolver); 59 returnFont = singleFont; 60 read(); 61 } 62 63 private void read() throws IOException { 64 returnFont.setFontName(pfm.getPostscriptName()); 65 returnFont.setCapHeight(pfm.getCapHeight()); 66 returnFont.setXHeight(pfm.getXHeight()); 67 returnFont.setAscender(pfm.getLowerCaseAscent()); 68 returnFont.setDescender(pfm.getLowerCaseDescent()); 69 returnFont.setFontBBox(pfm.getFontBBox()); 70 returnFont.setFirstChar(pfm.getFirstChar()); 71 returnFont.setLastChar(pfm.getFirstChar()); 72 returnFont.setFlags(pfm.getFlags()); 73 returnFont.setStemV(pfm.getStemV()); 74 returnFont.setItalicAngle(pfm.getItalicAngle()); 75 returnFont.setMissingWidth(0); 76 for (short i = pfm.getFirstChar(); i <= pfm.getLastChar(); i++) { 77 singleFont.setWidth(i, pfm.getCharWidth(i)); 78 } 79 singleFont.setEmbedFileName(this.fontFileURI); 80 81 } 82 83 84 public CustomFont getFont() { 85 return this.returnFont; 86 } 87 88 } 89 | Popular Tags |