Examples of TTFParser


Examples of org.apache.fontbox.ttf.TTFParser

            }
        }
       
        // Ask FontBox to parse the file for us
        TrueTypeFont font;
        TTFParser parser = new TTFParser();
        if (tis != null && tis.hasFile()) {
            font = parser.parseTTF(tis.getFile());
        } else {
            font = parser.parseTTF(stream);
        }

        // Report the details of the font
        metadata.set(Metadata.CONTENT_TYPE, TYPE.toString());
        metadata.set(TikaCoreProperties.CREATED, font.getHeader().getCreated().getTime());
View Full Code Here

Examples of org.apache.fontbox.ttf.TTFParser

    {
        InputStream arialIs = TestTTFParser.class.getClassLoader().getResourceAsStream(
                "org/apache/pdfbox/ttf/ArialMT.ttf");
        Assert.assertNotNull(arialIs);

        TTFParser parser = new TTFParser();

        TrueTypeFont arial = parser.parse(arialIs);

        CmapTable cmapTable = arial.getCmap();
        Assert.assertNotNull(cmapTable);

        CmapSubtable[] cmaps = cmapTable.getCmaps();
View Full Code Here

Examples of org.apache.fontbox.ttf.TTFParser

    /**
     * Adds an OTF or TTF font to the file cache. To reduce memory, the parsed font is not cached.
     */
    private void addOpenTypeFont(File otfFile) throws IOException
    {
        TTFParser ttfParser = new TTFParser(false, true);
        TrueTypeFont ttf = null;
        try
        {
            ttf = ttfParser.parse(otfFile);
        }
        catch (NullPointerException e) // TTF parser is buggy
        {
            LOG.error("Could not load font file: " + otfFile, e);
        }
View Full Code Here

Examples of org.apache.fontbox.ttf.TTFParser

        }

        File file = ttfFontFiles.get(postScriptName);
        if (file != null)
        {
            TTFParser ttfParser = new TTFParser(false, true);
            try
            {
                ttf = ttfParser.parse(file);

                ttfFonts.put(postScriptName, ttf);
                if (LOG.isDebugEnabled())
                {
                    LOG.debug("Loaded " + postScriptName + " from " + file);
View Full Code Here

Examples of org.apache.fontbox.ttf.TTFParser

        if (ff2Stream != null)
        {
            try
            {
                // embedded
                TTFParser ttfParser = new TTFParser(true);
                ttfFont = ttfParser.parse(ff2Stream.createInputStream());
            }
            catch (NullPointerException e) // TTF parser is buggy
            {
                LOG.warn("Could not read embedded TTF for font " + getBaseFont(), e);
                fontIsDamaged = true;
View Full Code Here

Examples of org.apache.fontbox.ttf.TTFParser

        InputStream stream2 = null;
        PDFontDescriptor fd;
        try
        {
            stream2 = stream.createInputStream();
            ttf = new TTFParser().parse(stream2);
            fd = createFontDescriptor(dict, ttf);
        }
        finally
        {
            IOUtils.closeQuietly(stream2);
View Full Code Here

Examples of org.apache.fontbox.ttf.TTFParser

            if (ff2Stream != null)
            {
                try
                {
                    // embedded
                    TTFParser ttfParser = new TTFParser(true);
                    ttfFont = ttfParser.parse(ff2Stream.createInputStream());
                }
                catch (NullPointerException e) // TTF parser is buggy
                {
                    LOG.warn("Could not read embedded TTF for font " + getBaseFont(), e);
                    fontIsDamaged = true;
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
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.