Package java.awt

Examples of java.awt.FontFormatException


         * 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

        Font newFont = addFont(path, type);
       
        if (newFont == null) {
            if ((new File(path)).canRead()) {
                //awt.9B=Can't create font - bad font data
                throw new FontFormatException ( Messages.getString("awt.9B") ); //$NON-NLS-1$                       
            } else {
                throw new IOException();
            }
        }
       
View Full Code Here

        Font newFont = addFont(path, type);
       
        if (newFont == null) {
            if ((new File(path)).canRead()) {
                //awt.9B=Can't create font - bad font data
                throw new FontFormatException ( Messages.getString("awt.9B") ); //$NON-NLS-1$                       
            }
            throw new IOException();
        }
       
        allFonts.add(newFont);
View Full Code Here

                bufferRef = null;
            }
            if (t instanceof FontFormatException) {
                throw (FontFormatException)t;
            } else {
                throw new FontFormatException("Unexpected runtime exception.");
            }
        }
    }
View Full Code Here

                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

TOP

Related Classes of 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.