Class PCLTTFFontReader

    • Field Detail

      • ttfFont

        protected TTFFile ttfFont
      • fontStream

        protected java.io.InputStream fontStream
      • charOffsets

        private java.util.Map<java.lang.Integer,​int[]> charOffsets
      • charMtxOffsets

        private java.util.Map<java.lang.Integer,​java.lang.Integer> charMtxOffsets
      • FONT_WEIGHT

        private static final java.util.Map<java.lang.Integer,​java.lang.Integer> FONT_WEIGHT
      • FONT_SERIF

        private static final java.util.Map<java.lang.Integer,​java.lang.Integer> FONT_SERIF
      • FONT_WIDTH

        private static final java.util.Map<java.lang.Integer,​java.lang.Integer> FONT_WIDTH
      • scaleFactor

        private int scaleFactor
    • Constructor Detail

      • PCLTTFFontReader

        public PCLTTFFontReader​(Typeface font)
                         throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • loadFont

        protected void loadFont()
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • readFontTables

        protected void readFontTables()
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • readFontTable

        private PCLTTFTable readFontTable​(OFTableName tableName)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • convertTTFWidthClass

        private int convertTTFWidthClass​(int widthClass)
      • convertTTFWeightClass

        private int convertTTFWeightClass​(int weightClass)
      • convertFromTTFSerifStyle

        private int convertFromTTFSerifStyle()
      • getScaleFactor

        public int getScaleFactor()
                           throws java.io.IOException
        Specified by:
        getScaleFactor in class PCLFontReader
        Throws:
        java.io.IOException
      • getFontSegments

        public java.util.List<PCLFontSegment> getFontSegments​(java.util.Map<java.lang.Character,​java.lang.Integer> mappedGlyphs)
                                                       throws java.io.IOException
        Description copied from class: PCLFontReader
        Segmented Font Data
        Specified by:
        getFontSegments in class PCLFontReader
        Throws:
        java.io.IOException
      • getCharacterComplement

        private byte[] getCharacterComplement()
        See Font Header Format 11-35 (Character Complement Array) in the PCL 5 Specification. Defined as an array of 8 bytes specific to certain character sets. In this case specifying 0 for all values (default complement) means the font is compatible with any character sets. '110' on least significant bits signifies unicode. See specification for further customization.
      • getGlobalTrueTypeData

        private byte[] getGlobalTrueTypeData​(java.util.Map<java.lang.Character,​java.lang.Integer> mappedGlyphs)
                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • writeTrueTypeTable

        private void writeTrueTypeTable​(java.io.ByteArrayOutputStream baos,
                                        OFTableName table,
                                        java.util.List<PCLTTFFontReader.TableOffset> tableOffsets)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • writeGDIR

        private void writeGDIR​(java.io.ByteArrayOutputStream baos)
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • copyTables

        private java.io.ByteArrayOutputStream copyTables​(java.util.List<PCLTTFFontReader.TableOffset> tableOffsets,
                                                         java.io.ByteArrayOutputStream baos,
                                                         byte[] hmtxTable,
                                                         int hmtxSize)
                                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • updateHHEA

        private byte[] updateHHEA​(byte[] tableData,
                                  int hmtxSize)
      • updateOffsets

        private java.io.ByteArrayOutputStream updateOffsets​(java.io.ByteArrayOutputStream baos,
                                                            java.util.Map<java.lang.Integer,​byte[]> offsets)
                                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • getCharacterOffsets

        public java.util.Map<java.lang.Integer,​int[]> getCharacterOffsets()
                                                                         throws java.io.IOException
        Description copied from class: PCLFontReader
        Character Definitions
        Specified by:
        getCharacterOffsets in class PCLFontReader
        Throws:
        java.io.IOException
      • writeSubsetHMTX

        private void writeSubsetHMTX​(java.io.ByteArrayOutputStream baos,
                                     OFTableName table,
                                     java.util.List<PCLTTFFontReader.TableOffset> tableOffsets,
                                     byte[] hmtxTable)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • getCheckSum

        protected static int getCheckSum​(byte[] data,
                                         int start,
                                         int size)
      • createHmtx

        protected byte[] createHmtx​(java.util.Map<java.lang.Character,​java.lang.Integer> mappedGlyphs)
      • writeUShort

        private void writeUShort​(byte[] out,
                                 int offset,
                                 int s)
        Appends a USHORT to the output array, updates currentPost but not realSize
      • scanMtxCharacters

        public java.util.Map<java.lang.Integer,​java.lang.Integer> scanMtxCharacters()
                                                                                   throws java.io.IOException
        Specified by:
        scanMtxCharacters in class PCLFontReader
        Throws:
        java.io.IOException