Package ae.java.awt

Examples of ae.java.awt.FontFormatException


                mapBuf = fc.map(FileChannel.MapMode.READ_ONLY, 0, fileSize);
                mapBuf.position(0);
                bufferRef = new WeakReference(mapBuf);
                fc.close();
            } catch (NullPointerException e) {
                throw new FontFormatException(e.toString());
            } catch (ClosedChannelException e) {
                /* NIO I/O is interruptible, recurse to retry operation.
                 * Clear interrupts before recursing in case NIO didn't.
                 */
                Thread.interrupted();
                return getBuffer();
            } catch (IOException e) {
                throw new FontFormatException(e.toString());
            }
        }
        return mapBuf;
    }
View Full Code Here


         * this as its called only from within the constructor before
         * there are other users of this object.
         */
        ByteBuffer bb = getBuffer();
        if (bb.capacity() < 6) {
            throw new FontFormatException("short file");
        }
        int val = bb.get(0) & 0xff;
        if ((bb.get(0) & 0xff) == 0x80) {
            verifyPFB(bb);
            bb.position(6);
        } else {
            verifyPFA(bb);
            bb.position(0);
        }
        initNames(bb);
        if (familyName == null || fullName == null) {
            throw new FontFormatException("Font name not found");
        }
        setStyle();
    }
View Full Code Here

        return fileSize;
    }

    private void verifyPFA(ByteBuffer bb) throws FontFormatException {
        if (bb.getShort() != 0x2521) { // 0x2521 is %!
            throw new FontFormatException("bad pfa font");
        }
        // remind - additional verification needed?
    }
View Full Code Here

                if (segType == 0x8001 || segType == 0x8002) {
                    bb.order(ByteOrder.LITTLE_ENDIAN);
                    int segLen = bb.getInt(pos+2);
                    bb.order(ByteOrder.BIG_ENDIAN);
                    if (segLen <= 0) {
                        throw new FontFormatException("bad segment length");
                    }
                    pos += segLen+6;
                } else if (segType == 0x8003) {
                    return;
                } else {
                    throw new FontFormatException("bad pfb file");
                }
            } catch (BufferUnderflowException bue) {
                throw new FontFormatException(bue.toString());
            } catch (Exception e) {
                throw new FontFormatException(e.toString());
            }
        }
    }
View Full Code Here

                } else if (tokenType == PSEOFTOKEN) {
                    eof = true;
                }
            }
        } catch (Exception e) {
                throw new FontFormatException(e.toString());
        }

        /* Ignore all fonts besides Type1 (e.g. Type3 fonts) */
        if (!"1".equals(fontType)) {
            throw new FontFormatException("Unsupported font type");
        }

    if (psName == null) { //no explicit FontName
                // Try to extract font name from the first text line.
                // According to Type1 spec first line consist of
                //  "%!FontType1-SpecVersion: FontName FontVersion"
                // or
                //  "%!PS-AdobeFont-1.0: FontName version"
                bb.position(0);
                if (bb.getShort() != 0x2521) { //if pfb (do not start with "%!")
                    //skip segment header and "%!"
                    bb.position(8);
                    //NB: assume that first segment is ASCII one
                    //  (is it possible to have valid Type1 font with first binary segment?)
                }
                String formatType = getSimpleToken(bb);
                if (!formatType.startsWith("FontType1-") && !formatType.startsWith("PS-AdobeFont-")) {
                        throw new FontFormatException("Unsupported font format [" + formatType + "]");
                }
                psName = getSimpleToken(bb);
        }

    //if we got to the end of file then we did not find at least one of FullName or FamilyName
View Full Code Here

                disposerRecord.channel = raf.getChannel();
                fileSize = (int)disposerRecord.channel.size();
                FontManager.addToPool(this);
            } catch (NullPointerException e) {
                close();
                throw new FontFormatException(e.toString());
            } catch (ClosedChannelException e) {
                /* NIO I/O is interruptible, recurse to retry operation.
                 * The call to channel.size() above can throw this exception.
                 * Clear interrupts before recursing in case NIO didn't.
                 * Note that close() sets disposerRecord.channel to null.
                 */
                Thread.interrupted();
                close();
                open();
            } catch (IOException e) {
                close();
                throw new FontFormatException(e.toString());
            }
        }
        return disposerRecord.channel;
    }
View Full Code Here

            case ttcfTag:
                buffer.getInt(); // skip TTC version ID
                directoryCount = buffer.getInt();
                if (fIndex >= directoryCount) {
                    throw new FontFormatException("Bad collection index");
                }
                fontIndex = fIndex;
                buffer = readBlock(TTCHEADERSIZE+4*fIndex, 4);
                headerOffset = buffer.getInt();
                break;

            case v1ttTag:
            case trueTag:
                break;

            default:
                throw new FontFormatException("Unsupported sfnt " + platName);
            }

            /* Now have the offset of this TT font (possibly within a TTC)
             * After the TT version/scaler type field, is the short
             * representing the number of tables in the table directory.
             * The table directory begins at 12 bytes after the header.
             * Each table entry is 16 bytes long (4 32-bit ints)
             */
            buffer = readBlock(headerOffset+4, 2);
            numTables = buffer.getShort();
            directoryOffset = headerOffset+DIRECTORYHEADERSIZE;
            ByteBuffer bbuffer = readBlock(directoryOffset,
                                           numTables*DIRECTORYENTRYSIZE);
            IntBuffer ibuffer = bbuffer.asIntBuffer();
            DirectoryEntry table;
            tableDirectory = new DirectoryEntry[numTables];
            for (int i=0; i<numTables;i++) {
                tableDirectory[i] = table = new DirectoryEntry();
                table.tag   =  ibuffer.get();
                /* checksum */ ibuffer.get();
                table.offset = ibuffer.get();
                table.length = ibuffer.get();
                if (table.offset + table.length > fileSize) {
                    throw new FontFormatException("bad table, tag="+table.tag);
                }
            }
            initNames();
        } catch (Exception e) {
            if (FontManager.logging) {
                FontManager.logger.severe(e.toString());
            }
            if (e instanceof FontFormatException) {
                throw (FontFormatException)e;
            } else {
                throw new FontFormatException(e.toString());
            }
        }
        if (familyName == null || fullName == null) {
            throw new FontFormatException("Font name not found");
        }
        /* The os2_Table is needed to gather some info, but we don't
         * want to keep it around (as a field) so obtain it once and
         * pass it to the code that needs it.
         */
 
View Full Code Here

                break;
            case Font.TYPE1_FONT:
                font2D = new Type1Font(fontFilePath, null);
                break;
            default:
                throw new FontFormatException("Unrecognised Font Format");
            }
        } catch (FontFormatException e) {
            if (isCopy) {
                java.security.AccessController.doPrivileged(
                     new java.security.PrivilegedAction() {
View Full Code Here

TOP

Related Classes of ae.java.awt.FontFormatException

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.