Examples of GlyphTable


Examples of org.jnode.awt.font.truetype.tables.GlyphTable

        g2.draw(gp);
    }

    public static void testGetGlyph(String s, int x, int y, int fontSize) throws IOException {

        final GlyphTable glyphTable = ttf.getGlyphTable();
        final CMapTable cmapTable = ttf.getCMapTable();
        final HorizontalHeaderTable hheadTable = ttf.getHorizontalHeaderTable();

        if (!(cmapTable.getNrEncodingTables() > 0)) {
            throw new RuntimeException("No Encoding is found!");
        }
        final CMapTable.EncodingTable encTable = cmapTable.getEncodingTable(0);
        if (encTable.getTableFormat() == null) {
            throw new RuntimeException("The table is NUll!!");
        }

        final double ascent = hheadTable.getAscent();
        final AffineTransform tx = new AffineTransform();
        double scale = fontSize / ascent;
        tx.translate(x, y + fontSize);
        System.out.println("Scale=" + scale + ", ascent=" + ascent);
        tx.scale(scale, -scale);
        tx.translate(0, ascent);

        final String[] types = {"move", "line", "quad", "cubic", "close"};

        for (int i = 0; i < s.length(); i++) {
            // get the index for the needed glyph
            final char ch = s.charAt(i);
            System.out.println("Getting index for char: " + ch);
            final int index = encTable.getTableFormat().getGlyphIndex(ch);
            final TTFGlyph glyph = (TTFGlyph) glyphTable.getGlyph(index);
            final GeneralPath shape = glyph.getShape();
            PathIterator pi = shape.getPathIterator(null);
            final float[] f = new float[6];
            while (!pi.isDone()) {
                final int type = pi.currentSegment(f);
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.