Class PDFontDescriptor


  • public class PDFontDescriptor
    extends PDObject
    Represents font descriptor.
    Author:
    Sergey Shemyakov
    • Constructor Detail

      • PDFontDescriptor

        public PDFontDescriptor​(COSObject obj)
        Constructor from font descriptor COSObject.
        Parameters:
        obj - is descriptor COSObject.
    • Method Detail

      • getFlags

        public Long getFlags()
        Returns:
        a collection of flags defining various characteristics of the font.
      • getFontName

        public ASAtom getFontName()
        Returns:
        the PostScript name of the font.
      • getFontFamily

        public String getFontFamily()
        Returns:
        a byte string specifying the preferred font family name.
      • getFontStretch

        public ASAtom getFontStretch()
        Returns:
        the font stretch value.
      • getFontWeight

        public Double getFontWeight()
        Returns:
        the weight (thickness) component of the fully-qualified font name or font specifier.
      • isFixedPitch

        public boolean isFixedPitch()
        Returns:
        true if all glyphs have the same width.
      • isSerif

        public boolean isSerif()
        Returns:
        true if glyphs have serifs, which are short strokes drawn at an angle on the top and bottom of glyph stems.
      • isSymbolic

        public boolean isSymbolic()
        Returns:
        true if font contains glyphs outside the Adobe standard Latin character set.
      • isScript

        public boolean isScript()
        Returns:
        true if glyphs resemble cursive handwriting.
      • isNonsymbolic

        public boolean isNonsymbolic()
        Returns:
        true if font uses the Adobe standard Latin character set or a subset of it.
      • isItalic

        public boolean isItalic()
        Returns:
        true if glyphs have dominant vertical strokes that are slanted.
      • isAllCap

        public boolean isAllCap()
        Returns:
        true if font contains no lowercase letters; typically used for display purposes, such as for titles or headlines.
      • isSmallCap

        public boolean isSmallCap()
        Returns:
        true if font contains both uppercase and lowercase letters.
      • isForceBold

        public boolean isForceBold()
        Returns:
        true if bold glyphs shall be painted with extra pixels even at very small text sizes by a conforming reader.
      • getFontBoundingBox

        public double[] getFontBoundingBox()
        Returns:
        a rectangle, expressed in the glyph coordinate system, that shall specify the font bounding box.
      • getItalicAngle

        public Double getItalicAngle()
        Returns:
        the angle, expressed in degrees counterclockwise from the vertical, of the dominant vertical strokes of the font.
      • getAscent

        public Double getAscent()
        Returns:
        the maximum height above the baseline reached by glyphs in this font.
      • getDescent

        public Double getDescent()
        Returns:
        the maximum depth below the baseline reached by glyphs in this font.
      • getLeading

        public Double getLeading()
        Returns:
        the spacing between baselines of consecutive lines of text.
      • getCapHeight

        public Double getCapHeight()
        Returns:
        the vertical coordinate of the top of flat capital letters, measured from the baseline.
      • getXHeight

        public Double getXHeight()
        Returns:
        the font’s x height: the vertical coordinate of the top of flat nonascending lowercase letters (like the letter x), measured from the baseline, in fonts that have Latin characters.
      • getStemV

        public Double getStemV()
        Returns:
        the thickness, measured horizontally, of the dominant vertical stems of glyphs in the font.
      • getStemH

        public Double getStemH()
        Returns:
        the thickness, measured vertically, of the dominant horizontal stems of glyphs in the font.
      • getAvgWidth

        public Double getAvgWidth()
        Returns:
        the average width of glyphs in the font.
      • getMaxWidth

        public Double getMaxWidth()
        Returns:
        the maximum width of glyphs in the font.
      • getMissingWidth

        public Double getMissingWidth()
        Returns:
        the width to use for character codes whose widths are not specified in a font dictionary’s Widths array.
      • getCharSet

        public String getCharSet()
        Returns:
        a string listing the character names defined in a font subset.
      • getFontFile

        public COSStream getFontFile()
        Returns:
        a stream containing a Type 1 font program.
      • getFontFile2

        public COSStream getFontFile2()
        Returns:
        a stream containing a TrueType font program.
      • getFontFile3

        public COSStream getFontFile3()
        Returns:
        a stream containing a font program whose format is specified by the Subtype entry in the stream dictionary.
      • canParseFontFile

        public boolean canParseFontFile​(ASAtom key)
        Checks if specific font program can be read from this font descriptor.
        Parameters:
        key - is key of font program in font descriptor dictionary, e.g. FontFile or FontFile2.
        Returns:
        true if value with this key exists and is a COSStream.
      • setFontName

        public void setFontName​(ASAtom fontName)
      • setFontFamily

        public void setFontFamily​(String fontFamily)
      • setFontStretch

        public void setFontStretch​(ASAtom fontStretch)
      • setFontWeight

        public void setFontWeight​(Double fontWeight)
      • setFixedPitch

        public void setFixedPitch​(Boolean fixedPitch)
      • setSerif

        public void setSerif​(Boolean serif)
      • setSymbolic

        public void setSymbolic​(Boolean symbolic)
      • setScript

        public void setScript​(Boolean script)
      • setNonSymblic

        public void setNonSymblic​(Boolean nonSymblic)
      • setItalic

        public void setItalic​(Boolean italic)
      • setAllCap

        public void setAllCap​(Boolean allCap)
      • setSmallCup

        public void setSmallCup​(Boolean smallCup)
      • setForceBold

        public void setForceBold​(Boolean forceBold)
      • setFontBoundingBox

        public void setFontBoundingBox​(double[] fontBoundingBox)
      • setItalicAngle

        public void setItalicAngle​(Double italicAngle)
      • setAscent

        public void setAscent​(Double ascent)
      • setDescent

        public void setDescent​(Double descent)
      • setLeading

        public void setLeading​(Double leading)
      • setCapHeight

        public void setCapHeight​(Double capHeight)
      • setxHeight

        public void setxHeight​(Double xHeight)
      • setStemV

        public void setStemV​(Double stemV)
      • setStemH

        public void setStemH​(Double stemH)
      • setAvgWidth

        public void setAvgWidth​(Double avgWidth)
      • setMaxWidth

        public void setMaxWidth​(Double maxWidth)
      • setMissingWidth

        public void setMissingWidth​(Double missingWidth)
      • setCharSet

        public void setCharSet​(String charSet)
      • getDescriptorFromMetrics

        public static PDFontDescriptor getDescriptorFromMetrics​(StandardFontMetrics sfm)
        Constructs font descriptor for given standard font metrics.
        Parameters:
        sfm - is standard font metrics.
        Returns:
        font descriptor with fields set in accordance with sfm.