Examples of TTFParser


Examples of org.apache.fontbox.ttf.TTFParser

    private byte[] rebuildTTF(PDFontDescriptorDictionary fd, InputStream inputStream) throws IOException
    {
        // this is one possible case of an incomplete subfont which leads to a font exception
        if (getFontEncoding() instanceof WinAnsiEncoding)
        {
            TTFParser ttfParser = new TTFParser(true);
            TrueTypeFont ttf = ttfParser.parseTTF(inputStream);
            TTFSubFont ttfSub = new TTFSubFont(ttf, "PDFBox-Rebuild");
            for (int i=getFirstChar();i<=getLastChar();i++)
            {
                ttfSub.addCharCode(i);
            }
View Full Code Here

Examples of org.apache.fontbox.ttf.TTFParser

                if( fontResource != null )
                {
                    retval = (TrueTypeFont)loadedExternalFonts.get( baseFont );
                    if( retval == null )
                    {
                        TTFParser ttfParser = new TTFParser();
                        InputStream fontStream = ResourceLoader.loadResource( fontResource );
                        if( fontStream == null )
                        {
                            throw new IOException( "Error missing font resource '" + externalFonts.get(baseFont) + "'" );
                        }
                        retval = ttfParser.parseTTF( fontStream );
                        loadedExternalFonts.put( baseFont, retval );
                    }
                }
            }
        }
View Full Code Here

Examples of org.apache.fontbox.ttf.TTFParser

            if (fd != null)
            {
                PDStream ff2Stream = fd.getFontFile2();
                if (ff2Stream != null)
                {
                    TTFParser ttfParser = new TTFParser(true);
                    trueTypeFont = ttfParser.parseTTF(ff2Stream.createInputStream());
                }
            }
            if (trueTypeFont == null)
            {
                // check if there is a font mapping for an external font file
View Full Code Here

Examples of org.apache.fontbox.ttf.TTFParser

    private void loadDescriptorDictionary(PDFontDescriptorDictionary fd, InputStream ttfData) throws IOException
    {
        TrueTypeFont ttf = null;
        try
        {
            TTFParser parser = new TTFParser();
            ttf = parser.parseTTF( ttfData );
            NamingTable naming = ttf.getNaming();
            List<NameRecord> records = naming.getNameRecords();
            for( int i=0; i<records.size(); i++ )
            {
                NameRecord nr = records.get( i );
View Full Code Here

Examples of org.apache.fontbox.ttf.TTFParser

    private byte[] rebuildTTF(PDFontDescriptorDictionary fd, InputStream inputStream) throws IOException
    {
        // this is one possible case of an incomplete subfont which leads to a font exception
        if (getFontEncoding() instanceof WinAnsiEncoding)
        {
            TTFParser ttfParser = new TTFParser(true);
            TrueTypeFont ttf = ttfParser.parseTTF(inputStream);
            TTFSubFont ttfSub = new TTFSubFont(ttf, "PDFBox-Rebuild");
            for (int i=getFirstChar();i<=getLastChar();i++)
            {
                ttfSub.addCharCode(i);
            }
View Full Code Here

Examples of org.apache.fontbox.ttf.TTFParser

                if( fontResource != null )
                {
                    retval = (TrueTypeFont)loadedExternalFonts.get( baseFont );
                    if( retval == null )
                    {
                        TTFParser ttfParser = new TTFParser();
                        InputStream fontStream = ResourceLoader.loadResource( fontResource );
                        if( fontStream == null )
                        {
                            throw new IOException( "Error missing font resource '" + externalFonts.get(baseFont) + "'" );
                        }
                        retval = ttfParser.parseTTF( fontStream );
                        loadedExternalFonts.put( baseFont, retval );
                    }
                }
            }
        }
View Full Code Here

Examples of org.apache.fontbox.ttf.TTFParser

            if (fd != null)
            {
                PDStream ff2Stream = fd.getFontFile2();
                if (ff2Stream != null)
                {
                    TTFParser ttfParser = new TTFParser(true);
                    trueTypeFont = ttfParser.parseTTF(ff2Stream.createInputStream());
                }
            }
            if (trueTypeFont == null)
            {
                // check if there is a font mapping for an external font file
View Full Code Here

Examples of org.apache.fontbox.ttf.TTFParser

     * @param ttfFilename the filename of the true type type
     * @throws IOException if something went wrong
     */
    private static void analyzeTTF(String ttfFilename) throws IOException
    {
        TTFParser ttfParser = new TTFParser(false,true);
        TrueTypeFont ttfFont = ttfParser.parseTTF(ttfFilename);
        if (ttfFont != null)
        {
            NamingTable namingTable = ttfFont.getNaming();
            if (namingTable != null && namingTable.getPSName() != null)
            {
View Full Code Here

Examples of org.apache.fontbox.ttf.TTFParser

    {
        String ttffontname = findTTFontname(fontname);
        TrueTypeFont ttfFont = null;
        if (ttffontname != null)
        {
            TTFParser ttfParser = new TTFParser();
            InputStream fontStream = ResourceLoader.loadResource(ttffontname);
            if (fontStream == null)
            {
                throw new IOException("Can't load external font: " + ttffontname);
            }
            ttfFont = ttfParser.parseTTF(fontStream);
        }
        return ttfFont;
    }
View Full Code Here

Examples of org.apache.fontbox.ttf.TTFParser

    public void parse(
            InputStream stream, ContentHandler handler,
            Metadata metadata, ParseContext context)
            throws IOException, SAXException, TikaException {
        TrueTypeFont font;
        TTFParser parser = new TTFParser();
        TikaInputStream tis = TikaInputStream.cast(stream);
        if (tis != null && tis.hasFile()) {
            font = parser.parseTTF(tis.getFile());
        } else {
            font = parser.parseTTF(stream);
        }

        metadata.set(Metadata.CONTENT_TYPE, TYPE.toString());
        metadata.set(DublinCore.DATE, font.getHeader().getCreated().getTime());
        metadata.set(
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.