Class PDFToUnicodeCMap.ToUnicodeCMapBuilder

    • Constructor Detail

      • ToUnicodeCMapBuilder

        public ToUnicodeCMapBuilder​(java.io.Writer writer)
    • Method Detail

      • writeCMap

        public void writeCMap()
                       throws java.io.IOException
        Writes the CMap to a Writer.
        Overrides:
        writeCMap in class CMapBuilder
        Throws:
        java.io.IOException - if an I/O error occurs
      • writeBFEntries

        protected void writeBFEntries()
                               throws java.io.IOException
        Writes the character mappings for this font.
        Overrides:
        writeBFEntries in class CMapBuilder
        Throws:
        java.io.IOException - if i/o exception
      • writeBFCharEntries

        protected void writeBFCharEntries​(char[] charArray)
                                   throws java.io.IOException
        Writes the entries for single characters of a base font (only characters which cannot be expressed as part of a character range).
        Parameters:
        charArray - all the characters to map
        Throws:
        java.io.IOException
      • padCharIndex

        private java.lang.String padCharIndex​(int charIndex)
      • writeBFRangeEntries

        protected void writeBFRangeEntries​(char[] charArray)
                                    throws java.io.IOException
        Writes the entries for character ranges for a base font.
        Parameters:
        charArray - all the characters to map
        Throws:
        java.io.IOException
      • endOfRange

        private int endOfRange​(char[] charArray,
                               int startOfRange)
        Find the end of the current range.
        Parameters:
        charArray - The array which is being tested.
        startOfRange - The index to the array element that is the start of the range.
        Returns:
        The index to the element that is the end of the range.
      • partOfRange

        private boolean partOfRange​(char[] charArray,
                                    int arrayIndex)
        Determine whether this array element should be part of a bfchar entry or a bfrange entry.
        Parameters:
        charArray - The array to be tested.
        arrayIndex - The index to the array element to be tested.
        Returns:
        True if this array element should be included in a range.
      • sameRangeEntryAsNext

        private boolean sameRangeEntryAsNext​(char[] charArray,
                                             int firstItem)
        Determine whether two bytes can be written in the same bfrange entry.
        Parameters:
        charArray - The array to be tested.
        firstItem - The first of the two items in the array to be tested. The second item is firstItem + 1.
        Returns:
        True if both 1) the next item in the array is sequential with this one, and 2) the first byte of the character in the first position is equal to the first byte of the character in the second position.
      • startOfRange

        private boolean startOfRange​(char[] charArray,
                                     int arrayIndex)
        Determine whether this array element should be the start of a bfrange entry.
        Parameters:
        charArray - The array to be tested.
        arrayIndex - The index to the array element to be tested.
        Returns:
        True if this array element is the beginning of a range.
      • padHexString

        private java.lang.String padHexString​(java.lang.String input,
                                              int numChars)
        Prepends the input string with a sufficient number of "0" characters to get the returned string to be numChars length.
        Parameters:
        input - The input string.
        numChars - The minimum characters in the output string.
        Returns:
        The padded string.