Class PdfSimpleFont<T extends FontProgram>

    • Field Detail

      • forceWidthsOutput

        protected boolean forceWidthsOutput
        Forces the output of the width array. Only matters for the 14 built-in fonts.
      • usedGlyphs

        protected byte[] usedGlyphs
        The array used with single byte encodings.
      • toUnicode

        protected CMapToUnicode toUnicode
        Currently only exists for the fonts that are parsed from the document. In the future, we might provide possibility to add custom mappings after a font has been created from a font file.
    • Constructor Detail

      • PdfSimpleFont

        protected PdfSimpleFont​(PdfDictionary fontDictionary)
      • PdfSimpleFont

        protected PdfSimpleFont()
    • Method Detail

      • appendGlyphs

        public int appendGlyphs​(java.lang.String text,
                                int from,
                                int to,
                                java.util.List<Glyph> glyphs)
        Description copied from class: PdfFont
        Append all supported glyphs and return number of processed chars. Composite font supports surrogate pairs.
        Specified by:
        appendGlyphs in class PdfFont
        Parameters:
        text - String to convert to glyphs.
        from - from index of the text.
        to - to index of the text.
        glyphs - array for a new glyphs, shall not be null.
        Returns:
        number of processed chars from text.
      • appendAnyGlyph

        public int appendAnyGlyph​(java.lang.String text,
                                  int from,
                                  java.util.List<Glyph> glyphs)
        Description copied from class: PdfFont
        Append any single glyph, even notdef. Returns number of processed chars: 2 in case surrogate pair, otherwise 1.
        Specified by:
        appendAnyGlyph in class PdfFont
        Parameters:
        text - String to convert to glyphs.
        from - from index of the text.
        glyphs - array for a new glyph, shall not be null.
        Returns:
        number of processed chars: 2 in case surrogate pair, otherwise 1
      • isAppendableGlyph

        private boolean isAppendableGlyph​(Glyph glyph)
        Checks whether the glyph is appendable, i.e. has valid unicode and code values.
        Parameters:
        glyph - not-null Glyph
      • getToUnicode

        public CMapToUnicode getToUnicode()
        Get the mapping of character codes to unicode values based on /ToUnicode entry of font dictionary.
        Returns:
        the CMapToUnicode built based on /ToUnicode, or null if /ToUnicode is not available
      • convertToBytes

        public byte[] convertToBytes​(java.lang.String text)
        Description copied from class: PdfFont
        Converts the text into bytes to be placed in the document. The conversion is done according to the font and the encoding and the characters used are stored.
        Specified by:
        convertToBytes in class PdfFont
        Parameters:
        text - the text to convert
        Returns:
        the conversion
      • decodeIntoGlyphLine

        public GlyphLine decodeIntoGlyphLine​(PdfString content)
        Decodes sequence of character codes (e.g. from content stream) into a GlyphLine
        Specified by:
        decodeIntoGlyphLine in class PdfFont
        Parameters:
        content - the string which is interpreted as a sequence of character codes. Note, that PdfString acts as a storage for char code values specific to given font, therefore individual character codes must not be interpreted as code units of the UTF-16 encoding
        Returns:
        the GlyphLine containing the glyphs encoded by the passed string
      • appendDecodedCodesToGlyphsList

        public boolean appendDecodedCodesToGlyphsList​(java.util.List<Glyph> list,
                                                      PdfString characterCodes)
        Decodes sequence of character codes (e.g. from content stream) to sequence of glyphs and appends them to the passed list.
        Overrides:
        appendDecodedCodesToGlyphsList in class PdfFont
        Parameters:
        list - the list to the end of which decoded glyphs are to be added
        characterCodes - the string which is interpreted as a sequence of character codes. Note, that PdfString acts as a storage for char code values specific to given font, therefore individual character codes must not be interpreted as code units of the UTF-16 encoding
        Returns:
        true if all codes where successfully decoded, false otherwise
      • isForceWidthsOutput

        public boolean isForceWidthsOutput()
        Gets the state of the property.
        Returns:
        value of property forceWidthsOutput
      • setForceWidthsOutput

        public void setForceWidthsOutput​(boolean forceWidthsOutput)
        Set to true to force the generation of the widths array.
        Parameters:
        forceWidthsOutput - true to force the generation of the widths array
      • flushFontData

        protected void flushFontData​(java.lang.String fontName,
                                     PdfName subtype)
      • isBuiltInFont

        protected boolean isBuiltInFont()
        Indicates that the font is built in, i.e. it is one of the 14 Standard fonts
        Returns:
        true in case the font is a Standard font and false otherwise
      • getFontDescriptor

        protected PdfDictionary getFontDescriptor​(java.lang.String fontName)
        Generates the font descriptor for this font or null if it is one of the 14 built in fonts.
        Specified by:
        getFontDescriptor in class PdfFont
        Returns:
        the PdfDictionary containing the font descriptor or null.
      • buildWidthsArray

        protected PdfArray buildWidthsArray​(int firstChar,
                                            int lastChar)
      • addFontStream

        protected abstract void addFontStream​(PdfDictionary fontDescriptor)
      • setFontProgram

        protected void setFontProgram​(T fontProgram)