Class SVGFont

    • Field Detail

      • EXTRA_LIGHT

        public static final float EXTRA_LIGHT
      • LIGHT

        public static final float LIGHT
      • DEMILIGHT

        public static final float DEMILIGHT
      • REGULAR

        public static final float REGULAR
      • SEMIBOLD

        public static final float SEMIBOLD
      • MEDIUM

        public static final float MEDIUM
      • DEMIBOLD

        public static final float DEMIBOLD
      • BOLD

        public static final float BOLD
      • HEAVY

        public static final float HEAVY
      • EXTRABOLD

        public static final float EXTRABOLD
      • ULTRABOLD

        public static final float ULTRABOLD
      • POSTURE_REGULAR

        public static final float POSTURE_REGULAR
      • POSTURE_OBLIQUE

        public static final float POSTURE_OBLIQUE
      • fontStyles

        static final float[] fontStyles
        Contains threshold value for the various Font styles. If a given style is in an interval, then it is mapped to the style at the top of that interval.
        See Also:
        styleToSVG(java.awt.Font)
      • svgStyles

        static final java.lang.String[] svgStyles
        SVG Styles corresponding to the fontStyles
      • fontWeights

        static final float[] fontWeights
        Contains threshold values for the various Font weights. If a given weight is in an interval, then it is mapped to the weight at the top of the interval.
        See Also:
        weightToSVG(java.awt.Font)
      • svgWeights

        static final java.lang.String[] svgWeights
        SVG Weights corresponding to the fontWeights
      • logicalFontMap

        static java.util.Map logicalFontMap
        Logical fonts mapping
      • COMMON_FONT_SIZE

        static final int COMMON_FONT_SIZE
        The common font size to use when generating all SVG fonts.
        See Also:
        Constant Field Values
      • fontStringMap

        final java.util.Map fontStringMap
        Used to keep track of which characters have been rendered by each font used. MapKey is the fontKey, mapValue is a sorted array of used characters.
    • Constructor Detail

      • SVGFont

        public SVGFont​(SVGGeneratorContext generatorContext)
        Parameters:
        generatorContext - used to build Elements
    • Method Detail

      • recordFontUsage

        public void recordFontUsage​(java.lang.String string,
                                    java.awt.Font font)
        Records that the specified font has been used to draw the text string. This is so we can keep track of which glyphs are required for each SVG font that is generated.
      • createCommonSizeFont

        private static java.awt.Font createCommonSizeFont​(java.awt.Font font)
        Creates a new Font that is of the common font size used for generating SVG fonts. The new Font will be the same as the specified font, with only its size attribute modified.
      • toSVG

        public SVGDescriptor toSVG​(GraphicContext gc)
        Converts part or all of the input GraphicContext into a set of attribute/value pairs and related definitions
        Parameters:
        gc - GraphicContext to be converted
        Returns:
        descriptor of the attributes required to represent some or all of the GraphicContext state, along with the related definitions
        See Also:
        SVGDescriptor
      • toSVG

        public SVGFontDescriptor toSVG​(java.awt.Font font,
                                       java.awt.font.FontRenderContext frc)
        Parameters:
        font - Font object which should be converted to a set of SVG attributes
        frc - The FontRenderContext which will be used to generate glyph elements for the SVGFont definition element
        Returns:
        description of attribute values that describe the font
      • familyToSVG

        public static java.lang.String familyToSVG​(java.awt.Font font)
        Parameters:
        font - whose family should be converted to an SVG string value.
      • styleToSVG

        public static java.lang.String styleToSVG​(java.awt.Font font)
        Parameters:
        font - whose style should be converted to an SVG string value.
      • weightToSVG

        public static java.lang.String weightToSVG​(java.awt.Font font)
        Parameters:
        font - whose weight should be converted to an SVG string value. Note that there is loss of precision for semibold and extrabold.