Package org.apache.fop.afp.fonts

Examples of org.apache.fop.afp.fonts.FontRuntimeException


        if ( AFP_DTD_1_2_ID.equals(publicId) ) {
            resource = getResource( AFP_DTD_1_2_RESOURCE );
        } else if ( AFP_DTD_1_1_ID.equals(publicId) ) {
            resource = getResource( AFP_DTD_1_1_RESOURCE );
        } else if ( AFP_DTD_1_0_ID.equals(publicId) ) {
            throw new FontRuntimeException(
                "The AFP Installed Font Definition 1.0 DTD is not longer supported" );
        } else if (systemId != null && systemId.indexOf("afp-fonts.dtd") >= 0 ) {
            throw new FontRuntimeException(
                "The AFP Installed Font Definition DTD must be specified using the public id" );
        } else {
            return null;
        }
View Full Code Here


            cl = ClassLoader.getSystemClassLoader();
        }

        URL resource = cl.getResource( resourcePath );
        if (resource == null) {
            throw new FontRuntimeException( "Resource " + resourcePath
                    + "could not be found on the classpath" );
        }

        return resource;
    }
View Full Code Here

                CharacterSet cs = raster.getCharacterSet(size);
                if (cs == null) {
                    String msg = "Character set not found for font "
                        + font.getFontName() + " with point size " + size;
                    LOG.error(msg);
                    throw new FontRuntimeException(msg);
                }

                fontDefinition.characterSet = cs.getNameBytes();

                if (fontDefinition.characterSet.length != 8) {
                    throw new IllegalArgumentException("The character set "
                        + new String(fontDefinition.characterSet,
                        AFPConstants.EBCIDIC_ENCODING)
                        + " must have a fixed length of 8 characters.");
                }

                fontDefinition.codePage = cs.getCodePage().getBytes(
                    AFPConstants.EBCIDIC_ENCODING);

                if (fontDefinition.codePage.length != 8) {
                    throw new IllegalArgumentException("The code page "
                        + new String(fontDefinition.codePage,
                        AFPConstants.EBCIDIC_ENCODING)
                        + " must have a fixed length of 8 characters.");
                }

            } else if (font instanceof OutlineFont) {
                OutlineFont outline = (OutlineFont) font;
                CharacterSet cs = outline.getCharacterSet();
                fontDefinition.characterSet = cs.getNameBytes();

                // There are approximately 72 points to 1 inch or 20 1440ths per point.

                fontDefinition.scale = 20 * size / 1000;

                fontDefinition.codePage = cs.getCodePage().getBytes(
                    AFPConstants.EBCIDIC_ENCODING);

                if (fontDefinition.codePage.length != 8) {
                    throw new IllegalArgumentException("The code page "
                        + new String(fontDefinition.codePage,
                        AFPConstants.EBCIDIC_ENCODING)
                        + " must have a fixed length of 8 characters.");
                }
            }  else if (font instanceof DoubleByteFont) {
                DoubleByteFont outline = (DoubleByteFont) font;
                CharacterSet cs = outline.getCharacterSet();
                fontDefinition.characterSet = cs.getNameBytes();

                // There are approximately 72 points to 1 inch or 20 1440ths per point.

                fontDefinition.scale = 20 * size / 1000;

                fontDefinition.codePage = cs.getCodePage().getBytes(
                    AFPConstants.EBCIDIC_ENCODING);

                //TODO Relax requirement for 8 characters
                if (fontDefinition.codePage.length != 8) {
                    throw new IllegalArgumentException("The code page "
                        + new String(fontDefinition.codePage,
                        AFPConstants.EBCIDIC_ENCODING)
                        + " must have a fixed length of 8 characters.");
                }
            } else {
                String msg = "Font of type " + font.getClass().getName()
                    + " not recognized.";
                LOG.error(msg);
                throw new FontRuntimeException(msg);
            }

            if (fontList.size() > 253) {
                // Throw an exception if the size is exceeded
                throw new MaximumSizeExceededException();
            } else {
                fontList.add(fontDefinition);
            }

        } catch (UnsupportedEncodingException ex) {
            throw new FontRuntimeException("Failed to create font "
                + " due to a UnsupportedEncodingException", ex);
        }
    }
View Full Code Here

        if ( AFP_DTD_1_2_ID.equals(publicId) ) {
            resource = getResource( AFP_DTD_1_2_RESOURCE );
        } else if ( AFP_DTD_1_1_ID.equals(publicId) ) {
            resource = getResource( AFP_DTD_1_1_RESOURCE );
        } else if ( AFP_DTD_1_0_ID.equals(publicId) ) {
            throw new FontRuntimeException(
                "The AFP Installed Font Definition 1.0 DTD is not longer supported" );
        } else if (systemId != null && systemId.indexOf("afp-fonts.dtd") >= 0 ) {
            throw new FontRuntimeException(
                "The AFP Installed Font Definition DTD must be specified using the public id" );
        } else {
            return null;
        }
View Full Code Here

            cl = ClassLoader.getSystemClassLoader();
        }

        URL resource = cl.getResource( resourcePath );
        if (resource == null) {
            throw new FontRuntimeException( "Resource " + resourcePath
                    + "could not be found on the classpath" );
        }

        return resource;
    }
View Full Code Here

                CharacterSet cs = raster.getCharacterSet(size);
                if (cs == null) {
                    String msg = "Character set not found for font "
                        + font.getFontName() + " with point size " + size;
                    log.error(msg);
                    throw new FontRuntimeException(msg);
                }

                fontDefinition.characterSet = cs.getNameBytes();

                if (fontDefinition.characterSet.length != 8) {
                    throw new IllegalArgumentException("The character set "
                        + new String(fontDefinition.characterSet,
                        AFPConstants.EBCIDIC_ENCODING)
                        + " must have a fixed length of 8 characters.");
                }

                fontDefinition.codePage = cs.getCodePage().getBytes(
                    AFPConstants.EBCIDIC_ENCODING);

                if (fontDefinition.codePage.length != 8) {
                    throw new IllegalArgumentException("The code page "
                        + new String(fontDefinition.codePage,
                        AFPConstants.EBCIDIC_ENCODING)
                        + " must have a fixed length of 8 characters.");
                }

            } else if (font instanceof OutlineFont) {
                OutlineFont outline = (OutlineFont) font;
                CharacterSet cs = outline.getCharacterSet();
                fontDefinition.characterSet = cs.getNameBytes();

                // There are approximately 72 points to 1 inch or 20 1440ths per point.

                fontDefinition.scale = 20 * size / 1000;

                fontDefinition.codePage = cs.getCodePage().getBytes(
                    AFPConstants.EBCIDIC_ENCODING);

                if (fontDefinition.codePage.length != 8) {
                    throw new IllegalArgumentException("The code page "
                        + new String(fontDefinition.codePage,
                        AFPConstants.EBCIDIC_ENCODING)
                        + " must have a fixed length of 8 characters.");
                }
            }  else if (font instanceof DoubleByteFont) {
                DoubleByteFont outline = (DoubleByteFont) font;
                CharacterSet cs = outline.getCharacterSet();
                fontDefinition.characterSet = cs.getNameBytes();

                // There are approximately 72 points to 1 inch or 20 1440ths per point.

                fontDefinition.scale = 20 * size / 1000;

                fontDefinition.codePage = cs.getCodePage().getBytes(
                    AFPConstants.EBCIDIC_ENCODING);

                //TODO Relax requirement for 8 characters
                if (fontDefinition.codePage.length != 8) {
                    throw new IllegalArgumentException("The code page "
                        + new String(fontDefinition.codePage,
                        AFPConstants.EBCIDIC_ENCODING)
                        + " must have a fixed length of 8 characters.");
                }
            } else {
                String msg = "Font of type " + font.getClass().getName()
                    + " not recognized.";
                log.error(msg);
                throw new FontRuntimeException(msg);
            }

            if (fontList.size() > 253) {
                // Throw an exception if the size is exceeded
                throw new MaximumSizeExceededException();
            } else {
                fontList.add(fontDefinition);
            }

        } catch (UnsupportedEncodingException ex) {
            throw new FontRuntimeException("Failed to create font "
                + " due to a UnsupportedEncodingException", ex);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.fop.afp.fonts.FontRuntimeException

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.