Package com.sun.pdfview.font.ttf

Examples of com.sun.pdfview.font.ttf.TrueTypeFont


                                    if (fontRa != null) {
                                        fontRa.close();
                                    }
                                }

                                TrueTypeFont ttf = TrueTypeFont.parseFont(fontBytes);
                                for (final String fontName : ttf.getNames()) {
                                    if (!namedFontsToLocalTtfFiles.containsKey(fontName)) {
                                        namedFontsToLocalTtfFiles.put(fontName, ttfFile);
                                    }
                                }
                            } catch (Throwable t) {
View Full Code Here


            OpenType ot = (OpenType) f;

            byte[] cmapData = ot.getFontTable (OpenType.TAG_CMAP);
            byte[] postData = ot.getFontTable (OpenType.TAG_POST);

            TrueTypeFont ttf = new TrueTypeFont (0x10000);

            cmapTable =
            (CmapTable) TrueTypeTable.createTable (ttf, "cmap",
                    ByteBuffer.wrap (cmapData));
            ttf.addTable ("cmap", cmapTable);

            postTable =
            (PostTable) TrueTypeTable.createTable (ttf, "post",
                    ByteBuffer.wrap (postData));
            ttf.addTable ("post", postTable);
        }
    }
View Full Code Here

        // fos.write(fontdata);
        // fos.close();

        try {
            // read the true type information
            TrueTypeFont ttf = TrueTypeFont.parseFont (fontdata);

            // System.out.println(ttf.toString());

            // get the cmap, post, and hmtx tables for later use
            cmapTable = (CmapTable) ttf.getTable ("cmap");
            postTable = (PostTable) ttf.getTable ("post");
            hmtxTable = (HmtxTable) ttf.getTable ("hmtx");

            // read the units per em from the head table
            HeadTable headTable = (HeadTable) ttf.getTable ("head");
            unitsPerEm = headTable.getUnitsPerEm ();

            /* Find out if we have the right info in our name table.
             * This is a hack because Java can only deal with fonts that
             * have a Microsoft encoded name in their name table (PlatformID 3).
             * We'll 'adjust' the font to add it if not, and take our chances
             * with our parsing, since it wasn't going to work anyway.
             */
            NameTable nameTable = null;

            try {
                nameTable = (NameTable) ttf.getTable ("name");
            } catch (Exception ex) {
                System.out.println ("Error reading name table for font " +
                        getBaseFont () + ".  Repairing!");
            }

            boolean nameFixed = fixNameTable (ttf, nameTable);

            /* Figure out if we need to hack the CMap table.  This might
             * be the case if we use characters that Java considers control
             * characters (0x9, 0xa and 0xd), that have to be re-mapped
             */
            boolean cmapFixed = fixCMapTable (ttf, cmapTable);

            // use the parsed font instead of the original
            if (nameFixed || cmapFixed) {
                // System.out.println("Using fixed font!");
                // System.out.println(ttf.toString());
                fontdata = ttf.writeFont ();

                // FileOutputStream fos2 = new FileOutputStream("/tmp/" + getBaseFont() + ".fix");
                // fos2.write(fontdata);
                // fos2.close();
            }
View Full Code Here

            OpenType ot = (OpenType) f;

            byte[] cmapData = ot.getFontTable (OpenType.TAG_CMAP);
            byte[] postData = ot.getFontTable (OpenType.TAG_POST);

            TrueTypeFont ttf = new TrueTypeFont (0x10000);

            this.cmapTable =
            (CmapTable) TrueTypeTable.createTable (ttf, "cmap",
                    ByteBuffer.wrap (cmapData));
            ttf.addTable ("cmap", this.cmapTable);

            this.postTable =
            (PostTable) TrueTypeTable.createTable (ttf, "post",
                    ByteBuffer.wrap (postData));
            ttf.addTable ("post", this.postTable);
        }
    }
View Full Code Here

        // fos.write(fontdata);
        // fos.close();

        try {
            // read the true type information
            TrueTypeFont ttf = TrueTypeFont.parseFont (fontdata);

            // System.out.println(ttf.toString());

            // get the cmap, post, and hmtx tables for later use
            this.cmapTable = (CmapTable) ttf.getTable ("cmap");
            this.postTable = (PostTable) ttf.getTable ("post");
            this.hmtxTable = (HmtxTable) ttf.getTable ("hmtx");

            // read the units per em from the head table
            HeadTable headTable = (HeadTable) ttf.getTable ("head");
            this.unitsPerEm = headTable.getUnitsPerEm ();

            /* Find out if we have the right info in our name table.
             * This is a hack because Java can only deal with fonts that
             * have a Microsoft encoded name in their name table (PlatformID 3).
             * We'll 'adjust' the font to add it if not, and take our chances
             * with our parsing, since it wasn't going to work anyway.
             */
            NameTable nameTable = null;

            try {
                nameTable = (NameTable) ttf.getTable ("name");
            } catch (Exception ex) {
                System.out.println ("Error reading name table for font " +
                        getBaseFont () + ".  Repairing!");
            }

            boolean nameFixed = fixNameTable (ttf, nameTable);

            /* Figure out if we need to hack the CMap table.  This might
             * be the case if we use characters that Java considers control
             * characters (0x9, 0xa and 0xd), that have to be re-mapped
             */
            boolean cmapFixed = fixCMapTable (ttf, this.cmapTable);

            // use the parsed font instead of the original
            if (nameFixed || cmapFixed) {
                // System.out.println("Using fixed font!");
                // System.out.println(ttf.toString());
                fontdata = ttf.writeFont ();

                // FileOutputStream fos2 = new FileOutputStream("/tmp/" + getBaseFont() + ".fix");
                // fos2.write(fontdata);
                // fos2.close();
            }
View Full Code Here

                                    if (fontRa != null) {
                                        fontRa.close();
                                    }
                                }

                                TrueTypeFont ttf = TrueTypeFont.parseFont(fontBytes);
                                for (final String fontName : ttf.getNames()) {
                                    if (!namedFontsToLocalTtfFiles.containsKey(fontName)) {
                                        namedFontsToLocalTtfFiles.put(fontName, ttfFile);
                                    }
                                }
                            } catch (Throwable t) {
View Full Code Here

TOP

Related Classes of com.sun.pdfview.font.ttf.TrueTypeFont

Copyright © 2018 www.massapicom. 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.