Package org.fontbox.encoding

Examples of org.fontbox.encoding.MacRomanEncoding


        isFixedPitch = data.readUnsignedInt();
        minMemType42 = data.readUnsignedInt();
        maxMemType42 = data.readUnsignedInt();
        mimMemType1 = data.readUnsignedInt();
        maxMemType1 = data.readUnsignedInt();
        MacRomanEncoding encoding = new MacRomanEncoding();
       
       
        if( formatType == 1.0f )
        {
            /*
             * This TrueType font file contains exactly the 258 glyphs in the standard
             * Macintosh TrueType.
             */
            glyphNames = new String[258];
            for( int i=0; i<glyphNames.length; i++)
            {
                String name = encoding.getName( i );
                if( name != null )
                {
                    glyphNames[i] = name;
                }
            }
        }
        else if( formatType == 2.0f )
        {
            int numGlyphs = data.readUnsignedShort();
            int[] glyphNameIndex = new int[numGlyphs];
            glyphNames = new String[ numGlyphs ];
            int maxIndex = Integer.MIN_VALUE;
            for( int i=0; i<numGlyphs; i++ )
            {
                int index = data.readUnsignedShort();
                glyphNameIndex[i] = index;
                maxIndex = Math.max( maxIndex, index );
            }
            String[] nameArray = null;
            if( maxIndex >= 258 )
            {
                nameArray = new String[ maxIndex-258 +1 ];
                for( int i=0; i<maxIndex-258+1; i++ )
                {
                    int numberOfChars = data.read();
                    nameArray[i]=data.readString( numberOfChars );
                }
            }
            for( int i=0; i<numGlyphs; i++ )
            {
                int index = glyphNameIndex[i];
                if( index < 258 )
                {
                    glyphNames[i] = encoding.getName( index );
                }
                else if( index >= 258 && index <= 32767 )
                {
                    glyphNames[i] = nameArray[index-258];
                }
                else
                {
                    throw new IOException( "Unknown glyph name index:" + index );
                }
            }
        }
        else if( formatType == 2.5f )
        {
            int[] glyphNameIndex = new int[maxp.getNumGlyphs()];
            for( int i=0; i<glyphNameIndex.length; i++)
            {
                int offset = data.readSignedByte();
                glyphNameIndex[i] = i+1+offset;
            }
            glyphNames = new String[glyphNameIndex.length];
            for( int i=0; i<glyphNames.length; i++)
            {
                String name = encoding.getName( glyphNameIndex[i] );
                if( name != null )
                {
                    glyphNames[i] = name;
                }
            }
View Full Code Here


        isFixedPitch = data.readUnsignedInt();
        minMemType42 = data.readUnsignedInt();
        maxMemType42 = data.readUnsignedInt();
        mimMemType1 = data.readUnsignedInt();
        maxMemType1 = data.readUnsignedInt();
        MacRomanEncoding encoding = new MacRomanEncoding();
       
       
        if( formatType == 1.0f )
        {
            /*
             * This TrueType font file contains exactly the 258 glyphs in the standard
             * Macintosh TrueType.
             */
            glyphNames = new String[258];
            for( int i=0; i<glyphNames.length; i++)
            {
                String name = encoding.getName( i );
                if( name != null )
                {
                    glyphNames[i] = name;
                }
            }
        }
        else if( formatType == 2.0f )
        {
            int numGlyphs = data.readUnsignedShort();
            int[] glyphNameIndex = new int[numGlyphs];
            glyphNames = new String[ numGlyphs ];
            int maxIndex = Integer.MIN_VALUE;
            for( int i=0; i<numGlyphs; i++ )
            {
                int index = data.readUnsignedShort();
                glyphNameIndex[i] = index;
                maxIndex = Math.max( maxIndex, index );
            }
            String[] nameArray = null;
            if( maxIndex >= 258 )
            {
                nameArray = new String[ maxIndex-258 +1 ];
                for( int i=0; i<maxIndex-258+1; i++ )
                {
                    int numberOfChars = data.read();
                    nameArray[i]=data.readString( numberOfChars );
                }
            }
            for( int i=0; i<numGlyphs; i++ )
            {
                int index = glyphNameIndex[i];
                if( index < 258 )
                {
                    glyphNames[i] = encoding.getName( index );
                }
                else if( index >= 258 && index <= 32767 )
                {
                    glyphNames[i] = nameArray[index-258];
                }
                else
                {
                    throw new IOException( "Unknown glyph name index:" + index );
                }
            }
        }
        else if( formatType == 2.5f )
        {
            int[] glyphNameIndex = new int[maxp.getNumGlyphs()];
            for( int i=0; i<glyphNameIndex.length; i++)
            {
                int offset = data.readSignedByte();
                glyphNameIndex[i] = i+1+offset;
            }
            glyphNames = new String[glyphNameIndex.length];
            for( int i=0; i<glyphNames.length; i++)
            {
                String name = encoding.getName( glyphNameIndex[i] );
                if( name != null )
                {
                    glyphNames[i] = name;
                }
            }
View Full Code Here

TOP

Related Classes of org.fontbox.encoding.MacRomanEncoding

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.