You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PCLFontReader.java 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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.render.pcl.fonts;
  19. import java.io.IOException;
  20. import java.util.List;
  21. import java.util.Map;
  22. import org.apache.fop.fonts.CustomFont;
  23. import org.apache.fop.fonts.Typeface;
  24. import org.apache.fop.fonts.truetype.FontFileReader;
  25. import org.apache.fop.fonts.truetype.OpenFont;
  26. public abstract class PCLFontReader {
  27. protected Typeface typeface;
  28. protected PCLByteWriterUtil pclByteWriter;
  29. protected CustomFont font;
  30. public PCLFontReader(Typeface font, PCLByteWriterUtil pclByteWriter) {
  31. this.typeface = font;
  32. this.pclByteWriter = pclByteWriter;
  33. }
  34. public void setFont(CustomFont mbFont) {
  35. this.font = mbFont;
  36. }
  37. /** Header Data **/
  38. public abstract int getDescriptorSize();
  39. public abstract int getHeaderFormat();
  40. public abstract int getFontType();
  41. public abstract int getStyleMSB();
  42. public abstract int getBaselinePosition();
  43. public abstract int getCellWidth();
  44. public abstract int getCellHeight();
  45. public abstract int getOrientation();
  46. public abstract int getSpacing();
  47. public abstract int getSymbolSet();
  48. public abstract int getPitch();
  49. public abstract int getHeight();
  50. public abstract int getXHeight();
  51. public abstract int getWidthType();
  52. public abstract int getStyleLSB();
  53. public abstract int getStrokeWeight();
  54. public abstract int getTypefaceLSB();
  55. public abstract int getTypefaceMSB();
  56. public abstract int getSerifStyle();
  57. public abstract int getQuality();
  58. public abstract int getPlacement();
  59. public abstract int getUnderlinePosition();
  60. public abstract int getUnderlineThickness();
  61. public abstract int getTextHeight();
  62. public abstract int getTextWidth();
  63. public abstract int getFirstCode();
  64. public abstract int getLastCode();
  65. public abstract int getPitchExtended();
  66. public abstract int getHeightExtended();
  67. public abstract int getCapHeight();
  68. public abstract int getFontNumber();
  69. public abstract String getFontName();
  70. public abstract int getScaleFactor() throws IOException;
  71. public abstract int getMasterUnderlinePosition() throws IOException;
  72. public abstract int getMasterUnderlineThickness() throws IOException;
  73. public abstract int getFontScalingTechnology();
  74. public abstract int getVariety();
  75. /** Segmented Font Data **/
  76. public abstract List<PCLFontSegment> getFontSegments(Map<Character, Integer> mappedGlyphs)
  77. throws IOException;
  78. /** Character Definitions **/
  79. public abstract Map<Integer, int[]> getCharacterOffsets() throws IOException;
  80. public abstract OpenFont getFontFile();
  81. public abstract FontFileReader getFontFileReader();
  82. /**
  83. * Gets the most significant byte from a 16-bit integer
  84. * @param s The number
  85. * @return The resulting byte value as an integer
  86. */
  87. protected int getMSB(int s) {
  88. return s >> 8;
  89. }
  90. /**
  91. * Gets the least significant byte from a 16-bit integer
  92. * @param s The number
  93. * @return The resulting byte value as an integer
  94. */
  95. protected int getLSB(int s) {
  96. byte b1 = (byte) (s >> 8);
  97. return s;
  98. }
  99. }