Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

Type1FontLoader.java 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /* $Id$ */
  18. package org.apache.fop.fonts.type1;
  19. import java.io.IOException;
  20. import java.io.InputStream;
  21. import org.apache.fop.fonts.FontLoader;
  22. import org.apache.fop.fonts.FontResolver;
  23. import org.apache.fop.fonts.FontType;
  24. import org.apache.fop.fonts.SingleByteFont;
  25. /**
  26. * Loads a Type 1 font into memory directly from the original font file.
  27. */
  28. public class Type1FontLoader extends FontLoader {
  29. private PFMFile pfm;
  30. private SingleByteFont singleFont;
  31. /**
  32. * Constructs a new Type 1 font loader.
  33. * @param fontFileURI the URI to the PFB file of a Type 1 font
  34. * @param in the InputStream reading the PFM file of a Type 1 font
  35. * @param resolver the font resolver used to resolve URIs
  36. * @throws IOException In case of an I/O error
  37. */
  38. public Type1FontLoader(String fontFileURI, InputStream in, FontResolver resolver)
  39. throws IOException {
  40. super(fontFileURI, in, resolver);
  41. }
  42. /**
  43. * @see FontLoader#read()
  44. */
  45. protected void read() throws IOException {
  46. pfm = new PFMFile();
  47. pfm.load(in);
  48. singleFont = new SingleByteFont();
  49. singleFont.setFontType(FontType.TYPE1);
  50. singleFont.setResolver(this.resolver);
  51. returnFont = singleFont;
  52. returnFont.setFontName(pfm.getPostscriptName());
  53. returnFont.setCapHeight(pfm.getCapHeight());
  54. returnFont.setXHeight(pfm.getXHeight());
  55. returnFont.setAscender(pfm.getLowerCaseAscent());
  56. returnFont.setDescender(pfm.getLowerCaseDescent());
  57. returnFont.setFontBBox(pfm.getFontBBox());
  58. returnFont.setFirstChar(pfm.getFirstChar());
  59. returnFont.setLastChar(pfm.getFirstChar());
  60. returnFont.setFlags(pfm.getFlags());
  61. returnFont.setStemV(pfm.getStemV());
  62. returnFont.setItalicAngle(pfm.getItalicAngle());
  63. returnFont.setMissingWidth(0);
  64. for (short i = pfm.getFirstChar(); i <= pfm.getLastChar(); i++) {
  65. singleFont.setWidth(i, pfm.getCharWidth(i));
  66. }
  67. singleFont.setEmbedFileName(this.fontFileURI);
  68. }
  69. }