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 code points can be included in the same bfrange entry. Range sizes are limited to a maximum of 256 (128 for surrogate pairs).
        Parameters:
        charArray - The array holding the code points to be tested.
        firstItem - The first char of the first code point in the array to be tested. The first byte of the second code point is firstItem + n, where n is the number of chars in the firstItem code point.
        Returns:
        True if both: 1) the next code point in the array is sequential with this one, and 2) this code point and the next are both NOT surrogate pairs or this code point and the next are both surrogate pairs and the high-surrogates are the same, and 3) the resulting range cannot be greater than 256 in size.
      • 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.