Class ExternalFontMapper

  • All Implemented Interfaces:
    com.lowagie.text.pdf.FontMapper

    public class ExternalFontMapper
    extends com.lowagie.text.pdf.DefaultFontMapper
    IText FontMapper implementation that works with externally supplied TTF files. It is suitable for use with JLatexMath. The paths of externally stored TTF files are supplied to the mapper at construction time. There are utility methods for extracting lists of the locations of such paths from supplied zip (or jar) files.
    Since:
    4 May 2012
    Author:
    Mark Taylor
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.lowagie.text.pdf.DefaultFontMapper

        com.lowagie.text.pdf.DefaultFontMapper.BaseFontParameters
    • Constructor Summary

      Constructors 
      Constructor Description
      ExternalFontMapper​(java.lang.String[] fontLocations)
      Constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.lowagie.text.pdf.BaseFont awtToPdf​(java.awt.Font font)  
      static ExternalFontMapper createMapperFromResourceList​(java.io.InputStream in)
      Creates a font mapper given a stream of strings giving resource paths, for resources available on the classpath.
      static ExternalFontMapper createMapperFromResourcePaths​(java.lang.String[] paths)
      Creates a font mapper given a list of font resource paths, for resources available on the classpath.
      static void main​(java.lang.String[] args)
      When given the names of one or more zip/jar files as arguments, this writes to standard output the absolute paths of any entries that appear to be a TTF file.
      static java.lang.String[] readLines​(java.io.InputStream in)
      Reads lines of text from a stream.
      static void writeLines​(java.lang.String[] lines, java.io.OutputStream out)
      Writes lines of text to a stream.
      • Methods inherited from class com.lowagie.text.pdf.DefaultFontMapper

        getAliases, getBaseFontParameters, getMapper, insertDirectory, insertNames, pdfToAwt, putAlias, putName
      • Methods inherited from class java.lang.Object

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

      • ExternalFontMapper

        public ExternalFontMapper​(java.lang.String[] fontLocations)
        Constructor.
        Parameters:
        fontLocations - locations for font TTF files as supplied to the FontFactory.register method; URLs work (probably files too)
    • Method Detail

      • awtToPdf

        public com.lowagie.text.pdf.BaseFont awtToPdf​(java.awt.Font font)
        Specified by:
        awtToPdf in interface com.lowagie.text.pdf.FontMapper
        Overrides:
        awtToPdf in class com.lowagie.text.pdf.DefaultFontMapper
      • createMapperFromResourcePaths

        public static ExternalFontMapper createMapperFromResourcePaths​(java.lang.String[] paths)
        Creates a font mapper given a list of font resource paths, for resources available on the classpath. These are mapped to URLs and passed to the constructor.
        Parameters:
        paths - absolute resource path strings for TTF files
        Returns:
        new font mapper
      • createMapperFromResourceList

        public static ExternalFontMapper createMapperFromResourceList​(java.io.InputStream in)
                                                               throws java.io.IOException
        Creates a font mapper given a stream of strings giving resource paths, for resources available on the classpath. The stream is read and closed, and createMapperFromResourcePaths(java.lang.String[]) is called. Each resource is on a separate line, encoding is UTF-8.
        Parameters:
        in - input stream
        Returns:
        new font mapper
        Throws:
        java.io.IOException
      • readLines

        public static java.lang.String[] readLines​(java.io.InputStream in)
                                            throws java.io.IOException
        Reads lines of text from a stream.
        Parameters:
        in - input stream
        Returns:
        lines
        Throws:
        java.io.IOException
      • writeLines

        public static void writeLines​(java.lang.String[] lines,
                                      java.io.OutputStream out)
                               throws java.io.IOException
        Writes lines of text to a stream.
        Parameters:
        lines - lines to write
        out - output stream
        Throws:
        java.io.IOException
      • main

        public static void main​(java.lang.String[] args)
                         throws java.io.IOException
        When given the names of one or more zip/jar files as arguments, this writes to standard output the absolute paths of any entries that appear to be a TTF file. The output of this is suitable for use with the createMapperFromResourceList(java.io.InputStream) method.
        Parameters:
        args - list of zip file names
        Throws:
        java.io.IOException