Class Java2DUtil


  • public final class Java2DUtil
    extends java.lang.Object
    Rendering-related utilities for Java2D.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Java2DUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static FontInfo buildDefaultJava2DBasedFontInfo​(FontInfo fontInfo, FOUserAgent userAgent)
      Builds a default FontInfo object for use with output formats using the Java2D font setup.
      private static java.awt.font.GlyphVector createGlyphVector​(java.lang.String text, java.awt.Graphics2D g2d)
      Creates a GlyphVector using characters.
      static java.awt.font.GlyphVector createGlyphVector​(java.lang.String text, java.awt.Graphics2D g2d, Font font, FontInfo fontInfo)
      Creates an instance of GlyphVector that correctly handle surrogate pairs and advanced font features such as GSUB/GPOS/GDEF.
      private static java.awt.font.GlyphVector createGlyphVectorMultiByteFont​(java.lang.String text, java.awt.Graphics2D g2d, MultiByteFont multiByteFont)
      Creates a GlyphVector using glyph indexes instead of characters.
      private static MultiByteFont getMultiByteFont​(java.lang.String fontName, FontInfo fontInfo)
      Returns an instance of MultiByteFont for the given font name.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Java2DUtil

        private Java2DUtil()
    • Method Detail

      • buildDefaultJava2DBasedFontInfo

        public static FontInfo buildDefaultJava2DBasedFontInfo​(FontInfo fontInfo,
                                                               FOUserAgent userAgent)
        Builds a default FontInfo object for use with output formats using the Java2D font setup.
        Parameters:
        fontInfo - the font info object to populate
        userAgent - the user agent
        Returns:
        the populated font information object
      • createGlyphVector

        public static java.awt.font.GlyphVector createGlyphVector​(java.lang.String text,
                                                                  java.awt.Graphics2D g2d,
                                                                  Font font,
                                                                  FontInfo fontInfo)
        Creates an instance of GlyphVector that correctly handle surrogate pairs and advanced font features such as GSUB/GPOS/GDEF.
        Parameters:
        text - Text to render
        g2d - the target Graphics2D instance
        font - the font instance
        fontInfo - the font information
        Returns:
        an instance of GlyphVector
      • createGlyphVector

        private static java.awt.font.GlyphVector createGlyphVector​(java.lang.String text,
                                                                   java.awt.Graphics2D g2d)
        Creates a GlyphVector using characters. Filters out non-bmp characters.
      • createGlyphVectorMultiByteFont

        private static java.awt.font.GlyphVector createGlyphVectorMultiByteFont​(java.lang.String text,
                                                                                java.awt.Graphics2D g2d,
                                                                                MultiByteFont multiByteFont)
        Creates a GlyphVector using glyph indexes instead of characters. To correctly support the advanced font features we have to build the GlyphVector passing the glyph indexes instead of the characters. This because some of the chars in text might have been replaced by an internal font representation during GlyphMapping.processWordMapping. Eg 'fi' replaced with the corresponding character in the font ligatures table (GSUB).