diff --git a/trunk/lib/LZMA.jar b/trunk/lib/LZMA.jar index aa485ec25..dc74d72be 100644 Binary files a/trunk/lib/LZMA.jar and b/trunk/lib/LZMA.jar differ diff --git a/trunk/lib/avi.jar b/trunk/lib/avi.jar index 5409c7678..740501fa0 100644 Binary files a/trunk/lib/avi.jar and b/trunk/lib/avi.jar differ diff --git a/trunk/lib/gif.jar b/trunk/lib/gif.jar index 05ad57001..8c6ec3efc 100644 Binary files a/trunk/lib/gif.jar and b/trunk/lib/gif.jar differ diff --git a/trunk/lib/nellymoser.jar b/trunk/lib/nellymoser.jar index 4c6973884..f89599dfb 100644 Binary files a/trunk/lib/nellymoser.jar and b/trunk/lib/nellymoser.jar differ diff --git a/trunk/lib/ttf.jar b/trunk/lib/ttf.jar new file mode 100644 index 000000000..651b36145 Binary files /dev/null and b/trunk/lib/ttf.jar differ diff --git a/trunk/libsrc/LZMA/build.xml b/trunk/libsrc/LZMA/build.xml index 9228eac00..39c801a28 100644 --- a/trunk/libsrc/LZMA/build.xml +++ b/trunk/libsrc/LZMA/build.xml @@ -51,8 +51,7 @@ -init-macrodef-junit: defines macro for junit execution -init-macrodef-debug: defines macro for class debugging -init-macrodef-java: defines macro for class execution - -do-jar-with-manifest: JAR building (if you are using a manifest) - -do-jar-without-manifest: JAR building (if you are not using a manifest) + -do-jar: JAR building run: execution of project -javadoc-build: Javadoc generation test-report: JUnit report generation diff --git a/trunk/libsrc/LZMA/nbproject/build-impl.xml b/trunk/libsrc/LZMA/nbproject/build-impl.xml index 8e7313383..4144cb57a 100644 --- a/trunk/libsrc/LZMA/nbproject/build-impl.xml +++ b/trunk/libsrc/LZMA/nbproject/build-impl.xml @@ -54,6 +54,7 @@ is divided into following sections: + @@ -71,10 +72,11 @@ is divided into following sections: - + - - + + + @@ -91,12 +93,6 @@ is divided into following sections: - - - - - - @@ -115,24 +111,12 @@ is divided into following sections: - + - + - - - - - - - - - - - - @@ -186,7 +170,15 @@ is divided into following sections: - + + + + + + + + + @@ -275,6 +267,7 @@ is divided into following sections: + @@ -314,6 +307,7 @@ is divided into following sections: + @@ -446,7 +440,7 @@ is divided into following sections: - + @@ -837,8 +831,8 @@ is divided into following sections: - - + + @@ -850,7 +844,7 @@ is divided into following sections: - + @@ -966,41 +960,25 @@ is divided into following sections: - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - - - - - - java -cp "${run.classpath.with.dist.jar}" ${main.class} - - + - + - + - + + + + + + @@ -1008,23 +986,41 @@ is divided into following sections: - + To run this application from the command line without Ant, try: java -jar "${dist.jar.resolved}" - + + + + + + + + + + + + + + + + + - + + - + + + + + + + + + + + Builds, tests, and runs the project ttf. + + + diff --git a/trunk/libsrc/ttf/manifest.mf b/trunk/libsrc/ttf/manifest.mf new file mode 100644 index 000000000..1574df4a2 --- /dev/null +++ b/trunk/libsrc/ttf/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/trunk/libsrc/ttf/nbproject/build-impl.xml b/trunk/libsrc/ttf/nbproject/build-impl.xml new file mode 100644 index 000000000..2451f7f11 --- /dev/null +++ b/trunk/libsrc/ttf/nbproject/build-impl.xml @@ -0,0 +1,1407 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/trunk/libsrc/ttf/nbproject/genfiles.properties b/trunk/libsrc/ttf/nbproject/genfiles.properties new file mode 100644 index 000000000..115ce4b20 --- /dev/null +++ b/trunk/libsrc/ttf/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=ffc041f7 +build.xml.script.CRC32=9bce9219 +build.xml.stylesheet.CRC32=8064a381@1.68.1.46 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=ffc041f7 +nbproject/build-impl.xml.script.CRC32=b06e210e +nbproject/build-impl.xml.stylesheet.CRC32=5a01deb7@1.68.1.46 diff --git a/trunk/libsrc/ttf/nbproject/project.properties b/trunk/libsrc/ttf/nbproject/project.properties new file mode 100644 index 000000000..10ccdfd83 --- /dev/null +++ b/trunk/libsrc/ttf/nbproject/project.properties @@ -0,0 +1,75 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +application.title=ttf +application.vendor=Jindra +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# Files in build.classes.dir which should be excluded from distribution jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=../../lib/ttf.jar +dist.javadoc.dir=${dist.dir}/javadoc +endorsed.classpath= +excludes= +includes=** +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs=-Xlint:unchecked -Xlint:deprecation +javac.deprecation=false +javac.processorpath=\ + ${javac.classpath} +javac.source=1.7 +javac.target=1.7 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +main.class=fontatest.FontaTest +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project. +# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. +# To set system properties for unit tests define test-sys-prop.name=value: +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/trunk/libsrc/ttf/nbproject/project.xml b/trunk/libsrc/ttf/nbproject/project.xml new file mode 100644 index 000000000..bce7aa78c --- /dev/null +++ b/trunk/libsrc/ttf/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + ttf + + + + + + + + + diff --git a/trunk/libsrc/ttf/src/fontastic/FContour.java b/trunk/libsrc/ttf/src/fontastic/FContour.java new file mode 100644 index 000000000..63f44d05a --- /dev/null +++ b/trunk/libsrc/ttf/src/fontastic/FContour.java @@ -0,0 +1,86 @@ +package fontastic; + +/** + * Fontastic + * A font file writer to create TTF and WOFF (Webfonts). + * http://code.andreaskoller.com/libraries/fontastic + * + * Copyright (C) 2013 Andreas Koller http://andreaskoller.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Koller http://andreaskoller.com + * @modified 06/19/2013 + * @version 0.4 (4) + */ + +import fontastic.FPoint; + +import java.util.ArrayList; +import java.util.List; + +/** + * Class FContour + * + * Stores a contour (list of FPoint). + * + */ +public class FContour { + + List points; + + FContour() { + this.points = new ArrayList<>(); + } + + FContour(PVector[] points) { + this.points = new ArrayList<>(); + for (PVector p : points) { + this.points.add(new FPoint(p)); + } + } + + FContour(PVector[] points, PVector[] controlpoints) { + this.points = new ArrayList<>(); + for (int i=0; i(); + for (int i=0; i getPoints() { + return points; + } + + public FPoint[] getPointsArray() { + FPoint[] pointsArray = points.toArray(new FPoint[points.size()]); + return pointsArray; + } + + public void setPoints(PVector[] points) { + this.points = new ArrayList<>(); + for (PVector p : points) { + this.points.add(new FPoint(p)); + } + } + +} \ No newline at end of file diff --git a/trunk/libsrc/ttf/src/fontastic/FGlyph.java b/trunk/libsrc/ttf/src/fontastic/FGlyph.java new file mode 100644 index 000000000..b2b0a53c7 --- /dev/null +++ b/trunk/libsrc/ttf/src/fontastic/FGlyph.java @@ -0,0 +1,116 @@ +package fontastic; + +/** + * Fontastic + * A font file writer to create TTF and WOFF (Webfonts). + * http://code.andreaskoller.com/libraries/fontastic + * + * Copyright (C) 2013 Andreas Koller http://andreaskoller.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Koller http://andreaskoller.com + * @modified 06/19/2013 + * @version 0.4 (4) + */ + + +import java.util.ArrayList; +import java.util.List; + +/** + * Class FGlyph + * + * Stores a glyph with all its properties. + * + */ +public class FGlyph { + + private char glyphChar; + private List contours; + private int advanceWidth = 512; + + FGlyph(char c) { + glyphChar = c; + this.contours = new ArrayList<>(); + } + + public void addContour() { + contours.add(new FContour()); + } + + public void addContour(PVector[] points) { + contours.add(new FContour(points)); + } + + public void addContour(FPoint[] points) { + contours.add(new FContour(points)); + } + + public void addContour(PVector[] points, PVector[] controlPoints) { + contours.add(new FContour(points, controlPoints)); + } + + public void addContour(FContour contour) { + contours.add(contour); + } + + public void setAdvanceWidth(int advanceWidth) { + this.advanceWidth = advanceWidth; + } + + public char getGlyphChar() { + return glyphChar; + } + + public int getAdvanceWidth() { + return advanceWidth; + } + + public List getContours() { + return contours; + } + + public FContour[] getContoursArray() { + FContour[] contoursArray = contours.toArray(new FContour[contours.size()]); + return contoursArray; + } + + public FContour getContour(int index) { + return contours.get(index); + } + + public int getContourCount() { + return contours.size(); + } + + public void setContour(int index, PVector[] points) { + contours.set(index, new FContour(points)); + } + + public void setContour(int index, FPoint[] points) { + contours.set(index, new FContour(points)); + } + + public void setContour(int index, FContour contour) { + contours.set(index, contour); + } + + public void clearContours() { + this.contours.clear(); + } + +} \ No newline at end of file diff --git a/trunk/libsrc/ttf/src/fontastic/FPoint.java b/trunk/libsrc/ttf/src/fontastic/FPoint.java new file mode 100644 index 000000000..e2bd71bcb --- /dev/null +++ b/trunk/libsrc/ttf/src/fontastic/FPoint.java @@ -0,0 +1,82 @@ +package fontastic; + +/** + * Fontastic + * A font file writer to create TTF and WOFF (Webfonts). + * http://code.andreaskoller.com/libraries/fontastic + * + * Copyright (C) 2013 Andreas Koller http://andreaskoller.com + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Koller http://andreaskoller.com + * @modified 06/19/2013 + * @version 0.4 (4) + */ + + + +/** + * Class FPoint extends PVector + * + * Stores a point with x and y coordinates and optional PVector controlPoint1 and controlPoint2. + * + */ +public class FPoint extends PVector { + + public PVector controlPoint; + + private boolean hasControlPoint; + + public FPoint() { + } + + public FPoint(PVector point) { + this.x = point.x; + this.y = point.y; + this.hasControlPoint = false; + } + + public FPoint(float x, float y) { + this.x = x; + this.y = y; + this.hasControlPoint = false; + } + + + public FPoint(PVector point, PVector controlPoint) { + this.x = point.x; + this.y = point.y; + this.controlPoint = controlPoint; + this.hasControlPoint = true; + } + + public void setControlPoint(PVector controlPoint1) { + this.controlPoint = controlPoint1; + this.hasControlPoint = true; + } + + public void setControlPoint(float x, float y) { + this.controlPoint = new PVector(x,y); + this.hasControlPoint = true; + } + + + public boolean hasControlPoint1() { + return hasControlPoint; + } + +} \ No newline at end of file diff --git a/trunk/libsrc/ttf/src/fontastic/Fontastic.java b/trunk/libsrc/ttf/src/fontastic/Fontastic.java new file mode 100644 index 000000000..717939e92 --- /dev/null +++ b/trunk/libsrc/ttf/src/fontastic/Fontastic.java @@ -0,0 +1,518 @@ +/** + * Fontastic A font file writer to create TTF + * http://code.andreaskoller.com/libraries/fontastic + * + * Copyright (C) 2013 Andreas Koller http://andreaskoller.com + * + * Uses: doubletype http://sourceforge.net/projects/doubletype/ for TTF creation + * + * This library is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 2.1 of the License, or (at your option) + * any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @author Andreas Koller http://andreaskoller.com + * @modified 03/16/2014 JPEXS - removed Woff + * @version 0.4 (4) + */ +package fontastic; + +import org.doubletype.ossa.*; +import org.doubletype.ossa.module.*; +import org.doubletype.ossa.adapter.*; + +import java.io.*; +import java.util.ArrayList; +import java.util.Map; +import java.util.List; +import java.util.Scanner; +import java.util.regex.Pattern; +import java.util.regex.Matcher; + +/** + * Fontastic A font file writer to create TTF and WOFF (Webfonts). + * http://code.andreaskoller.com/libraries/fontastic + * + */ +public class Fontastic { + + private org.doubletype.ossa.module.TypefaceFile typeface; + private org.doubletype.ossa.Engine m_engine; + + private String fontname; + + private List glyphs; + + private int advanceWidth = 512; + + private File ttffile; + private File outfile; + private File tempDir; + + public final static String VERSION = "0.4"; + + /** + * Uppercase alphabet 26 characters * + */ + public final static char alphabet[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', + 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', + 'U', 'V', 'W', 'X', 'Y', 'Z'}; + /** + * Lowercase alphabet 26 characters * + */ + public final static char alphabetLc[] = {'a', 'b', 'c', 'd', 'e', 'f', + 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', + 't', 'u', 'v', 'w', 'x', 'y', 'z'}; + + /** + * Return the version of the library. + * + * @return String + */ + public static String version() { + return VERSION; + } + + /** + * Constructor + * + * @example Fontastic f = new Fontastic(this, "MyFont"); + * + * @param theParent Your processing sketch (this). + * @param fontname Font name + * + */ + public Fontastic(String fontname, File outfile) throws IOException { + this.fontname = fontname; + this.outfile = outfile; + intitialiseFont(); + this.glyphs = new ArrayList<>(); + } + + /** + * Returns the font name. + * + * @return String + */ + public String getFontname() { + return fontname; + } + + private static File createTempDirectory() + throws IOException { + File temp; + temp = File.createTempFile("temp", Long.toString(System.nanoTime())); + + + + if (!(temp.delete())) { + throw new IOException("Could not delete temp file: " + temp.getAbsolutePath()); + } + + if (!(temp.mkdirs())) { + throw new IOException("Could not create temp directory: " + temp.getAbsolutePath()); + } + + return (temp); + } + + /** + * Creates and initialises a new typeface. Font data is put into sketch + * folder data/fontname. + */ + private void intitialiseFont() throws IOException { + + tempDir = createTempDirectory(); + /*if (!tempDir.exists()) { + if(!tempDir.mkdirs()){ + if (!tempDir.exists()) { + throw new IOException("Cannot create temp dir"); + } + } + } else { + //deleteFolderContents(tempDir, false); + }*/ + + + m_engine = Engine.getSingletonInstance(); + m_engine.buildNewTypeface(fontname, tempDir); + + this.setFontFamilyName(fontname); + this.setVersion("CC BY-SA 3.0 http://creativecommons.org/licenses/by-sa/3.0/"); // default + // license + + String directoryName = tempDir + File.separator + "bin" + File.separator; + + ttffile = new File(directoryName + fontname + ".ttf"); + } + + /** + * Builds the font and writes the .ttf and the .woff file as well as a HTML + * template for previewing the WOFF. If debug is set (default is true) then + * you'll see the .ttf and .woff file name in the console. + */ + public void buildFont() throws FileNotFoundException { + // Create TTF file with doubletype + m_engine.getTypeface().addRequiredGlyphs(); + //m_engine.fireAction(); + //m_engine.addDefaultGlyphs(); + + for (FGlyph glyph : glyphs) { + + m_engine.checkUnicodeBlock(glyph.getGlyphChar()); + GlyphFile glyphFile = m_engine.addNewGlyph(glyph.getGlyphChar()); + glyphFile.setAdvanceWidth(glyph.getAdvanceWidth()); + + for (FContour contour : glyph.getContours()) { + + EContour econtour = new EContour(); + econtour.setType(EContour.k_quadratic); + + for (FPoint point : contour.points) { + + EContourPoint e = new EContourPoint(point.x, point.y, true); + if (point.hasControlPoint1()) { + + econtour.addContourPoint(new EContourPoint(point.controlPoint.x, point.controlPoint.y, false)); + /*EControlPoint cp1 = new EControlPoint(true, + point.controlPoint1.x, point.controlPoint1.y); + e.setControlPoint1(cp1); + */ + } +/* + if (point.hasControlPoint2()) { + EControlPoint cp2 = new EControlPoint(false, + point.controlPoint2.x, point.controlPoint2.y); + e.setControlPoint2(cp2); + } */ + + econtour.addContourPoint(e); + } + + glyphFile.addContour(econtour); + } + glyphFile.saveGlyphFile(); + } + + m_engine.buildTrueType(false); + + // End TTF creation + if(outfile.exists()){ + outfile.delete(); + } + ttffile.renameTo(outfile); + cleanup(); + } + + /** + * Deletes all the glyph files created by doubletype in your data/fontname + * folder. + */ + private void cleanup() { + File[] filesToExclude = new File[0]; + + deleteFolderContents(tempDir, true, filesToExclude); + + } + + /** + * Sets the author of the font. + */ + public void setAuthor(String author) throws FileNotFoundException { + m_engine.setAuthor(author); + } + + /** + * Sets the copyright year of the font. + */ + public void setCopyrightYear(String copyrightYear) throws FileNotFoundException { + m_engine.setCopyrightYear(copyrightYear); + } + + /** + * Sets the version of the font (default is "0.1"). + */ + public void setVersion(String version) { + m_engine.getTypeface().getGlyph().getHead().setVersion(version); + } + + /** + * Sets the font family name of the font. Also called in the constructor. If + * changed with setFontFamilyName() it won't affect folder the font is + * stored in. + */ + public void setFontFamilyName(String fontFamilyName) throws FileNotFoundException { + m_engine.setFontFamilyName(fontFamilyName); + } + + /** + * Sets the sub family of the font. + */ + public void setSubFamily(String subFamily) throws FileNotFoundException { + m_engine.getTypeface().setSubFamily(subFamily); + } + + /** + * Sets the license of the font (default is "CC BY-SA 3.0 + * http://creativecommons.org/licenses/by-sa/3.0/") + */ + public void setTypefaceLicense(String typefaceLicense) throws FileNotFoundException { + m_engine.setTypefaceLicense(typefaceLicense); + } + + /** + * Sets the baseline of the font. + */ + public void setBaseline(float baseline) throws FileNotFoundException { + m_engine.setBaseline(baseline); + } + + /** + * Sets the meanline of the font. + */ + public void setMeanline(float meanline) throws FileNotFoundException { + m_engine.setMeanline(meanline); + } + + /** + * Sets the advanceWidth of the font. Can be changed for every glyph + * individually. Won't affect already created glyphs. + */ + public void setAdvanceWidth(int advanceWidth) { + m_engine.setAdvanceWidth(advanceWidth); + this.advanceWidth = advanceWidth; + } + + public void setTopSideBearing(float topSideBearing) throws FileNotFoundException { + try { + m_engine.getTypeface().setTopSideBearing(topSideBearing); + } catch (OutOfRangeException e) { + System.out + .println("Error while setting aopSideBearing (must be within range " + + m_engine.getTypeface().getEm()); + e.printStackTrace(); + } + } + + public void setBottomSideBearing(float bottomSideBearing) throws FileNotFoundException { + try { + m_engine.getTypeface().setBottomSideBearing(bottomSideBearing); + } catch (OutOfRangeException e) { + System.out + .println("Error while setting bottomSideBearing (must be within range " + + m_engine.getTypeface().getEm()); + e.printStackTrace(); + } + } + + public void setAscender(float ascender) throws FileNotFoundException { + try { + m_engine.getTypeface().setAscender(ascender); + } catch (OutOfRangeException e) { + System.out + .println("Error while setting ascender (must be within range 0 to " + + m_engine.getTypeface().getEm() + ")"); + e.printStackTrace(); + } + } + + public void setDescender(float descender) throws FileNotFoundException { + try { + m_engine.getTypeface().setDescender(descender); + } catch (OutOfRangeException e) { + System.out + .println("Error while setting descender (must be within range 0 to " + + m_engine.getTypeface().getEm() + ")"); + e.printStackTrace(); + } + } + + public void setXHeight(float xHeight) throws FileNotFoundException { + try { + m_engine.getTypeface().setXHeight(xHeight); + } catch (OutOfRangeException e) { + System.out + .println("Error while setting xHeight (must be within range 0 to " + + m_engine.getTypeface().getEm() + + " as well as lower than the ascender " + + m_engine.getTypeface().getAscender() + ")"); + e.printStackTrace(); + } + } + + /** + * Sets the default metrics for the typeface: setTopSideBearing(170); // 2 + * px setAscender(683); // 8 px setXHeight(424); // 5 px setDescender(171); + * // 2 px setBottomSideBearing(0); // 0px + * + */ + public void setDefaultMetrics() throws FileNotFoundException { + m_engine.getTypeface().setDefaultMetrics(); + } + + /** + * Add a glyph + * + * @param c Character of the glyph. + * + * @return FGlyph that has been created. + * + */ + public FGlyph addGlyph(char c) { + + FGlyph glyph = new FGlyph(c); + glyph.setAdvanceWidth(advanceWidth); + glyphs.add(glyph); + return glyph; + + } + + /** + * Add a glyph and its one contour + * + * @param c Character of the glyph. + * + * @param FContour Shape of the glyph as FContour. + * + * @return The glyph FGlyph that has been created. You can use this to store + * the glyph and add contours afterwards. Alternatively, you can call + * getGlyph(char c) to retrieve it. + */ + public FGlyph addGlyph(char c, FContour contour) { + + FGlyph glyph = new FGlyph(c); + glyphs.add(glyph); + glyph.addContour(contour); + + glyph.setAdvanceWidth(advanceWidth); + return glyph; + + } + + /** + * Add a glyph and its contours + * + * @param c Character of the glyph. + * + * @param FContour [] Shape of the glyph in an array of FContour. + * + * @return The FGlyph that has been created. You can use this to store the + * glyph and add contours afterwards. Alternatively, you can call + * getGlyph(char c) to retrieve it. + */ + public FGlyph addGlyph(char c, FContour[] contours) { + + FGlyph glyph = new FGlyph(c); + glyphs.add(glyph); + + for (FContour contour : contours) { + // if (debug) System.out.println(p.x + " - " + p.y); + glyph.addContour(contour); + } + glyph.setAdvanceWidth(advanceWidth); + return glyph; + + } + + /** + * Get glyph by character + * + * @param c The character of the glyph + * + * @return The glyph + */ + public FGlyph getGlyph(char c) { + + FGlyph glyph = null; + for (int i = 0; i < glyphs.size(); i++) { + if (glyphs.get(i).getGlyphChar() == c) { + glyph = glyphs.get(i); + break; + } + } + return glyph; + + } + + /** + * Engine getter + * + * @return The doubletype Engine used for font creation, so that you can + * access all functions of doubletype in case you need them. + */ + public Engine getEngine() { + return m_engine; + } + + /** + * Returns the TypefaceFile + * + * @return The doubletype TypefaceFile used for font creation, so that you + * can access functions of doubletype in case you need them. + */ + public TypefaceFile getTypefaceFile() { + return m_engine.getTypeface(); + } + + /** + * Returns the .ttf file name + * + * @return The .ttf file name, which is being created when you call build() + */ + public String getTTFfilename() { + return ttffile.toString(); + } + + private static void deleteFolderContents(File folder, + boolean deleteFolderItself) { + File[] files = folder.listFiles(); + if (files != null) { // some JVMs return null for empty dirs + for (File f : files) { + if (f.isDirectory()) { + deleteFolderContents(f, true); + f.delete(); + } else { + f.delete(); + } + } + } + if (deleteFolderItself) { + folder.delete(); + } + } + + private static void deleteFolderContents(File folder, + boolean deleteFolderItself, File[] exceptions) { + File[] files = folder.listFiles(); + if (files != null) { // some JVMs return null for empty dirs + for (File f : files) { + boolean deleteFile = true; + for (File exceptfile : exceptions) { + if (f.equals(exceptfile)) { + deleteFile = false; + } + } + if (deleteFile) { + if (f.isDirectory()) { + deleteFolderContents(f, true, exceptions); + f.delete(); + } else { + f.delete(); + } + } + } + } + if (deleteFolderItself) { + folder.delete(); + } + } +} diff --git a/trunk/libsrc/ttf/src/fontastic/PVector.java b/trunk/libsrc/ttf/src/fontastic/PVector.java new file mode 100644 index 000000000..42786aab2 --- /dev/null +++ b/trunk/libsrc/ttf/src/fontastic/PVector.java @@ -0,0 +1,27 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +package fontastic; + +/** + * + * @author JPEXS + */ +public class PVector { + public double x; + public double y; + + public PVector() { + } + + + + public PVector(double x, double y) { + this.x = x; + this.y = y; + } + +} diff --git a/trunk/libsrc/ttf/src/fontatest/FontaTest.java b/trunk/libsrc/ttf/src/fontatest/FontaTest.java new file mode 100644 index 000000000..801ba5211 --- /dev/null +++ b/trunk/libsrc/ttf/src/fontatest/FontaTest.java @@ -0,0 +1,31 @@ +package fontatest; + +import fontastic.FPoint; +import fontastic.Fontastic; +import fontastic.PVector; +import java.io.File; +import java.io.IOException; + + +public class FontaTest { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) throws IOException { + File file=new File("example.ttf"); + file.delete(); + Fontastic f = new Fontastic("ExampleFont",file); + f.setAuthor("Nobody"); + FPoint[] points = new FPoint[]{ // Define a PVector array containing the points of the shape + new FPoint(0, 0), + new FPoint(512,0), + //new FPoint(256, 1024), + new FPoint(new PVector(256,1024), new PVector(512,512)), + new FPoint(0, 0) + }; + f.addGlyph('P').addContour(points); // Assign contour to character A + f.buildFont(); + } + +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/ActiveList.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/ActiveList.java new file mode 100644 index 000000000..dfacfb5fa --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/ActiveList.java @@ -0,0 +1,199 @@ + /* + * $Id: ActiveList.java,v 1.7 2004/11/15 03:39:38 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2003, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa; + +import java.util.*; + +import org.doubletype.ossa.adapter.*; + +/** + * @author e.e + */ +public class ActiveList { + private static ActiveList s_actives = null; + + public static ActiveList getSingletonInstance() { + if (s_actives == null) + s_actives = new ActiveList(); + + return s_actives; + } + + // -------------------------------------------------------------- + + public ArrayList m_activeObjects = new ArrayList<>(); + + public void unselectAll() { + m_activeObjects.clear(); + } + + public boolean hasSelected() { + return size() > 0; + } + + public int size() { + return m_activeObjects.size(); + } + + public GlyphObject get(int a_index) { + return m_activeObjects.get(a_index); + } + + public boolean isSelected(Object a_value) { + int i; + + // use equal method to compare this will catch XContour etc... + for (i = 0; i < size(); i++) { + if (get(i) == a_value) { + return true; + } // if + } // for i + + return false; + } + + public void addActive(GlyphObject a_object) { + if (isSelected(a_object)) { + return; + } // if + + m_activeObjects.add(a_object); + } + + public void setActives(ActiveList a_actives) { + unselectAll(); + + int i; + for (i = 0; i < a_actives.size(); i++) { + addActive(a_actives.get(i)); + } // for i + } + + private GlyphObject getTheActive() { + GlyphObject retval = null; + + if (m_activeObjects.size() == 1) { + retval = get(0); + } // if + + return retval; + } + + public boolean hasActiveModule() { + return (getTheActive() instanceof EModuleInvoke); + } + + public EModuleInvoke getActiveModule() { + if (hasActiveModule()) { + return (EModuleInvoke) getTheActive(); + } else { + return null; + } // if-else + } + + public boolean hasActiveContour() { + return (getTheActive() instanceof EContour); + } + + public EContour getActiveContour() { + if (getTheActive() instanceof EContour) { + return (EContour) getTheActive(); + } else { + return null; + } // if-else + } + + public boolean hasActiveInclude() { + return (getTheActive() instanceof EIncludeInvoke); + } + + public EIncludeInvoke getActiveInclude() { + if (hasActiveInclude()) { + return (EIncludeInvoke) getTheActive(); + } // if + + return null; + } + + public boolean hasActiveControlPoint() { + return (getTheActive() instanceof EControlPoint); + } + + public EControlPoint getActiveControlPoint() { + if (hasActiveControlPoint()) { + return (EControlPoint) getTheActive(); + } // if + + return null; + } + + public boolean hasActivePoint() { + return (getTheActive() instanceof EContourPoint); + } + + public EContourPoint getActivePoint() { + if (hasActivePoint()) { + return (EContourPoint) getTheActive(); + } else { + return null; + } // if + } + + public boolean hasActiveHint() { + return (getTheActive() instanceof EHint); + } + + public String getSelectedAsString() { + String retval = ""; + + if (!hasSelected()) { + return retval; + } // if + + retval = ""; + + int i; + for (i = 0; i < size(); i++) { + GlyphObject active = get(i); + retval += active.toString(); + } // for i + + retval += ""; + + return retval; + } + +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/AppSettings.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/AppSettings.java new file mode 100644 index 000000000..f5ca77e1e --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/AppSettings.java @@ -0,0 +1,55 @@ +/* + */ +package org.doubletype.ossa; + +import java.io.*; +import java.util.Properties; + +/** + * @author e.e + */ +public class AppSettings extends Object { + private static String k_lastTypefaceFile = "lastTypefaceFile"; + + private static File s_fileName = new File("./.properties"); + private static Properties s_properties; + + public static String getLastTypefaceDir() { + loadPropertyFile(); + return s_properties.getProperty(k_lastTypefaceFile, "./"); + } + + public static void setLastTypefaceDir(String a_value) { + loadPropertyFile(); + s_properties.setProperty(k_lastTypefaceFile, a_value); + savePropertyFile(); + } + + private static void loadPropertyFile() { + if (s_properties != null) { + return; + } // if + + s_properties = new Properties(); + if (s_fileName.exists()) { + try { + s_properties.load(new FileInputStream(s_fileName)); + } catch (IOException e) { + e.printStackTrace(); + } // try-catch + } // if + } + + private static void savePropertyFile() { + if (s_properties == null) { + return; + } // if + + try { + s_properties.store(new FileOutputStream(s_fileName), + "DoubleType AppSetting File"); + } catch (IOException e) { + e.printStackTrace(); + } // try-catch + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/Engine.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/Engine.java new file mode 100644 index 000000000..94c92bd19 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/Engine.java @@ -0,0 +1,762 @@ +/* + * $Id: Engine.java,v 1.84 2004/12/27 04:56:03 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2003, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa; + +import java.awt.*; +import java.awt.datatransfer.*; +import java.awt.event.*; +import java.awt.geom.*; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.*; +import java.io.*; +import java.net.MalformedURLException; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.*; +import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.*; +import javax.swing.event.*; + +import org.doubletype.ossa.adapter.*; +import org.doubletype.ossa.module.*; +import org.doubletype.ossa.truetype.*; + +/** + * @author e.e + */ +public class Engine { + // -------------------------------------------------------------- + + // used by findFile + public static final int USER_CANCELLED = -1; + public static final int FILE_NOT_FOUND = 0; + public static final int FILE_FOUND = 1; + + // used by Find + public static final int SEARCH_BY_EXAMPLE = 0; + public static final int SEARCH_UNICODE = 1; + public static final int SEARCH_JIS_CODE = 2; + + // public static final double k_fontSizes [] = {9, 10, 11, 12, 14, 18, 24, 36, 72}; + public static final int k_defaultPixelSize = 16; + public static final int k_resolutions [] = {96, 72, 75, 100}; + public static final int k_defaultResolution = 96; + public static final int k_zooms [] = {25, 50, 100}; + public static final int k_defaultZoom = 100; + + // -------------------------------------------------------------- + + private static int s_em = 1024; + private static Engine s_singleton = null; + + public static Engine getSingletonInstance() { + if (s_singleton == null) + s_singleton = new Engine(); + return s_singleton; + } + + public static int getEm() { + return TTPixelSize.getEm(); + } + + // -------------------------------------------------------------- + + private UiBridge m_ui; + + private TypefaceFile m_typeface; + private GlyphFile m_root; + private ActiveList m_actives; + private ArrayList m_listeners = new ArrayList<>(); + + private String m_foundFileName; + private Clipboard m_clipboard; + private JFileChooser m_gifChooser; + private JFileChooser m_chooser; + + private Action m_deleteAction; + private Action m_addPointAction; + private Action m_toggleAction; + private Action m_hintAction; + private Action m_contourAction; + private Action m_moduleAction; + private Action m_includeAction; + private Action m_selectNextAction; + private Action m_roundAction; + private Action m_propertyAction; + private Action m_convertControlPointAction; + private Action m_convertContourAction; + + private String m_msgAlreadyExists = " already exists!"; + private String m_msgNoTypeface = "no typeface"; + private String m_msgEmptyGlyphTitle = "glyph title is empty"; + private String m_msgGlyphName = "glyph name?"; + private String m_msgCircular = "circular include!"; + private String m_msgNoJis = "Charset ISO-2022-JP is not supported.\n" + + "Please include charsets.jar in classpath."; + + // -------------------------------------------------------------- + + private Engine() { + //GlyphFactory.setFactory(new EGlyphFactory()); + + + + m_typeface = null; + m_root = null; + + m_clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + m_actives = ActiveList.getSingletonInstance(); + + initActions(); + } + + private void initActions() { + + } + + public Action [] buildCommands() { + ArrayList actions = buildCommandsArrayList(); + Action [] retval = new Action[actions.size()]; + int i; + for (i = 0; i < actions.size(); i++) { + retval[i] = (Action) actions.get(i); + } // for i + + return retval; + } + + private ArrayList buildCommandsArrayList() { + ArrayList retval = new ArrayList<>(); + + if (m_root == null) { + return retval; + } // if + + if (m_actives.hasActiveContour()) { + retval.add(m_convertContourAction); + } + + if (m_actives.hasActiveControlPoint()) { + EControlPoint controlPoint = m_actives.getActiveControlPoint(); + retval.add(m_convertControlPointAction); + } + + if (m_actives.hasActivePoint()) { + EContourPoint point = m_actives.getActivePoint(); + + retval.add(m_toggleAction); + + if (!point.isRounded()) { + retval.add(m_hintAction); + } // if + + if (!point.hasHintForCurrentPpem()) { + retval.add(m_roundAction); + } // if + } // if + + if (m_actives.size() > 0) { + // retval.add(m_propertyAction); + retval.add(m_deleteAction); + } // if + + if (m_actives.hasActivePoint()) { + retval.add(m_addPointAction); + } // if + + /*if (!GlyphAction.isPointVisible()) { + retval.add(m_moduleAction); + retval.add(m_contourAction); + retval.add(m_includeAction); + } // if*/ + + return retval; + } + + public void localize(ResourceBundle a_bundle) { + m_msgAlreadyExists = a_bundle.getString("msgAlreadyExists"); + m_msgNoTypeface = a_bundle.getString("msgNoTypeface"); + m_msgEmptyGlyphTitle = a_bundle.getString("msgEmptyGlyphTitle"); + m_msgGlyphName = a_bundle.getString("msgGlyphName"); + m_msgCircular = a_bundle.getString("msgCircular"); + } + + private void showPropertyDialog() { + if (m_actives.size() != 1) { + return; + } // if + + m_ui.showPropertyDialog(m_actives.get(0)); + fireAction(); + } + + public void setUi(UiBridge a_ui) { + m_ui = a_ui; + } + + + + public void selectNext() { + if (m_root == null) { + return; + } // if + + m_root.selectNext(); + fireAction(); + } + + public void delete() { + if (m_root == null) + return; + if (!m_actives.hasSelected()) { + return; + } // if + + m_root.remove(); + + fireAction(); + } + + public void cutToClipboard() { + if (m_root == null) + return; + if (!m_actives.hasSelected()) { + return; + } // if + + copyToClipboard(); + delete(); + + fireAction(); + } + + public void copyToClipboard() { + if (m_root == null) + return; + if (!m_actives.hasSelected()) { + return; + } // if + + String s = m_actives.getSelectedAsString(); + if (s.equals("")) { + return; + } // if + + StringSelection selection = new StringSelection(s); + + try { + m_clipboard.setContents(selection, selection); + } catch (Exception e) { + e.printStackTrace(); + } // try-catch + + fireAction(); + } + + public void pasteFromClipboard() { + if (m_root == null) + return; + Transferable content = null; + String s = ""; + + try { + content = m_clipboard.getContents(this); + if (content == null) + return; + s = (String) content.getTransferData(DataFlavor.stringFlavor); + if (s.equals("")) { + return; + } // if + } catch (Exception e) { + e.printStackTrace(); + return; + } // try-catch + + try { + m_root.addObjectFromClipboard(s); + } catch (GlyphFile.CircularIncludeException e) { + Logger.getLogger(Engine.class.getName()).log(Level.SEVERE, m_msgCircular, e); + } + + fireAction(); + } + + public void undo() { + if (m_root == null) + return; + + m_root.undo(); + fireAction(); + } + + public void redo() { + if (m_root == null) + return; + + m_root.redo(); + fireAction(); + } + + public void setAdvanceWidth(int a_value) { + if (m_root == null) + return; + + m_root.setAdvanceWidth(a_value); + fireAction(); + } + + public void moveLeft() { + move(new Point2D.Double(-1, 0)); + } + + public void moveUp() { + move(new Point2D.Double(0, 1)); + } + + public void moveDown() { + move(new Point2D.Double(0, -1)); + } + + public void moveRight() { + move(new Point2D.Double(1, 0)); + } + + private void move(Point2D a_delta) { + if (m_root == null) { + return; + } // if + + m_root.move(a_delta); + } + + public void buildNewTypeface(String a_name, File a_dir) throws FileNotFoundException { + if (a_name == null || a_name.equals("")) { + return; + } // if + + TypefaceFile typeface = new TypefaceFile(a_name, a_dir); + typeface.setAuthor("no body"); + DateFormat format = new SimpleDateFormat("yyyy"); + typeface.setCopyrightYear(format.format(new Date())); + typeface.setFontFamilyName(a_name); + typeface.setSubFamily("Regular"); + typeface.addCodePage(TTCodePage.US_ASCII.toString()); + typeface.addCodePage(TTCodePage.Latin_1.toString()); + + setTypeface(typeface); + } + + public void addDefaultGlyphs() throws FileNotFoundException { + m_typeface.addRequiredGlyphs(); + m_typeface.addBasicLatinGlyphs(); + + fireAction(); + } + + public void openTypeface() throws FileNotFoundException { + if (m_chooser == null) { + m_chooser = new JFileChooser(new File(AppSettings.getLastTypefaceDir())); + } // if + + m_chooser.setFileFilter(new TypefaceFileFilter()); + int returnVal = m_chooser.showOpenDialog(null); + + if (returnVal != JFileChooser.APPROVE_OPTION) { + return; + } // if + + AppSettings.setLastTypefaceDir(m_chooser.getSelectedFile().toString()); + openTypeface(m_chooser.getSelectedFile()); + } + + private void openTypeface(File a_file) throws FileNotFoundException { + setTypeface(new TypefaceFile(a_file)); + + if (m_typeface.addRequiredGlyphs()) { + fireAction(); + } // if + } + + public void setTypeface(TypefaceFile a_typeface) { + m_typeface = a_typeface; + fireAction(); + } + + public void changeUnicode(long a_unicode) throws FileNotFoundException { + if (m_typeface == null || m_root == null) { + return; + } // if + + m_typeface.setGlyphUnicode(m_root, a_unicode); + fireAction(); + } + + public int findFile(long a_unicode) { + if (m_typeface == null) + return USER_CANCELLED; + + m_foundFileName = m_typeface.unicodeToFileName(a_unicode); + if (m_foundFileName != null) { + return FILE_FOUND; + } // if + + return FILE_NOT_FOUND; + } + + public String getFoundFileName() { + return m_foundFileName; + } + + + /** + * Create glyph out of given unicode, and add it to the typeface. + * @param a_unicode + */ + public GlyphFile addNewGlyph(long a_unicode) throws FileNotFoundException { + GlyphFile retval; + + retval = m_typeface.createGlyph(a_unicode); + addGlyphToTypeface(retval); + + return retval; + } + + public void checkUnicodeBlock(long a_unicode) throws FileNotFoundException { + TTUnicodeRange range = TTUnicodeRange.of(a_unicode); + if (range == null){ + return; + } + + if (m_typeface.containsUnicodeRange(range.toString())){ + return; + } + m_typeface.addUnicodeRange(range.toString()); + } + + private void addGlyphToTypeface(GlyphFile a_file) throws FileNotFoundException { + m_typeface.addGlyph(a_file); + m_typeface.saveGlyphFile(); + + setRoot(a_file); + } + + public GlyphFile openGlyphFile(String a_fileName) { + ModuleManager manager = ModuleManager.getSingletonInstance(); + GlyphFile retval = manager.getReloadedGlyphFile(a_fileName); + setRoot(retval); + + return retval; + } + + public void removeGlyphFromTypeface(String a_fileName) { + if (m_typeface == null) + return; + + m_typeface.removeGlyph(a_fileName); + fireAction(); + } + + public Font buildTrueType(boolean a_isDebug) { + Font retval = null; + + if (m_typeface == null) + return retval; + + + + try { + m_typeface.buildTTF(a_isDebug); + retval = m_typeface.getFont(); + } catch (Exception e) { + Logger.getLogger(Engine.class.getName()).log(Level.SEVERE, null,e); + } // try-catch + + return retval; + } + + public void saveGlyph() throws FileNotFoundException { + if (m_root == null) + return; + + if (m_root.getGlyphTitle().equals("")) { + Logger.getLogger(Engine.class.getName()).log(Level.SEVERE, m_msgEmptyGlyphTitle); + return; + } // if + + m_root.saveGlyphFile(); + fireAction(); + } + + public TypefaceFile getTypeface() { + return m_typeface; + } + + public File getGlyphPath() { + return m_typeface.getGlyphPath(); + } + + + public GlyphFile getRoot() { + return m_root; + } + + public void setRoot(GlyphFile a_file) { + m_root = a_file; + fireAction(); + } + + public void addActionListener(ActionListener a_listener) { + m_listeners.add(a_listener); + } + + public void fireAction() { + ActionEvent e = new ActionEvent(this, Event.ACTION_EVENT, "foo"); + + for (ActionListener listener: m_listeners) { + listener.actionPerformed(e); + } // for listener + } + + public String includeFileName() { + String retval = ""; + + JFileChooser chooser = new JFileChooser(getGlyphPath()); + chooser.setFileFilter(new GlyphFileFilter()); + + int returnVal = chooser.showOpenDialog(null); + + if (returnVal == JFileChooser.APPROVE_OPTION) { + retval = chooser.getSelectedFile().getName().toString(); + } // if + + return retval; + } + + public void addCodePage(String a_codePage) throws FileNotFoundException { + if (m_typeface == null) { + return; + } // if + + m_typeface.addCodePage(a_codePage); + fireAction(); + } + + public void removeCodePage(String a_codePage) throws FileNotFoundException { + if (m_typeface == null) { + return; + } // if + + m_typeface.removeCodePage(a_codePage); + fireAction(); + } + + public void setAuthor(String a_value) throws FileNotFoundException { + if (m_typeface == null) { + return; + } // if + + m_typeface.setAuthor(a_value); + m_typeface.saveGlyphFile(); + fireAction(); + } + + public void setCopyrightYear(String a_value) throws FileNotFoundException { + if (m_typeface == null) { + return; + } // if + + m_typeface.setCopyrightYear(a_value); + m_typeface.saveGlyphFile(); + fireAction(); + } + + public void setFontFamilyName(String a_value) throws FileNotFoundException { + if (m_typeface == null) { + return; + } // if + + m_typeface.setFontFamilyName(a_value); + fireAction(); + } + + public void setTypefaceLicense(String a_value) throws FileNotFoundException { + if (m_typeface == null) { + return; + } // if + + m_typeface.setLicense(a_value); + m_typeface.saveGlyphFile(); + fireAction(); + } + + public void setBaseline(double a_value) throws FileNotFoundException { + if (m_typeface == null) { + return; + } // if + + double min = m_typeface.getBottomSideBearing(); + double max = m_typeface.getMeanline(); + + if (a_value < min) { + a_value = min; + } // if + + if (a_value > max) { + a_value = max; + } // if + + try { + m_typeface.setDescender(a_value - min); + m_typeface.setAscender(m_typeface.getEm() + - m_typeface.getTopSideBearing() - a_value); + m_typeface.setXHeight(max - a_value); + } + catch (OutOfRangeException e) { + e.printStackTrace(); + } // try-catch + + fireAction(); + } + + public void setMeanline(double a_value) throws FileNotFoundException { + if (m_typeface == null) { + return; + } // if + + double min = m_typeface.getBaseline(); + double max = m_typeface.getEm() + - m_typeface.getTopSideBearing(); + + if (a_value < min) { + a_value = min; + } // if + + if (a_value > max) { + a_value = max; + } // if + + try { + m_typeface.setXHeight(a_value - min); + } + catch (OutOfRangeException e) { + e.printStackTrace(); + } // try-catch + + fireAction(); + } + + public void mousePressed(MouseEvent a_event) { + + } + + + public void mouseDragged(MouseEvent a_event) { + + } + + public void mouseReleased(MouseEvent a_event) { + + } + + public void setAction(String a_key) { + + } + + public void keyPressed(KeyEvent a_event) { + if (a_event.getModifiers() == 0) { + if (a_event.getKeyCode() == KeyEvent.VK_TAB) { + + m_selectNextAction.actionPerformed(null); + } // if + } else if (a_event.getModifiers() == KeyEvent.SHIFT_MASK) { + + } // if + + fireAction(); + } + + private JFileChooser createImageChooser() { + JFileChooser retval; + + retval = new JFileChooser(new File(AppSettings.getLastTypefaceDir())); + retval.setFileFilter(new javax.swing.filechooser.FileFilter() { + public boolean accept(File a_file) { + if (a_file.isDirectory()) + return true; + + String s = a_file.toString().toLowerCase(); + if (s.endsWith(".gif") + || s.endsWith(".jpg") + || s.endsWith(".jpeg") + || s.endsWith(".png")) + return true; + + return false; + } + + //The description of this filter + public String getDescription() { + return "Image Files"; + } + }); + + return retval; + } + + + + + public ArrayList getPixelSizes() { + return TTPixelSize.getList(); + } + + class MyTreeListener implements TreeSelectionListener { + public void valueChanged(TreeSelectionEvent a_event) { + TreePath path = a_event.getPath(); + Object obj = path.getLastPathComponent(); + String s = obj.toString(); + + TreePath parent = path.getParentPath(); + if (parent != null) { + obj = parent.getLastPathComponent(); + s = obj.toString() + "->" + s; + } // if + + } + } + +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/GlyphColor.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/GlyphColor.java new file mode 100644 index 000000000..fa6bb987a --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/GlyphColor.java @@ -0,0 +1,67 @@ +/* + * $Id: GlyphColor.java,v 1.6 2004/07/11 06:25:11 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2003, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa; + +import java.awt.*; + + +/** + * @author e.e + */ +public class GlyphColor { + public static Color MAROON = new Color(120, 21, 11); + public static Color ORANGE = new Color(231, 113, 18); // (238, 176, 55); + public static Color OLIVE = new Color(98, 106, 7); + public static Color INDIGO = new Color(22, 16, 149); + public static Color GREEN = new Color(21, 142, 5); + public static Color RED = new Color(250, 0, 0); + public static Color GRAY = new Color(0x33, 0x33, 0x33); + public static Color CYAN = new Color(15, 187, 157); // 15, 108, 140 + public static Color AZURE = new Color(0x00, 0x66, 0xcc); + public static Color TAN = new Color(0xcc, 0x99, 0x66); + public static Color SILVER = new Color(0xe0, 0xdf, 0xe3); + + + public static Color BACKGROUND = Color.WHITE; + public static Color CROSS = Color.LIGHT_GRAY; + public static Color POINT = ORANGE; + public static Color NUMBER = Color.GRAY; + public static Color SELECTED = RED; + public static Color CONTOUR = AZURE; + public static Color HINT = OLIVE; + public static Color INCLUDE = OLIVE; + public static Color MODULE = MAROON; +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/GlyphFileFilter.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/GlyphFileFilter.java new file mode 100644 index 000000000..b93ba5a42 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/GlyphFileFilter.java @@ -0,0 +1,60 @@ +/* + * $Id: GlyphFileFilter.java,v 1.2 2004/01/20 03:35:27 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2003-2004, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa; + +import java.io.File; +import javax.swing.filechooser.FileFilter; + +/** + * @author e.e + */ +public class GlyphFileFilter extends FileFilter { + public boolean accept(File a_file) { + if (a_file.isDirectory()) { + return false; + } // if + + if (! (a_file.toString().toLowerCase().endsWith(".glyph"))) + return false; + + return true; + } + + //The description of this filter + public String getDescription() { + return "glyph files"; + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/HistoryList.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/HistoryList.java new file mode 100644 index 000000000..53fe5e867 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/HistoryList.java @@ -0,0 +1,104 @@ + /* + * $Id: HistoryList.java,v 1.1 2004/09/05 17:08:03 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2004, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa; + +import java.util.*; +import org.doubletype.ossa.module.GlyphFile; + +/** Caretaker of MementoPattern. + * @author e.e + */ +public class HistoryList { + private GlyphFile m_file; + private ArrayList m_list = new ArrayList<>(); + private int m_index = -1; + + + public HistoryList(GlyphFile a_file) { + m_file = a_file; + } + + private void printHistoryArray() { + int i; + for (i = 0; i <= m_index; i++) { + Memento memento = m_list.get(i); + System.out.println(memento.toString()); + } // for i + } + + /** + * Records snapshot into history queue. + * Takes place after each action. + * Updates modified time with the current system time. + * @param a_description + */ + public void record(String a_description) { + add(m_file.createMemento(a_description)); + } + + private void add(Memento a_memento) { + while (m_list.size() - 1 > m_index) { + m_list.remove(m_list.size() - 1); + } // if + + m_list.add(a_memento); + m_index = m_list.size() - 1; + } + + public void undo() { + if (m_list.size() == 0 + || m_index <= 0) { + return; + } // if + + m_index--; + m_file.restore(get(m_index)); + } + + public void redo() { + if (m_list.size() == 0 + || m_index >= m_list.size() - 1) { + return; + } // if + + m_index++; + m_file.restore(get(m_index)); + } + + private Memento get(int a_index) { + return m_list.get(a_index); + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/ImageSizer.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/ImageSizer.java new file mode 100644 index 000000000..dd409e8f7 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/ImageSizer.java @@ -0,0 +1,91 @@ +/* + * $Id: ImageSizer.java,v 1.1 2004/03/04 12:52:50 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2003-2004, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa; + +import java.awt.*; +import java.awt.image.*; + +/** + * @author e.e + */ +public class ImageSizer { + private Dimension m_size = new Dimension(-1, -1); + private boolean m_isImcomplete; + + private ImageObserver m_observer = new ImageObserver() { + public synchronized boolean imageUpdate( + Image a_image, + int a_flag, + int a_x, + int a_y, + int a_width, + int a_height) { + if ((a_flag & WIDTH) != 0) + m_size.width = a_width; + if ((a_flag & HEIGHT) != 0) + m_size.height = a_height; + if ((a_flag & (ERROR | ABORT)) != 0) + m_isImcomplete = true; + + boolean retval = !resultKnown(); + if (!retval) { + notifyAll(); + } // if + + return retval; + } + }; + + public ImageSizer(Image a_image) { + m_size.width = a_image.getWidth(m_observer); + m_size.height = a_image.getHeight(m_observer); + } + + private boolean resultKnown() { + return m_size.width != -1 + && m_size.height != -1 + || m_isImcomplete; + } + + //returns null iff error or abort + public Dimension getImageSize() throws InterruptedException { + synchronized (m_observer) { + while (!resultKnown()) + m_observer.wait(); + return m_isImcomplete ? null : new Dimension(m_size); + } + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/Memento.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/Memento.java new file mode 100644 index 000000000..19661eedc --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/Memento.java @@ -0,0 +1,89 @@ + /* + * $Id: Memento.java,v 1.1 2004/09/05 17:08:03 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2003 - 2004, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa; + +import java.io.*; +import java.util.zip.*; + +/** + * @author e.e + */ +public class Memento { + private String m_description; + private byte [] m_compressed; + private int m_originalSize; + private long m_entryTime; + + public Memento(String a_description, byte [] a_data) { + m_description = a_description; + m_originalSize = a_data.length; + + ByteArrayOutputStream out = new ByteArrayOutputStream(); + ZipOutputStream zip = new ZipOutputStream(out); + + try { + zip.putNextEntry(new ZipEntry(a_description)); + zip.write(a_data); + zip.closeEntry(); + zip.close(); + } + catch (IOException ioe) { + ioe.printStackTrace(); + } + + m_compressed = out.toByteArray(); + m_entryTime = System.currentTimeMillis(); + } + + public InputStream getData() { + ZipInputStream zip = null; + + try { + zip = new ZipInputStream( + new ByteArrayInputStream(m_compressed)); + ZipEntry entry = zip.getNextEntry(); + } + catch (IOException ioe) { + ioe.printStackTrace(); + } + + return zip; + } + + public String toString() { + return m_description; + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/ModuleManager.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/ModuleManager.java new file mode 100644 index 000000000..f1a6e7f92 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/ModuleManager.java @@ -0,0 +1,96 @@ +/* + * $Id: ModuleManager.java,v 1.5 2004/01/14 06:49:39 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2003, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa; + +import java.util.*; +import org.doubletype.ossa.module.*; +import java.io.*; + +/** + * @author e.e + */ +public class ModuleManager { + private static ModuleManager s_singleton = null; + + public static ModuleManager getSingletonInstance() { + if (s_singleton == null) + s_singleton = new ModuleManager(); + return s_singleton; + } + + + private Hashtable m_modules = new Hashtable<>(); + private Hashtable m_files = new Hashtable<>(); + + private ModuleManager() { + } + + public void clear() { + m_modules.clear(); + m_files.clear(); + } + + public GlyphModule getModule(String a_name) throws Exception { + if (m_modules.containsKey(a_name)) { + return (GlyphModule) m_modules.get(a_name); + } // if + + GlyphModule retval; + + retval = (GlyphModule) Class.forName(a_name).newInstance(); + m_modules.put(a_name, retval); + + return retval; + } + + public GlyphFile getGlyphFile(String a_name) { + if (m_files.containsKey(a_name)) { + return (GlyphFile) m_files.get(a_name); + } // if + + return getReloadedGlyphFile(a_name); + } + + public GlyphFile getReloadedGlyphFile(String a_name) { + GlyphFile retval; + + Engine engine = Engine.getSingletonInstance(); + retval = new GlyphFile(new File(engine.getGlyphPath(), a_name)); + m_files.put(a_name, retval); + + return retval; + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/MyTableModel.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/MyTableModel.java new file mode 100644 index 000000000..24f671dd6 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/MyTableModel.java @@ -0,0 +1,73 @@ +/* + * $Id: MyTableModel.java,v 1.1 2004/02/09 05:34:17 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2003-2004, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa; + +import javax.swing.table.*; +import org.doubletype.ossa.module.*; + +/** + * @author e.e + */ +public class MyTableModel extends AbstractTableModel { + protected Engine m_engine; + protected GlyphFile m_file = null; + + protected MyTableModel(Engine a_engine) { + m_engine = a_engine; + } + + public int getColumnCount() { + return 2; + } + + public int getRowCount() { + reset(); + + return 0; + } + + public Object getValueAt(int a_row, int a_column) { + reset(); + + Object retval = null; + + return retval; + } + + protected void reset() { + + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/OutOfRangeException.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/OutOfRangeException.java new file mode 100644 index 000000000..4016eabe9 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/OutOfRangeException.java @@ -0,0 +1,49 @@ +/* + * $Id: OutOfRangeException.java,v 1.1 2004/02/23 14:19:30 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2003, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa; + +/** + * @author e.e + */ +public class OutOfRangeException extends Exception { + private double m_value; + + public OutOfRangeException(double a_value) { + super(); + + m_value = a_value; + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/Renderer.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/Renderer.java new file mode 100644 index 000000000..623e6739f --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/Renderer.java @@ -0,0 +1,44 @@ +/* + * $Id: Renderer.java,v 1.1 2004/06/18 09:14:01 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2004, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa; + +/** + * @author e.e + */ +public interface Renderer { + boolean isRenderNeeded(); + void render(java.awt.Graphics2D a_graphics); +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/Tabbable.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/Tabbable.java new file mode 100644 index 000000000..bc9f0e23c --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/Tabbable.java @@ -0,0 +1,5 @@ +package org.doubletype.ossa; + +public interface Tabbable { + boolean isClosable(); +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/TabbedPaneCloseButtonUI.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/TabbedPaneCloseButtonUI.java new file mode 100644 index 000000000..0d9504efc --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/TabbedPaneCloseButtonUI.java @@ -0,0 +1,188 @@ +// http://forums.sun.com/thread.jspa?forumID=257&threadID=453521 + +package org.doubletype.ossa; + +import java.awt.Color; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.Rectangle; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; + +import javax.swing.plaf.basic.BasicTabbedPaneUI; + +public class TabbedPaneCloseButtonUI extends BasicTabbedPaneUI { + private final int k_xButtonOffset = 19; + private final int k_yButtonOffset = 4; + private final int k_wButton = 14; // was 13 + private final int k_hButton = 13; // was 12 + + private int m_lastKnownSelected = -1; + private Color m_red = new Color(217, 76, 74); + private Color m_selectedColor = Color.white; + private Color m_unselectedColor = new Color(160, 197, 241); + + public TabbedPaneCloseButtonUI() { + super(); + } + + protected void paintTabBackground(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected) + { + if (isSelected) + { + g.setColor(m_selectedColor); + } + else + { + g.setColor(m_unselectedColor); + } + + g.fillRect(x, y, w, h); + } + + protected int calculateTabHeight(int tabPlacement, int tabIndex, int fontHeight) + { + return fontHeight + 4; + } + + protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected) + { + g.setColor(darkShadow); + g.drawLine(x, y + h - 2, x, y); + g.drawLine(x, y, x + w, y); + g.drawLine(x + w, y + h - 2, x + w, y); + } + + protected void paintTab(Graphics g, int tabPlacement, Rectangle[] rects, + int tabIndex, Rectangle iconRect, Rectangle textRect) { + + super.paintTab(g, tabPlacement, rects, tabIndex, iconRect, textRect); + } + + protected void paintFocusIndicator(Graphics g, int tabPlacement, Rectangle[] rects, int tabIndex, Rectangle iconRect, Rectangle textRect, boolean isSelected) + { + } + + protected void paintContentBorderTopEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) + { + if (selectedIndex < 0) { + return; + } // if + + Rectangle rect = getTabBounds(selectedIndex, calcRect); + g.setColor(darkShadow); + g.drawLine(x, y, rect.x, y); + g.drawLine(rect.x + rect.width, y, x + w, y); + g.setColor(m_selectedColor); + g.drawLine(rect.x + 1, y, rect.x + rect.width -1, y); + } + + protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) + { + } + + protected void paintContentBorderRightEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) + { + } + + protected void paintContentBorderLeftEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) + { + } + + protected void paintText(Graphics g, int tabPlacement, java.awt.Font font, FontMetrics metrics, int tabIndex, String title, Rectangle textRect, boolean isSelected) + { + if (tabPane.getComponentAt(tabIndex) instanceof Tabbable) { + Tabbable tabbable = (Tabbable) tabPane.getComponentAt(tabIndex); + if (!tabbable.isClosable()) { + super.paintText(g, tabPlacement, font, metrics, tabIndex, title, textRect, isSelected); + return; + } // if + } // if + + if (isSelected) // isSelected + { + super.paintText(g, tabPlacement, font, metrics, tabIndex, title, textRect, isSelected); + Rectangle rect = rects[tabIndex]; + g.setColor(m_red); + int xButton = rect.x + rect.width - k_xButtonOffset; // -19 + int yButton = rect.y + k_yButtonOffset; // +4 + g.fillRect(xButton, yButton, k_wButton, k_hButton); + g.setColor(Color.white); + g.drawLine(xButton + 3, rect.y + 7, xButton + 9, rect.y + 13); + g.drawLine(xButton + 9, rect.y + 7, xButton + 3, rect.y + 13); + g.drawLine(xButton + 4, rect.y + 7, xButton + 10, rect.y + 13); + g.drawLine(xButton + 10, rect.y + 7, xButton + 4, rect.y + 13); + + m_lastKnownSelected = tabIndex; + } + else + { + super.paintText(g, tabPlacement, font, metrics, tabIndex, title, textRect, isSelected); + } + } + + protected int calculateTabWidth(int tabPlacement, int tabIndex, + FontMetrics metrics) { + if (tabPane.getComponentAt(tabIndex) instanceof Tabbable) { + Tabbable tabbable = (Tabbable) tabPane.getComponentAt(tabIndex); + if (!tabbable.isClosable()) { + return super.calculateTabWidth(tabPlacement, tabIndex, metrics); + } // if + } // if + + return super.calculateTabWidth(tabPlacement, tabIndex, metrics) + 34; // +24 + } + + protected MouseListener createMouseListener() { + return new MyMouseHandler(); + } + + class MyMouseHandler extends MouseHandler { + private int m_selectedOnPressed = -1; + + public MyMouseHandler() { + super(); + } + + public void mousePressed(MouseEvent e) { + m_selectedOnPressed = m_lastKnownSelected; + super.mousePressed(e); + } + + public void mouseReleased(MouseEvent e) { + int x = e.getX(); + int y = e.getY(); + int tabIndex = -1; + int tabCount = tabPane.getTabCount(); + for (int i = 0; i < tabCount; i++) { + if (rects[i].contains(x, y)) { + tabIndex = i; + break; + } // if + } // for i + + // skip if this is not current. + if (tabPane.getSelectedIndex() != tabIndex) { + return; + } // if + + if (m_selectedOnPressed != tabIndex) { + return; + } // if + + if (tabIndex >= 0 && !e.isPopupTrigger()) { + Rectangle tabRect = rects[tabIndex]; + y = y - tabRect.y; + + int xButton = tabRect.x + tabRect.width - k_xButtonOffset; + if ((x >= xButton + 1) + && (x <= xButton + k_wButton - 2) + && (y >= k_yButtonOffset + 1) + && (y <= k_yButtonOffset + k_hButton - 2)) { + tabPane.remove(tabIndex); + } + } + } + } + +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/TypefaceFileFilter.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/TypefaceFileFilter.java new file mode 100644 index 000000000..446cdad16 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/TypefaceFileFilter.java @@ -0,0 +1,59 @@ +/* + * $Id: TypefaceFileFilter.java,v 1.1 2004/01/20 03:35:27 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2003-2004, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa; + +import java.io.File; +import javax.swing.filechooser.FileFilter; + +/** + * @author e.e + */ +public class TypefaceFileFilter extends FileFilter { + public boolean accept(File a_file) { + if (a_file.isDirectory()) + return true; + + if (! (a_file.toString().toLowerCase().endsWith(".dtyp"))) + return false; + + return true; + } + + //The description of this filter + public String getDescription() { + return "typeface files"; + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/UiBridge.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/UiBridge.java new file mode 100644 index 000000000..c49d75c7d --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/UiBridge.java @@ -0,0 +1,12 @@ +/* + */ +package org.doubletype.ossa; + +import org.doubletype.ossa.adapter.*; + +/** + * @author e.e + */ +public interface UiBridge { + void showPropertyDialog(GlyphObject a_object); +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/UnicodeBuilder.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/UnicodeBuilder.java new file mode 100644 index 000000000..b10718938 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/UnicodeBuilder.java @@ -0,0 +1,184 @@ +/* + * $Id: UnicodeBuilder.java,v 1.1 2004/09/11 10:09:07 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2004, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa; + +import java.nio.ByteBuffer; +import java.nio.CharBuffer; +import java.nio.charset.CharacterCodingException; +import java.nio.charset.Charset; +import java.nio.charset.CharsetDecoder; +import java.util.logging.Level; +import java.util.logging.Logger; + + +/** + * @author e.e + */ +public class UnicodeBuilder { + public static final String k_jisCharset = "ISO-2022-JP"; + + /** + * pops dialog and asks user for unicode. + * @return true on success, false otherwise. + */ + public static Long askUnicode() { + Engine engine = Engine.getSingletonInstance(); + + throw new UnsupportedOperationException(); + } + + public static Long build(String a_value, int a_option) { + if (a_value == null + || a_value.length() == 0) { + return null; + } // if + + switch (a_option) { + case Engine.SEARCH_BY_EXAMPLE: { + return buildByExample(a_value); + } // case + + case Engine.SEARCH_UNICODE: { + return buildByUnicode(a_value); + } // case + + case Engine.SEARCH_JIS_CODE: { + return buildByJisCode(a_value); + } // case + } // switch + + return null; + } + + private static Long buildByExample(String a_value) { + if (a_value.length() > 1) { + return null; + } // if + + return new Long((long) a_value.charAt(0)); + } + + private static Long buildByUnicode(String a_value) { + if (a_value.length() == 1) { + return buildByExample(a_value); + } // if + + try { + return new Long(Long.parseLong(a_value, 16)); + } catch (NumberFormatException e) { + Logger.getLogger(Engine.class.getName()).log(Level.SEVERE, null,e); + } + + return null; + } + + private static Long buildByJisCode(String a_value) { + if (a_value.length() == 1) { + return buildByExample(a_value); + } // if + + try { + Long retval = jisX0208ToUnicode(Long.parseLong(a_value, 16)); + + if (retval == null) { + Logger.getLogger(Engine.class.getName()).log(Level.SEVERE, "Bad JIS Code."); + } // if + + return retval; + } catch (NumberFormatException e) { + Logger.getLogger(Engine.class.getName()).log(Level.SEVERE, null, e); + } // try + + return null; + } + + /** + * converts JIS X0208 code into unicode using ISO-2022-JP decoder. + * @param a_value JIS code + * @return unicode + */ + public static Long jisX0208ToUnicode(long a_value) { + if (!isJisSupported()) { + return null; + } // if + + Charset jis = Charset.forName(k_jisCharset); + ByteBuffer in = ByteBuffer.allocate(5); + CharsetDecoder jisDecoder; + jisDecoder = jis.newDecoder(); + + long high = (0xff00 & a_value) >> 8; + long low = 0x00ff & a_value; + + if (high < 0x21 || high > 0x7e || low < 0x21 || high > 0x7e) { + return null; + } // if + + char c = (char) a_value; + + in.rewind(); + in.put((byte) 0x1b); + in.put((byte) 0x24); + in.put((byte) 0x40); + + in.putChar(c); + in.position(0); + + try { + CharBuffer out = jisDecoder.decode(in); + if (out.length() > 0) { + return new Long(out.get(0)); + } // if + } catch (CharacterCodingException e) { + e.printStackTrace(); + } // try-catch + + return null; + } + + public static boolean isJisSupported() { + return Charset.isSupported(k_jisCharset); + } + + /** + * + */ + public UnicodeBuilder() { + super(); + // TODO Auto-generated constructor stub + } + +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/CubicSegment.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/CubicSegment.java new file mode 100644 index 000000000..44c33e025 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/CubicSegment.java @@ -0,0 +1,398 @@ +/* + * $Id: CubicSegment.java,v 1.2 2004/12/27 04:56:02 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2004, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa.adapter; + +import java.util.*; +import java.awt.geom.*; + +import org.doubletype.ossa.xml.*; + +/** + * @author e.e + */ +public class CubicSegment { + public static final int LINE = 0; + public static final int CURVE = 1; + + private static final double k_tolerance = 5; + private static final double k_minTolerance = 10; + private static final int k_maxTrial = 3; + + /** + * converts cubic contour into cubic segments. + * @param a_contour + * @return + */ + public static ArrayList toSegments(EContour a_contour) { + ArrayList retval = new ArrayList<>(); + XContourPoint [] points = a_contour.getContourPoint(); + if (points.length < 2) { + return retval; + } // if + + EContourPoint startPoint = (EContourPoint) points[points.length - 1]; + for (int i = 0; i < points.length; i++) { + EContourPoint endPoint = (EContourPoint) points[i]; + retval.add(new CubicSegment(startPoint, endPoint)); + startPoint = endPoint; + } // for + + return retval; + } + + /** + * converts cubic segments into cubic contour. + * @param a_segments + * @return + */ + public static EContour toContour(ArrayList a_segments) { + EContour retval = new EContour(); + retval.setType(EContour.k_cubic); + + EControlPoint controlPoint1 = null; + for (int i = 0; i < a_segments.size(); i++) { + CubicSegment segment = (CubicSegment) a_segments.get(i); + EContourPoint startPoint = (EContourPoint) segment.m_startPoint.clone(); + + if (controlPoint1 != null) { + startPoint.setControlPoint1(controlPoint1); + controlPoint1 = null; + } // if + + if (segment.m_controlPoint1 != null) { + EControlPoint controlPoint2 = new EControlPoint(false, + segment.m_controlPoint1.getX(), + segment.m_controlPoint1.getY()); + startPoint.setControlPoint2(controlPoint2); + } // if + + retval.addContourPoint(startPoint); + + if (segment.m_controlPoint2 != null) { + controlPoint1 = new EControlPoint(true, + segment.m_controlPoint2.getX(), + segment.m_controlPoint2.getY()); + } + } // for i + + return retval; + } + + private EContourPoint m_startPoint = null; + private EContourPoint m_controlPoint1 = null; + private EContourPoint m_controlPoint2 = null; + private EContourPoint m_endPoint = null; + + private int m_type = LINE; + + + public CubicSegment(EContourPoint a_startPoint, EContourPoint a_endPoint) { + m_startPoint = a_startPoint; + m_endPoint = a_endPoint; + + if ((!a_startPoint.hasControlPoint2()) && (!a_endPoint.hasControlPoint1())) { + m_type = LINE; + return; + } // if + + if (a_startPoint.hasControlPoint2() || a_endPoint.hasControlPoint1()) { + m_type = CURVE; + + if (a_startPoint.hasControlPoint2()) { + m_controlPoint1 = (EContourPoint) a_startPoint.getControlPoint2().getContourPoint(); + } else { + m_controlPoint1 = a_startPoint; + } // if-else + + if (a_endPoint.hasControlPoint1()) { + m_controlPoint2 = (EContourPoint) a_endPoint.getControlPoint1().getContourPoint(); + } else { + m_controlPoint2 = a_endPoint; + } // if-else + } // if + } + + public CubicSegment(EContourPoint a_startPoint, EContourPoint a_controlPoint1, + EContourPoint a_controlPoint2, EContourPoint a_endPoint) { + m_startPoint = a_startPoint; + m_controlPoint1 = a_controlPoint1; + m_controlPoint2 = a_controlPoint2; + m_endPoint = a_endPoint; + m_type = CURVE; + } + + public ArrayList toQuadraticSegments() { + ArrayList retval = new ArrayList<>(); + + if (m_type == LINE) { + retval.add(new QuadraticSegment(m_startPoint, null, m_endPoint)); + return retval; + } // if + + return toQuadraticSegments(0); + } + + //JPEXS start + private static Point2D.Double movePoint(Point2D point, double dx, double dy) { + return new Point2D.Double(point.getX() + dx, point.getY() + dy); + } + + private static Point2D getMidPoint(Point2D p0, Point2D p1) { + return getPointOnSegment(p0, p1, 0.5); + } + + private static Point2D getPointOnSegment(Point2D p0, Point2D p1, double ratio) { + double x = p0.getX() + ((p1.getX() - p0.getX()) * ratio); + double y = p0.getY() + ((p1.getY() - p0.getY()) * ratio); + return new Point2D.Double(x, y); + } + private static double[][] approximateCubic(double[] cubicControlPointCoords) { + if (cubicControlPointCoords.length < 8) { + throw new IllegalArgumentException("Must have at least 8 coordinates"); + } + + //extract point objects from source array + Point2D p0 = new Point2D.Double(cubicControlPointCoords[0], cubicControlPointCoords[1]); + Point2D p1 = new Point2D.Double(cubicControlPointCoords[2], cubicControlPointCoords[3]); + Point2D p2 = new Point2D.Double(cubicControlPointCoords[4], cubicControlPointCoords[5]); + Point2D p3 = new Point2D.Double(cubicControlPointCoords[6], cubicControlPointCoords[7]); + + //calculates the useful base points + Point2D pa = getPointOnSegment(p0, p1, 3.0 / 4.0); + Point2D pb = getPointOnSegment(p3, p2, 3.0 / 4.0); + + //get 1/16 of the [P3, P0] segment + double dx = (p3.getX() - p0.getX()) / 16.0; + double dy = (p3.getY() - p0.getY()) / 16.0; + + //calculates control point 1 + Point2D pc1 = getPointOnSegment(p0, p1, 3.0 / 8.0); + + //calculates control point 2 + Point2D pc2 = getPointOnSegment(pa, pb, 3.0 / 8.0); + pc2 = movePoint(pc2, -dx, -dy); + + //calculates control point 3 + Point2D pc3 = getPointOnSegment(pb, pa, 3.0 / 8.0); + pc3 = movePoint(pc3, dx, dy); + + //calculates control point 4 + Point2D pc4 = getPointOnSegment(p3, p2, 3.0 / 8.0); + + //calculates the 3 anchor points + Point2D pa1 = getMidPoint(pc1, pc2); + Point2D pa2 = getMidPoint(pa, pb); + Point2D pa3 = getMidPoint(pc3, pc4); + + //return the points for the four quadratic curves + return new double[][]{ + {pc1.getX(), pc1.getY(), pa1.getX(), pa1.getY()}, + {pc2.getX(), pc2.getY(), pa2.getX(), pa2.getY()}, + {pc3.getX(), pc3.getY(), pa3.getX(), pa3.getY()}, + {pc4.getX(), pc4.getY(), p3.getX(), p3.getY()}}; + } + + //JPEXS end + + private ArrayList toQuadraticSegments(int a_trial) { + ArrayList retval = new ArrayList<>(); + + a_trial++; + + double[][] quadCoords =approximateCubic(new double[]{m_startPoint.getX(),m_startPoint.getY(),m_controlPoint1.getX(),m_controlPoint1.getY(),m_controlPoint2.getX(),m_controlPoint2.getY(),m_endPoint.getX(),m_endPoint.getY()}); + EContourPoint lastPoint=m_startPoint; + for (int i = 0; i < quadCoords.length; i++) { + retval.add(new QuadraticSegment( + lastPoint, + new EContourPoint(quadCoords[i][0], quadCoords[i][1], true), + new EContourPoint(quadCoords[i][2], quadCoords[i][3], false))); + lastPoint = new EContourPoint(quadCoords[i][2],quadCoords[i][3],true); + } + /*EContourPoint intersection = calculateIntersection(); + + double deltaX = 0.125 * (m_startPoint.getX() + m_endPoint.getX() + 4 * intersection.getX() + - 3 * (m_controlPoint1.getX() + m_controlPoint2.getX())); + double deltaY = 0.125 * (m_startPoint.getY() + m_endPoint.getY() + 4 * intersection.getY() + - 3 * (m_controlPoint1.getY() + m_controlPoint2.getY())); + double deltaSqr = (deltaX * deltaX + deltaY * deltaY); + + if (deltaSqr > (k_minTolerance * k_minTolerance) + || ((a_trial < k_maxTrial) && (deltaSqr > (k_tolerance * k_tolerance)))) { + return toSplitQuadraticSegments(a_trial); + } // if + + retval.add(new QuadraticSegment(m_startPoint, intersection, m_endPoint));*/ + return retval; + } + + private ArrayList toSplitQuadraticSegments(int a_trial) { + EContourPoint p01 = midPoint(m_startPoint, m_controlPoint1); + EContourPoint p12 = midPoint(m_controlPoint1, m_controlPoint2); + EContourPoint p23 = midPoint(m_controlPoint2, m_endPoint); + + EContourPoint pA = midPoint(p01, p12); + EContourPoint pB = midPoint(p12, p23); + + EContourPoint pAB = midPoint(pA, pB); + + CubicSegment firstCubicSegment = new CubicSegment(m_startPoint, p01, pA, pAB); + CubicSegment secondCubicSegment = new CubicSegment(pAB, pB, p23, m_endPoint); + + ArrayList firstHalf = firstCubicSegment.toQuadraticSegments(a_trial); + ArrayList secondHalf = secondCubicSegment.toQuadraticSegments(a_trial); + + firstHalf.addAll(secondHalf); + + return firstHalf; + } + + private EContourPoint midPoint(EContourPoint a_start, EContourPoint a_end) { + Point2D p = calculateMidPoint(a_start, a_end); + EContourPoint retval = new EContourPoint(p.getX(), p.getY(), true); + + ArrayList ppems = getPpems(a_start, a_end); + EPoint startPoint, endPoint; + for (int i = 0; i < ppems.size(); i++) { + Long ppemObject = (Long) ppems.get(i); + long ppem = ppemObject.longValue(); + + if (retval.hasHintForPpem(ppem)) { + continue; + } // if + + startPoint = a_start.getHintIfPossible(ppem); + endPoint = a_end.getHintIfPossible(ppem); + + p = calculateMidPoint(startPoint, endPoint); + EHint hint = new EHint(p.getX(), p.getY(), ppem); + retval.addHint(hint); + } // for i + + return retval; + } + + private Point2D calculateMidPoint(EPoint a_p1, EPoint a_p2) { + Point2D retval = new Point2D.Double((a_p1.getX() + a_p2.getX()) / 2.0, + (a_p1.getY() + a_p2.getY()) / 2.0); + return retval; + } + + /** + * calculate intersection of line (a_start, a_controlPoint1) and + * line (a_end, a_controlPoint2) + * @return + */ + private EContourPoint calculateIntersection() { + EContourPoint retval = new EContourPoint(m_startPoint.getX(), m_startPoint.getY(), false); + Point2D intersection = calculateIntersection(m_startPoint, m_controlPoint1, m_controlPoint2, m_endPoint); + retval.getPoint2d().setX(intersection.getX()); + retval.getPoint2d().setY(intersection.getY()); + + EPoint startPoint, controlPoint1, controlPoint2, endPoint; + ArrayList ppems = getPpems(m_startPoint, m_controlPoint1, m_controlPoint2, m_endPoint); + for (int i = 0; i < ppems.size(); i++) { + Long ppemObject = (Long) ppems.get(i); + long ppem = ppemObject.longValue(); + + if (retval.hasHintForPpem(ppem)) { + continue; + } // if + + startPoint = m_startPoint.getHintIfPossible(ppem); + controlPoint1 = m_controlPoint1.getHintIfPossible(ppem); + controlPoint2 = m_controlPoint2.getHintIfPossible(ppem); + endPoint = m_endPoint.getHintIfPossible(ppem); + + Point2D p = calculateIntersection(startPoint, controlPoint1, controlPoint2, endPoint); + EHint hint = new EHint(p.getX(), p.getY(), ppem); + retval.addHint(hint); + } // for i + + return retval; + } + + private Point2D calculateIntersection(EPoint a_p1, EPoint a_p2, EPoint a_p3, EPoint a_p4) { + Point2D retval = new Point2D.Double(a_p1.getX(), a_p1.getY()); + + double deltaX1 = a_p2.getX() - a_p1.getX(); + double deltaX2 = a_p3.getX() - a_p4.getX(); + if (deltaX1 == 0) { + deltaX1 = 0.1; + } // if + if (deltaX2 == 0) { + deltaX2 = 0.2; + } // if + + double incline1 = (a_p2.getY() - a_p1.getY()) / deltaX1; + double incline2 = (a_p3.getY() - a_p4.getY()) / deltaX2; + if (incline1 == incline2) { + return retval; + } // if + + double x = (-incline2 * a_p4.getX() + a_p4.getY() + +incline1 * a_p1.getX() - a_p1.getY()) / (incline1 - incline2); + double y = incline1 * (x - a_p1.getX()) + a_p1.getY(); + + retval.setLocation(x, y); + return retval; + } + + private ArrayList getPpems(EContourPoint a_start, EContourPoint a_end) { + ArrayList retval = new ArrayList<>(); + collectPpemsFromHints(retval, a_start.getHint()); + collectPpemsFromHints(retval, a_end.getHint()); + return retval; + } + + private void collectPpemsFromHints(ArrayList a_ppems, XHint[] a_hints) { + for (XHint hint: a_hints) { + if (!a_ppems.contains(hint.getPpem())) { + a_ppems.add(hint.getPpem()); + } // if + } // for i + } + + private ArrayList getPpems(EContourPoint a_start, EContourPoint a_controlPoint1, + EContourPoint a_controlPoint2, EContourPoint a_end) { + ArrayList retval = new ArrayList<>(); + collectPpemsFromHints(retval, a_start.getHint()); + collectPpemsFromHints(retval, a_controlPoint1.getHint()); + collectPpemsFromHints(retval, a_controlPoint2.getHint()); + collectPpemsFromHints(retval, a_end.getHint()); + return retval; + } + +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/EContour.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/EContour.java new file mode 100644 index 000000000..793b5d894 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/EContour.java @@ -0,0 +1,243 @@ +/* + * $Id: EContour.java,v 1.11 2004/12/17 04:13:17 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2003-2004, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa.adapter; + +import java.awt.*; +import java.awt.geom.*; +import java.util.ArrayList; + +import org.doubletype.ossa.xml.*; +import org.doubletype.ossa.*; +import org.doubletype.ossa.module.Rectangle; + +/** + * @author e.e + */ +public class EContour extends XContour implements GlyphObject, PointAggregate { + public static final String k_quadratic = "quadratic"; + public static final String k_cubic = "cubic"; + public static final int k_defaultPixelSize = 16; + + public static EContour createAt(Point2D a_point) { + EContour retval = new EContour(); + retval.setType(k_cubic); + + EContourPoint point; + double x, y; + + x = a_point.getX(); + y = a_point.getY(); + point = new EContourPoint(x, y, true); + retval.addContourPoint(point); + + + x += Rectangle.k_defaultPen; + point = new EContourPoint(x, y, true); + retval.addContourPoint(point); + + y += Rectangle.k_defaultPen; + point = new EContourPoint(x, y, true); + retval.addContourPoint(point); + + x -= Rectangle.k_defaultPen; + point = new EContourPoint(x, y, true); + retval.addContourPoint(point); + + return retval; + } + + // -------------------------------------------------------------- + + public EContour() { + initDefaults(); + } + + public EContour(RStack a_stack) { + super(a_stack); + initDefaults(); + } + + /** set default values + */ + private void initDefaults() { + if (getType() == null) { + setType(k_quadratic); + } // if + } + + public boolean isCubic() { + return getType().equals(k_cubic); + } + + public EContour transpose(AffineTransform a_trans) { + EContour retval = new EContour(); + retval.setType(this.getType()); + + XContourPoint[] points = getContourPoint(); + int i; + for (i = 0; i < points.length; i++) { + EContourPoint point = (EContourPoint) points[i]; + retval.addContourPoint(point.transpose(a_trans)); + } // if + + return retval; + } + + // -------------------------------------------------------------- + + public void display(Graphics2D g, AffineTransform a_trans) { + g.setColor(GlyphColor.CONTOUR); + + if (isSelected()) { + g.setColor(GlyphColor.SELECTED); + } // if + + int ppem =EContour.k_defaultPixelSize; + g.draw(toShape(a_trans, ppem)); + } + + public boolean isSelected() { + return EObject.getActives().isSelected(this); + } + + public Shape toShape(AffineTransform a_trans, int a_ppem) { + return transpose(a_trans).toShape(a_ppem); + } + + private Shape toShape(int a_ppem) { + Emulator emulator = Emulator.getInstance(); + + return emulator.createShape(this, a_ppem); + } + + public void move(Point2D a_delta) { + movePoints(getContourPoint(), a_delta); + } + + private void movePoints(XContourPoint [] a_points, Point2D a_delta) { + int i; + for (i = 0; i < a_points.length; i++) { + EContourPoint point = (EContourPoint) a_points[i]; + EObject.movePoint(point, a_delta); + } // for i + } + + public void remove() { + XBody parent = (XBody) rGetParentRNode(); + parent.removeContour(this); + } + + // PointAggregate + public void removePoint(EContourPoint a_point) { + removeContourPoint(a_point); + + if (getContourPoint().length < 2) { + remove(); + } // if + } + + // PointAggregate + public void movePoint(EContourPoint a_point, Point2D a_delta) { + EObject.movePoint(a_point, a_delta); + } + + // PointAggregate + public GlyphObject insertPoint(EContourPoint a_point) { + int i; + int len = getContourPoint().length; + + for (i = 0; i < len; i++) { + if (getContourPoint(i) == a_point) { + break; + } // if + } // for + + EContourPoint nextPoint; + nextPoint = (EContourPoint) getContourPoint((i + 1) % len); + + double x = (a_point.getX() + nextPoint.getX()) / 2; + double y = (a_point.getY() + nextPoint.getY()) / 2; + + EContourPoint retval = new EContourPoint(x, y, true); + addContourPoint(i + 1, retval); + + return retval; + } + + public boolean hit(Rectangle2D a_rect, AffineTransform a_trans) { + return EObject.hit(this, a_rect, a_trans); + } + + public void convert() { + XBody parent = (XBody) rGetParentRNode(); + + if (isCubic()) { + parent.addContour(toQuadratic()); + } else { + parent.addContour(toCubic()); + } // else + + remove(); + } + + public EContour toQuadratic() { + if (!isCubic()) { + return this; + } // if + + ArrayList quadraticSegments = new ArrayList<>(); + for (CubicSegment segment: CubicSegment.toSegments(this)) { + quadraticSegments.addAll(segment.toQuadraticSegments()); + } // for i + + return QuadraticSegment.toContour(quadraticSegments); + } + + public EContour toCubic() { + if (isCubic()) { + return this; + } // if + + ArrayList quadraticSegments = QuadraticSegment.toSegments(this); + ArrayList cubicSegments = new ArrayList<>(); + for (int i = 0; i < quadraticSegments.size(); i++) { + QuadraticSegment quadraticSegment = (QuadraticSegment) quadraticSegments.get(i); + cubicSegments.add(quadraticSegment.toCubicSegment()); + } // for i + + return CubicSegment.toContour(cubicSegments); + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/EContourPoint.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/EContourPoint.java new file mode 100644 index 000000000..e28994177 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/EContourPoint.java @@ -0,0 +1,419 @@ +/* + * $Id: EContourPoint.java,v 1.10 2004/12/27 04:56:02 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2004, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa.adapter; + +import org.doubletype.ossa.*; +import org.doubletype.ossa.xml.*; +import java.awt.*; +import java.awt.geom.*; + +/** + * @author e.e + */ +public class EContourPoint extends XContourPoint implements GlyphObject, EPoint { + public static String k_on = "on"; + public static String k_off = "off"; + public static String k_true = "true"; + public static String k_false = "false"; + + private int m_number = 0; + + /** offset of this from the global coord. + * For contours, it will be 0. + * For module invoke, it will be pos.x. + */ + private double m_xOffset = 0; + private double m_yOffset = 0; + + private Point2D m_adjusted; + + public EContourPoint() { + super(); + } + + public EContourPoint(RStack a_stack) { + super(a_stack); + correctControlPoint(); + } + + public EContourPoint(double a_x, double a_y, boolean a_isOn) { + setPoint2d(new XPoint2d()); + getPoint2d().setX(a_x); + getPoint2d().setY(a_y); + + setOn(a_isOn); + } + + /** Move the second control point if it was incorrectly set to the first one. + * + */ + private void correctControlPoint() { + if (!hasControlPoint1()) { + return; + } // if + + EControlPoint controlPoint = (EControlPoint) getControlPoint1(); + if (controlPoint.isFirst()) { + return; + } // if + + setControlPoint2(controlPoint); + setControlPoint1(null); + } + + public EContourPoint transpose(AffineTransform a_trans) { + EContourPoint retval = new EContourPoint(); + + retval.setPoint2d(EObject.createTransform(getPoint2d(), a_trans)); + retval.setOn(isOn()); + retval.setRounded(isRounded()); + + if (hasControlPoint1()) { + EControlPoint controlPoint = (EControlPoint) getControlPoint1(); + retval.setControlPoint1(controlPoint.transpose(a_trans)); + } // if + if (hasControlPoint2()) { + EControlPoint controlPoint = (EControlPoint) getControlPoint2(); + retval.setControlPoint2(controlPoint.transpose(a_trans)); + } // if + + int i; + XHint [] hints = getHint(); + for (i = 0; i < hints.length; i++) { + EHint hint = (EHint) hints[i]; + retval.addHint(hint.createTransform(a_trans)); + } // for i + + return retval; + } + + public void setNumber(int a_number) { + m_number = a_number; + } + + public void setOffset(double a_x, double a_y) { + m_xOffset = a_x; + m_yOffset = a_y; + } + + private AffineTransform buildOffsetTrans(AffineTransform a_trans) { + if (m_xOffset == 0 && m_yOffset == 0) { + return a_trans; + } // if + + AffineTransform retval = (AffineTransform) a_trans.clone(); + retval.translate(m_xOffset, m_yOffset); + + return retval; + } + public static final int k_defaultPixelSize = 16; + + public void display(Graphics2D g, AffineTransform a_trans) { + AffineTransform trans = buildOffsetTrans(a_trans); + + int ppem = k_defaultPixelSize; + Shape rect = toShape(trans, ppem); + g.setColor(GlyphColor.POINT); + if (isRounded()) { + g.setColor(GlyphColor.GRAY); + } // if + + if (isSelected()) { + g.setColor(GlyphColor.SELECTED); + } // if + + if (isOn()) + g.fill(rect); + else + g.draw(rect); + } + + + + public boolean isSelected() { + return EObject.getActives().isSelected(this); + } + + public void resetAdjusted() { + setAdjusted(getX(), getY()); + } + + public void roundAdjusted(int a_ppem) { + if (!isRounded()) { + return; + } // if + + setAdjusted(round(getX(), a_ppem), + round(getY(), a_ppem)); + } + + public void hintAdjusted(int a_ppem) { + if (!hasHintForPpem(a_ppem)) { + return; + } // if + + EHint hint = getHintForPpem(a_ppem); + setAdjusted(hint.getX(), hint.getY()); + } + + public void setAdjusted(double a_x, double a_y) { + m_adjusted = new Point2D.Double(a_x, a_y); + } + + public Point2D getAdjusted() { + return m_adjusted; + } + + public Shape toShape(AffineTransform a_trans, int a_ppem) { + return EObject.toShape(getPoint2d(), a_trans); + } + + public double getX() { + return getPoint2d().getX(); + } + + public double getY() { + return getPoint2d().getY(); + } + + public boolean isOn() { + return getType().equals(k_on); + } + + public boolean isRounded() { + return getRounded(); + } + + public void toggleRounded() { + if (hasHintForCurrentPpem()) { + return; + } // if + + setRounded(!isRounded()); + } + + public Point2D toPoint2D() { + return new Point2D.Double(getX(), getY()); + } + + public boolean hasHint() { + return (getHint().length > 0); + } + + public boolean hasHintForCurrentPpem() { + return hasHintForPpem(EContour.k_defaultPixelSize); + } + + public boolean hasHintForPpem(long a_ppem) { + return getHintForPpem(a_ppem) != null; + } + + public EPoint getHintIfPossible(long a_ppem) { + if (hasHintForPpem(a_ppem)) { + return getHintForPpem(a_ppem); + } // if + + return this; + } + + public EHint getCurrentHint() { + return getHintForPpem(EContour.k_defaultPixelSize); + } + + public EHint getHintForPpem(long a_ppem) { + int i; + XHint[] hints = getHint(); + for (i = 0; i < hints.length; i++) { + EHint hint = (EHint) hints[i]; + if (hint.getPpem() == a_ppem) { + return hint; + } // if + } // for i + + return null; + } + + public EHint addHint(int a_ppem) { + if (hasHintForPpem(a_ppem)) { + return getHintForPpem(a_ppem); + } // if + + EHint retval = new EHint(getX() + Engine.getEm() / a_ppem, getY(), a_ppem); + addHint(retval); + return retval; + } + + public GlyphObject add() { + return getParent().insertPoint(this); + } + + public void remove() { + getParent().removePoint(this); + } + + public PointAggregate getParent() { + if (rGetParentRNode() instanceof EControlPoint) { + EControlPoint controlPoint = (EControlPoint) rGetParentRNode(); + return controlPoint.getParent().getParent(); + } + + if (rGetParentRNode() instanceof PointAggregate) { + return (PointAggregate) rGetParentRNode(); + } // if + + return (PointAggregate) rGetParentRNode(); + } + + public XContourPoint cloneAt(Point2D a_point) { + EContourPoint retval = (EContourPoint) clone(); + Point2D delta = new Point2D.Double(a_point.getX() - this.getX(), a_point.getY() - this.getY()); + EObject.movePoint(retval, delta); + return retval; + } + + /** Moves point by the specified delta. A GlyphObject method. + * Delegates the implementation to the host since a point + * moves differently depending on the host. + * For example the first point hosted by a module invoke would + * always be (0, 0) so the invoke position would move instead. + */ + public void move(Point2D a_delta) { + PointAggregate parent = (PointAggregate) rGetParentRNode(); + parent.movePoint(this, a_delta); + } + + public void toggleOnCurve() { + if (isControlPoint()) { + return; + } // if + + if (getParent() instanceof EContour) { + EContour contour = (EContour) getParent(); + if (contour.isCubic()) { + toggleCubicControlPoint(); + return; + } // if + } // if + + setOn(!isOn()); + } + + public boolean isControlPoint() { + return (getParent() instanceof EContourPoint); + } + + private void toggleCubicControlPoint() { + if (hasControlPoint1() || hasControlPoint2()) { + setControlPoint1(null); + setControlPoint2(null); + } else { + setControlPoint1(new EControlPoint(true, getX() + 100, getY())); + setControlPoint2(new EControlPoint(false, getX() - 100, getY())); + } // if + } + + public boolean hasControlPoint1() { + return (getControlPoint1() != null); + } + + public boolean hasControlPoint2() { + return (getControlPoint2() != null); + } + + public void setOn(boolean a_isOnCurve) { + if (a_isOnCurve) { + setType(k_on); + } else { + setType(k_off); + } // if + } + + public boolean hitHint(Rectangle2D a_rect, AffineTransform a_trans) { + int ppem = EContour.k_defaultPixelSize; + if (!hasHintForPpem(ppem)) + return false; + + EHint hint = getHintForPpem(ppem); + + Shape hitArea = hint.toShape(a_trans, ppem); + if (!hitArea.intersects(a_rect)) { + return false; + } // if + + EObject.getActives().addActive(hint); + return true; + } + + public boolean hit(Rectangle2D a_rect, AffineTransform a_trans) { + return EObject.hit(this, a_rect, buildOffsetTrans(a_trans)); + } + + /** Round the value after converting to pixel coordinate system. + */ + private double round(double a_value, long a_ppem) { + double em = Engine.getEm(); + double funitInGrid = em / a_ppem; + + double pixelValue = a_value / funitInGrid; + return funitInGrid * roundSymetric(pixelValue); + } + + /** round symetrically about zero. + * Math.round(0.5) returns 1. Math.round(-0.5) returns 0, + * since it's Math.floor(a_value + -0.5). + * -0.5 should round to -1 if it's symetric about zero. + * @param a_value number to be rounded. + * @return round value. + */ + private int roundSymetric(double a_value) { + if (a_value < 0) { + int retval = (int) Math.round(-a_value); + return -retval; + } else { + return (int) Math.round(a_value); + } // if-else + } + + public void removeControlPoint(EControlPoint a_point) { + if (hasControlPoint1() && (getControlPoint1() == a_point)) { + setControlPoint1(null); + } // if + + if (hasControlPoint2() && (getControlPoint2() == a_point)) { + setControlPoint2(null); + } // if + } +} \ No newline at end of file diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/EControlPoint.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/EControlPoint.java new file mode 100644 index 000000000..70ed77625 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/EControlPoint.java @@ -0,0 +1,244 @@ +/* + * $Id: EControlPoint.java,v 1.6 2004/12/27 04:56:02 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2003-2004, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa.adapter; + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.Shape; +import java.awt.geom.AffineTransform; +import java.awt.geom.Line2D; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; + +import org.doubletype.ossa.GlyphColor; +import org.doubletype.ossa.xml.*; + +/** + * @author e.e + */ +public class EControlPoint extends XControlPoint implements GlyphObject, EPoint { + private static final String k_true = "true"; + + private double m_xOffset = 0; + private double m_yOffset = 0; + + public EControlPoint(boolean a_isFirst, double a_x, double a_y) { + setSmooth(true); + setFirst(a_isFirst); + setContourPoint(new EContourPoint(a_x, a_y, false)); + } + + /** + * + */ + public EControlPoint() { + super(); + } + + /** + * @param stack + */ + public EControlPoint(RStack stack) { + super(stack); + } + + public boolean isSelected() { + return EObject.getActives().isSelected(this); + } + + /** toggle smooth-ness + */ + public void convert() { + EContourPoint parent = getParent(); + boolean value = !getSmooth(); + parent.getControlPoint1().setSmooth(value); + parent.getControlPoint2().setSmooth(value); + move(new Point2D.Double(0, 0)); + } + + public boolean isFirst() { + return getFirst(); + } + + public boolean hit(Rectangle2D a_rect, AffineTransform a_trans) { + return EObject.hit(this, a_rect, buildOffsetTrans(a_trans)); + } + + public void setOffset(double a_x, double a_y) { + m_xOffset = a_x; + m_yOffset = a_y; + } + + private AffineTransform buildOffsetTrans(AffineTransform a_trans) { + if (m_xOffset == 0 && m_yOffset == 0) { + return a_trans; + } // if + + AffineTransform retval = (AffineTransform) a_trans.clone(); + retval.translate(m_xOffset, m_yOffset); + + return retval; + } + + public void remove() { + getParent().removeControlPoint(this); + } + + public EContourPoint getParent() { + return (EContourPoint) rGetParentRNode(); + } + + public Shape toShape(AffineTransform a_trans, int a_ppem) { + return EObject.toShape(getContourPoint().getPoint2d(), a_trans); + } + + public void move(Point2D a_delta) { + // if the parent is active, she will move this. + if (getParent().isSelected()) { + return; + } // if + + EObject.movePoint((EContourPoint) getContourPoint(), a_delta); + + if (isSmooth() && hasSibling()) { + smoothSibling(); + } // if + } + + public void rotateTo45() { + double theta = getTheta() + Math.PI / 8; + theta = Math.PI / 4 * Math.floor(theta / (Math.PI / 4)); + + rotateToTheta(theta); + if (isSmooth() && hasSibling()) { + smoothSibling(); + } // if + } + + private void smoothSibling() { + getSibling().rotateToTheta(getTheta() + Math.PI); + } + + private double getTheta() { + EContourPoint parent = getParent(); + return Math.atan2(getY() - parent.getY(), + getX() - parent.getX()); + } + + private void rotateToTheta(double a_theta) { + EContourPoint parent = getParent(); + double d = parent.toPoint2D().distance(toPoint2D()); + double x = parent.getX() + Math.cos(a_theta) * d; + double y = parent.getY() + Math.sin(a_theta) * d; + Point2D delta = new Point2D.Double(x - getX(), y - getY()); + EObject.movePoint((EContourPoint) getContourPoint(), delta); + } + + public Point2D toPoint2D() { + EContourPoint point = (EContourPoint) getContourPoint(); + return point.toPoint2D(); + } + + public boolean isSmooth() { + return getSmooth(); + } + + public boolean hasSibling() { + EContourPoint parent = getParent(); + if (parent.getControlPoint1() == this) { + return parent.hasControlPoint2(); + } else { + return parent.hasControlPoint1(); + } // if + } + + public EControlPoint getSibling() { + EContourPoint parent = getParent(); + if (parent.getControlPoint1() == this) { + return (EControlPoint) parent.getControlPoint2(); + } else { + return (EControlPoint) parent.getControlPoint1(); + } // if + } + + public void display(Graphics2D g, AffineTransform a_trans) { + AffineTransform trans = buildOffsetTrans(a_trans); + displayLine(g, trans); + + Shape rect = toShape(trans, EContour.k_defaultPixelSize); + g.setColor(GlyphColor.POINT); + if (isSelected()) { + g.setColor(GlyphColor.SELECTED); + } // if + + g.draw(rect); + } + + private void displayLine(Graphics2D g, AffineTransform a_trans) { + EContourPoint parent = getParent(); + Line2D line = new Line2D.Double(parent.getX(), + parent.getY(), + getX(), + getY()); + AffineTransform oldTrans = g.getTransform(); + + g.transform(a_trans); + g.setColor(Color.BLACK); + g.draw(line); + g.setTransform(oldTrans); + } + + public EControlPoint transpose(AffineTransform a_trans) { + EControlPoint retval = new EControlPoint(); + EContourPoint point = (EContourPoint) getContourPoint(); + retval.setContourPoint(point.transpose(a_trans)); + retval.setSmooth(getSmooth()); + + return retval; + } + + + public double getX() { + EContourPoint point = (EContourPoint) getContourPoint(); + return point.getX(); + } + + public double getY() { + EContourPoint point = (EContourPoint) getContourPoint(); + return point.getY(); + } +} + diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/EGlyphFactory.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/EGlyphFactory.java new file mode 100644 index 000000000..4575f06e8 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/EGlyphFactory.java @@ -0,0 +1,109 @@ +/* + * $Id: EGlyphFactory.java,v 1.3 2004/11/10 01:49:49 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2003-2004, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa.adapter; + +import org.doubletype.ossa.xml.*; + +/** + * @author e.e + */ +public class EGlyphFactory extends DefaultGlyphFactory { + public static IGlyphFactory s_factory = null; + + public static IGlyphFactory getFactory() { + if (s_factory == null) { + s_factory = new EGlyphFactory(); + } // if + + return s_factory; + } + + public EGlyphFactory() { + } + + public XModule createXModule() { + return new EModuleInvoke(); + } + + public Class getXModuleClass() { + return (EModuleInvoke.class); + } + + public XContour createXContour() { + return new EContour(); + } + + public Class getXContourClass() { + return (EContour.class); + } + + public XInclude createXInclude() { + return new EIncludeInvoke(); + } + + public Class getXIncludeClass() { + return (EIncludeInvoke.class); + } + + public XHint createXHint() { + return new EHint(); + } + + public Class getXHintClass() { + return (EHint.class); + } + + public XContourPoint createXContourPoint() { + return new EContourPoint(); + } + + public XContourPoint createXContourPoint(RStack a_stack) { + return new EContourPoint(a_stack); + } + + public Class getXContourPointClass() { + return (EContourPoint.class); + } + + public XControlPoint createXControlPoint() { + return new EControlPoint(); + } + + + public Class getXControlPointClass() { + return (EControlPoint.class); + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/EHint.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/EHint.java new file mode 100644 index 000000000..fedad33ca --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/EHint.java @@ -0,0 +1,195 @@ +/* + * $Id: EHint.java,v 1.4 2004/12/27 04:56:03 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2003-2004, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa.adapter; + +import java.awt.*; +import java.awt.geom.*; + +import org.doubletype.ossa.xml.*; +import org.doubletype.ossa.*; + +/** + * @author e.e + */ +public class EHint extends XHint implements GlyphObject, EPoint { + /** offset of this from the global coord. + * For contours, it will be 0. + * For module invoke, it will be pos.x. + * @see EContourPoint + */ + private double m_xOffset = 0; + private double m_yOffset = 0; + + public EHint() { + } + + public EHint(double a_x, double a_y, long a_ppem) { + XPoint2d point = new XPoint2d(); + point.setX(a_x); + point.setY(a_y); + + setPoint2d(point); + setPpem(a_ppem); + } + + public void setOffset(double a_x, double a_y) { + m_xOffset = a_x; + m_yOffset = a_y; + } + + private AffineTransform buildOffsetTrans(AffineTransform a_trans) { + if (m_xOffset == 0 && m_yOffset == 0) { + return a_trans; + } // if + + AffineTransform retval = (AffineTransform) a_trans.clone(); + retval.translate(m_xOffset, m_yOffset); + + return retval; + } + + public void display(Graphics2D g, AffineTransform a_trans) { + AffineTransform trans = buildOffsetTrans(a_trans); + + EContourPoint point = (EContourPoint) rGetParentRNode(); + + Shape rect = toShape(trans, EContour.k_defaultPixelSize); + Line2D line = new Line2D.Double(point.getX(), + point.getY(), + getX(), + getY()); + + AffineTransform oldTrans = g.getTransform(); + + g.transform(trans); + g.setColor(Color.BLACK); + g.draw(line); + g.setTransform(oldTrans); + + g.setColor(GlyphColor.HINT); + if (isSelected()) { + g.setColor(GlyphColor.SELECTED); + } // if + + if (point.isOn()) + g.fill(rect); + else + g.draw(rect); + } + + public boolean isSelected() { + return EObject.getActives().isSelected(this); + } + + public Shape toShape(AffineTransform a_trans, int a_ppem) { + return EObject.toShape(getPoint2d(), a_trans); + } + + public double getX() { + return getPoint2d().getX(); + } + + public double getY() { + return getPoint2d().getY(); + } + + public Point2D toPoint2D() { + return new Point2D.Double(getX(), getY()); + } + + /** + * @see org.doubletype.ossa.adapter.DObject#move(java.awt.geom.Point2D) + */ + public void move(Point2D a_delta) { + EObject.movePoint(getPoint2d(), a_delta); + + double gridWidth = ((double) Engine.getEm()) / getPpem(); + EContourPoint point = (EContourPoint) rGetParentRNode(); + + XPoint2d posHint = getPoint2d(); + XPoint2d posPoint = point.getPoint2d(); + double xDelta = posHint.getX() - posPoint.getX(); + double yDelta = posHint.getY() - posPoint.getY(); + + xDelta = correctDelta(xDelta, gridWidth); + yDelta = correctDelta(yDelta, gridWidth); + + posHint.setX(posPoint.getX() + xDelta); + posHint.setY(posPoint.getY() + yDelta); + } + + private double correctDelta(double a_delta, double a_width) { + double retval = a_delta; + + if (retval > a_width) { + retval = a_width; + } // if + + if (retval < -a_width) { + retval = -a_width; + } // if + + return retval; + } + + /** + * @see org.doubletype.ossa.adapter.DObject#remove() + */ + public void remove() { + getParent().removeHint(this); + } + + public EContourPoint getParent() { + return (EContourPoint) rGetParentRNode(); + } + + public PointAggregate getPointHost() { + return getParent().getParent(); + } + + public boolean hit(Rectangle2D a_rect, AffineTransform a_trans) { + return EObject.hit(this, a_rect, buildOffsetTrans(a_trans)); + } + + public EHint createTransform(AffineTransform a_trans) { + EHint retval = new EHint(); + + retval.setPpem(getPpem()); + retval.setPoint2d(EObject.createTransform(getPoint2d(), a_trans)); + + return retval; + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/EIncludeInvoke.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/EIncludeInvoke.java new file mode 100644 index 000000000..2210d11d0 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/EIncludeInvoke.java @@ -0,0 +1,167 @@ +/* + * $Id: EIncludeInvoke.java,v 1.1 2004/09/04 21:54:07 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2003-2004, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa.adapter; + +import java.awt.*; +import java.awt.geom.*; +import org.doubletype.ossa.xml.*; +import org.doubletype.ossa.*; +import org.doubletype.ossa.module.*; +import java.util.*; + +/** + * @author e.e + */ +public class EIncludeInvoke extends XInclude implements VarStackFrame, GlyphObject { + public static EIncludeInvoke create(String a_fileName) { + EIncludeInvoke retval = new EIncludeInvoke(); + retval.setHref(a_fileName); + retval.setInvoke(EObject.createInvoke(new Point2D.Double())); + + return retval; + } + + /** environment with invoke args. */ + private Hashtable m_augmented = new Hashtable<>(); + private VarStack m_stack = VarStack.getSingletonInstance(); + + public EIncludeInvoke() { + } + + public EIncludeInvoke(RStack a_stack) { + setup(a_stack); + } + + public void display(Graphics2D g, AffineTransform a_trans) { + g.setColor(GlyphColor.INCLUDE); + if (isSelected()) { + g.setColor(GlyphColor.SELECTED); + } // if + + g.draw(toShape(a_trans,EContour.k_defaultPixelSize)); + } + + public boolean isSelected() { + return EObject.getActives().isSelected(this); + } + + public Shape toShape(AffineTransform a_trans, int a_ppem) { + Shape retval; + + ModuleManager manager = ModuleManager.getSingletonInstance(); + GlyphFile file = manager.getGlyphFile(getHref()); + + XPoint2d pos = getInvoke().getInvokePos().getPoint2d(); + + AffineTransform trans = new AffineTransform(); + trans.setTransform(a_trans); + trans.translate(pos.getX(), pos.getY()); + + m_stack.push(this); + retval = file.toShape(trans); + m_stack.pop(); + + return retval; + } + + public GlyphModule getModule() { + ModuleManager manager = ModuleManager.getSingletonInstance(); + return manager.getGlyphFile(getHref()); + } + + // for var stack frame + public boolean hasVariable(String a_name) { + return m_augmented.containsKey(a_name); + } + + // for var stack frame. + public double getValue(String a_name) { + Double d = (Double) m_augmented.get(a_name); + return d.doubleValue(); + } + + // for var stack frame. + public void beforePush() { + getModule().beforePush(); + loadInvoke(getInvoke()); + } + + public void remove() { + XBody parent = (XBody) rGetParentRNode(); + parent.removeInclude(this); + } + + public void move(Point2D a_delta) { + XPoint2d point = getInvoke().getInvokePos().getPoint2d(); + EObject.movePoint(point, a_delta); + } + + /** + * loads invoke arguments into this module to build augmented environment. + * @param a_invoke + */ + private void loadInvoke(XInvoke a_invoke) { + copyVarsToAug(); + + int i; + XInvokeVarg [] vargs = a_invoke.getInvokeVarg(); + for (i = 0; i < vargs.length; i++) { + loadVarg(vargs[i]); + } // for i + } + + private void loadVarg(XInvokeVarg a_varg) { + String name = a_varg.getName(); + String src = a_varg.getSrc(); + GlyphModule module = getModule(); + + if (!module.hasVariable(name)) { + return; + } // if + + double value = m_stack.get(src); + m_augmented.put(name, new Double(value)); + } + + private void copyVarsToAug() { + m_augmented.clear(); + m_augmented.putAll(getModule().getVars()); + } + + public boolean hit(Rectangle2D a_rect, AffineTransform a_trans) { + return EObject.hit(this, a_rect, a_trans); + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/EModuleInvoke.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/EModuleInvoke.java new file mode 100644 index 000000000..25962b6c5 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/EModuleInvoke.java @@ -0,0 +1,288 @@ +/* + * $Id: EModuleInvoke.java,v 1.4 2004/11/08 06:29:51 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2003-2004, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa.adapter; + +import org.doubletype.ossa.*; +import org.doubletype.ossa.module.*; +import org.doubletype.ossa.xml.*; +import java.awt.geom.*; +import java.awt.*; +import java.util.*; + +/** + * @author e.e + */ +public class EModuleInvoke extends XModule implements VarStackFrame, GlyphObject, PointAggregate { + public static EModuleInvoke create() { + return createAt(new Point2D.Double(0, 254.0)); + } + + public static EModuleInvoke createAt(Point2D a_point) { + EModuleInvoke retval = new EModuleInvoke(); + + retval.setName(org.doubletype.ossa.module.Rectangle.class.getName()); + retval.setInvoke(EObject.createInvoke(a_point)); + + double x, y; + XContourPoint point; + + x = 0.0; + y = 0.0; + point = new EContourPoint(x, y, true); + retval.addContourPoint(point); + + + x += 426.0; + point = new EContourPoint(x, y, true); + retval.addContourPoint(point); + + y -= 254.0; + point = new EContourPoint(x, y, true); + retval.addContourPoint(point); + + x -= 426.0; + point = new EContourPoint(x, y, true); + retval.addContourPoint(point); + + return retval; + } + + + /** environment with invoke args. */ + private Hashtable m_augmented = new Hashtable<>(); + private VarStack m_stack = VarStack.getSingletonInstance(); + + // -------------------------------------------------------------- + + public EModuleInvoke() { + } + + public EModuleInvoke(RStack a_stack) { + setup(a_stack); + } + + // -------------------------------------------------------------- + + public void display(Graphics2D g, AffineTransform a_trans) { + if (isSelected()) { + g.setColor(GlyphColor.SELECTED); + } else { + g.setColor(GlyphColor.MODULE); + } // if + + g.draw(toShape(a_trans, EContour.k_defaultPixelSize)); + } + + public boolean isSelected() { + return EObject.getActives().isSelected(this); + } + + public Shape toShape(AffineTransform a_trans, int a_ppem) { + EContour contour = toContour(a_trans); + return contour.toShape(new AffineTransform(), a_ppem); + } + + // -------------------------------------------------------------- + + public EContour toContour(AffineTransform a_trans) { + EContour retval; + + GlyphModule module = getModule(); + + m_stack.push(this); + EContour untransContour = module.toContour(this); + m_stack.pop(); + + XPoint2d pos = getInvoke().getInvokePos().getPoint2d(); + AffineTransform trans = (AffineTransform) a_trans.clone(); + trans.translate(pos.getX(), pos.getY()); + + retval = untransContour.transpose(trans); + + return retval; + } + + public GlyphModule getModule() { + return getModuleForName(getName()); + } + + private GlyphModule getModuleForName(String a_name) { + GlyphModule retval = null; + + try { + ModuleManager manager = ModuleManager.getSingletonInstance(); + retval = manager.getModule(a_name); + } catch (Exception e) { + e.printStackTrace(); + } // try-catch + + return retval; + } + + public void remove() { + XBody parent = (XBody) rGetParentRNode(); + parent.removeModule(this); + } + + public void move(Point2D a_delta) { + XPoint2d point = getInvoke().getInvokePos().getPoint2d(); + EObject.movePoint(point, a_delta); + } + + // PointAggregate + public void removePoint(EContourPoint a_point) { + boolean isFirst = (a_point == getContourPoint(0)); + removeContourPoint(a_point); + + GlyphModule module = getModuleForName(getName()); + + if (getContourPoint().length < module.getMinimumPointCount()) + { + remove(); + return; + } // if + + if (!isFirst) { + return; + } // if + + EContourPoint newFirst = (EContourPoint) getContourPoint(0); + Point2D pos = newFirst.toPoint2D(); + Point2D delta = new Point2D.Double(-pos.getX(), -pos.getY()); + moveModulePoints(delta); + move(pos); + } + + public void moveModulePoints(Point2D a_delta) { + XContourPoint [] points = getContourPoint(); + + int i; + for (i = 0; i < points.length; i++) { + EContourPoint point = (EContourPoint) points[i]; + EObject.movePoint(point, a_delta); + } // for i + } + + // for var stack frame + public boolean hasVariable(String a_name) { + return m_augmented.containsKey(a_name); + } + + // for var stack frame. + public double getValue(String a_name) { + Double d = (Double) m_augmented.get(a_name); + return d.doubleValue(); + } + + // for var stack frame. + public void beforePush() { + loadInvoke(getInvoke()); + } + + /** + * loads invoke arguments into this module to build augmented environment. + * @param a_invoke + */ + private void loadInvoke(XInvoke a_invoke) { + copyVarsToAug(); + + // load varg + int i; + XInvokeVarg [] vargs = a_invoke.getInvokeVarg(); + for (i = 0; i < vargs.length; i++) { + loadVarg(vargs[i]); + } // for i + } + + private void loadVarg(XInvokeVarg a_varg) { + String name = a_varg.getName(); + String src = a_varg.getSrc(); + GlyphModule module = getModule(); + + if (!module.hasVariable(name)) { + System.out.println(name + " does not exist in " + + module.toString()); + + return; + } // if + + double value = m_stack.get(src); + m_augmented.put(name, new Double(value)); + } + + private void copyVarsToAug() { + m_augmented.clear(); + m_augmented.putAll(getModule().getVars()); + } + + public void movePoint(EContourPoint a_point, Point2D a_delta) { + EObject.movePoint(a_point, a_delta); + + if (a_point != getContourPoint(0)) { + return; + } // if + + Point2D negative = new Point2D.Double(-a_delta.getX(), -a_delta.getY()); + moveModulePoints(negative); + move(a_delta); + } + + public GlyphObject insertPoint(EContourPoint a_point) { + int i; + int len = getContourPoint().length; + + for (i = 0; i < len; i++) { + if (getContourPoint(i) == a_point) { + break; + } // if + } // for + + EContourPoint nextPoint; + nextPoint = (EContourPoint) getContourPoint((i + 1) % len); + + double x = (a_point.getX() + nextPoint.getX()) / 2; + double y = (a_point.getY() + nextPoint.getY()) / 2; + + EContourPoint retval = new EContourPoint(x, y, true); + addContourPoint(i + 1, retval); + + return retval; + } + + public boolean hit(Rectangle2D a_rect, AffineTransform a_trans) { + return EObject.hit(this, a_rect, a_trans); + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/EObject.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/EObject.java new file mode 100644 index 000000000..5f5f7e0c2 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/EObject.java @@ -0,0 +1,158 @@ +/* + * $Id: EObject.java,v 1.2 2004/11/08 06:29:51 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2003-2004, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa.adapter; + +import java.awt.geom.*; +import java.awt.*; + +import org.doubletype.ossa.*; +import org.doubletype.ossa.truetype.TTPixelSize; +import org.doubletype.ossa.xml.*; + +/** Decorator class of xml objects. + * @author e.e + */ +public abstract class EObject { + public static final String k_on = "on"; + public static final String k_off = "off"; + + private static ActiveList s_actives = null; + + + static ActiveList getActives() { + if (s_actives == null) { + s_actives = ActiveList.getSingletonInstance(); + } // if + + return s_actives; + } + + static Shape toShape(XPoint2d a_point, AffineTransform a_trans) { + + double ratio= EContour.k_defaultPixelSize/TTPixelSize.getEm(); + + double x = a_point.getX(); + double y = a_point.getY(); + double e = 3 / ratio; + Point2D source, dest; + source = new Point2D.Double(x, y); + dest = new Point2D.Double(); + dest = a_trans.transform(source, dest); + x = dest.getX(); + y = dest.getY(); + + return new Rectangle2D.Double(x - e, y - e, 2 * e + 1, 2 * e + 1); + } + + static void movePoint(XPoint2d a_point, Point2D a_delta) { + double x = a_point.getX() + a_delta.getX(); + double y = a_point.getY() + a_delta.getY(); + + a_point.setX(x); + a_point.setY(y); + } + + /** + * move the point and hint + * @param a_point + * @param a_delta + */ + public static void movePoint(EContourPoint a_point, Point2D a_delta) { + movePoint(a_point.getPoint2d(), a_delta); + + XHint [] hints = a_point.getHint(); + for (int i = 0; i < hints.length; i++) { + XHint hint = hints[i]; + movePoint(hint.getPoint2d(), a_delta); + } // for i + + if (a_point.hasControlPoint1()) { + EContourPoint point = (EContourPoint) a_point.getControlPoint1().getContourPoint(); + movePoint(point, a_delta); + } // if + if (a_point.hasControlPoint2()) { + EContourPoint point = (EContourPoint) a_point.getControlPoint2().getContourPoint(); + movePoint(point, a_delta); + } // if + } + + public static boolean hit(GlyphObject a_object, Rectangle2D a_rect, AffineTransform a_trans) { + int ppem = EContour.k_defaultPixelSize; + Shape hitArea = a_object.toShape(a_trans, ppem); + if (!hitArea.intersects(a_rect)) { + return false; + } // if + + EObject.getActives().addActive(a_object); + return true; + } + + public static XInvoke createInvoke(Point2D a_point) { + XInvoke retval = new XInvoke(); + retval.setInvokePos(createInvokePos(a_point.getX(), a_point.getY())); + return retval; + } + + public static XPoint2d createTransform(XPoint2d a_point, AffineTransform a_trans) { + XPoint2d retval = new XPoint2d(); + + double x = a_point.getX(); + double y = a_point.getY(); + Point2D source = new Point2D.Double(x, y); + Point2D dest = new Point2D.Double(); + a_trans.transform(source, dest); + + retval.setX(dest.getX()); + retval.setY(dest.getY()); + + return retval; + } + + private static XInvokePos createInvokePos(double a_x, double a_y) { + XInvokePos retval = new XInvokePos(); + retval.setPoint2d(createPoint2d(a_x, a_y)); + return retval; + } + + + private static XPoint2d createPoint2d(double a_x, double a_y) { + XPoint2d retval = new XPoint2d(); + retval.setX(a_x); + retval.setY(a_y); + return retval; + } + +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/EPoint.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/EPoint.java new file mode 100644 index 000000000..4a59fb58a --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/EPoint.java @@ -0,0 +1,44 @@ +/* + * $Id: EPoint.java,v 1.1 2004/12/27 04:56:02 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2004, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa.adapter; + +/** + * @author e.e + */ +public interface EPoint { + double getX(); + double getY(); +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/Emulator.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/Emulator.java new file mode 100644 index 000000000..c3b695969 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/Emulator.java @@ -0,0 +1,360 @@ +/* + * $Id: Emulator.java,v 1.6 2004/12/27 04:56:02 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2004, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa.adapter; + +import java.awt.*; +import java.awt.geom.*; +import java.util.*; +import org.doubletype.ossa.xml.*; + +/** Emulator emulates font engine. + * @author e.e + */ +public class Emulator { + private static Emulator s_instance = null; + + // singleton pattern + public static Emulator getInstance() { + if (s_instance == null) { + s_instance = new Emulator(); + } // if + + return s_instance; + } + + private Emulator() { + super(); + } + + public Shape createShape(EContour a_contour, int a_ppem) { + if (a_contour.isCubic()) { + // return createBezierCurve(a_contour); + EContour contour = a_contour.toQuadratic(); + return createShape(contour, a_ppem); + } // if + + return concretePointsToShape(createConcretePoints( + createAdjustedPoints(a_contour, a_ppem))); + } + + private Shape createBezierCurve(EContour a_contour) { + GeneralPath retval = new GeneralPath(); + XContourPoint [] points = a_contour.getContourPoint(); + + if (points.length < 2) { + return retval; + } // if + + EContourPoint startPoint = (EContourPoint) points[points.length - 1]; + retval.moveTo((float) startPoint.getX(), (float) startPoint.getY()); + + for (int i = 0; i < points.length; i++) { + EContourPoint toPoint = (EContourPoint) points[i]; + EControlPoint controlPoint1 = (EControlPoint) startPoint.getControlPoint2(); + EControlPoint controlPoint2 = (EControlPoint) toPoint.getControlPoint1(); + + // line segment + if ((controlPoint1 == null) && (controlPoint2 == null)) { + retval.lineTo((float) toPoint.getX(), (float) toPoint.getY()); + + } // if + + if ((controlPoint1 != null) && (controlPoint2 == null)) { + retval.curveTo((float) controlPoint1.getX(), (float) controlPoint1.getY(), + (float) toPoint.getX(), (float) toPoint.getY(), + (float) toPoint.getX(), (float) toPoint.getY()); + } // if + + if ((controlPoint1 == null) && (controlPoint2 != null)) { + retval.curveTo((float) startPoint.getX(), (float) startPoint.getY(), + (float) controlPoint2.getX(), (float) controlPoint2.getY(), + (float) toPoint.getX(), (float) toPoint.getY()); + } // if + + if ((controlPoint1 != null) && (controlPoint2 != null)) { + retval.curveTo((float) controlPoint1.getX(), (float) controlPoint1.getY(), + (float) controlPoint2.getX(), (float) controlPoint2.getY(), + (float) toPoint.getX(), (float) toPoint.getY()); + } // if + + startPoint = toPoint; + } // for + + return retval; + } + + private Shape concretePointsToShape(java.util.List a_listOfPoints) { + GeneralPath retval = new GeneralPath(); + EContourPoint p; + + if (a_listOfPoints.size() < 3) + return retval; + + p = (EContourPoint) a_listOfPoints.get(0); + retval.moveTo((float) p.getX(), (float) p.getY()); + + int i = 0; + while (i < a_listOfPoints.size() - 1) { + i++; + EContourPoint nextPoint = (EContourPoint) a_listOfPoints.get(i); + + if (nextPoint.isOn()) { + retval.lineTo((float) nextPoint.getX(), (float) nextPoint.getY()); + } else { + EContourPoint controlPoint = nextPoint; + i++; + EContourPoint toPoint = (EContourPoint) a_listOfPoints.get(i); + + retval.quadTo((float) controlPoint.getX(), + (float) controlPoint.getY(), + (float) toPoint.getX(), (float) toPoint.getY()); + } // if-else + } // for + + return retval; + } + + private java.util.List createConcretePoints(java.util.List a_points) { + java.util.List retval = new ArrayList<>(); + + if (a_points.size() < 3) + return retval; + + EContourPoint lastPoint = (EContourPoint) a_points.get(a_points.size() - 1); + for (int i = 0; i < a_points.size(); i++) { + EContourPoint point = (EContourPoint) a_points.get(i); + + if (!point.isOn() && !lastPoint.isOn()) { + double xMidpoint = (point.getX() + lastPoint.getX()) / 2; + double yMidpoint = (point.getY() + lastPoint.getY()) / 2; + retval.add(new EContourPoint(xMidpoint, yMidpoint, true)); + } // if + + retval.add(new EContourPoint(point.getX(), point.getY(), point.isOn())); + lastPoint = point; + } // for i + + // all contours should start with on-curve point + // move off-curve point to the end if a contour starts with one. + EContourPoint point = (EContourPoint) retval.get(0); + if (!point.isOn()) { + retval.remove(0); + retval.add(point); + } // if + + point = (EContourPoint) retval.get(0); + retval.add(point); + + return retval; + } + + private java.util.List createAdjustedPoints(EContour a_contour, int a_ppem) { + java.util.List retval = new ArrayList<>(); + + XContourPoint [] points = a_contour.getContourPoint(); + if (points.length < 3) { + return retval; + } // if + + boolean isRounded = false; + for (int i = 0; i < points.length; i++) { + EContourPoint point = (EContourPoint) points[i]; + point.resetAdjusted(); + + if (point.isRounded()) { + isRounded = true; + point.roundAdjusted(a_ppem); + } // if + + retval.add(point); + } // for i + + if (isRounded) { + interpolate(retval, true); + interpolate(retval, false); + } // if + + for (int i = 0; i < retval.size(); i++) { + EContourPoint point = (EContourPoint) retval.get(i); + if (point.hasHintForPpem(a_ppem)) { + point.hintAdjusted(a_ppem); + } // if + } // for i + + return promoteAdjustedToMain(retval); + } + + private java.util.List promoteAdjustedToMain(java.util.List a_points) { + java.util.List retval = new ArrayList<>(); + for (int i = 0; i < a_points.size(); i++) { + EContourPoint original = (EContourPoint) a_points.get(i); + EContourPoint adjusted = new EContourPoint(original.getAdjusted().getX(), + original.getAdjusted().getY(), + original.isOn()); + + retval.add(adjusted); + } // for i + + return retval; + } + + private void interpolate(java.util.List a_points, boolean a_isX) { + Collection sorted = sortPoints(a_points, a_isX); + + Iterator itr = sorted.iterator(); + + EContourPoint first = (EContourPoint) itr.next(); + if (!first.isRounded()) { + shiftPoint(first, a_points, a_isX); + } // if + + EContourPoint second = (EContourPoint) itr.next(); + EContourPoint third = null; + while (itr.hasNext()) { + third = (EContourPoint) itr.next(); + + if (!second.isRounded()) { + if (first.isRounded() + && third.isRounded()) { + interpolate(first, second, third, a_isX); + } else { + shiftPoint(second, a_points, a_isX); + } // if-else + } // if + + first = second; + second = third; + } // while + + EContourPoint last = third; + if (!last.isRounded()) { + shiftPoint(last, a_points, a_isX); + } // if + } + + private Collection sortPoints(java.util.List a_points, boolean a_isX) { + Map sorted = new TreeMap<>(); + + for (int i = 0; i < a_points.size(); i++) { + EContourPoint original = (EContourPoint) a_points.get(i); + Double value = new Double(getPointValue(original, a_isX)); + + while (sorted.containsKey(value)) { + value = new Double(value.doubleValue() + 0.01); + } // while + sorted.put(value, original); + } // for i + + return sorted.values(); + } + + private void interpolate(EContourPoint a_first, EContourPoint a_second, EContourPoint a_third, boolean a_isX) { + double firstValue = getPointValue(a_first, a_isX); + double secondValue = getPointValue(a_second, a_isX); + double thirdValue = getPointValue(a_third, a_isX); + double adjustedFirst = getAdjustedValue(a_first, a_isX); + double adjustedThird = getAdjustedValue(a_third, a_isX); + + double ratio = (secondValue - firstValue) / (thirdValue - firstValue); + + secondValue = adjustedFirst + ratio * (adjustedThird - adjustedFirst); + setAdjusted(a_second, secondValue, a_isX); + } + + private void shiftPoint(EContourPoint a_point, java.util.List a_points, boolean a_isX) { + EContourPoint closest = closestTouchedPoint(a_point, a_points); + if (closest == null) { + return; + } // if + + double delta = getAdjustedValue(closest, a_isX) - getPointValue(closest, a_isX); + double value = getPointValue(a_point, a_isX) + delta; + setAdjusted(a_point, value, a_isX); + } + + private void setAdjusted(EContourPoint a_point, double a_value, boolean a_isX) { + double x = a_point.getX(); + double y = a_point.getY(); + + if (a_isX) { + x = a_value; + } else { + y = a_value; + } // if-else + + a_point.setAdjusted(x, y); + } + + private double getPointValue(EContourPoint a_point, boolean a_isX) { + if (a_isX) { + return a_point.getX(); + } else { + return a_point.getY(); + } // if-else + } + + private double getAdjustedValue(EContourPoint a_point, boolean a_isX) { + if (a_isX) { + return a_point.getAdjusted().getX(); + } else { + return a_point.getAdjusted().getY(); + } // if-else + } + + private EContourPoint closestTouchedPoint(EContourPoint a_point, java.util.List a_points) { + EContourPoint retval = null; + double min = Double.MAX_VALUE; + for (int i = 0; i < a_points.size(); i++) { + EContourPoint target = (EContourPoint) a_points.get(i); + if (target == a_point) { + continue; + } // if + + if (!target.isRounded()) { + continue; + } // if + + double d = a_point.toPoint2D().distance(target.toPoint2D()); + if (d < min) { + min = d; + retval = target; + } // if + + } // for i + + return retval; + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/GlyphObject.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/GlyphObject.java new file mode 100644 index 000000000..2a7e70724 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/GlyphObject.java @@ -0,0 +1,51 @@ +/* + * $Id: GlyphObject.java,v 1.1 2004/09/04 21:54:06 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2003-2004, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa.adapter; + +import java.awt.*; +import java.awt.geom.*; + +/** + * @author e.e + */ +public interface GlyphObject { + void move(Point2D a_delta); + void remove(); + Shape toShape(AffineTransform a_trans, int a_ppem); + boolean isSelected(); + void display(Graphics2D g, AffineTransform a_trans); + boolean hit(Rectangle2D a_rect, AffineTransform a_trans); +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/PointAggregate.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/PointAggregate.java new file mode 100644 index 000000000..b1b6a5003 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/PointAggregate.java @@ -0,0 +1,49 @@ +/* + * $Id: PointAggregate.java,v 1.2 2004/09/18 07:30:44 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2004, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa.adapter; + +import java.awt.geom.*; +import org.doubletype.ossa.xml.*; + +/** + * @author e.e + */ +public interface PointAggregate { + void removePoint(EContourPoint a_point); + void movePoint(EContourPoint a_point, Point2D a_delta); + GlyphObject insertPoint(EContourPoint a_point); + XContourPoint[] getContourPoint(); +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/QuadraticSegment.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/QuadraticSegment.java new file mode 100644 index 000000000..758a160cd --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/adapter/QuadraticSegment.java @@ -0,0 +1,188 @@ +/* + * $Id: QuadraticSegment.java,v 1.1 2004/12/15 11:54:18 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2004, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa.adapter; + +import java.util.*; + +import org.doubletype.ossa.xml.XContourPoint; + +/** + * @author e.e + */ +public class QuadraticSegment { + public static final int LINE = 0; + public static final int CURVE = 1; + + /** + * converts quadratic contour into a list of quadratic segments. + * @param a_contour + * @return + */ + public static ArrayList toSegments(EContour a_contour) { + ArrayList retval = new ArrayList<>(); + + ArrayList points = toConcreatePoints(a_contour); + if (points.size() < 3) { + return retval; + } // if + + for (int i = 0; i < points.size() - 1; i++) { + EContourPoint startPoint = (EContourPoint) points.get(i); + EContourPoint nextPoint = (EContourPoint) points.get(i + 1); + + // if this is a line segment + if (nextPoint.isOn()) { + retval.add(new QuadraticSegment(startPoint, null, nextPoint)); + } else { + EContourPoint offCurvePoint = nextPoint; + i++; + nextPoint = (EContourPoint) points.get(i + 1); + retval.add(new QuadraticSegment(startPoint, offCurvePoint, nextPoint)); + } // if-else + } // for i + + return retval; + } + + /** + * converts a list of quadratic segments into a quadratic contour. + * @param a_segments + * @return + */ + public static EContour toContour(ArrayList a_segments) { + EContour retval = new EContour(); + retval.setType(EContour.k_quadratic); + + for (QuadraticSegment segment: a_segments) { + EContourPoint startPoint = (EContourPoint) segment.m_startPoint.clone(); + startPoint.setControlPoint1(null); + startPoint.setControlPoint2(null); + + if (segment.m_type == LINE) { + retval.addContourPoint(startPoint); + + } else { + retval.addContourPoint(startPoint); + retval.addContourPoint(segment.m_offCurvePoint); + } + } // for i + + return retval; + } + + /** + * converts quadratic contour to concreate points by inserting + * on-curve point between off-curve points. + * @param a_contour + * @return + */ + private static ArrayList toConcreatePoints(EContour a_contour) { + ArrayList retval = new ArrayList<>(); + + XContourPoint [] points = a_contour.getContourPoint(); + if (points.length < 3) + return retval; + + EContourPoint fromPoint = (EContourPoint) points[points.length - 1]; + for (XContourPoint point: points) { + EContourPoint toPoint = (EContourPoint) point; + if (!toPoint.isOn() && !fromPoint.isOn()) { + double xMidpoint = (toPoint.getX() + fromPoint.getX()) / 2; + double yMidpoint = (toPoint.getY() + fromPoint.getY()) / 2; + retval.add(new EContourPoint(xMidpoint, yMidpoint, true)); + } // if + + retval.add(toPoint); + fromPoint = toPoint; + } // for i + + // all contours should start with on-curve point + // move off-curve point to the end if a contour starts with one. + EContourPoint firstPoint = (EContourPoint) retval.get(0); + if (!firstPoint.isOn()) { + retval.remove(0); + retval.add(firstPoint); + } // if + + retval.add(retval.get(0)); + + return retval; + } + + private EContourPoint m_startPoint; + private EContourPoint m_offCurvePoint; + private EContourPoint m_endPoint; + + private int m_type = LINE; + + /** + * + */ + public QuadraticSegment(EContourPoint a_startPoint, EContourPoint a_offCurvePoint, + EContourPoint a_endPoint) { + m_startPoint = a_startPoint; + m_offCurvePoint = a_offCurvePoint; + m_endPoint = a_endPoint; + + if (m_offCurvePoint != null) { + m_type = CURVE; + } // if + } + + /** + * Convert quadratic segment to cubic. + * @param a_segment + * @return + */ + public CubicSegment toCubicSegment() { + // if the segment is a line + if (m_type == LINE) { + return new CubicSegment(m_startPoint, m_endPoint); + } // if + + double x, y; + x = m_startPoint.getX() + 2.0 / 3.0 * (m_offCurvePoint.getX() - m_startPoint.getX()); + y = m_startPoint.getY() + 2.0 / 3.0 * (m_offCurvePoint.getY() - m_startPoint.getY()); + EContourPoint controlPoint1 = new EContourPoint(x, y, false); + + x = m_offCurvePoint.getX() + 1.0 / 3.0 * (m_endPoint.getX() - m_offCurvePoint.getX()); + y = m_offCurvePoint.getY() + 1.0 / 3.0 * (m_endPoint.getY() - m_offCurvePoint.getY()); + EContourPoint controlPoint2 = new EContourPoint(x, y, false); + + return new CubicSegment(m_startPoint, controlPoint1, controlPoint2, m_endPoint); + } + +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/module/GlyphFile.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/module/GlyphFile.java new file mode 100644 index 000000000..fd57a24d3 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/module/GlyphFile.java @@ -0,0 +1,1141 @@ + /* + * $Copyright: copyright (c) 2003-2008, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa.module; + +import org.doubletype.ossa.*; +import org.doubletype.ossa.xml.*; +import org.doubletype.ossa.adapter.*; +import org.doubletype.ossa.truetype.*; + +import java.io.*; +import java.awt.*; +import java.awt.geom.*; + +import javax.xml.transform.*; +import javax.xml.transform.stream.*; +import javax.xml.transform.dom.*; +import java.net.*; +import java.util.*; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.w3c.dom.*; +import javax.xml.parsers.*; +import org.xml.sax.*; + +/** + * @author e.e + */ +public class GlyphFile extends GlyphModule { + protected static String s_emptyFileName = "empty.glyph"; + private static final String k_dotGlyph = ".glyph"; + private static Transformer s_transformer = null; + + static { + GlyphFactory.setFactory(EGlyphFactory.getFactory()); + } + + public static File createFileName(File a_dir, String a_name) { + return new File(a_dir, a_name + k_dotGlyph); + } + + /** + * http://www.atmarkit.co.jp/fxml/rensai2/xmltool04/02.html + * @return + */ + private static Transformer getTransformer() { + if (s_transformer == null) { + TransformerFactory transFactory + = TransformerFactory.newInstance(); + try { + s_transformer = transFactory.newTransformer(); + } + catch (TransformerConfigurationException e) { + } + + s_transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); + s_transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + } // if + + return s_transformer; + } + + private static XStartGlyphElement loadGlyphElement(URL a_url) { + IGlyphFactory factory = GlyphFactory.getFactory(); + + XStartGlyphElement retval = null; + + try { + retval = factory.createXStartGlyphElement(a_url); + } catch( SAXException | ParserConfigurationException | IOException e) { + e.printStackTrace(); + } + + return retval; + } + + private static XStartGlyphElement loadGlyphElement(InputStream a_in) { + IGlyphFactory factory = GlyphFactory.getFactory(); + XStartGlyphElement retval = null; + + try { + retval = factory.createXStartGlyphElement(a_in); + } catch( SAXException | ParserConfigurationException | IOException e) { + e.printStackTrace(); + } + + return retval; + } + // -------------------------------------------------------------- + + protected XStartGlyphElement m_glyph; + protected File m_fileName; + protected long m_modifiedTime = 0; + protected long m_savedTime = 0; + protected HistoryList m_history; + + private final int k_halfWidth = 512; + private final int k_fullWidth = 1024; + private String m_selectedNodeName = ""; + private boolean m_isMoving = false; + private PointAggregate m_pointHost; + + + // -------------------------------------------------------------- + + /** + * creates new file + */ + public GlyphFile(File a_dir, String a_name, long a_unicode) throws FileNotFoundException { + super(); + + m_fileName = createFileName(a_dir, a_name); + + init(getClass().getResource(s_emptyFileName)); + setGlyphTitle(a_name); + setUnicode(Long.toHexString(a_unicode)); + + /*int eastAsianWidth = UCharacter.getIntPropertyValue( + (int) a_unicode, + 0x1004); //UProperty.EAST_ASIAN_WIDTH); + */ + int eastAsianWidth = 5; //?? + if (eastAsianWidth == 5 || eastAsianWidth == 1) { + setAdvanceWidth(k_fullWidth); + } // if + + saveGlyphFile(); + } + + /** + * creates new file + * @param a_dir parent dir + * @param a_name glyph name + */ + public GlyphFile(File a_dir, String a_name) throws FileNotFoundException { + super(); + init(getClass().getResource(s_emptyFileName)); + setGlyphTitle(a_name); + m_fileName = createFileName(a_dir, a_name); + saveGlyphFile(); + } + + /** + * opens existing file + * @param a_file + */ + public GlyphFile(File a_file) { + super(); + + m_fileName = a_file; + + URL url = null; + + try { + url = a_file.toURI().toURL(); + } catch(MalformedURLException e) { + e.printStackTrace(); + } + + init(url); + } + + protected GlyphFile(URL a_url) { + super(); + init(a_url); + } + + private void init(URL a_url) { + m_glyph = loadGlyphElement(a_url); + ModuleManager.getSingletonInstance().clear(); + + //m_display = Engine.getSingletonInstance().getDisplay(); + m_history = new HistoryList(this); + + m_history.record("loadFile"); + m_savedTime = m_modifiedTime; + } + + /** + * initialize .notdef + */ + public void initNotDef(int a_advanceWidth) throws FileNotFoundException { + setAdvanceWidth(a_advanceWidth); + + EContour contour = new EContour(); + contour.setType(EContour.k_cubic); + contour.addContourPoint(new EContourPoint(0.0, 0.0, true)); + contour.addContourPoint(new EContourPoint(438.0, 0.0, true)); + contour.addContourPoint(new EContourPoint(438.0, 683.0, true)); + contour.addContourPoint(new EContourPoint(0.0, 683.0, true)); + addContour(contour); + + contour = new EContour(); + contour.setType(EContour.k_cubic); + contour.addContourPoint(new EContourPoint(365.0, 73.0, true)); + contour.addContourPoint(new EContourPoint(73.0, 73.0, true)); + contour.addContourPoint(new EContourPoint(73.0, 610.0, true)); + contour.addContourPoint(new EContourPoint(365.0, 610.0, true)); + addContour(contour); + + saveGlyphFile(); + } + + public void initNullGlyph() throws FileNotFoundException { + setAdvanceWidth(0); + saveGlyphFile(); + } + + public void initSpace(int a_advanceWidth) throws FileNotFoundException { + setAdvanceWidth(a_advanceWidth); + saveGlyphFile(); + } + + public void beforePush() { + loadVar(); + } + + public void undo() { + m_history.undo(); + } + + public void redo() { + m_history.redo(); + } + + public void restore(Memento a_memento) { + m_glyph = loadGlyphElement(a_memento.getData()); + ModuleManager.getSingletonInstance().clear(); + } + + // -------------------------------------------------------------- + + public XStartGlyphElement getGlyph() { + return m_glyph; + } + + // -------------------------------------------------------------- + + public void saveGlyphFile() throws FileNotFoundException { + saveGlyphFile(m_fileName); + } + + protected void saveGlyphFile(File a_file) throws FileNotFoundException { + FileOutputStream output = new FileOutputStream(a_file); + saveGlyphFile(output); + try { + output.close(); //JPEXS + } catch (IOException ex) { + Logger.getLogger(GlyphFile.class.getName()).log(Level.SEVERE, null, ex); + } + } + + public void saveGlyphFile(OutputStream a_output) { + try { + Transformer transformer = getTransformer(); + Document document = m_glyph.makeDocument(); + DOMSource source = new DOMSource(document); + StreamResult result = new StreamResult(a_output); + transformer.transform(source, result); + } catch (ParserConfigurationException | TransformerException e) { + e.printStackTrace(); + } + + m_savedTime = System.currentTimeMillis(); + m_modifiedTime = m_savedTime; + } + + public Memento createMemento(String a_description) { + m_modifiedTime = System.currentTimeMillis(); + byte [] bytes = m_glyph.makeTextDocument().getBytes(); + return new Memento(a_description, bytes); + } + + public boolean hasUnsavedChange() { + return (m_savedTime != m_modifiedTime); + } + + public void setAuthor(String a_value) { + m_glyph.getHead().setAuthor(a_value); + m_history.record("setAuthor"); + } + + public String getAuthor() { + return m_glyph.getHead().getAuthor(); + } + + public void setCopyrightYear(String a_value) { + m_glyph.getHead().setCopyright(a_value); + m_history.record("setCopyrightYear"); + } + + public String getCopyrightYear() { + return m_glyph.getHead().getCopyright(); + } + + public void setAdvanceWidth(int a_width) { + m_glyph.getHead().setAdvanceWidth(a_width); + m_history.record("setAdvanceWidth"); + } + + public int getAdvanceWidth() { + if (!m_glyph.getHead().checkAdvanceWidth()) { + setAdvanceWidth(k_halfWidth); + } // if + + return (int) m_glyph.getHead().getAdvanceWidth(); + } + + public Iterator createIterator() { + return new GlyphIterator(this); + } + + + // -------------------------------------------------------------- + + public void display(Graphics2D g, AffineTransform a_trans) + { + Iterator i = createIterator(); + while (i.hasNext()) { + GlyphObject object = (GlyphObject) i.next(); + object.display(g, a_trans); + } // while + } + + // -------------------------------------------------------------- + + public static final int k_defaultPixelSize = 16; //PPM + + /** converts this glyph into Shape. + * It could be called for root's preview mode or by include invoke. + * Pushing either this GlyphFile or DIncludeInvoke should be + * handled before this. + */ + public Shape toShape(AffineTransform a_trans) { + + + int ppem = k_defaultPixelSize; + + GeneralPath retval = new GeneralPath(); + Iterator i = createIterator(); + while (i.hasNext()) { + GlyphObject object = (GlyphObject) i.next(); + + if (object instanceof EContourPoint + || object instanceof EHint) { + continue; + } // if + + retval.append(object.toShape(a_trans, ppem), false); + } // if + + return retval; + } + + // -------------------------------------------------------------- + + /** + * Generates array of XContour from local contours and modules. + * Used for TTF building. + */ + private XContour [] toContours() { + XContour [] retval; + ArrayList list = new ArrayList<>(); + XContour [] contours = m_glyph.getBody().getContour(); + for (int i = 0; i < contours.length; i++) { + EContour contour = (EContour) contours[i]; + list.add(contour.toQuadratic()); + } // for i + + XModule [] modules = m_glyph.getBody().getModule(); + for (int i = 0; i < modules.length; i++) { + EModuleInvoke module = (EModuleInvoke) modules[i]; + + // push and pop happens inside toContour + list.add(module.toContour(new AffineTransform())); + } // for i + + if (list.size() == 0) + return null; + + retval = new XContour[list.size()]; + for (int i = 0; i < list.size(); i++) { + retval[i] = list.get(i); + } // for i + + return retval; + } + + // -------------------------------------------------------------- + + public boolean isMoving() { + return m_isMoving; + } + + // -------------------------------------------------------------- + + public void beginMove() { + m_isMoving = true; + } + + // -------------------------------------------------------------- + + public void endMove() { + if (!m_isMoving) { + return; + } // if + + m_isMoving = false; + + m_history.record("move"); + } + + // -------------------------------------------------------------- + + public void move(Point2D a_delta) { + int i; + for (i = 0; i < m_actives.size(); i++) { + GlyphObject active = m_actives.get(i); + active.move(a_delta); + } // for i + } + + + // -------------------------------------------------------------- + + public void fitMove() { + if (m_actives.hasActiveControlPoint()) { + EControlPoint controlPoint = m_actives.getActiveControlPoint(); + controlPoint.rotateTo45(); + } // if + } + + // -------------------------------------------------------------- + + public boolean isHittingSelected(Point2D a_point) { + ActiveList oldActiveObjects = new ActiveList(); + oldActiveObjects.setActives(m_actives); + + m_actives.unselectAll(); + hit(a_point, false, false); + + int i, j; + for (i = 0; i < m_actives.size(); i++) { + GlyphObject selected = m_actives.get(i); + for (j = 0; j < oldActiveObjects.size(); j++) { + GlyphObject old = oldActiveObjects.get(j); + + if (selected == old) { + m_actives.setActives(oldActiveObjects); + return true; + } // if + } // for j + } // for i + + m_actives.setActives(oldActiveObjects); + + return false; + } + + // -------------------------------------------------------------- + + /** hits a point to add them in active object queue. + * @param a_single when it is true, the method returns after + * finding the first hit. + */ + public boolean hit(Point2D a_point, + boolean a_isAppend, + boolean a_isSelectOnlyOne) { + if (a_point == null) { + return false; + } // if + + Rectangle2D rect = new Rectangle2D.Double( + a_point.getX(), a_point.getY(), + 1.0, 1.0); + return hit(rect, a_isAppend, a_isSelectOnlyOne); + } + + public void selectNext() { + Iterator i = new SelectionIterator(this); + + if (m_actives.size() == 1) { + boolean isFound = false; + + // loop the iterator in reverse order of drawing + while (i.hasNext()) { + GlyphObject object = (GlyphObject) i.next(); + + if (m_actives.isSelected(object)) { + isFound = true; + continue; + } // if + + if (!isFound) { + continue; + } // if + + m_actives.unselectAll(); + m_actives.addActive(object); + return; + } // while i + } // if + + i = new SelectionIterator(this); + if (i.hasNext()) { + GlyphObject object = (GlyphObject) i.next(); + m_actives.unselectAll(); + m_actives.addActive(object); + return; + } // if + } + + // -------------------------------------------------------------- + + public boolean hit(Rectangle2D a_rect, + boolean a_isAppend, + boolean a_single) { + + + if (!a_isAppend) { + m_actives.unselectAll(); + } // if + + return hitObjects(a_rect, a_single); + } + + // -------------------------------------------------------------- + + private boolean hitObjects(Rectangle2D a_rect, boolean a_isSelectOnlyOne) { + boolean retval = false; + + Iterator i = new SelectionIterator(this); + + // loop the iterator in reverse order of drawing + while (i.hasNext()) { + GlyphObject object = (GlyphObject) i.next(); + + if (!object.hit(a_rect, new AffineTransform())) { + continue; + } // if + + retval = true; + + if (a_isSelectOnlyOne) { + return true; + } // if + } // while i + + return retval; + } + + // -------------------------------------------------------------- + + /** used for cut and paste. + */ + public void addObjectFromClipboard(String a_value) throws CircularIncludeException { + Reader reader = new StringReader(a_value); + Document document = null; + try { + document = UJAXP.getDocument(reader); + } catch (Exception e) { + e.printStackTrace(); + return; + } // try-catch + + Element root = document.getDocumentElement(); + if (!root.getNodeName().equals("clipboard")) { + return; + } // if + + Node child; + for (child = root.getFirstChild(); child != null; + child = child.getNextSibling()) { + if (!(child instanceof Element)) { + continue; + } // if + Element element = (Element) child; + + IGlyphFactory factory = GlyphFactory.getFactory(); + + + if (XModule.isMatch(element)) { + EModuleInvoke module = (EModuleInvoke) factory.createXModule(element); + addModule(module); + continue; + } // if + + if (XContour.isMatch(element)) { + EContour contour = (EContour) factory.createXContour(element); + addContour(contour); + continue; + } // if + + if (XInclude.isMatch(element)) { + EIncludeInvoke include = (EIncludeInvoke) factory.createXInclude(element); + addInclude(include); + continue; + } // if + } // while + } + + // -------------------------------------------------------------- + + private boolean isCircularInclude(String a_href) { + if (getShortFileName().equals(a_href)) { + return true; + } // if + + ModuleManager manager = ModuleManager.getSingletonInstance(); + XInclude [] includes = m_glyph.getBody().getInclude(); + int i; + for (i = 0; i < includes.length; i++) { + XInclude include = includes[i]; + GlyphFile child = manager.getGlyphFile(include.getHref()); + + if (child.isCircularInclude(a_href)) { + return true; + } // if + } // for i + + return false; + } + + // -------------------------------------------------------------- + + public void addInclude(String a_fileName) throws CircularIncludeException { + addInclude(EIncludeInvoke.create(a_fileName)); + } + + public void addInclude(XInclude a_include) throws CircularIncludeException { + if (isCircularInclude(a_include.getHref())) { + throw new CircularIncludeException(); + } // if + + m_actives.unselectAll(); + m_actives.addActive((GlyphObject) a_include); + m_glyph.getBody().addInclude(a_include); + m_history.record("addInclude"); + } + + // -------------------------------------------------------------- + + /** + * pasted module from clipboard or ModuleInvokeAction + * @param a_module + */ + public XModule addModule(EModuleInvoke a_module) { + m_actives.unselectAll(); + m_actives.addActive(a_module); + m_glyph.getBody().addModule(a_module); + m_history.record("addModule"); + + return a_module; + } + + // -------------------------------------------------------------- + + /** add contour from clipboard or ContourAction + * @param a_contour + */ + public void addContour(EContour a_contour) { + m_actives.unselectAll(); + m_actives.addActive(a_contour); + m_glyph.getBody().addContour(a_contour); + m_history.record("addContour"); + } + + + // -------------------------------------------------------------- + + + public void addPoint() { + if (!m_actives.hasActivePoint()) { + return; + } // if + + EContourPoint contourPoint = m_actives.getActivePoint(); + m_actives.unselectAll(); + m_actives.addActive(contourPoint.add()); + + m_history.record("addPoint"); + } + + // -------------------------------------------------------------- + + public void addHint(int a_ppem) { + if (!m_actives.hasActivePoint()) + return; + + EContourPoint contourPoint = m_actives.getActivePoint(); + m_actives.unselectAll(); + m_actives.addActive(contourPoint.addHint(a_ppem)); + + if (contourPoint.hasControlPoint1()) { + EContourPoint p = (EContourPoint) contourPoint.getControlPoint1().getContourPoint(); + m_actives.addActive(p.addHint(a_ppem)); + } // if + + if (contourPoint.hasControlPoint2()) { + EContourPoint p = (EContourPoint) contourPoint.getControlPoint2().getContourPoint(); + m_actives.addActive(p.addHint(a_ppem)); + } // if + + + m_history.record("addHint"); + } + + public void toggleRounded() { + if (!m_actives.hasActivePoint()) + return; + + EContourPoint contourPoint = m_actives.getActivePoint(); + contourPoint.toggleRounded(); + + m_history.record("toggleGridfit"); + } + + public void convertControlPoint() { + if (!m_actives.hasActiveControlPoint()) { + return; + } // if + + EControlPoint controlPoint = m_actives.getActiveControlPoint(); + controlPoint.convert(); + + m_history.record("convertControlPoint"); + } + + public void convertContour() { + if (!m_actives.hasActiveContour()) { + return; + } // if + + EContour contour = m_actives.getActiveContour(); + contour.convert(); + + m_history.record("convertContour"); + } + + // -------------------------------------------------------------- + + public void remove() { + if (!m_actives.hasSelected()) + return; + + int i; + for (i = 0; i < m_actives.size(); i++) { + GlyphObject active = m_actives.get(i); + active.remove(); + } // for i + + m_history.record("remove"); + + m_actives.unselectAll(); + } + + // -------------------------------------------------------------- + + public void toggleOnOff() { + if (!m_actives.hasSelected()) + return; + + int i; + for (i = 0; i < m_actives.size(); i++) { + GlyphObject active = m_actives.get(i); + if (!(active instanceof EContourPoint)) { + continue; + } // if + + EContourPoint point = (EContourPoint) active; + point.toggleOnCurve(); + } // for i + + m_history.record("toggleOnOff"); + } + + private void loadVar() { + XParamListParam [] params = m_glyph.getHead().getHeadGlobal().getParamListParam(); + int i; + for (i = 0; i < params.length; i++) { + XParamListParam param = params[i]; + addVar(param.getName(), param.getContent()); + } // for i + } + + public String getSelectedNodeName() { + return m_selectedNodeName; + } + + public void addFileVar() { + XParamListParam param = new XParamListParam(); + param.setName("New parameter"); + param.setContent(0.0); + m_history.record("addFileVar"); + + m_glyph.getHead().getHeadGlobal().addParamListParam(param); + } + + public void removeFileVar(int a_index) { + m_history.record("removeFileVar"); + + m_glyph.getHead().getHeadGlobal().removeParamListParam(a_index); + } + + + public void addInvokeArg(int a_type) { + + } + + public void removeInvokeArg(int a_type, int a_index) { + + } + + public String getIncludeName() { + String retval = ""; + + if (!m_actives.hasActiveInclude()) + return retval; + retval = m_actives.getActiveInclude().getHref(); + + return retval; + } + + public void setIncludeName(String a_name) { + if (!m_actives.hasActiveInclude()) + return; + + m_actives.getActiveInclude().setHref(a_name); + m_history.record("setIncludeName"); + } + + public void setGlyphTitle(String a_title) { + m_glyph.getHead().setTitle(a_title); + m_history.record("setGlyphTitle"); + } + + public String getGlyphTitle() { + String retval = ""; + + retval = m_glyph.getHead().getTitle(); + + if (retval.equals("empty")) { + retval = ""; + } // if + + return retval; + } + + public String getModuleName() { + String retval = ""; + + if (!m_actives.hasActiveModule()) + return retval; + retval = m_actives.getActiveModule().getName(); + + return retval; + } + + public String getUnicode() { + return getUnicodeAsString(); + } + + public String getUnicodeAsString() { + return m_glyph.getHead().getUnicode(); + } + + public long getUnicodeAsLong() { + long retval = -1; + + String s = getUnicodeAsString(); + if (s.equals("")) { + return retval; + } // if + + try { + retval = Long.parseLong(s, 16); + } catch (NumberFormatException e) { + retval = -1; + } // try-catch + + return retval; + } + + protected void setUnicode(String a_unicode) { + m_glyph.getHead().setUnicode(a_unicode); + m_history.record("setUnicode"); + } + + public boolean isSimple() { + return (m_glyph.getBody().getInclude().length == 0); + } + + public boolean isWhiteSpace() { + long unicode = getUnicodeAsLong(); + + if (unicode == 0x0020 + || unicode == 0x00a0 + || unicode == 0x200b + || unicode == 0x2060 + || unicode == 0x3000 + || unicode == 0xfeff) + { + return true; + } // if + + return false; + } + + public String getShortFileName() { + return m_fileName.getName(); + } + + public void setLicense(String a_value) { + m_glyph.getHead().setLicense(a_value); + m_history.record("setLicense"); + } + + public String getLicense() { + return m_glyph.getHead().getLicense(); + } + + public PointAggregate getPointHost() { + return m_pointHost; + } + + public void buildPointHost() { + m_pointHost = null; + + /*if (!GlyphAction.isPointVisible()) { + return; + } // if*/ + + int i; + for (i = 0; i < m_actives.size(); i++) { + GlyphObject object = (GlyphObject) m_actives.get(i); + PointAggregate host = null; + + if (object instanceof EContourPoint) { + EContourPoint point = (EContourPoint) object; + host = point.getParent(); + + if (host instanceof EContourPoint) { + EContourPoint hostPoint = (EContourPoint) host; + host = hostPoint.getParent(); + } // if + } else if (object instanceof EHint) { + EHint hint = (EHint) object; + host = hint.getPointHost(); + } // if-else + + if (host == null) { + continue; + } // if + + if (m_pointHost == null) { + m_pointHost = host; + } else { + if (m_pointHost != host) { + m_pointHost = null; + return; + } // if + } // if + } // while + } + + public boolean isRequiredGlyph() { + long unicode = getUnicodeAsLong(); + + return (unicode == TTUnicodeRange.k_notDef + || unicode == TTUnicodeRange.k_null + || unicode == TTUnicodeRange.k_cr + || unicode == TTUnicodeRange.k_space); + } + + public TTGlyph toSimpleGlyph() { + // convert the file into array of contours + XContour [] contours = toContours(); + if ((contours == null) && (!isRequiredGlyph())) { + return null; + } // if + + TTGlyph retval = new TTGlyph(); + retval.setSimple(true); + retval.setAdvanceWidth(getAdvanceWidth()); + + if (contours == null) { + return retval; + } // if + + ArrayList points = new ArrayList<>(); + for (int i = 0; i < contours.length; i++) { + XContour contour = contours[i]; + XContourPoint [] contourPoints = contour.getContourPoint(); + for (int j = 0; j < contourPoints.length; j++) { + points.add((EContourPoint) contourPoints[j]); + } // for j + retval.addEndPoint(points.size() - 1); + } // for i + + for (EContourPoint point: points) { + loadContourPoint(retval, point); + } // for point + + boolean hasGridfit = false; + // I need int i here. + for (int i = 0; i < points.size(); i++) { + EContourPoint point = points.get(i); + + if (!point.isRounded()) { + continue; + } // if + + hasGridfit = true; + loadGridfit(retval, point, i); + } // for i + + if (hasGridfit) { + retval.addInstruction(TTGlyph.IUP1); + retval.addInstruction(TTGlyph.IUP0); + } // if + + // I need int i here. + for (int i = 0; i < points.size(); i++) { + EContourPoint point = points.get(i); + if (point.getHint().length == 0) { + continue; + } // if + + loadHint(retval, point, i); + } // for i + + return retval; + } + + private void loadContourPoint(TTGlyph a_glyph, EContourPoint a_point) { + double x = a_point.getX(); + double y = a_point.getY(); + Point p = new Point((int) x, (int) y); + int flag = 0; + if (a_point.isOn()) { + flag = TTGlyph.k_onCurve; + } // if + + a_glyph.addPoint(p); + a_glyph.addFlag(flag); + } + + private void loadGridfit(TTGlyph a_glyph, EContourPoint a_point, int a_index) { + if (!a_point.isRounded()) { + return; + } // if + + a_glyph.addInstruction(TTGlyph.PUSHB000); + a_glyph.addInstruction(a_index); + a_glyph.addInstruction(TTGlyph.MDAP1); + } + + + private void loadHint(TTGlyph a_glyph, EContourPoint a_point, int a_index) { + double x = a_point.getX(); + double y = a_point.getY(); + + XHint [] hints = a_point.getHint(); + + for (int i = 0; i < hints.length; i++) { + EHint hint = (EHint) hints[i]; + double xHint = hint.getX(); + double yHint = hint.getY(); + + if (x == xHint && y == yHint) { + continue; + } // if + + double xDelta = xHint - x; + double yDelta = yHint - y; + int instruction = TTGlyph.DELTAP1; + double deltaStep = ((double) Engine.getEm()) / hint.getPpem() / 8; + int xShift = (int) Math.round(xDelta / deltaStep); + int yShift = (int) Math.round(yDelta / deltaStep); + + if (xShift == 0 && yShift == 0) { + continue; + } // if + + a_glyph.addInstruction(TTGlyph.PUSHB000); + a_glyph.addInstruction((int) hint.getPpem()); + a_glyph.addInstruction(TTGlyph.SDB); + + if (xShift != 0) { + a_glyph.addInstruction(TTGlyph.SVTCA1); + a_glyph.addInstruction(TTGlyph.PUSHB010); + a_glyph.addInstruction(TTGlyph.toDeltaArg(0, xShift)); + a_glyph.addInstruction(a_index); + a_glyph.addInstruction(1); + a_glyph.addInstruction(TTGlyph.DELTAP1); + } // if + + if (yShift != 0) { + a_glyph.addInstruction(TTGlyph.SVTCA0); + a_glyph.addInstruction(TTGlyph.PUSHB010); + a_glyph.addInstruction(TTGlyph.toDeltaArg(0, yShift)); + a_glyph.addInstruction(a_index); + a_glyph.addInstruction(1); + a_glyph.addInstruction(TTGlyph.DELTAP1); + } // if + } // for i + } + + public class CircularIncludeException extends Exception {} +} \ No newline at end of file diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/module/GlyphIterator.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/module/GlyphIterator.java new file mode 100644 index 000000000..d606360f5 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/module/GlyphIterator.java @@ -0,0 +1,237 @@ + /* + * $Id: GlyphIterator.java,v 1.11 2004/12/27 04:56:03 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2003-2004, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa.module; + +import java.util.*; + +import org.doubletype.ossa.xml.*; +import org.doubletype.ossa.adapter.*; + +/** Iterates through contours, module invokes, then include invokes. + * Used in GlyphFile display + * @author e.e + */ +public class GlyphIterator implements Iterator { + protected GlyphFile m_file; + private int m_index = 0; + protected java.util.List m_list = new ArrayList<>(); + + public GlyphIterator(GlyphFile a_file) { + m_file = a_file; + buildList(); + } + + protected void buildList() { + addIncludes(); + addContours(); + addModules(); + + } + + protected void addContours() { + XContour [] contours = m_file.getGlyph().getBody().getContour(); + for (int i = 0; i < contours.length; i++) { + m_list.add(contours[i]); + } // for i + } + + protected void addControlPoints() { + XContour [] contours = m_file.getGlyph().getBody().getContour(); + for (int i = 0; i < contours.length; i++) { + EContour contour = (EContour) contours[i]; + if (!contour.isCubic()) { + continue; + } // if + + addControlPoints(contour, 0, 0); + } // for i + } + + private void addControlPoints(PointAggregate a_object, double a_x, double a_y) { + XContourPoint [] points = a_object.getContourPoint(); + + for (int i = 0; i < points.length; i++) { + EContourPoint point = (EContourPoint) points[i]; + + if (!isPointVisible(point)) { + continue; + } // if + + if (point.hasControlPoint1()) { + EControlPoint controlPoint = (EControlPoint) point.getControlPoint1(); + controlPoint.setOffset(a_x, a_y); + m_list.add(controlPoint); + } // if + + if (point.hasControlPoint2()) { + EControlPoint controlPoint = (EControlPoint) point.getControlPoint2(); + controlPoint.setOffset(a_x, a_y); + m_list.add(controlPoint); + } // if + } // for j + } + + protected void addHints() { + XContour [] contours = m_file.getGlyph().getBody().getContour(); + for (int i = 0; i < contours.length; i++) { + addHints((EContour) contours[i], 0, 0); + } // for i + + XModule [] modules = m_file.getGlyph().getBody().getModule(); + for (int i = 0; i < modules.length; i++) { + EModuleInvoke module = (EModuleInvoke) modules[i]; + double x = module.getInvoke().getInvokePos().getPoint2d().getX(); + double y = module.getInvoke().getInvokePos().getPoint2d().getY(); + + addHints(module, x, y); + } // for i + } + + private void addHints(PointAggregate a_object, double a_x, double a_y) { + XContourPoint [] points = a_object.getContourPoint(); + + for (int i = 0; i < points.length; i++) { + EContourPoint point = (EContourPoint) points[i]; + + if (!isPointVisible(point)) { + continue; + } // if + + if (point.hasHintForCurrentPpem()) { + EHint hint = point.getCurrentHint(); + hint.setOffset(a_x, a_y); + m_list.add(hint); + } // if + + if (point.hasControlPoint1()) { + EContourPoint p = (EContourPoint) point.getControlPoint1().getContourPoint(); + if (p.hasHintForCurrentPpem()) { + EHint hint = p.getCurrentHint(); + hint.setOffset(a_x, a_y); + m_list.add(hint); + } // if + } + + if (point.hasControlPoint2()) { + EContourPoint p = (EContourPoint) point.getControlPoint2().getContourPoint(); + if (p.hasHintForCurrentPpem()) { + EHint hint = p.getCurrentHint(); + hint.setOffset(a_x, a_y); + m_list.add(hint); + } // if + } // if + } // for j + } + + private boolean isPointVisible(EContourPoint a_point) { + if (m_file.getPointHost() == null) { + return true; + } // if + + if (m_file.getPointHost() == a_point.getParent()) { + return true; + } // if + + return false; + } + + protected void addPoints() { + XContour [] contours = m_file.getGlyph().getBody().getContour(); + for (int i = 0; i < contours.length; i++) { + addPoints((EContour) contours[i], 0, 0); + } // for i + + XModule [] modules = m_file.getGlyph().getBody().getModule(); + for (int i = 0; i < modules.length; i++) { + EModuleInvoke module = (EModuleInvoke) modules[i]; + double x = module.getInvoke().getInvokePos().getPoint2d().getX(); + double y = module.getInvoke().getInvokePos().getPoint2d().getY(); + + addPoints(module, x, y); + } // for i + } + + private void addPoints(PointAggregate a_object, double a_x, double a_y) { + XContourPoint [] points = a_object.getContourPoint(); + + for (int i = 0; i < points.length; i++) { + EContourPoint point = (EContourPoint) points[i]; + + if (!isPointVisible(point)) { + continue; + } // if + + point.setNumber(i); + point.setOffset(a_x, a_y); + m_list.add(point); + } // for j + } + + protected void addModules() { + XModule [] modules = m_file.getGlyph().getBody().getModule(); + for (int i = 0; i < modules.length; i++) { + m_list.add(modules[i]); + } // for i + } + + protected void addIncludes() { + XInclude [] includes = m_file.getGlyph().getBody().getInclude(); + for (int i = 0; i < includes.length; i++) { + m_list.add(includes[i]); + } // for i; + } + + /* (non-Javadoc) + * @see java.util.Iterator#remove() + */ + public void remove() { + + } + + /* (non-Javadoc) + * @see java.util.Iterator#hasNext() + */ + public boolean hasNext() { + return m_index < m_list.size(); + } + + /* (non-Javadoc) + * @see java.util.Iterator#next() + */ + public Object next() { + return m_list.get(m_index++); + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/module/GlyphModule.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/module/GlyphModule.java new file mode 100644 index 000000000..0027252aa --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/module/GlyphModule.java @@ -0,0 +1,90 @@ +/* + * $Id: GlyphModule.java,v 1.12 2004/09/04 21:54:19 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2003, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa.module; + +import org.doubletype.ossa.adapter.*; +import org.doubletype.ossa.*; +import java.util.*; + +/** + * @author e.e + */ +public class GlyphModule implements VarStackFrame { + protected VarStack m_stack = VarStack.getSingletonInstance(); + private Hashtable m_vars = new Hashtable<>(); + protected ActiveList m_actives = ActiveList.getSingletonInstance(); + + // -------------------------------------------------------------- + + public GlyphModule() { + } + + public Hashtable getVars() { + return m_vars; + } + + // for var stack frame + public boolean hasVariable(String a_name) { + return m_vars.containsKey(a_name); + } + + // for var stack frame. + public double getValue(String a_name) { + Double d = (Double) m_vars.get(a_name); + return d.doubleValue(); + } + + // for var stack frame. + public void beforePush() { + } + + /** + * Base for generating contours from modules. + * @param a_moduleInvoke + * @return XContour object which represents the module. + */ + public EContour toContour(EModuleInvoke a_moduleInvoke) { + throw new RuntimeException("Unimplemented contour creation."); + } + + public void addVar(String a_name, double a_value) { + m_vars.put(a_name, new Double(a_value)); + } + + public int getMinimumPointCount() { + return 2; + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/module/Rectangle.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/module/Rectangle.java new file mode 100644 index 000000000..813dfcbb8 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/module/Rectangle.java @@ -0,0 +1,192 @@ +/* + * $Id: Rectangle.java,v 1.16 2004/09/04 21:54:19 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2003, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa.module; + +import org.doubletype.ossa.xml.*; +import org.doubletype.ossa.adapter.*; + +import java.awt.geom.*; + +/** + * @author e.e + * + */ +public class Rectangle extends GlyphModule { + public static final double k_defaultPen = 68.0; + public static final double k_defaultWeight = 1.0; + public static final String k_weight = "weight"; + + public Rectangle() { + super(); + + addVar(k_weight, k_defaultWeight); + } + + public EContour toContour(EModuleInvoke a_moduleInvoke) { + int i; + EContour retval = new EContour(); + XContourPoint[] points = a_moduleInvoke.getContourPoint(); + + // can't make rectangle with one or zero point + if (points.length < 2) { + retval.addContourPoint(new EContourPoint(0, 0, true)); + return retval; + } // if + + double pen = m_stack.get(k_weight) * k_defaultPen; + boolean steeps[] = new boolean[points.length - 1]; + double thetas[] = new double[points.length - 1]; + Point2D outStartPoints[] = new Point2D[points.length - 1]; + Point2D inStartPoints[] = new Point2D[points.length - 1]; + Point2D outPoints [] = new Point2D[points.length]; + Point2D inPoints[] = new Point2D[points.length]; + + // treat each segment as a vector (start point and theta) + for (i = 0; i < points.length - 1; i++) { + EContourPoint start = (EContourPoint) points[i]; + EContourPoint end = (EContourPoint) points[i + 1]; + + // calculate theta of the vector + double theta; + if (start.toPoint2D().distance(end.toPoint2D()) > 0) { + theta = Math.atan2(end.getY() - start.getY(), + end.getX() - start.getX()); + } else { + theta = 0.0; + } // if + + thetas[i] = theta; + outStartPoints[i] = start.toPoint2D(); + + // turn the vector 90 degrees clockwise to create the + // starting point of the parallel vector (in-vector) + inStartPoints[i] = new Point2D.Double(start.getX() + (pen * Math.cos(theta - Math.PI / 2)), + start.getY() + (pen * Math.sin(theta - Math.PI / 2)) ); + } // for i + + for (i = 0; i < points.length; i++) { + EContourPoint point = (EContourPoint) points[i]; + + if (i == 0) { + // dynamically generate the point using vertical line thru p0 and the ideal line. + double cuttingTheta; + if (isSteep(thetas[i])) { + cuttingTheta = 0.0; + } else { + cuttingTheta = Math.PI / 2; + } // if-else + + outPoints[i] = getIntersection(point.toPoint2D(), cuttingTheta, + outStartPoints[i], thetas[i]); + inPoints[i] = getIntersection(point.toPoint2D(), cuttingTheta, + inStartPoints[i], thetas[i]); + continue; + } else if (i == points.length - 1) { + // vertial and ideal. + double cuttingTheta; + if (isSteep(thetas[i - 1])) { + cuttingTheta = 0.0; + } else { + cuttingTheta = Math.PI / 2; + } // if + + outPoints[i] = getIntersection(point.toPoint2D(), cuttingTheta, + outStartPoints[i - 1], thetas[i - 1]); + inPoints[i] = getIntersection(point.toPoint2D(), cuttingTheta, + inStartPoints[i - 1], thetas[i - 1]); + + continue; + } // if + + if (thetas[i - 1] != thetas[i]) { + outPoints[i] = getIntersection(outStartPoints[i - 1], thetas[i - 1], + outStartPoints[i], thetas[i]); + inPoints[i] = getIntersection(inStartPoints[i - 1], thetas[i - 1], + inStartPoints[i], thetas[i]); + } else { + outPoints[i] = outStartPoints[i]; + inPoints[i] = inStartPoints[i]; + } // if + } // for i + + for (i = 0; i < points.length; i++) { + EContourPoint point = (EContourPoint) points[i]; + + retval.addContourPoint(i, point.cloneAt(outPoints[i])); + retval.addContourPoint(i + 1, point.cloneAt(inPoints[i])); + } // if + + return retval; + } + + private boolean isSteep(double a_theta) { + return (a_theta > (Math.PI / 4) && a_theta < (3 * Math.PI / 4)) + || (a_theta < (-Math.PI / 4) && a_theta > (-3 * Math.PI / 4)); + } + + /** + * Intersection of two lines line0 and line1, defined by a point and slope. + * @param a_p0 a point line0 goes thru. + * @param a_theta0 the slope of line0, given in radian. + * @param a_p1 a point line1 goes thru. + * @param a_theta1 the slope of line1, given in radian. + * @return the intersection of line0 and line1, if any; a_p1, otherwise. + */ + private Point2D getIntersection(Point2D a_p0, double a_theta0, + Point2D a_p1, double a_theta1) { + Point2D retval = new Point2D.Double(); + retval.setLocation(a_p1); + + if (a_theta0 == a_theta1) + return retval; + + double cos0 = Math.cos(a_theta0); + double sin0 = Math.sin(a_theta0); + double cos1 = Math.cos(a_theta1); + double sin1 = Math.sin(a_theta1); + double deltaX = a_p1.getX() - a_p0.getX(); + double deltaY = a_p1.getY() - a_p0.getY(); + + double r1 = (cos0 * deltaY - sin0 * deltaX) + / (sin0 * cos1 - cos0 * sin1); + double x = a_p1.getX() + cos1 * r1; + double y = a_p1.getY() + sin1 * r1; + + retval.setLocation(x, y); + + return retval; + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/module/SelectionIterator.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/module/SelectionIterator.java new file mode 100644 index 000000000..14bb377b4 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/module/SelectionIterator.java @@ -0,0 +1,69 @@ + /* + * $Id: SelectionIterator.java,v 1.2 2004/11/08 06:29:52 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2004, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa.module; + +import java.util.*; + +import org.doubletype.ossa.adapter.*; +import org.doubletype.ossa.xml.IRNode; + + +/** + * @author e.e + */ +public class SelectionIterator extends GlyphIterator implements Iterator { + + /** + * @param a_file + */ + public SelectionIterator(GlyphFile a_file) { + super(a_file); + } + + protected void buildList() { + super.buildList(); + + List reverseList = new ArrayList<>(); + for (int i = m_list.size() - 1; i >= 0; i--) { + IRNode object = m_list.get(i); + + + reverseList.add(object); + } // for i + + m_list = reverseList; + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/module/TypefaceFile.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/module/TypefaceFile.java new file mode 100644 index 000000000..9133ea84f --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/module/TypefaceFile.java @@ -0,0 +1,677 @@ +/* + * $Copyright: copyright (c) 2003-2008, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa.module; + +import java.io.*; +import java.util.*; + +import org.doubletype.ossa.*; +import org.doubletype.ossa.xml.*; +import org.doubletype.ossa.adapter.*; +import org.doubletype.ossa.truetype.*; +import java.awt.*; + +/** + * @author e.e + */ +public class TypefaceFile extends GlyphFile { + private final double k_defaultTopSideBearing = 170; // 2 px + private final double k_defaultAscender = 683; // 8 px + private final double k_defaultXHeight = 424; // 5 px + private final double k_defaultDescender = 171; // 2 px + private final double k_defaultBottomSideBearing = 0; // 0 px + private final double k_em = 1024; + private final int k_defaultAdvanceWidth = 512; + private final String k_dotDtyp = ".dtyp"; + private final String k_dotTtf = ".ttf"; + + private File m_dir; + private Hashtable m_nameToIndeces = new Hashtable<>(); + private File m_ttfFile; + private Font m_font = null; + private File m_binFolder; + + public TypefaceFile(String a_name, File a_dir) throws FileNotFoundException { + super(TypefaceFile.class.getResource(s_emptyFileName)); + + m_dir = a_dir; + setGlyphTitle(a_name); + + m_fileName = new File(m_dir, a_name + k_dotDtyp); + initFileName(); + + saveGlyphFile(); + } + + public TypefaceFile(File a_file) { + super(a_file); + + m_dir = a_file.getParentFile(); + m_fileName = a_file; + + initFileName(); + } + + private void initFileName() { + m_binFolder = new File(m_dir, "bin"); + if (!m_binFolder.exists()) { + m_binFolder.mkdir(); + } // if + + String fileName = getGlyphTitle() + k_dotTtf; + m_ttfFile = new File(m_binFolder, fileName); + } + + public GlyphFile createGlyph(long a_unicode) throws FileNotFoundException { + String name = Character.getName((int) a_unicode); + if (name == null) { + name = "NAC_" + Long.toHexString(a_unicode); + } // if + + name = name.replace(' ', '_'); + return new GlyphFile( + getGlyphPath(), name, a_unicode); + } + + public boolean addRequiredGlyphs() throws FileNotFoundException { + boolean retval = false; + + if (unicodeToFileName(TTUnicodeRange.k_notDef) == null) { + GlyphFile glyph = new GlyphFile(getGlyphPath(), "NOTDEF", TTUnicodeRange.k_notDef); + glyph.initNotDef(k_defaultAdvanceWidth); + addGlyph(0, glyph); + retval = true; + } // if + + if (unicodeToFileName(TTUnicodeRange.k_null) == null) { + GlyphFile glyph = new GlyphFile(getGlyphPath(), "NULL", TTUnicodeRange.k_null); + glyph.initNullGlyph(); + addGlyph(1, glyph); + retval = true; + } // if + + if (unicodeToFileName(TTUnicodeRange.k_cr) == null) { + GlyphFile glyph = new GlyphFile(getGlyphPath(), "CR", TTUnicodeRange.k_cr); + glyph.initSpace(k_defaultAdvanceWidth); + addGlyph(2, glyph); + retval = true; + } // if + + if (unicodeToFileName(TTUnicodeRange.k_space) == null) { + GlyphFile glyph = new GlyphFile(getGlyphPath(), "SPACE", TTUnicodeRange.k_space); + glyph.initSpace(k_defaultAdvanceWidth); + addGlyph(3, glyph); + retval = true; + } // if + + if (retval) { + saveGlyphFile(); + } // if + + return retval; + } + + public void addBasicLatinGlyphs() throws FileNotFoundException { + String basicLatin = Character.UnicodeBlock.BASIC_LATIN.toString(); + TTUnicodeRange.find(basicLatin); + TTUnicodeRange range = TTUnicodeRange.getLastFound(); + addUnicodeRange(basicLatin); + for (long i = range.getStartCode(); i <= range.getEndCode(); i++) { + if (i != 0x0020) { + addGlyph(createGlyph(i)); + } // if + } // for i + + saveGlyphFile(); + } + + public File getGlyphPath() { + return m_dir; + } + + public String unicodeToFileName(long a_unicode) { + for (XGlyphFile glyphFile: m_glyph.getBody().getGlyphFile()) { + if (glyphFile.getUnicode() == a_unicode) { + return glyphFile.getHref(); + } // if + } // for i + + return null; + } + + /** + * change glyph's unicode mapping. + * @param a_glyphFile + * @param a_unicode + */ + public void setGlyphUnicode(GlyphFile a_glyphFile, long a_unicode) throws FileNotFoundException { + int i; + XGlyphFile [] glyphFiles = m_glyph.getBody().getGlyphFile(); + for (i = 0; i < glyphFiles.length; i++) { + XGlyphFile glyphFile = glyphFiles[i]; + + if (glyphFile.getHref().equals( + a_glyphFile.getShortFileName())) { + continue; + } // if + + glyphFile.setUnicode(a_unicode); + a_glyphFile.setUnicode(Long.toHexString(a_unicode)); + a_glyphFile.saveGlyphFile(); + saveGlyphFile(); + + return; + } // for i + } + + public void addGlyph(GlyphFile a_file) { + XGlyphFile xglyphFile = new XGlyphFile(); + xglyphFile.setHref(a_file.getShortFileName()); + xglyphFile.setUnicode(a_file.getUnicodeAsLong()); + m_glyph.getBody().addGlyphFile(xglyphFile); + } + + public void addGlyph(int a_index, GlyphFile a_file) { + XGlyphFile xglyphFile = new XGlyphFile(); + xglyphFile.setHref(a_file.getShortFileName()); + xglyphFile.setUnicode(a_file.getUnicodeAsLong()); + m_glyph.getBody().addGlyphFile(a_index, xglyphFile); + } + + public void removeGlyph(String a_fileName) { + for (XGlyphFile file: m_glyph.getBody().getGlyphFile()) { + if (file.getHref().equals(a_fileName)) { + m_glyph.getBody().removeGlyphFile(file); + return; + } // if + } + } + + public ArrayList getChildFileNames() { + ArrayList retval = new ArrayList<>(); + XGlyphFile [] files = m_glyph.getBody().getGlyphFile(); + + for (int i = 0; i < files.length; i++) { + XGlyphFile file = files[i]; + retval.add(file.getHref()); + } // for i + + return retval; + } + + public Object [] getCodePages() { + int i; + Object [] retval; + String [] codePages = m_glyph.getHead().getCodePage(); + retval = new Object[codePages.length]; + for (i = 0; i < codePages.length; i++) { + retval[i] = codePages[i]; + } // for i + + return retval; + } + + public boolean containsUnicodeRange(String a_unicodeRange) { + int i; + String [] unicodeRanges = m_glyph.getHead().getUnicodeRange(); + + for (i = 0; i < unicodeRanges.length; i++) { + if (unicodeRanges[i].equals(a_unicodeRange)) { + return true; + } // if + } // for i + + return false; + } + + public void addUnicodeRange(String a_unicodeRange) throws FileNotFoundException { + if (containsUnicodeRange(a_unicodeRange)) { + return; + } // if + + m_glyph.getHead().addUnicodeRange(a_unicodeRange); + saveGlyphFile(); + } + + public boolean containsCodePage(String a_codePage) { + int i; + String [] codePages = m_glyph.getHead().getCodePage(); + + for (i = 0; i < codePages.length; i++) { + if (codePages[i].equals(a_codePage)) { + return true; + } // if + } // for i + + return false; + } + + public void addCodePage(String a_codePage) throws FileNotFoundException { + if (containsCodePage(a_codePage)) { + return; + } // if + + m_glyph.getHead().addCodePage(a_codePage); + saveGlyphFile(); + } + + public void removeCodePage(String a_codePage) throws FileNotFoundException { + if (!containsCodePage(a_codePage)) { + return; + } // if + + m_glyph.getHead().removeCodePage(a_codePage); + saveGlyphFile(); + } + + public void setFontFamilyName(String a_value) throws FileNotFoundException { + m_glyph.getHead().setFontFamily(a_value); + saveGlyphFile(); + } + + public String getFontFamilyName() { + return m_glyph.getHead().getFontFamily(); + } + + public String getVersion() throws FileNotFoundException { + if (m_glyph.getHead().getVersion() == null) { + m_glyph.getHead().setVersion("0.1"); + saveGlyphFile(); + } // if + + return m_glyph.getHead().getVersion(); + } + + public void setSubFamily(String a_value) throws FileNotFoundException { + m_glyph.getHead().setFontSubFamily(a_value); + saveGlyphFile(); + } + + public void setDefaultMetrics() throws FileNotFoundException { + XHead head = m_glyph.getHead(); + head.setTopSideBearing(k_defaultTopSideBearing); + head.setAscender(k_defaultAscender); + head.setXHeight(k_defaultXHeight); + head.setDescender(k_defaultDescender); + head.setBottomSideBearing(k_defaultBottomSideBearing); + + saveGlyphFile(); + } + + public double getEm() { + return k_em; + } + + public double getBaseline() throws FileNotFoundException { + return getBottomSideBearing() + getDescender(); + } + + public double getMeanline() throws FileNotFoundException { + return getBottomSideBearing() + + getDescender() + getXHeight(); + } + + public double getBodyBottom() throws FileNotFoundException { + return getBottomSideBearing(); + } + + public double getBodyTop() throws FileNotFoundException { + return getEm() - getTopSideBearing(); + } + + public double getTopSideBearing() throws FileNotFoundException { + if (!m_glyph.getHead().checkTopSideBearing()) { + setDefaultMetrics(); + } // if + + return m_glyph.getHead().getTopSideBearing(); + } + + public double getAscender() throws FileNotFoundException { + if (!m_glyph.getHead().checkAscender()) { + setDefaultMetrics(); + } // if + + return m_glyph.getHead().getAscender(); + } + + public double getXHeight() throws FileNotFoundException { + if (!m_glyph.getHead().checkXHeight()) { + setDefaultMetrics(); + } // if + + return m_glyph.getHead().getXHeight(); + } + + public double getDescender() throws FileNotFoundException { + if (!m_glyph.getHead().checkDescender()) { + setDefaultMetrics(); + } // if + + return m_glyph.getHead().getDescender(); + } + + public double getBottomSideBearing() throws FileNotFoundException { + if (!m_glyph.getHead().checkBottomSideBearing()) { + setDefaultMetrics(); + } // if + + return m_glyph.getHead().getBottomSideBearing(); + } + + public void setTopSideBearing(double a_value) throws OutOfRangeException, FileNotFoundException { + checkBoundary(a_value); + m_glyph.getHead().setTopSideBearing(a_value); + saveGlyphFile(); + } + + private void checkBoundary(double a_value) throws OutOfRangeException { + if (a_value > k_em || a_value < 0) { + throw new OutOfRangeException(a_value); + } // if + } + + public void setAscender(double a_value) throws OutOfRangeException, FileNotFoundException { + checkBoundary(a_value); + m_glyph.getHead().setAscender(a_value); + saveGlyphFile(); + } + + public void setXHeight(double a_value) throws OutOfRangeException, FileNotFoundException { + checkBoundary(a_value); + if (a_value > getAscender()) { + throw new OutOfRangeException(a_value); + } // if + + m_glyph.getHead().setXHeight(a_value); + + m_history.record("setXHeight"); + saveGlyphFile(); + } + + public void setDescender(double a_value) throws OutOfRangeException, FileNotFoundException { + checkBoundary(a_value); + m_glyph.getHead().setDescender(a_value); + saveGlyphFile(); + } + + public void setBottomSideBearing(double a_value) throws OutOfRangeException, FileNotFoundException { + checkBoundary(a_value); + m_glyph.getHead().setBottomSideBearing(a_value); + saveGlyphFile(); + } + + public double getBodyHeight() throws FileNotFoundException { + return k_em - getTopSideBearing() - getBottomSideBearing(); + } + +// -------------------------------------------------------------------- + + /** + * Calls FontFileWriter to produce TrueType font file. + * @throws FileNotFoundException + */ + public void buildTTF(boolean a_isDebug) throws Exception { + String randomString = UUID.randomUUID().toString().substring(0, 4); + + File tempFile = new File(m_binFolder, + getGlyphTitle() + "_" + randomString + k_dotTtf); + File target; + String fontFamilyName; + + if (a_isDebug) { + target = tempFile; + fontFamilyName = getGlyphTitle() + " " + randomString; + } else { + target = m_ttfFile; + fontFamilyName = getFontFamilyName(); + } // if-else + + target.delete(); + FontFileWriter writer; + ModuleManager.getSingletonInstance().clear(); + m_stack.clear(); + m_stack.push(this); + try (RandomAccessFile randomAccessFile = new RandomAccessFile(target, "rw")) { + writer = new FontFileWriter(randomAccessFile); + + writer.setFontFamilyName(fontFamilyName); + writer.setCopyrightYear(getCopyrightYear()); + writer.setFontVersion(getVersion()); + writer.setManufacturer(getAuthor()); + writer.setAscent((int) getAscender()); + writer.setXHeight((int) getXHeight()); + writer.setDescent((int) getDescender()); + writer.setLineGap((int) (getTopSideBearing() + getBottomSideBearing())); + + loadCodePages(writer); + loadUnicodeRanges(writer); + loadGlyphs(writer); + writer.write(); + } + if (!a_isDebug && target.exists()) { + copyFile(target, tempFile); + } // if + + FileInputStream in = new FileInputStream(tempFile); + m_font = Font.createFont(Font.TRUETYPE_FONT, + (InputStream) in); + in.close(); + + ModuleManager.getSingletonInstance().clear(); + m_stack.pop(); // pop this + } + + private void copyFile(File a_in, File a_out) throws Exception { + FileInputStream in = new FileInputStream(a_in); + FileOutputStream out = new FileOutputStream(a_out); + byte [] buffer = new byte[1024]; + int i = 0; + while ((i = in.read(buffer)) != -1) { + out.write(buffer, 0, i); + } // while + + in.close(); + out.close(); + } + + public Font getFont() { + return m_font; + } + + private void loadCodePages(FontFileWriter a_writer) { + for (String codePageName: m_glyph.getHead().getCodePage()) { + TTCodePage codePage = TTCodePage.forName(codePageName); + if (codePage == null) { + continue; + } // if + + a_writer.setCodeRangeFlag(codePage.getOsTwoFlag()); + } // for codePageName + } + + private void loadUnicodeRanges(FontFileWriter a_writer) { + String [] unicodeRanges = m_glyph.getHead().getUnicodeRange(); + int i; + for (i = 0; i < unicodeRanges.length; i++) { + if (!TTUnicodeRange.find(unicodeRanges[i])) { + continue; + } // if + + a_writer.addUnicodeRange(TTUnicodeRange.getLastFound()); + } // for i + } + + private void loadGlyphs(FontFileWriter a_writer) throws Exception { + m_nameToIndeces.clear(); + + for (String fileName: getChildFileNames()) { + GlyphFile glyphFile = nameToGlyphFile(fileName); + loadGlyph(glyphFile, glyphFile, a_writer); + } // for + } + + private GlyphFile nameToGlyphFile(String a_fileName) throws FileNotFoundException { + File file = new File(m_dir, a_fileName); + + if (!file.exists()) { + throw new FileNotFoundException(a_fileName); + } // if + + GlyphFile retval = new GlyphFile(file); + + return retval; + } + + /** + * load the glyph into FontFileWriter. + * @param a_fileName + * @param a_writer + * @throws Exception + */ + private void loadGlyph(GlyphFile a_glyphFile, VarStackFrame a_frame, FontFileWriter a_writer) throws Exception { + if (m_nameToIndeces.containsKey(a_glyphFile.getShortFileName())) { + return; + } // if + + /* + if (a_glyphFile.getUnicodeAsLong() == TTUnicodeRange.k_null) { + return; + } // if + */ + + TTGlyph glyph = null; + m_stack.push(a_frame); + + if (a_glyphFile.isSimple()) { + // glyph will be null if it is empty + glyph = a_glyphFile.toSimpleGlyph(); + } else { + glyph = createCompoundGlyph(a_glyphFile, a_writer); + } // if + + m_stack.pop(); + + if (glyph == null && a_glyphFile.isWhiteSpace()) { + glyph = new TTGlyph(); + } // if + + if (glyph == null) { + return; + } // if + + int glyphIndex = a_writer.addGlyph(glyph); + m_nameToIndeces.put(a_glyphFile.getShortFileName(), glyphIndex); + long unicode = a_glyphFile.getUnicodeAsLong(); + + if (unicode != -1 && glyph != null) { + long existingIndex = a_writer.getCharacterMapping(unicode); + if (existingIndex != 0) { + throw new Exception(Long.toHexString(unicode) + " is mapped already."); + } // if + + a_writer.addCharacterMapping(unicode, glyphIndex); + } // if + } + + private TTGlyph createCompoundGlyph(GlyphFile a_glyphFile, + FontFileWriter a_writer) throws Exception + { + TTGlyph retval = new TTGlyph(); + ArrayList locs = new ArrayList<>(); + ArrayList indeces = new ArrayList<>(); + + retval.setSimple(false); + retval.setAdvanceWidth(a_glyphFile.getAdvanceWidth()); + + TTGlyph simple = a_glyphFile.toSimpleGlyph(); + if (simple != null) { + int glyphIndex = a_writer.addGlyph(simple); + + locs.add(new Point(0, 0)); + indeces.add(glyphIndex); + } // if + + XInclude [] includes = a_glyphFile.m_glyph.getBody().getInclude(); + int i; + for (i = 0; i < includes.length; i++) { + EIncludeInvoke include = (EIncludeInvoke) includes[i]; + GlyphFile glyphFile = nameToGlyphFile(include.getHref()); + + // load the glyph included in this one + loadGlyph(glyphFile, include, a_writer); + Integer n = m_nameToIndeces.get(glyphFile.getShortFileName()); + if (n == null) { + continue; + } // if + + indeces.add(n); + XPoint2d pos = include.getInvoke().getInvokePos().getPoint2d(); + locs.add(new Point((int) pos.getX(), (int) pos.getY())); + } // for i + + int flag = TTGlyph.ARG_1_AND_2_ARE_WORDS + | TTGlyph.ARGS_ARE_XY_VALUES + | TTGlyph.ROUND_XY_TO_GRID; + int numOfCompositePoints = 0; + int numOfCompositeContours = 0; + int componentDepth = 0; + + for (int glyfIndex: indeces) { + TTGlyph glyph = a_writer.getGlyph(glyfIndex); + numOfCompositePoints += glyph.getNumOfCompositePoints(); + numOfCompositeContours += glyph.getNumOfCompositeContours(); + if (glyph.getComponentDepth() > componentDepth) { + componentDepth = glyph.getComponentDepth(); + } // if + + retval.addGlyfIndex(glyfIndex); + if (i < indeces.size() - 1) { + retval.addFlag(flag | TTGlyph.MORE_COMPONENTS); + } else { + retval.addFlag(flag); + } // if-else + + Point loc = locs.get(i); + retval.addArg1(loc.x); + retval.addArg2(loc.y); + } // for + + retval.setNumOfCompositePoints(numOfCompositePoints); + retval.setNumOfCompositeContours(numOfCompositeContours); + retval.setComponentDepth(componentDepth + 1); + + return retval; + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/module/VarStack.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/module/VarStack.java new file mode 100644 index 000000000..2f8526487 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/module/VarStack.java @@ -0,0 +1,112 @@ + /* + * $Id: VarStack.java,v 1.1 2004/04/21 10:54:41 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2004, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa.module; + +import java.util.*; + +/** + * @author e.e + */ +public class VarStack { + private static VarStack s_varstack = null; + + public static VarStack getSingletonInstance() { + if (s_varstack == null) + s_varstack = new VarStack(); + + return s_varstack; + } + + // -------------------------------------------------------------- + + private ArrayList m_stack = new ArrayList<>(); + + // -------------------------------------------------------------- + + public void push(VarStackFrame a_frame) { + a_frame.beforePush(); + m_stack.add(a_frame); + } + + public VarStackFrame pop() { + VarStackFrame retval = peek(); + if (retval == null) { + return retval; + } // if + + m_stack.remove(retval); + + return retval; + } + + public VarStackFrame peek() { + if (m_stack.size() <= 0) { + return null; + } // if + + return (VarStackFrame) m_stack.get(m_stack.size() - 1); + } + + public void clear() { + m_stack.clear(); + } + + public int size() { + return m_stack.size(); + } + + /** + * goes through the var stack and returns the variable value + * @param a_name name of the variable + * @return the value of the variable + */ + public double get(String a_name) { + int i; + double retval = 0.0; + + for (i = 0; i < m_stack.size(); i++) { + VarStackFrame frame + = (VarStackFrame) m_stack.get(m_stack.size() - i - 1); + if (!frame.hasVariable(a_name)) { + continue; + } // if + + return frame.getValue(a_name); + } // for i + + return retval; + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/module/VarStackFrame.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/module/VarStackFrame.java new file mode 100644 index 000000000..aa27f9709 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/module/VarStackFrame.java @@ -0,0 +1,53 @@ + /* + * $Id: VarStackFrame.java,v 1.1 2004/04/21 10:55:02 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2004, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa.module; + +/** + * @author e.e + */ +public interface VarStackFrame { + /** + * tests if the variable is declared in this module. + * @param a_name name of the variable + * @return true, if declared; false, otherwise. + */ + boolean hasVariable(String a_name); + double getValue(String a_name); + + /** fired before push by the var stack. + */ + void beforePush(); +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/module/empty.glyph b/trunk/libsrc/ttf/src/org/doubletype/ossa/module/empty.glyph new file mode 100644 index 000000000..6fdefeb4d --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/module/empty.glyph @@ -0,0 +1,21 @@ + + + + + + + Nobody + 2004 + temp + Regular + All rights reserved. + + + + + + + + + + diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/CmapWriter.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/CmapWriter.java new file mode 100644 index 000000000..eb1640bf3 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/CmapWriter.java @@ -0,0 +1,316 @@ +/* + * $Id: CmapWriter.java,v 1.8 2004/01/27 00:35:08 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2003, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa.truetype; + +import java.io.*; +import java.util.*; + +/** + * @author e.e + */ +public class CmapWriter extends FontFormatWriter { + final long k_basicLatinStart = 0x20; + final long k_basicLatinEnd = 0x7e; + final long k_tableEnd = 0xffff; + final int k_unmappedChar = 0x0; + + private OS2Writer m_os2; + private List m_unicodes = new ArrayList<>(); + private List m_startCodes = new ArrayList<>(); + private List m_endCodes = new ArrayList<>(); + private Hashtable m_unicode2glyph = new Hashtable<>(); + private List m_unicodeRanges = new ArrayList<>(); + private List m_idDeltas = new ArrayList<>(); + private List m_idRangeOffsets = new ArrayList<>(); + private boolean m_isIncludeVersion0; + private byte [] m_version0; + private byte [] m_version4; + private byte [] m_version12; + + public CmapWriter(OS2Writer a_os2) { + super(); + + m_os2 = a_os2; + m_isIncludeVersion0 = false; + } + + @SuppressWarnings("unchecked") + private void prepare() { + Collections.sort(m_unicodeRanges); + + TTUnicodeRange range = (TTUnicodeRange) m_unicodeRanges.get(0); + m_os2.m_usFirstCharIndex = (int) range.getStartCode(); + m_os2.m_usLastCharIndex = (int) range.getEndCode(); + + int i; + for (i = 0; i < m_unicodeRanges.size(); i++) { + range = m_unicodeRanges.get(i); + + m_startCodes.add(range.getStartCode()); + m_endCodes.add(range.getEndCode()); + m_idDeltas.add(0L); + m_idRangeOffsets.add( + 2L * (m_unicodeRanges.size() - i) + 2L + + 2L * (m_unicodes.size())); + + m_os2.m_usLastCharIndex = (int) range.getEndCode(); + m_os2.setUnicodeRangeFlag(range.getOsTwoFlag()); + + for (long unicode = range.getStartCode(); + unicode <= range.getEndCode(); unicode++) + { + m_unicodes.add(unicode); + } // for unicode + } // for i + + m_startCodes.add(k_tableEnd); + m_endCodes.add(k_tableEnd); + m_idDeltas.add(1L); + m_idRangeOffsets.add(0L); + } + + public void write() throws IOException { + prepare(); + + if (m_isIncludeVersion0) { + storeVersion0(); + } // if + storeVersion4(); + + reset(); + + writeUInt16(0); // table version number + writeUInt16(getNumOfEncoding()); // num of encodings + + if (m_isIncludeVersion0) { + writeUInt16(TTName.k_macintosh); + writeUInt16(TTName.k_macRomanEncode); + writeUInt32(size() + 4 + 8); + } // if + + writeUInt16(TTName.k_microsoft); + writeUInt16(TTName.k_winUnicodeEncode); + int version4Offset = size() + 4; + if (m_isIncludeVersion0) { + version4Offset += m_version0.length; + } // if + writeUInt32(version4Offset); + + if (m_isIncludeVersion0) { + m_buffer.write(m_version0); + } // if + + m_buffer.write(m_version4); + pad(); + } + + private int getNumOfEncoding() { + if (m_isIncludeVersion0) { + return 2; + } // if + + return 1; + } + + public void addUnicodeRange(TTUnicodeRange a_range) { + m_unicodeRanges.add(a_range); + } + + public void addMapping(long a_unicode, long a_glyfIndex) { + m_unicode2glyph.put(a_unicode, a_glyfIndex); + } + + /** + * Find 'glyf' index for the given unicode. + * This method returns 0, if a_key was not found, which will be treated + * as unmapped character. + * @param a_key Long object with unicode value. + * @return 'glyf' index if a_key was found; 0 otherwise. + */ + public long getGlyfIndex(Long a_key) { + long retval = 0; + + if (m_unicode2glyph.containsKey(a_key)) { + retval = m_unicode2glyph.get(a_key); + } // if + + return retval; + } + + private void storeVersion0() throws IOException { + reset(); + writeVersion0(); + m_version0 = toByteArray(); + reset(); + } + + private void storeVersion4() throws IOException { + reset(); + writeVersion4(); + m_version4 = toByteArray(); + reset(); + } + + private void storeVersion12() throws IOException { + reset(); + writeVersion12(); + m_version12 = toByteArray(); + reset(); + } + + protected String getTag() { + return "cmap"; + } + + private void writeVersion0() throws IOException { + writeUInt16(0); + writeUInt16(262); + writeUInt16(0); + int i; + for (i = 0; i < 256; i++) { + if ((i == 0x000) || (i == 0x0008) || (i == 0x001D)) { + writeUInt8((int) getGlyfIndex(TTUnicodeRange.k_null)); // .null + } + else if ((i == 0x0009) || (i == 0x000d)) { + writeUInt8((int) getGlyfIndex(TTUnicodeRange.k_cr)); // CR + } + else { + writeUInt8((int) getGlyfIndex((long) i)); + } // if + } // for i + } + + private void writeVersion4() throws IOException { + int segCount = m_startCodes.size(); + int i; + + // endCount + for (i = 0; i < segCount; i++) { + Long n = (Long) m_endCodes.get(i); + writeUInt16(n.intValue()); + } // for i + + // reserverdPad + writeUInt16(0); + + // startCount + for (i = 0; i < segCount; i++) { + Long n = m_startCodes.get(i); + writeUInt16(n.intValue()); + } // for i + + // idDelta + for (i = 0; i < segCount; i++) { + Long n = m_idDeltas.get(i); + writeInt16(n.intValue()); + } // for i + + // idRangeOffset + for (i = 0; i < segCount; i++) { + Long n = m_idRangeOffsets.get(i); + writeInt16(n.intValue()); + } + + // glyphIdArray 2 bytes each + for (i = 0; i < m_unicodes.size(); i++) { + Long unicode = m_unicodes.get(i); + writeUInt16((int) getGlyfIndex(unicode)); + } // for i + + byte [] bytes = m_bytes.toByteArray(); + + reset(); + + writeUInt16(4); + writeUInt16(bytes.length + 14); + writeUInt16(0); + writeUInt16(segCount * 2); + + int searchRange = getSearchRange(segCount); + writeUInt16(searchRange); + writeUInt16(getEntrySelector(searchRange)); + writeUInt16(getRangeShift(segCount, searchRange)); + m_buffer.write(bytes); + } + + public void writeVersion12() throws IOException { + ArrayList startCharCode = new ArrayList<>(); + ArrayList endCharCode = new ArrayList<>(); + ArrayList startGlyphCode = new ArrayList<>(); + + // TODO: map to real one + startCharCode.add(k_basicLatinStart); + endCharCode.add(k_basicLatinEnd); + startGlyphCode.add(1L); + + long length = 16 + 12 * startCharCode.size(); + + writeFixed32(12.0); + writeUInt32(length); + writeUInt32(0); + writeUInt32(startCharCode.size()); + + int i; + for (i = 0; i < startCharCode.size(); i++) { + writeUInt32(startCharCode.get(i)); + writeUInt32(endCharCode.get(i)); + writeUInt32(startGlyphCode.get(i)); + } // for i + } + + /** + * Used for searchRange + * @param a_value + * @return + */ + private int getSearchRange(int a_value) { + int retval + = (int) Math.pow(2, Math.floor(Math.log(a_value) / Math.log(2))); + return 2 * retval; + } + + private int getEntrySelector(int a_searchRange) { + int retval + = (int) (Math.log(a_searchRange / 2) / Math.log(2)); + return retval; + } + + private int getRangeShift(int a_value, int a_searchRange) { + int retval + = 2 * a_value - a_searchRange; + return retval; + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/FontFileWriter.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/FontFileWriter.java new file mode 100644 index 000000000..97ff35df3 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/FontFileWriter.java @@ -0,0 +1,286 @@ +/* + * $Id: FontFileWriter.java,v 1.15 2004/10/04 02:25:39 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2003, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + + +package org.doubletype.ossa.truetype; + +import java.io.*; +import java.util.*; + +/** + * @author e.e + */ +public class FontFileWriter extends FontFormatWriter { + private CmapWriter m_cmap; + private GlyfWriter m_glyf; + private LocaWriter m_loca; + private HeadWriter m_head; + private HdmxWriter m_hdmx; + private HheaWriter m_hhea; + private HmtxWriter m_hmtx; + private MaxpWriter m_maxp; + private NameWriter m_name; + private PostWriter m_post; + private OS2Writer m_os2; + + protected RandomAccessFile m_file; + private ArrayList m_tables = new ArrayList<>(); + + public FontFileWriter(RandomAccessFile a_file) { + super(); + + m_file = a_file; + + m_loca = new LocaWriter(); + m_maxp = new MaxpWriter(); + m_head = new HeadWriter(); + m_hdmx = new HdmxWriter(); + m_os2 = new OS2Writer(m_head); + m_cmap = new CmapWriter(m_os2); + + m_glyf = new GlyfWriter(m_loca, m_maxp, + m_head, m_hdmx); + + m_hhea = new HheaWriter(m_glyf, m_head); + m_hmtx = new HmtxWriter(m_glyf, m_hhea); + m_name = new NameWriter(); + m_post = new PostWriter(); + + // http://www.microsoft.com/typography/otspec/recom.htm + // head, hhea, maxp, OS/2, hmtx, LTSH, VDMX, hdmx, cmap, + // fpgm, prep, cvt, loca, glyf, kern, name, post, gasp, PCLT, DSIG + /* + m_tables.add(m_head); + m_tables.add(m_hhea); + m_tables.add(m_maxp); + m_tables.add(m_os2); + m_tables.add(m_hmtx); + m_tables.add(m_hdmx); + m_tables.add(m_cmap); + m_tables.add(m_loca); + m_tables.add(m_glyf); + m_tables.add(m_name); + m_tables.add(m_post); + */ + + // Verdana has head, hhea, maxp, OS/2, gasp, name, cmap, loca + // LTSH, VDMX, prep, fpgm, cvt, hmtx, hdmx, glyf, post, kern, edt0, DSIG + m_tables.add(m_head); + m_tables.add(m_hhea); + m_tables.add(m_maxp); + m_tables.add(m_os2); + m_tables.add(m_name); + m_tables.add(m_cmap); + m_tables.add(m_loca); + + m_tables.add(m_hmtx); + m_tables.add(m_hdmx); + m_tables.add(m_glyf); + m_tables.add(m_post); + } + + /** + * write TrueType file to the random access file + */ + public void write() throws IOException { + m_cmap.write(); + // hmtx must be written before hhea + m_hmtx.write(); + m_hhea.write(); + + m_glyf.write(); + m_loca.write(); + + m_head.setCheckSumAdjustment(0); + m_head.write(); + m_maxp.write(); // must be written after m_glyf + m_hdmx.write(); + m_name.write(); + m_post.write(); + m_os2.write(); + + writeTableDirectory(); + byte [] tableDir = toByteArray(); + for (FontFormatWriter table: m_tables) { + m_buffer.write(table.toByteArray()); + } // for table + + long checkSum = 0xb1b0afba - (0xffffffff & getCheckSum()); + m_head.setCheckSumAdjustment(checkSum); + m_head.reset(); + m_head.write(); + + reset(); + + m_buffer.write(tableDir); + for (FontFormatWriter table: m_tables) { + m_buffer.write(table.toByteArray()); + } // for table + + m_file.write(toByteArray()); + m_file.close(); + } + + public void setAscent(int a_value) { + m_os2.setTypoAscender(a_value); + m_os2.setCapHeight(a_value); + } + + public void setDescent(int a_value) { + m_os2.setTypoDescender(-a_value); + } + + public void setXHeight(int a_value) { + m_os2.setXHeight(a_value); + } + + public void setLineGap(int a_value) { + m_os2.setTypoLineGap(a_value); + m_hhea.setLineGap(a_value); + } + + public void setFontFamilyName(String a_name) { + m_name.m_familyName = a_name; + } + + public void setCopyrightYear(String a_year) { + m_name.m_year = a_year; + } + + public void setManufacturer(String a_manufacturer) { + m_name.m_manufacturer = a_manufacturer; + } + + public void setFontVersion(String a_version) { + m_name.m_version = a_version; + } + + public void addUnicodeRange(TTUnicodeRange a_range) { + m_cmap.addUnicodeRange(a_range); + } + + /** + * http://www.microsoft.com/typography/otspec/os2.htm + * @param a_codeRange position of the bit. For example, JIS will be 17. + */ + public void setCodeRangeFlag(int a_codeRange) { + m_os2.setCodePageRangeFlag(a_codeRange); + } + + /** + * adds glyph to the 'glyf' subtable. + * @param a_glyph the glyph to be added. + * @return 'glyf' index of the added glyph. + */ + public int addGlyph(TTGlyph a_glyph) { + return m_glyf.add(a_glyph); + } + + public TTGlyph getGlyph(int a_index) { + return m_glyf.getGlyph(a_index); + } + + /** + * adds character mapping to + * @param a_unicode unicode of the character + * @param a_glyfIndex 'glyf' index obtained from #addGlyph + */ + public void addCharacterMapping(long a_unicode, long a_glyfIndex) { + m_cmap.addMapping(a_unicode, a_glyfIndex); + } + + public long getCharacterMapping(long a_unicode) { + return m_cmap.getGlyfIndex(new Long(a_unicode)); + } + + /** + * writes table directory. + * @throws IOException + */ + private void writeTableDirectory() throws IOException { + int headerLength = m_tables.size() * 16 + 16; + int tableOffset = headerLength; + for (FontFormatWriter table: m_tables) { + table.setOffset(tableOffset); + tableOffset += table.size(); + } // for table + + @SuppressWarnings("unchecked") + ArrayList tables = (ArrayList) m_tables.clone(); + Collections.sort(tables, new Comparator() { + public int compare(FontFormatWriter a_lhs, FontFormatWriter a_rhs) { + return a_lhs.getTag().compareTo(a_rhs.getTag()); + } + + public boolean equals(Object a_value) { + return false; + } + }); + + writeFixed32(1.0); + + int numOfTables = tables.size(); + writeUInt16(numOfTables); + int searchRange = getSearchRange(numOfTables); + writeUInt16(searchRange); + int entrySelector = getEntrySelector(numOfTables); + writeUInt16(entrySelector); + writeUInt16(numOfTables * 16 - searchRange); + + for (FontFormatWriter table: tables) { + writeTag(table.getTag()); + writeUInt32(table.getCheckSum()); + writeUInt32(table.getOffset()); + writeUInt32(table.size()); + } // for + + // padding is always 4 zeros + for (int i = 0; i < 4; i++) { + writeUInt8(0); + } // for i + } + + private int getSearchRange(int a_value) { + int retval + = (int) (Math.pow(2, Math.floor(Math.log(a_value) / Math.log(2)))); + return 16 * retval; + } + + private int getEntrySelector(int a_value) { + int retval + = (int) Math.floor(Math.log(a_value) / Math.log(2)); + return retval; + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/FontFormatWriter.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/FontFormatWriter.java new file mode 100644 index 000000000..2d2030cc8 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/FontFormatWriter.java @@ -0,0 +1,173 @@ +/* + * $Id: FontFormatWriter.java,v 1.6 2004/01/28 11:44:08 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2003, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa.truetype; + +import java.io.*; +import java.util.*; + +/** + * @author e.e + */ +public class FontFormatWriter { + protected DataOutputStream m_buffer; + protected ByteArrayOutputStream m_bytes; + private int m_offset; + + public FontFormatWriter() { + init(); + } + + protected void init() { + m_bytes = new ByteArrayOutputStream(); + m_buffer = new DataOutputStream(m_bytes); + m_offset = 0; + } + + public void write() throws IOException { + } + + public byte[] toByteArray() { + return m_bytes.toByteArray(); + } + + /** + * Size of buffer in bytes. + * @return size of buffer in bytes. + */ + public int size() { + return m_bytes.size(); + } + + public void reset() { + m_bytes.reset(); + } + + protected void writeFixed32(double a_value) throws IOException { + final int k_denom = 16384; + + short mantissa = (short) Math.floor(a_value); + int fraction = (int) ((a_value - mantissa) * k_denom); + if (fraction > k_denom) { + fraction = 0; + mantissa++; + } // if + + m_buffer.writeShort(mantissa); + m_buffer.writeShort(fraction); + } + + protected void writeUInt16(int a_value) throws IOException { + writeInt16((short) (0xffff & a_value)); + } + + protected void writeInt16(int a_value) throws IOException { + m_buffer.writeShort((short) a_value); + } + + protected void writeFWord(int a_value) throws IOException { + writeInt16(a_value); + } + + protected void writeUFWord(int a_value) throws IOException { + writeUInt16(a_value); + } + + protected void writeUInt32 (long a_value) throws IOException { + writeInt32((int) (0xffffffff & a_value)); + } + + protected void writeInt32(int a_value) throws IOException { + m_buffer.writeInt(a_value); + } + + protected void writeUInt8(int a_byte) throws IOException { + m_buffer.writeByte(a_byte); + } + + protected void writeTag(String a_value) throws IOException { + String s = a_value + " "; + + int i; + for (i = 0; i < 4; i++) { + writeUInt8(s.charAt(i)); + } // for i + } + + protected void writeLongDateTime(Date a_date) throws IOException { + long sec = a_date.getTime() / 1000; + sec += (1970 - 1904) * 365 * 24 * 60 * 60; + m_buffer.writeLong(sec); + } + + protected String getTag() { + throw new RuntimeException("unimplemnted call to getTag"); + } + + protected long getCheckSum() { + long retval = 0; + byte [] bytes = toByteArray(); + + for (int i = 0; i < bytes.length / 4; i++) { + long n = 0; + for (int j = 0; j < 4; j++) { + n += bytes[4 * i + j] << ((4 - j) * 8); + } // for j + retval += n; + } // for i + + return retval; + } + + protected void pad() throws IOException { + int align = 4; + int numOfPad = align - toByteArray().length % align; + if (numOfPad == align) + return; + + int i; + for (i = 0; i < numOfPad; i++) { + writeUInt8(0); + } // for i + } + + public int getOffset() { + return m_offset; + } + + public void setOffset(int a_value) { + m_offset = a_value; + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/GlyfWriter.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/GlyfWriter.java new file mode 100644 index 000000000..8a89e92b1 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/GlyfWriter.java @@ -0,0 +1,203 @@ +/* + * $Id: GlyfWriter.java,v 1.17 2004/09/23 07:47:39 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2003, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + + +package org.doubletype.ossa.truetype; + +import java.io.*; +import java.awt.*; +import java.util.*; + +/** + * @author e.e + */ +public class GlyfWriter extends FontFormatWriter { + private ArrayList m_glyphs; + + private LocaWriter m_loca; + private MaxpWriter m_maxp; + private HeadWriter m_head; + private HdmxWriter m_hdmx; + + public GlyfWriter(LocaWriter a_loca, MaxpWriter a_maxp, + HeadWriter a_head, HdmxWriter a_hdmx) { + super(); + + m_loca = a_loca; + m_maxp = a_maxp; + m_head = a_head; + m_hdmx = a_hdmx; + m_glyphs = new ArrayList<>(); + } + + public void write() throws IOException { + m_hdmx.setNumGlyphs(numOfGlyph()); + m_maxp.setNumGlyphs(numOfGlyph()); + m_loca.m_offsets.clear(); + + for (int i = 0; i < m_glyphs.size(); i++) { + writeGlyph(m_glyphs.get(i)); + m_hdmx.updatePixelWidth(i, m_glyphs.get(i)); + } // for i + + m_loca.m_offsets.add(size()); + } + + public int add(TTGlyph a_glyph) { + m_head.updateMax(a_glyph.getMax()); + m_head.updateMin(a_glyph.getMin()); + + m_glyphs.add(a_glyph); + return m_glyphs.size() - 1; + } + + public int numOfGlyph() { + return m_glyphs.size(); + } + + public TTGlyph getGlyph(int a_index) { + return m_glyphs.get(a_index); + } + + private void writeGlyph(TTGlyph a_glyph) throws IOException { + m_loca.m_offsets.add(size()); + + if (a_glyph == null) { + return; + } // if + + if (a_glyph.isSimple()) { + writeSimpleGlyph(a_glyph); + } else { + writeCompoundGlyph(a_glyph); + } // if-else + + pad(); + } + + /** + * @param a_glyph + * @throws IOException + */ + private void writeSimpleGlyph(TTGlyph a_glyph) throws IOException { + if (a_glyph.getNumOfContours() == 0) { + return; + } // if + + m_maxp.updateNumOfContours(a_glyph.getNumOfContours()); + writeInt16(a_glyph.getNumOfContours()); + writeMinMax(a_glyph); + + int i; + for (i = 0; i < a_glyph.getNumOfContours(); i++) { + writeUInt16(a_glyph.getEndPoint(i)); + } // for i + + int numOfInst = a_glyph.getNumOfInstructions(); + m_maxp.updateSizeOfInstructions(numOfInst); + + writeUInt16(numOfInst); + for (i = 0; i < numOfInst; i++) { + writeUInt8(a_glyph.getInstruction(i)); + } // for i + + for (i = 0; i < a_glyph.getNumOfFlags(); i++) { + int flag = a_glyph.getFlag(i); + writeUInt8(flag); + } // for i + + // update num of points + m_maxp.updateNumOfPoints(a_glyph.getNumOfPoints()); + + int lastX = 0; + for (i = 0; i < a_glyph.getNumOfPoints(); i++) { + Point point = a_glyph.getPoint(i); + + writeInt16(point.x - lastX); + lastX = point.x; + } // for i + + int lastY = 0; + for (i = 0; i < a_glyph.getNumOfPoints(); i++) { + Point point = a_glyph.getPoint(i); + + writeInt16(point.y - lastY); + lastY = point.y; + } // for i + } + + /** + * @param a_glyph + * @throws IOException + */ + private void writeCompoundGlyph(TTGlyph a_glyph) throws IOException { + int i; + + m_maxp.updateNumOfCompositePoints(a_glyph.getNumOfCompositePoints()); + m_maxp.updateNumOfCompositeContours(a_glyph.getNumOfCompositeContours()); + + writeInt16(-1); + writeMinMax(a_glyph); + + int numOfGlyphs = a_glyph.getNumOfFlags(); + m_maxp.updateNumOfComponentElements(numOfGlyphs); + m_maxp.updateComponentDepth(a_glyph.getComponentDepth()); + + for (i = 0; i < numOfGlyphs; i++) { + writeUInt16(a_glyph.getFlag(i)); + writeUInt16(a_glyph.getGlyfIndex(i)); + writeInt16(a_glyph.getArg1(i)); + writeInt16(a_glyph.getArg2(i)); + } // for i + } + + /** + * @param a_glyph + * @throws IOException + */ + private void writeMinMax(TTGlyph a_glyph) throws IOException { + Point min = a_glyph.getMin(); + Point max = a_glyph.getMax(); + + writeFWord(min.x); + writeFWord(min.y); + writeFWord(max.x); + writeFWord(max.y); + } + + protected String getTag() { + return "glyf"; + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/HdmxWriter.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/HdmxWriter.java new file mode 100644 index 000000000..1ba5a6c3f --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/HdmxWriter.java @@ -0,0 +1,117 @@ +/* + * $Copyright: copyright (c) 2003-2008, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + + +package org.doubletype.ossa.truetype; + +import java.io.*; +import java.util.*; + +/** + * HtmxWriter depends on GlyfWriter. + * + * @author e.e + */ +public class HdmxWriter extends FontFormatWriter { + static public int getNumOfPixelSizes() { + return TTPixelSize.getList().size(); + } + + static public ArrayList getPixelSizes() { + return TTPixelSize.getList(); + } + + private int m_numGlyphs = 98; // set by GlyfWriter + + public HdmxWriter() { + super(); + } + + /** set the number of glyphs in the font */ + public void setNumGlyphs(int a_value) { + m_numGlyphs = a_value; + + for (TTPixelSize pixelSize: getPixelSizes()) { + pixelSize.setPixelWidthsSize(a_value); + } // for pixelSize + } + + public void updatePixelWidth(int a_glyphIndex, TTGlyph a_glyph) { + double advanceWidth = a_glyph.getAdvanceWidth(); + double em = TTPixelSize.getEm(); + + for (TTPixelSize pixelSize: TTPixelSize.getList()) { + int width = (int) Math.round(((double) pixelSize.getPixel() * advanceWidth) / em); + pixelSize.setPixelWidth(a_glyphIndex, width); + } // pixelSize + } + + /** + * writes htmx record. + * The size of a device record is calculated to align it to 32bit boundary. + */ + public void write() throws IOException { + int numOfPads = 4 - ((m_numGlyphs + 2) % 4); + if (numOfPads == 4) { + numOfPads = 0; + } // if + int size = m_numGlyphs + 2 + numOfPads; // 2 comes from the ppem and max + + // format version number + writeInt16(0); + + // number of device records + writeInt16(getNumOfPixelSizes()); + //System.out.printf("num of pixel sizes %d\n", getNumOfPixelSizes()); + // size of device record + writeInt32(size); + //System.out.printf("num of glyphs %d\n", m_numGlyphs); + for (TTPixelSize pixelSize: getPixelSizes()) { + writeUInt8(pixelSize.getPixel()); + writeUInt8(pixelSize.getMaxPixelWidth()); + for (int pixelWidth: pixelSize.getPixelWidths()) { + writeUInt8(pixelWidth); + } // for pixelWidth + + for (int j = 0; j < numOfPads; j++) { + writeUInt8(0); + } // for j + } // for pixelSize + + pad(); + } + + protected String getTag() { + return "hdmx"; + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/HeadWriter.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/HeadWriter.java new file mode 100644 index 000000000..3b23d4e49 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/HeadWriter.java @@ -0,0 +1,156 @@ +/* + * $Id: HeadWriter.java,v 1.7 2004/09/26 09:15:48 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2003, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + + +package org.doubletype.ossa.truetype; + +import java.io.*; +import java.util.*; +import java.awt.*; + +/** + * @author e.e + */ +public class HeadWriter extends FontFormatWriter { + static public final int k_yZeroIsBaseLine = 0x1; // bit 0 + static public final int k_xLeftMostBlackIsLsb = 0x2; // bit 1 + static public final int k_scaledPointDiffer = 0x4; // bit 2 + static public final int k_useIntegerScaling = 0x8; // bit 3 + + // used by microsoft + static public final int k_scaleLinear = 0x10; + + // for vertical fonts + static public final int k_xZeroIsBaseLine = 0x20; + // 0x40 + static public final int k_linguisticRendering = 0x80; + static public final int k_defaultMetamorphosis = 0x100; + static public final int k_rightToLeft = 0x200; + static public final int k_indicRearrangement = 0x400; + + + private final long k_magicNumber = 0x5f0f3cf5; + + private long m_checkSumAdjustment = 0; + private Point m_min = new Point(0, 0); + private Point m_max = new Point(0, 0); + + public HeadWriter() { + super(); + } + + void setCheckSumAdjustment(long a_value) { + m_checkSumAdjustment = a_value; + } + + public Point getMin() { + return m_min; + } + + public Point getMax() { + return m_max; + } + + public void updateMin(Point a_value) { + if (a_value.x < m_min.x) { + m_min.x = a_value.x; + } // if + + if (a_value.y < m_min.y) { + m_min.y = a_value.y; + } // if + } + + public void updateMax(Point a_value) { + if (a_value.x > m_max.x) { + m_max.x = a_value.x; + } // if + + if (a_value.y > m_max.y) { + m_max.y = a_value.y; + } // if + } + + public void write() throws IOException { + // table version number + writeFixed32(1.0); + + // fontRevision + writeFixed32(1.0); + + writeUInt32(m_checkSumAdjustment); + writeUInt32(k_magicNumber); + + // LSB is the distance from 0, 0 to the left of the glyph bounds. + // flags + writeUInt16(k_yZeroIsBaseLine + | k_xLeftMostBlackIsLsb + | k_scaledPointDiffer);; + + // unitsPerEm + writeUInt16(1024); + + // created, modified + writeLongDateTime(new Date()); + writeLongDateTime(new Date()); + + writeFWord(m_min.x); + writeFWord(m_min.y); + writeFWord(m_max.x); + writeFWord(m_max.y); + + // macStyle + writeUInt16(0); + + // lowestRecPPEM + writeUInt16(11); + + // font direction hint + // 2, for strongly left to right + // but also contains neutrals + writeInt16(2); + + // indexToLocFormat. 1, for long + writeInt16(1); + + // glyfDataFormat + writeInt16(0); + pad(); + } + + protected String getTag() { + return "head"; + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/HheaWriter.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/HheaWriter.java new file mode 100644 index 000000000..7c75f8748 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/HheaWriter.java @@ -0,0 +1,108 @@ +/* + * $Id: HheaWriter.java,v 1.5 2004/09/26 09:15:48 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2003, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + + +package org.doubletype.ossa.truetype; + +import java.io.*; + +/** + * HheaWriter depends on HtmxWriter. + * @author e.e + */ +public class HheaWriter extends FontFormatWriter { + private GlyfWriter m_glyf; + private HeadWriter m_head; + + private int m_lineGap = 0; + private int m_maxAdvanceWidth = 0; + private int m_minRightSideBearing = 0; + + public HheaWriter(GlyfWriter a_glyf, HeadWriter a_head) { + super(); + + m_glyf = a_glyf; + m_head = a_head; + } + + public void setLineGap(int a_value) { + m_lineGap = a_value; + } + + public void setMaxAdvanceWidth(int a_value) { + m_maxAdvanceWidth = a_value; + } + + public void setMinRightSideBearing(int a_value) { + m_minRightSideBearing = a_value; + } + + public void write() throws IOException { + // table version number + writeFixed32(1.0); + + writeFWord(m_head.getMax().y); + writeFWord(m_head.getMin().y); + writeFWord(m_lineGap); + writeUFWord(m_maxAdvanceWidth); + + int minLeftSideBearing = m_head.getMin().x; + writeFWord(minLeftSideBearing); + writeFWord(m_minRightSideBearing); + + int xMaxExtent = m_head.getMax().x - m_head.getMin().x; + writeFWord(xMaxExtent); + + // caratSlopeRise + writeInt16(1); + writeInt16(0); + + // reserved + for (int i = 0; i < 5; i++) { + writeInt16(0); + } // for i + + writeInt16(0); + + int numOfHMetrics = m_glyf.numOfGlyph(); + writeUInt16(numOfHMetrics); + + pad(); + } + + protected String getTag() { + return "hhea"; + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/HmtxWriter.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/HmtxWriter.java new file mode 100644 index 000000000..f8a487329 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/HmtxWriter.java @@ -0,0 +1,89 @@ +/* + * $Id: HmtxWriter.java,v 1.10 2004/10/04 02:25:39 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2003, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + + +package org.doubletype.ossa.truetype; + +import java.io.*; + +/** + * HtmxWriter depends on GlyfWriter. + * + * @author e.e + */ +public class HmtxWriter extends FontFormatWriter { + HheaWriter m_hhea; + GlyfWriter m_glyf; + + public HmtxWriter(GlyfWriter a_glyf, HheaWriter a_hhea) { + super(); + + m_hhea = a_hhea; + m_glyf = a_glyf; + } + + public void write() throws IOException { + int i; + + TTGlyph glyphZero = m_glyf.getGlyph(0); + int maxWidth = glyphZero.getAdvanceWidth(); + int minRightSideBearing = glyphZero.getRightSideBearing(); + for (i = 0; i < m_glyf.numOfGlyph(); i++) { + TTGlyph glyph = m_glyf.getGlyph(i); + + if (glyph.getAdvanceWidth() > maxWidth) { + maxWidth = glyph.getAdvanceWidth(); + } // if + + if (glyph.getRightSideBearing() < minRightSideBearing) { + minRightSideBearing = glyph.getRightSideBearing(); + } // if + + writeUFWord(glyph.getAdvanceWidth()); + writeFWord(glyph.getLeftSideBearing()); + } // for i + + writeFWord(0); + + m_hhea.setMaxAdvanceWidth(maxWidth); + m_hhea.setMinRightSideBearing(minRightSideBearing); + + pad(); + } + + protected String getTag() { + return "hmtx"; + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/LocaWriter.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/LocaWriter.java new file mode 100644 index 000000000..4a2056d0b --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/LocaWriter.java @@ -0,0 +1,67 @@ +/* + * $Id: LocaWriter.java,v 1.3 2004/01/15 07:06:27 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2003, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + + +package org.doubletype.ossa.truetype; + +import java.io.*; +import java.util.*; + +/** + * @author e.e + */ +public class LocaWriter extends FontFormatWriter { + public ArrayList m_offsets = new ArrayList<>(); + + public LocaWriter() { + super(); + } + + public void write() throws IOException { + // assume glyf table is already written, + // and offsets are stored in m_offsets + + int i; + for (i = 0; i < m_offsets.size(); i++) { + writeUInt32(m_offsets.get(i)); + } // for i + + pad(); + } + + protected String getTag() { + return "loca"; + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/MaxpWriter.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/MaxpWriter.java new file mode 100644 index 000000000..16880ab29 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/MaxpWriter.java @@ -0,0 +1,137 @@ +/* + * $Id: MaxpWriter.java,v 1.11 2004/06/27 07:26:46 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2003, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + + +package org.doubletype.ossa.truetype; + +import java.io.*; + +/** + * @author e.e + */ +public class MaxpWriter extends FontFormatWriter { + private int m_numGlyphs = 98; // set by GlyfWriter + private int m_maxPoints = 0; + private int m_maxContours = 0; + private int m_maxCompositePoints = 0; + private int m_maxCompositeContours = 0; + private int m_maxZones = 2; + private int m_maxTwilightPoints = 128; + private int m_maxStorage = 64; + private int m_maxFunctionDefs = 128; + private int m_maxInstructionDefs = 128; + private int m_maxStackElements = 128; + private int m_maxSizeOfInstructions = 128; + private int m_maxComponentElements = 128; + private int m_maxComponentDepth = 0; + + public MaxpWriter() { + super(); + } + + public void write() throws IOException { + writeFixed32(1.0); + writeUInt16(m_numGlyphs); + writeUInt16(m_maxPoints); + writeUInt16(m_maxContours); + writeUInt16(m_maxCompositePoints); + writeUInt16(m_maxCompositeContours); + writeUInt16(m_maxZones); + writeUInt16(m_maxTwilightPoints); + writeUInt16(m_maxStorage); + writeUInt16(m_maxFunctionDefs); + writeUInt16(m_maxInstructionDefs); + writeUInt16(m_maxStackElements); + writeUInt16(m_maxSizeOfInstructions); + writeUInt16(m_maxComponentElements); + writeUInt16(m_maxComponentDepth); + pad(); + } + + protected String getTag() { + return "maxp"; + } + + /** set the number of glyphs in the font */ + public void setNumGlyphs(int a_value) { + m_numGlyphs = a_value; + } + + /** update points in non-compound glyph */ + public void updateNumOfPoints(int a_value) { + if (a_value > m_maxPoints) { + m_maxPoints = a_value; + } // if + } + + /** update points in non-compound glyph */ + public void updateNumOfContours(int a_value) { + if (a_value > m_maxContours) { + m_maxContours = a_value; + } // if + } + + public void updateNumOfCompositePoints(int a_value) { + if (a_value > m_maxCompositePoints) { + m_maxCompositePoints = a_value; + } // if + } + + public void updateNumOfCompositeContours(int a_value) { + if (a_value > m_maxCompositeContours) { + m_maxCompositeContours = a_value; + } // if + } + + /** update byte count for glyph instructions */ + public void updateSizeOfInstructions(int a_value) { + if (a_value > m_maxSizeOfInstructions) { + m_maxSizeOfInstructions = a_value; + } // if + } + + public void updateNumOfComponentElements(int a_value) { + if (a_value > m_maxComponentElements) { + m_maxComponentElements = a_value; + } // if + } + + public void updateComponentDepth(int a_value) { + if (a_value > m_maxComponentDepth) { + m_maxComponentDepth = a_value; + } // if + } + +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/NameWriter.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/NameWriter.java new file mode 100644 index 000000000..37641a200 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/NameWriter.java @@ -0,0 +1,183 @@ +/* + * $Id: NameWriter.java,v 1.9 2004/06/16 07:02:52 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2003, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + + +package org.doubletype.ossa.truetype; + +import java.io.*; +import java.util.*; + +/** + * @author e.e + */ +public class NameWriter extends FontFormatWriter { + public static final String k_regular = "Regular"; + private static final String k_utf16be = "UTF-16BE"; + private static final String k_iso8859_1 = "ISO-8859-1"; + + String m_copyright = "\u00A9 Copyright"; + String m_familyName = "Temp"; + String m_subFamilyName = k_regular; + String m_unique = "eed3si9n: Temp Regular: 2003"; + String m_fullFontName = "Temp"; + String m_version = "0.00"; + String m_psName = "Temp"; + String m_tradeMark = ""; + String m_manufacturer = "eed3si9n"; + String m_year = "2004"; + String m_sample = "The quick brown fox jumps over the lazy dog."; + + private ArrayList m_names = new ArrayList<>(); + + public NameWriter() { + super(); + } + + private void prepare() { + m_copyright = "\u00A9 Copyright " + + m_year + + ", " + + m_manufacturer + + "."; + m_unique = "dtype: " + + m_manufacturer + ": " + + m_familyName + " " + + m_subFamilyName + ": " + + "Version " + m_version + ": " + + m_year; + m_fullFontName = m_familyName; + m_psName = m_fullFontName; + + if (m_tradeMark.length() == 0) { + m_tradeMark = "n/a"; + } // if + + m_names.clear(); + addNames(); + } + + private void addNames() { + addMacintoshRomanEnglish(0, m_copyright); + addMacintoshRomanEnglish(1, m_familyName); + addMacintoshRomanEnglish(2, m_subFamilyName); + addMacintoshRomanEnglish(3, m_unique); + addMacintoshRomanEnglish(4, m_fullFontName); + addMacintoshRomanEnglish(5, "Version " + m_version); + addMacintoshRomanEnglish(6, m_psName); + addMacintoshRomanEnglish(7, m_tradeMark); + addMacintoshRomanEnglish(8, m_manufacturer); + + addMicrosoftUnicodeEnglish(0, m_copyright); + addMicrosoftUnicodeEnglish(1, m_familyName); + addMicrosoftUnicodeEnglish(2, m_subFamilyName); + addMicrosoftUnicodeEnglish(3, m_unique); + addMicrosoftUnicodeEnglish(4, m_fullFontName); + addMicrosoftUnicodeEnglish(5, "Version " + m_version); + addMicrosoftUnicodeEnglish(6, m_psName); + addMicrosoftUnicodeEnglish(7, m_tradeMark); + addMicrosoftUnicodeEnglish(8, m_manufacturer); + // addMicrosoftUnicodeEnglish(19, m_sample); + } + + private void addMacintoshRomanEnglish(int a_nameId, String a_value) { + try { + add(TTName.k_macintosh, + TTName.k_macRomanEncode, + TTName.k_macEnglishLang, + a_nameId, + a_value.getBytes(k_iso8859_1)); + } + catch (IOException e) { + e.printStackTrace(); + } // try-catch + } + + private void addMicrosoftUnicodeEnglish(int a_nameId, String a_value) { + try { + add(TTName.k_microsoft, + TTName.k_winUnicodeEncode, + TTName.k_winEnglishLang, + a_nameId, + a_value.getBytes(k_utf16be)); + } + catch (IOException e) { + e.printStackTrace(); + } + } + + private void add(int a_platformId, int a_encodingId, int a_languageId, + int a_nameId, byte a_bytes[]) { + TTName name = new TTName(a_platformId, + a_encodingId, + a_languageId, + a_nameId, + a_bytes); + m_names.add(name); + } + + public void write() throws IOException { + prepare(); + + // table version number + writeUInt16(0); + + // number of name records + writeUInt16(m_names.size()); + + // Offset to start of string storage (from start of table). + writeUInt16(12 * m_names.size() + 6); + + int offset = 0; + for (TTName name: m_names) { + writeUInt16(name.getPlatformId()); + writeUInt16(name.getEncodingId()); + writeUInt16(name.getLanguageId()); + writeUInt16(name.getNameId()); + writeUInt16(name.getStringLength()); + writeUInt16(offset); + offset += name.getStringLength(); + } // for i + + for (TTName name: m_names) { + m_buffer.write(name.getBytes()); + } // for i + + pad(); + } + + protected String getTag() { + return "name"; + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/OS2Writer.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/OS2Writer.java new file mode 100644 index 000000000..54cf6a398 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/OS2Writer.java @@ -0,0 +1,242 @@ +/* + * $Id: OS2Writer.java,v 1.11 2004/10/04 02:25:39 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2003, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + + +package org.doubletype.ossa.truetype; + +import java.io.*; + +/** + * @author e.e + */ +public class OS2Writer extends FontFormatWriter { + final int FW_THIN = 100; + final int FW_EXTRALIGHT = 200; + final int FW_LIGHT = 300; + final int FW_NORMAL = 400; + final int FW_MEDIUM = 500; + final int FW_SEMIBOLD = 600; + final int FW_BOLD = 700; + final int FW_EXTRABOLD = 800; + final int FW_BLACK = 900; + + final int FWIDTH_NORMAL = 5; + + final int k_editableEmbedding = 0x0008; + + final int k_sansSerif = 0x0800; + + // unicode + final int k_basicLatin = 0x0001; + final int k_latin1Supplement = 0x0002; + + final int k_regular = 0x40; + final int k_basicLatinStart = 0x0020; + final int k_basciLatinEnd = 0x007e; + + private HeadWriter m_head; + + int m_xAvgCharWidth = 512; + int m_usWeightClass = FW_NORMAL; + int m_usWidthClass = FWIDTH_NORMAL; + int m_fsType = 0; + int m_ySubscriptXSize = 128; + int m_ySubscriptYSize = 128; + int m_ySubscriptXOffset = 0; + int m_ySubscriptYOffset = -64; + int m_ySuperscriptXSize = 128; + int m_ySuperscriptYSize = 128; + int m_ySuperscriptXOffset = 0; + int m_ySuperscriptYOffset = 64; + int m_yStrikeoutSize = 51; + int m_yStrikeoutPosition = 512; + int m_sFamilyClass = k_sansSerif; + + long m_ulUnicodeRange1 = k_basicLatin | k_latin1Supplement; + long m_ulUnicodeRange2 = 0; + long m_ulUnicodeRange3 = 0; + long m_ulUnicodeRange4 = 0; + String m_vendId = "dtyp"; + int m_fsSelection = k_regular; + int m_usFirstCharIndex = k_basicLatinStart; + int m_usLastCharIndex = k_basciLatinEnd; + private int m_sTypoAscender = 1024; + private int m_sTypoDescender = 0; + private int m_sTypoLineGap = 0; + private int m_usWinAscent = 1024; + private int m_usWinDescent = 0; + long m_ulCodePageRange1 = 0; + long m_ulCodePageRange2 = 0; + private int m_sxHeight = 512; + private int m_sCapHeight = 1024; + int m_usDefaultChar = 0x0; + int m_usBreakChar = 0x20; + int m_usMaxContext = 1; + + public OS2Writer(HeadWriter a_head) { + super(); + + m_head = a_head; + } + + public void setCapHeight(int a_value) { + m_sCapHeight = a_value; + } + + public void setXHeight(int a_value) { + m_sxHeight = a_value; + } + + public void setTypoAscender(int a_value) { + m_sTypoAscender = a_value; + } + + public void setTypoDescender(int a_value) { + m_sTypoDescender = a_value; + } + + public void setTypoLineGap(int a_value) { + m_sTypoLineGap = a_value; + } + + public void setUnicodeRangeFlag(int a_pos) { + int which = a_pos / 32; + int where = a_pos % 32; + long what = 0x1 << where; + + switch (which) { + case 0: { + m_ulUnicodeRange1 |= what; + } break; + + case 1: { + m_ulUnicodeRange2 |= what; + } break; + + case 2: { + m_ulUnicodeRange3 |= what; + } break; + + case 3: { + m_ulUnicodeRange4 |= what; + } break; + } // switch + } + + public void setCodePageRangeFlag(int a_pos) { + int which = a_pos / 32; + int where = a_pos % 32; + long what = 0x1 << where; + + switch (which) { + case 0: { + m_ulCodePageRange1 |= what; + } break; + + case 1: { + m_ulCodePageRange2 |= what; + } break; + } // switch + } + + public void write() throws IOException { + m_usWinAscent = m_head.getMax().y; + m_usWinDescent = 0; + if (m_head.getMin().y < 0) { + m_usWinDescent = -m_head.getMin().y; + } // if + + // table version number + writeUInt16(0x02); + + writeInt16(m_xAvgCharWidth); + writeUInt16(m_usWeightClass); + writeUInt16(m_usWidthClass); + writeInt16(m_fsType); + writeInt16(m_ySubscriptXSize); + writeInt16(m_ySubscriptYSize); + writeInt16(m_ySubscriptXOffset); + writeInt16(m_ySubscriptYOffset); + writeInt16(m_ySuperscriptXSize); + writeInt16(m_ySuperscriptYSize); + writeInt16(m_ySuperscriptXOffset); + writeInt16(m_ySuperscriptYOffset); + writeInt16(m_yStrikeoutSize); + writeInt16(m_yStrikeoutPosition); + writeInt16(m_sFamilyClass); + + writePanose(); + + writeUInt32(m_ulUnicodeRange1); + writeUInt32(m_ulUnicodeRange2); + writeUInt32(m_ulUnicodeRange3); + writeUInt32(m_ulUnicodeRange4); + writeTag(m_vendId); + writeUInt16(m_fsSelection); + writeUInt16(m_usFirstCharIndex); + writeUInt16(m_usLastCharIndex); + writeUInt16(m_sTypoAscender); + writeUInt16(m_sTypoDescender); + writeUInt16(m_sTypoLineGap); + writeUInt16(m_usWinAscent); + writeUInt16(m_usWinDescent); + writeUInt32(m_ulCodePageRange1); + writeUInt32(m_ulCodePageRange2); + writeInt16(m_sxHeight); + writeInt16(m_sCapHeight); + writeUInt16(m_usDefaultChar); + writeUInt16(m_usBreakChar); + writeUInt16(m_usMaxContext); + + pad(); + } + + private void writePanose() throws IOException { + writeUInt8(0); // family + writeUInt8(0); // serif + writeUInt8(0); // weight + writeUInt8(0); // proportion + writeUInt8(0); // contrast + writeUInt8(0); // stroke + writeUInt8(0); // arm style + writeUInt8(0); // letterform + writeUInt8(0); // midline + writeUInt8(0); // x-height + } + + protected String getTag() { + return "OS/2 "; + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/PostWriter.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/PostWriter.java new file mode 100644 index 000000000..ecd99a16b --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/PostWriter.java @@ -0,0 +1,76 @@ +/* + * $Id: PostWriter.java,v 1.3 2004/01/11 13:14:45 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2003, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + + +package org.doubletype.ossa.truetype; + +import java.io.*; + +/** + * @author e.e + */ +public class PostWriter extends FontFormatWriter { + boolean m_isMonospaced = false; + + public PostWriter() { + super(); + } + + public void write() throws IOException { + // table version number + writeFixed32(1.0); + writeFixed32(10.0); // italic angle + writeFWord(0); // underline pos + writeFWord(60); // underline thickness + + if (m_isMonospaced) { + writeUInt32(1); // fixed pitch + } else { + writeUInt32(0); + } // if + + // vm memory stuff + writeUInt32(0); + writeUInt32(0); + writeUInt32(0); + writeUInt32(0); + + pad(); + } + + protected String getTag() { + return "post"; + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/TTCodePage.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/TTCodePage.java new file mode 100644 index 000000000..ccf0398a0 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/TTCodePage.java @@ -0,0 +1,189 @@ +/* + * $Id: TTCodePage.java,v 1.3 2004/05/16 12:59:07 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2003-2004, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa.truetype; + +import java.util.*; +import java.nio.charset.*; + +/** + * @author e.e + */ +public class TTCodePage { + static public TTCodePage US_ASCII = new TTCodePage("US-ASCII", + "US-ASCII", + 64); + static public TTCodePage Latin_1 = new TTCodePage("windows-1252", + "Latin 1 windows-1252", + 0); + static private boolean s_isInitialized = false; + static private ArrayList s_list = new ArrayList<>(); + + static public String [] getNames() { + initList(); + String [] retval = new String[s_list.size()]; + int i; + for (i = 0; i < s_list.size(); i++) { + TTCodePage codePage = (TTCodePage) s_list.get(i); + retval[i] = codePage.getName(); + } // for i + + return retval; + } + + static public TTCodePage forName(String a_name) { + initList(); + + TTCodePage retval = null; + for (TTCodePage codePage: s_list) { + if (codePage.getName().equals(a_name)) { + return codePage; + } + } // for + + for (TTCodePage codePage: s_list) { + if (codePage.getCharset() == null) { + continue; + } // if + + if (codePage.getCharset().name().equals(a_name)) { + return codePage; + } + } // for + + return retval; + } + + static private void initList() { + if (s_isInitialized) + return; + + s_isInitialized = true; + + s_list.add(US_ASCII); + s_list.add(Latin_1); + s_list.add(new TTCodePage("ISO-2022-JP", + "Japan-JIS", + 17)); + s_list.add(new TTCodePage("windows-1250", + "Latin 2: Eastern Europe windows-1250", + 1)); + s_list.add(new TTCodePage("windows-1251", + "Cyrillic windows-1251", + 2)); + s_list.add(new TTCodePage("windows-1253", + "Greek windows-1253", + 3)); + s_list.add(new TTCodePage("windows-1254", + "Turkish windows-1254", + 4)); + s_list.add(new TTCodePage("windows-1258", + "Vietnamese windows-1258", + 8)); + + + // extended + s_list.add(new TTCodePage("windows-1255", + "Hebrew windows-1255", + 5)); + s_list.add(new TTCodePage("windows-1256", + "Arabic windows-1256", + 6)); + s_list.add(new TTCodePage("windows-1257", + "Windows Baltic", + 7)); + + // TODO: 16 Thai 874 + s_list.add(new TTCodePage( + "Thai windows-874", + 16)); + + s_list.add(new TTCodePage("x-mswin-936", + "Chinese: Simplified", + 18)); + + // TODO: 19 Korean Wansung + s_list.add(new TTCodePage( + "Korean Wansung", + 19)); + + s_list.add(new TTCodePage("x-windows-950", + "Chinese: Traditional", + 20)); + } + + + private String m_name; + + /** http://www.microsoft.com/typography/otspec/os2.htm + */ + private int m_osTwoFlag = 0; + private Charset m_charset = null; + + public TTCodePage(String a_charsetName, String a_name, + int a_osTwoFlag) + { + if (Charset.isSupported(a_charsetName)) { + m_charset = Charset.forName(a_charsetName); + } // if + + m_name = a_name; + m_osTwoFlag = a_osTwoFlag; + } + + public TTCodePage(String a_name, + int a_osTwoFlag) + { + m_name = a_name; + m_osTwoFlag = a_osTwoFlag; + } + + public String toString() { + return m_name; + } + + public String getName() { + return m_name; + } + + + public Charset getCharset() { + return m_charset; + } + + public int getOsTwoFlag() { + return m_osTwoFlag; + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/TTGlyph.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/TTGlyph.java new file mode 100644 index 000000000..de32707b3 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/TTGlyph.java @@ -0,0 +1,391 @@ +/* + * $Copyright: copyright (c) 2003-2008, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa.truetype; + +import java.awt.*; +import java.util.*; + +/** + * @author e.e + */ +public class TTGlyph { + // -------------------------------------------------------------- + public static final int k_onCurve = 0x1; + + public static final int ARG_1_AND_2_ARE_WORDS = 0x1; + public static final int ARGS_ARE_XY_VALUES = 0x2; + public static final int ROUND_XY_TO_GRID = 0x4; + public static final int WE_HAVE_A_SCALE = 0x8; + // 0x10 is obsolete + public static final int MORE_COMPONENTS = 0x20; + public static final int WE_HAVE_AN_X_AND_Y_SCALE = 0x40; + public static final int WE_HAVE_A_TWO_BY_TWO = 0x80; + public static final int WE_HAVE_INSTRUCTIONS = 0x100; + public static final int USE_MY_METRICS = 0x200; + public static final int OVERLAP_COMPOUND = 0x400; + + /** Move Direct Absolute Point - do not round */ + public static final int MDAP0 = 0x2E; + + /** Move Direct Absolute Point - round the value */ + public static final int MDAP1 = 0x2F; + + /** Interpolate Untouched Points through the outline - y-direction */ + public static final int IUP0 = 0x30; + + /** Interpolate Untouched Points through the outline - x-direction */ + public static final int IUP1 = 0x31; + + /** push one byte */ + public static final int PUSHB000 = 0xB0; + + /** push two bytes */ + public static final int PUSHB001 = 0xB1; + + /** push three bytes */ + public static final int PUSHB010 = 0xB2; + public static final int PUSHB011 = 0xB3; + public static final int PUSHB100 = 0xB4; + public static final int PUSHB101 = 0xB5; + public static final int PUSHB110 = 0xB6; + public static final int PUSHB111 = 0xB7; + + /** set vector to y-axis. */ + public static final int SVTCA0 = 0x00; + + /** set vector to x-axis. */ + public static final int SVTCA1 = 0x01; + public static final int SPVFS = 0x0A; // set projection vector + public static final int SFVFS = 0x0B; // set freedom vector + public static final int SFVTPV = 0x0E; + public static final int DELTAP1 = 0x5D; + public static final int DELTAP2 = 0x71; + public static final int DELTAP3 = 0x72; + + /** set delta base */ + public static final int SDB = 0x5E; + + // -------------------------------------------------------------- + + /** + * converts double into F2Dot14, 16 bit fixed point format. + * @param a_value + * @return + */ + public static int toF2Dot14(double a_value) { + int retval = 0; + + if (a_value >= 2.0 || a_value < -2.0) { + throw new RuntimeException(Double.toString(a_value) + " out of range"); + } // if + + int mantissa = (int) Math.floor(a_value); + int fraction = (int) Math.floor((a_value - mantissa) * 16384); + + int twoBitPart = mantissa; + if (mantissa < 0) { + twoBitPart = 4 + mantissa; + } // if + + retval = (twoBitPart << 14) | fraction; + + return retval; + } + + public static int toDeltaArg(int a_relativePpem, int a_step) { + int retval = 0; + + if (a_step < -8 || a_step > 8 || a_step == 0) { + throw new RuntimeException("Out of range"); + } // if + + int selector = 0; + if (a_step > 0) { + selector = a_step + 7; + } else { + selector = a_step + 8; + } // if + + retval = (a_relativePpem << 4) | (selector); + + return retval; + } + + // -------------------------------------------------------------- + + private ArrayList m_points = new ArrayList<>(); + private ArrayList m_endPtsOfContours = new ArrayList<>(); + private ArrayList m_instructions = new ArrayList<>(); + private ArrayList m_flags = new ArrayList<>(); + private ArrayList m_glyfIndeces = new ArrayList<>(); + private ArrayList m_arg1s = new ArrayList<>(); + private ArrayList m_arg2s = new ArrayList<>(); + + private boolean m_isSimple = true; + private int m_advanceWidth = 512; + + private int m_numOfCompositePoints = 0; + private int m_numOfCompositeContours = 0; + private int m_componentDepth = 0; + + private Point m_min = null; + private Point m_max = null; + + // -------------------------------------------------------------- + + public TTGlyph() { + init(); + } + + public void init() { + m_isSimple = true; + m_points.clear(); + m_endPtsOfContours.clear(); + m_instructions.clear(); + m_flags.clear(); + m_glyfIndeces.clear(); + m_arg1s.clear(); + m_arg2s.clear(); + m_advanceWidth = 512; + } + + public void buildCompound() { + init(); + + m_isSimple = false; + + addFlag(ARG_1_AND_2_ARE_WORDS + | ARGS_ARE_XY_VALUES + | ROUND_XY_TO_GRID + | MORE_COMPONENTS); + addFlag(ARG_1_AND_2_ARE_WORDS + | ARGS_ARE_XY_VALUES + | ROUND_XY_TO_GRID); + + addGlyfIndex(3); + addGlyfIndex(3); + + addArg1(0); + addArg2(0); + addArg1(0); + addArg2(500); + } + + /** + * add the index of the last point in the contour + * @param a_index + */ + public void addEndPoint(int a_value) { + m_endPtsOfContours.add(a_value); + } + + public int getNumOfContours() { + if (isSimple()) { + return m_endPtsOfContours.size(); + } else { + return -1; + } // if-else + } + + public int getEndPoint(int a_index) { + return m_endPtsOfContours.get(a_index); + } + + public int getAdvanceWidth() { + return m_advanceWidth; + } + + public void setAdvanceWidth(int a_value) { + m_advanceWidth = a_value; + } + + public Point getMax() { + if (m_max == null) { + m_max = new Point(0, 0); + } // if + + return m_max; + } + + public Point getMin() { + if (m_min == null) { + m_min = new Point(0, 0); + } // if + + return m_min; + } + + public boolean isSimple() { + return m_isSimple; + } + + public void setSimple(boolean a_isSimple) { + m_isSimple = a_isSimple; + } + + public void addInstruction(int a_value) { + m_instructions.add(a_value); + } + + public int getInstruction(int a_index) { + return m_instructions.get(a_index); + } + + public int getNumOfInstructions() { + return m_instructions.size(); + } + + public void addFlag(int a_value) { + m_flags.add(a_value); + } + + public int getFlag(int a_index) { + return m_flags.get(a_index); + } + + public int getNumOfFlags() { + return m_flags.size(); + } + + public void addPoint(Point a_value) { + m_points.add(a_value); + updateMinMax(a_value); + } + + private void updateMinMax(Point a_value) { + if (m_max == null) { + m_max = new Point(a_value); + } // if + + if (m_min == null) { + m_min = new Point(a_value); + } // if + + if (a_value.x > m_max.x) { + m_max.x = a_value.x; + } // if + + if (a_value.x < m_min.x) { + m_min.x = a_value.x; + } // if + + if (a_value.y > m_max.y) { + m_max.y = a_value.y; + } // if + + if (a_value.y < m_min.y) { + m_min.y = a_value.y; + } // if + } + + public Point getPoint(int a_index) { + return m_points.get(a_index); + } + + public int getNumOfPoints() { + return m_points.size(); + } + + public int getLastIndex() { + return m_points.size() - 1; + } + + public void addGlyfIndex(int a_value) { + m_glyfIndeces.add(a_value); + } + + public int getGlyfIndex(int a_index) { + return m_glyfIndeces.get(a_index); + } + + public void addArg1(int a_value) { + m_arg1s.add(a_value); + } + + public int getArg1(int a_index) { + return m_arg1s.get(a_index); + } + + public void addArg2(int a_value) { + m_arg2s.add(a_value); + } + + public int getArg2(int a_index) { + return m_arg2s.get(a_index); + } + + public int getNumOfCompositePoints() { + if (isSimple()) { + return getNumOfPoints(); + } else { + return m_numOfCompositePoints; + } + } + + public void setNumOfCompositePoints(int a_value) { + m_numOfCompositePoints = a_value; + } + + public int getNumOfCompositeContours() { + if (isSimple()) { + return getNumOfContours(); + } else { + return m_numOfCompositeContours; + } // if-else + } + + public void setNumOfCompositeContours(int a_value) { + m_numOfCompositeContours = a_value; + } + + public int getComponentDepth() { + if (isSimple()) { + return 0; + } else { + return m_componentDepth; + } // if-else + } + + public void setComponentDepth(int a_value) { + m_componentDepth = a_value; + } + + public int getLeftSideBearing() { + return getMin().x; + } + + public int getRightSideBearing() { + return getAdvanceWidth() - getMax().x; + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/TTName.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/TTName.java new file mode 100644 index 000000000..659712f16 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/TTName.java @@ -0,0 +1,93 @@ +/* + * $Id: TTName.java,v 1.2 2005/01/21 05:37:26 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2004, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa.truetype; + +public class TTName { + public static final int k_unicode = 0; + public static final int k_unicodeDefaultEncode = 0; + + public static final int k_macintosh = 1; + public static final int k_macRomanEncode = 0; + public static final int k_macEnglishLang = 0; + + public static final int k_microsoft = 3; + public static final int k_winSymbolEncode = 0; + public static final int k_winUnicodeEncode = 1; + public static final int k_winShiftJisEncode = 2; + public static final int k_winEnglishLang = 0x409; + private int m_platformId; + private int m_encodingId; + private int m_languageId; + private int m_nameId; + private byte m_bytes[]; + + public TTName(int a_platformId, + int a_encodingId, + int a_languageId, + int a_nameId, + byte a_bytes[]) { + m_platformId = a_platformId; + m_encodingId = a_encodingId; + m_languageId = a_languageId; + m_nameId = a_nameId; + m_bytes = a_bytes; + } + + public int getPlatformId() { + return m_platformId; + } + + public int getEncodingId() { + return m_encodingId; + } + + public int getLanguageId() { + return m_languageId; + } + + public int getNameId() { + return m_nameId; + } + + // BUGFIX 958996 + public byte[] getBytes() { + return m_bytes; + } + + public int getStringLength() { + return m_bytes.length; + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/TTPixelSize.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/TTPixelSize.java new file mode 100644 index 000000000..d81b15dc7 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/TTPixelSize.java @@ -0,0 +1,107 @@ +package org.doubletype.ossa.truetype; + +import java.util.ArrayList; + +public class TTPixelSize { + static private int s_em = 1024; + static private boolean s_isInitialized = false; + static private ArrayList s_list = new ArrayList<>(); + + static public int getEm() { + return s_em; + } + + static public ArrayList getList() { + initList(); + return s_list; + } + + static private void initList() { + if (s_isInitialized) + return; + + s_isInitialized = true; + + // s_list.add(new TTPixelSize(9, "9px: 7pt(96dpi)/9pt(72dpi)")); + // s_list.add(new TTPixelSize(10, "10px: 7.5pt(96dpi)/10pt(72dpi)")); + s_list.add(new TTPixelSize(11, "11px: 8pt(96dpi)/11pt(72dpi)")); + s_list.add(new TTPixelSize(12, "12px: 9pt(96dpi)/12pt(72dpi)")); + s_list.add(new TTPixelSize(13, "13px: 10pt(96dpi)/13pt(72dpi)")); + s_list.add(new TTPixelSize(14, "14px: 10.5pt(96dpi)/14pt(72dpi)")); + s_list.add(new TTPixelSize(15, "15px: 11pt(96dpi)/15pt(72dpi)")); + s_list.add(new TTPixelSize(16, "16px: 12pt(96dpi)/16pt(72dpi)")); + s_list.add(new TTPixelSize(17, "17px: 13pt(96dpi)/17pt(72dpi)")); + s_list.add(new TTPixelSize(18, "18px: 13.5pt(96dpi)/18pt(72dpi)")); + s_list.add(new TTPixelSize(19, "19px: 14pt(96dpi)/14pt(72dpi)")); + s_list.add(new TTPixelSize(20, "20px: 15pt(96dpi)/20pt(72dpi)")); + s_list.add(new TTPixelSize(21, "21px: 16pt(96dpi)/21pt(72dpi)")); + s_list.add(new TTPixelSize(22, "22px: 16.5pt(96dpi)/22pt(72dpi)")); + s_list.add(new TTPixelSize(23, "23px: 17pt(96dpi)/23pt(72dpi)")); + s_list.add(new TTPixelSize(24, "24px: 18pt(96dpi)/24pt(72dpi)")); + s_list.add(new TTPixelSize(27, "27px: 20pt(96dpi)")); + s_list.add(new TTPixelSize(29, "29px: 22pt(96dpi)")); + s_list.add(new TTPixelSize(32, "32px: 24pt(96dpi)")); + s_list.add(new TTPixelSize(33, "33px: 8pt(300dpi) ")); + // s_list.add(new TTPixelSize(35, "35px: 26pt(96dpi) ")); + s_list.add(new TTPixelSize(37, "37px: 28pt(96dpi)")); + // s_list.add(new TTPixelSize(38, "38px: 9pt(300dpi)"); + s_list.add(new TTPixelSize(42, "42px: 10pt(300dpi)")); + // s_list.add(new TTPixelSize(44, "44px: 10.5pt(300dpi)")); + s_list.add(new TTPixelSize(46, "46px: 11pt(300dpi)")); + s_list.add(new TTPixelSize(50, "50px: 12pt(300dpi)")); + s_list.add(new TTPixelSize(54, "54px: 13pt(300dpi)")); + s_list.add(new TTPixelSize(58, "58px: 14pt(300dpi)")); + s_list.add(new TTPixelSize(67, "67px: 16pt(300dpi)")); + s_list.add(new TTPixelSize(75, "75px: 18pt(300dpi)")); + s_list.add(new TTPixelSize(83, "83px: 20pt(300dpi)")); + s_list.add(new TTPixelSize(92, "92px: 22pt(300dpi)")); + s_list.add(new TTPixelSize(100, "100px: 24pt(300dpi)")); + } + + private int m_pixel; + private String m_description; + private int m_pixelWidths[]; + private int m_maxPixelWidth = 0; + + public TTPixelSize(int a_pixel, String a_description) + { + m_pixel = a_pixel; + m_description = a_description; + } + + public int getPixel() { + return m_pixel; + } + + public String getDescription() { + return m_description; + } + + /** + * sets the size of the pixel widths. Use num of glyphs. + * @param a_size + */ + public void setPixelWidthsSize(int a_size) { + m_pixelWidths = new int[a_size]; + m_maxPixelWidth = 0; + } + + public void setPixelWidth(int a_glyphIndex, int a_value) { + m_pixelWidths[a_glyphIndex] = a_value; + if (a_value > m_maxPixelWidth) { + m_maxPixelWidth = a_value; + } // if + } + + public int [] getPixelWidths() { + return m_pixelWidths; + } + + public int getPixelWidth(int a_glyphIndex) { + return m_pixelWidths[a_glyphIndex]; + } + + public int getMaxPixelWidth() { + return m_maxPixelWidth; + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/TTUnicodeRange.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/TTUnicodeRange.java new file mode 100644 index 000000000..c55084c16 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/truetype/TTUnicodeRange.java @@ -0,0 +1,380 @@ +/* + * $Id: TTUnicodeRange.java,v 1.1 2004/01/25 11:00:10 eed3si9n Exp $ + * + * $Copyright: copyright (c) 2003-2004, e.e d3si9n $ + * $License: + * This source code is part of DoubleType. + * DoubleType is a graphical typeface designer. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * In addition, as a special exception, e.e d3si9n gives permission to + * link the code of this program with any Java Platform that is available + * to public with free of charge, including but not limited to + * Sun Microsystem's JAVA(TM) 2 RUNTIME ENVIRONMENT (J2RE), + * and distribute linked combinations including the two. + * You must obey the GNU General Public License in all respects for all + * of the code used other than Java Platform. If you modify this file, + * you may extend this exception to your version of the file, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * $ + */ + +package org.doubletype.ossa.truetype; + +import java.util.*; + +import java.lang.Character.UnicodeBlock; + +/** + * @author e.e + */ +public class TTUnicodeRange implements Comparable { + public static final long k_notDef = 0x0001; + public static final long k_null = 0x0000; + public static final long k_cr = 0x000D; + public static final long k_space = 0x0020; + + static private boolean s_isInitialized = false; + static private ArrayList s_list = new ArrayList<>(); + static private TTUnicodeRange s_selected = null; + + static public TTUnicodeRange of(long a_unicode) { + initList(); + + TTUnicodeRange retval = null; + UnicodeBlock block = UnicodeBlock.of((int)a_unicode); + if (block == null) + return retval; + + int i; + for (i = 0; i < s_list.size(); i++) { + TTUnicodeRange range = s_list.get(i); + if (range.m_block.equals(block)) { + return range; + } // if + } // for i + + return retval; + } + + static public TTUnicodeRange getLastFound() { + return s_selected; + } + + static private void initList() { + if (s_isInitialized) + return; + + s_isInitialized = true; + + s_list.add(new TTUnicodeRange( + UnicodeBlock.BASIC_LATIN, 0x0020, 0x007F, 0, 63)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.LATIN_1_SUPPLEMENT, 0x0080, 0x00FF, 1, 0)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.LATIN_EXTENDED_A, 0x0100, 0x017f, 2)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.LATIN_EXTENDED_B, 0x0180, 0x024f, 3)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.IPA_EXTENSIONS, 0x0250, 0x02af, 4)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.SPACING_MODIFIER_LETTERS, 0x02B0, 0x02FF, 5)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.COMBINING_DIACRITICAL_MARKS, 0x0300, 0x036F, 6)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.GREEK, 0x0370, 0x03FF, 7, 3)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.CYRILLIC, 0x0400, 0x04FF, 9, 2)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.ARMENIAN, 0x0530, 0x058F, 10)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.HEBREW, 0x0590, 0x05FF, 11, 5)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.ARABIC, 0x0600, 0x06FF, 13, 6)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.SYRIAC, 0x0700, 0x074F, 71)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.THAANA, 0x0780, 0x07BF, 72)); + + s_list.add(new TTUnicodeRange( + UnicodeBlock.DEVANAGARI, 0x0900, 0x097F, 15)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.BENGALI, 0x0980, 0x09FF, 16)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.GURMUKHI, 0x0A00, 0x0A7F, 17)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.GUJARATI, 0x0A80, 0x0AFF, 18)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.ORIYA, 0x0B00, 0x0B7F, 19)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.TAMIL, 0x0B80, 0x0BFF, 20)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.TELUGU, 0x0C00, 0x0C7F, 21)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.KANNADA, 0x0C80, 0x0CFF, 22)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.MALAYALAM, 0x0D00, 0x0D7F, 23)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.SINHALA, 0x0D80, 0x0DFF, 73)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.THAI, 0x0E00, 0x0E7F, 24, 16)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.LAO, 0x0E80, 0x0EFF, 25)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.TIBETAN, 0x0F00, 0x0FFF, 70)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.MYANMAR, 0x1000, 0x109F, 74)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.GEORGIAN, 0x10A0, 0x10FF, 26)); + // TODO: wansung or johab? + s_list.add(new TTUnicodeRange( + UnicodeBlock.HANGUL_JAMO, 0x1100, 0x11FF, 28, 19)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.ETHIOPIC, 0x1200, 0x137F, 75)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.CHEROKEE, 0x13A0, 0x13FF, 76)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS, 0x1400, 0x167F, 77)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.OGHAM, 0x1680, 0x169F, 78)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.RUNIC, 0x16A0, 0x16FF, 79)); + + // TODO: tagalog, hanunoo, buhid, tagbanwa + + s_list.add(new TTUnicodeRange( + UnicodeBlock.KHMER, 0x1780, 0x17FF, 80)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.MONGOLIAN, 0x1800, 0x18AF, 81)); + + // linbu, tai le, khmer symbol, phonetic extensions, + + s_list.add(new TTUnicodeRange( + UnicodeBlock.LATIN_EXTENDED_ADDITIONAL, 0x1E00, 0x1EFF, 29)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.GREEK_EXTENDED, 0x1F00, 0x1FFF, 30)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.GENERAL_PUNCTUATION, 0x2000, 0x206F, 31)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.SUPERSCRIPTS_AND_SUBSCRIPTS, 0x2070, 0x209F, 32)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.CURRENCY_SYMBOLS, 0x20A0, 0x20CF, 33)); + + // combining diacritical marks + s_list.add(new TTUnicodeRange( + UnicodeBlock.COMBINING_MARKS_FOR_SYMBOLS, 0x20D0, 0x20FF, 34)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.LETTERLIKE_SYMBOLS, 0x2100, 0x214F, 35)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.NUMBER_FORMS, 0x2150, 0x218F, 36)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.ARROWS, 0x2190, 0x21FF, 37)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.MATHEMATICAL_OPERATORS, 0x2200, 0x22FF, 38)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.MISCELLANEOUS_TECHNICAL, 0x2300, 0x23FF, 39)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.CONTROL_PICTURES, 0x2400, 0x243F, 40)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.OPTICAL_CHARACTER_RECOGNITION, 0x2440, 0x245F, 41)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.ENCLOSED_ALPHANUMERICS, 0x2460, 0x24FF, 42)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.BOX_DRAWING, 0x2500, 0x257F, 43)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.BLOCK_ELEMENTS, 0x2580, 0x259F, 44)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.GEOMETRIC_SHAPES, 0x25A0, 0x25FF, 45)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.MISCELLANEOUS_SYMBOLS, 0x2600, 0x26FF, 46)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.DINGBATS, 0x2700, 0x27BF, 47)); + + // TODO: mics. math symbols A, supplemental arrows A + + s_list.add(new TTUnicodeRange( + UnicodeBlock.BRAILLE_PATTERNS, 0x2800, 0x28FF, 82)); + + // TODO: supplemental arrows B, mics. math symbols B, + // supplemental math op., mics. symbols and arrows + + +// CJKV supplements + s_list.add(new TTUnicodeRange( + UnicodeBlock.CJK_RADICALS_SUPPLEMENT, 0x2E80, 0x2EFF, 59)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.KANGXI_RADICALS, 0x2F00, 0x2FDF, 59)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.IDEOGRAPHIC_DESCRIPTION_CHARACTERS, 0x2FF0, 0x2FFF, 59)); + + + s_list.add(new TTUnicodeRange( + UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION, 0x3000, 0x303f, 48)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.HIRAGANA, 0x3040, 0x309f, 49, 17)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.KATAKANA, 0x30a0, 0x30ff, 50, 17)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.BOPOMOFO, 0x3100, 0x312f, 51)); + // TODO: wansung or johab? + s_list.add(new TTUnicodeRange( + UnicodeBlock.HANGUL_COMPATIBILITY_JAMO, 0x3130, 0x0318F, 52, 19)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.KANBUN, 0x3190, 0x319F, 59)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.BOPOMOFO_EXTENDED, 0x31A0, 0x31BF, 51)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.KATAKANA_PHONETIC_EXTENSIONS, 0x31F0, 0x31FF, 50, 17)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.ENCLOSED_CJK_LETTERS_AND_MONTHS, 0x3200, 0x32FF, 54)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.CJK_COMPATIBILITY, 0x3300, 0x33ff, 55)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A, 0x03400, 0x4dbf, 59)); + // TODO: yijing hex symbols + + // the kanji characters + s_list.add(new TTUnicodeRange( + UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS, 0x4e00, 0x9fff, 59, 17)); + + s_list.add(new TTUnicodeRange( + UnicodeBlock.YI_SYLLABLES, 0xA000, 0xA48F, 83)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.YI_RADICALS, 0xA490, 0xA4CF, 83)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.HANGUL_SYLLABLES, 0xAC00, 0xD7AF, 56)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.HIGH_SURROGATES, 0xD800, 0xDB7F, 0)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.HIGH_PRIVATE_USE_SURROGATES, 0xDB80, 0xDBFF, 0)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.LOW_SURROGATES, 0xDC00, 0xDFFF, 0)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.PRIVATE_USE_AREA, 0xE000, 0xF8FF, 60)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS, 0xf900, 0xfaff, 61)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.ALPHABETIC_PRESENTATION_FORMS, 0xFB00, 0xFB4F, 62)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.ARABIC_PRESENTATION_FORMS_A, 0xFB50, 0xFDFF, 62)); + + // TODO: variation selectors + + s_list.add(new TTUnicodeRange( + UnicodeBlock.COMBINING_HALF_MARKS, 0xFE20, 0xFE2F, 64)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.CJK_COMPATIBILITY_FORMS, 0xFE30, 0xFE4F, 65)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.SMALL_FORM_VARIANTS, 0xFE50, 0xFE6F, 66)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.ARABIC_PRESENTATION_FORMS_B, 0xFE70, 0xFEFF, 67)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS, 0xFF00, 0xFFEF, 68, 17)); + s_list.add(new TTUnicodeRange( + UnicodeBlock.SPECIALS, 0xFFF0, 0xFFFF, 69)); + } + + static public boolean find(String a_unicodeRange) { + initList(); + + s_selected = null; + + int i; + for (i = 0; i < s_list.size(); i++) { + TTUnicodeRange range = (TTUnicodeRange) s_list.get(i); + if (range.m_block.toString().equals(a_unicodeRange)) { + s_selected = range; + + return true; + } // if + } // for i + + return false; + } + + + private UnicodeBlock m_block = null; + private long m_start = 0; + private long m_end = 0; + + /** http://www.microsoft.com/typography/otspec/os2.htm + */ + private int m_osTwoFlag = 0; + + /** http://www.microsoft.com/typography/otspec/os2.htm + */ + private int m_codePageFlag = 0; + + public TTUnicodeRange(UnicodeBlock a_block, + long a_start, + long a_end, + int a_osTwoFlag) + { + m_block = a_block; + m_start = a_start; + m_end = a_end; + m_osTwoFlag = a_osTwoFlag; + } + + public TTUnicodeRange(UnicodeBlock a_block, + long a_start, + long a_end, + int a_osTwoFlag, + int a_codePageFlag) + { + m_block = a_block; + m_start = a_start; + m_end = a_end; + m_osTwoFlag = a_osTwoFlag; + m_codePageFlag = a_codePageFlag; + } + + public boolean equals(Object a_object) { + TTUnicodeRange object = (TTUnicodeRange) a_object; + return (m_start == object.m_start); + } + + public int compareTo(Object a_object) { + TTUnicodeRange object = (TTUnicodeRange) a_object; + if (this.m_start < object.m_start) { + return -1; + } else if (this.m_start == object.m_start) { + return 0; + } else + return 1; + } + + public String toString() { + return m_block.toString(); + } + + public long getStartCode() { + return m_start; + } + + public long getEndCode() { + return m_end; + } + + public int getOsTwoFlag() { + return m_osTwoFlag; + } + + public int getCodeRangeFlag() { + return m_codePageFlag; + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/xml/AbstractGlyphFactory.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/xml/AbstractGlyphFactory.java new file mode 100644 index 000000000..d2d75cb43 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/xml/AbstractGlyphFactory.java @@ -0,0 +1,3291 @@ +/* + * The Relaxer artifact + * Copyright (c) 2000-2004, ASAMI Tomoharu, All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package org.doubletype.ossa.xml; + +import java.io.*; +import java.net.URL; +import javax.xml.parsers.*; +import org.w3c.dom.*; +import org.xml.sax.*; + +/** + * AbstractGlyphFactory is generated by Relaxer based on glyph.rng. + * + * @version glyph.rng 1.0 (Tue Nov 09 20:22:48 EST 2004) + * @author Relaxer 1.1b (http://www.relaxer.org) + */ +public abstract class AbstractGlyphFactory implements IGlyphFactory { + protected org.xml.sax.ErrorHandler errorHandler; + protected org.xml.sax.EntityResolver entityResolver; + protected String baseUri; + + /** + * Gets a Class of XParamListParam. + * + * @return Class + */ + public Class getXParamListParamClass() { + return (createXParamListParam().getClass()); + } + + /** + * Gets a Class of XHeadGlobal. + * + * @return Class + */ + public Class getXHeadGlobalClass() { + return (createXHeadGlobal().getClass()); + } + + /** + * Gets a Class of XHeadLocal. + * + * @return Class + */ + public Class getXHeadLocalClass() { + return (createXHeadLocal().getClass()); + } + + /** + * Gets a Class of XHead. + * + * @return Class + */ + public Class getXHeadClass() { + return (createXHead().getClass()); + } + + /** + * Gets a Class of XGlyphFile. + * + * @return Class + */ + public Class getXGlyphFileClass() { + return (createXGlyphFile().getClass()); + } + + /** + * Gets a Class of XContour. + * + * @return Class + */ + public Class getXContourClass() { + return (createXContour().getClass()); + } + + /** + * Gets a Class of XPoint2d. + * + * @return Class + */ + public Class getXPoint2dClass() { + return (createXPoint2d().getClass()); + } + + /** + * Gets a Class of XInvokePos. + * + * @return Class + */ + public Class getXInvokePosClass() { + return (createXInvokePos().getClass()); + } + + /** + * Gets a Class of XInvokeArg. + * + * @return Class + */ + public Class getXInvokeArgClass() { + return (createXInvokeArg().getClass()); + } + + /** + * Gets a Class of XInvokeVarg. + * + * @return Class + */ + public Class getXInvokeVargClass() { + return (createXInvokeVarg().getClass()); + } + + /** + * Gets a Class of XInvoke. + * + * @return Class + */ + public Class getXInvokeClass() { + return (createXInvoke().getClass()); + } + + /** + * Gets a Class of XInclude. + * + * @return Class + */ + public Class getXIncludeClass() { + return (createXInclude().getClass()); + } + + /** + * Gets a Class of XModule. + * + * @return Class + */ + public Class getXModuleClass() { + return (createXModule().getClass()); + } + + /** + * Gets a Class of XBody. + * + * @return Class + */ + public Class getXBodyClass() { + return (createXBody().getClass()); + } + + /** + * Gets a Class of XStartGlyphElement. + * + * @return Class + */ + public Class getXStartGlyphElementClass() { + return (createXStartGlyphElement().getClass()); + } + + /** + * Gets a Class of XControlPoint. + * + * @return Class + */ + public Class getXControlPointClass() { + return (createXControlPoint().getClass()); + } + + /** + * Gets a Class of XHint. + * + * @return Class + */ + public Class getXHintClass() { + return (createXHint().getClass()); + } + + /** + * Gets a Class of XContourPoint. + * + * @return Class + */ + public Class getXContourPointClass() { + return (createXContourPoint().getClass()); + } + + /** + * Gets a Class of XParamList. + * + * @return Class + */ + public Class getXParamListClass() { + return (createXParamList().getClass()); + } + + /** + * Sets a errorHandler. + * + * @param errorHandler + */ + public void setErrorHandler(org.xml.sax.ErrorHandler errorHandler) { + this.errorHandler = errorHandler; + } + + /** + * Gets a errorHandler. + * + * @return org.xml.sax.ErrorHandler + */ + public org.xml.sax.ErrorHandler getErrorHandler() { + return (errorHandler); + } + + /** + * Sets a entityResolver. + * + * @param entityResolver + */ + public void setEntityResolver(org.xml.sax.EntityResolver entityResolver) { + this.entityResolver = entityResolver; + } + + /** + * Gets a entityResolver. + * + * @return org.xml.sax.EntityResolver + */ + public org.xml.sax.EntityResolver getEntityResolver() { + return (entityResolver); + } + + /** + * Sets a baseUri. + * + * @param baseUri + */ + public void setBaseUri(String baseUri) { + this.baseUri = baseUri; + } + + /** + * Gets a baseUri. + * + * @return String + */ + public String getBaseUri() { + return (baseUri); + } + + /** + * Creates a Object by the File file. + * This method is a template method for concrete classes. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return Object + */ + public Object create(File file) throws IOException, SAXException, ParserConfigurationException { + Object node = create(UJAXP.getDocument(file, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (node); + } + + /** + * Creates a Object by the String representation of URI uri. + * This method is a template method for concrete classes. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return Object + */ + public Object create(String uri) throws IOException, SAXException, ParserConfigurationException { + Object node = create(UJAXP.getDocument(uri, baseUri, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (node); + } + + /** + * Creates a Object by the URL url. + * This method is a template method for concrete classes. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return Object + */ + public Object create(URL url) throws IOException, SAXException, ParserConfigurationException { + Object node = create(UJAXP.getDocument(url, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (node); + } + + /** + * Creates a Object by the InputStream in. + * This method is a template method for concrete classes. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return Object + */ + public Object create(InputStream in) throws IOException, SAXException, ParserConfigurationException { + Object node = create(UJAXP.getDocument(in, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (node); + } + + /** + * Creates a Object by the InputSource is. + * This method is a template method for concrete classes. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return Object + */ + public Object create(InputSource is) throws IOException, SAXException, ParserConfigurationException { + Object node = create(UJAXP.getDocument(is, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (node); + } + + /** + * Creates a Object by the Reader reader. + * This method is a template method for concrete classes. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return Object + */ + public Object create(Reader reader) throws IOException, SAXException, ParserConfigurationException { + Object node = create(UJAXP.getDocument(reader, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (node); + } + + /** + * Creates a Object by the copy Object. + * This method is a template method for concrete classes. + * + * @param source + * @return Object + */ + public Object create(Object source) { + if (source instanceof XParamListParam) { + XParamListParam node = createXParamListParam(); + node.setup((XParamListParam)source); + return(node); + } else if (source instanceof XHeadGlobal) { + XHeadGlobal node = createXHeadGlobal(); + node.setup((XHeadGlobal)source); + return(node); + } else if (source instanceof XHeadLocal) { + XHeadLocal node = createXHeadLocal(); + node.setup((XHeadLocal)source); + return(node); + } else if (source instanceof XHead) { + XHead node = createXHead(); + node.setup((XHead)source); + return(node); + } else if (source instanceof XGlyphFile) { + XGlyphFile node = createXGlyphFile(); + node.setup((XGlyphFile)source); + return(node); + } else if (source instanceof XContour) { + XContour node = createXContour(); + node.setup((XContour)source); + return(node); + } else if (source instanceof XPoint2d) { + XPoint2d node = createXPoint2d(); + node.setup((XPoint2d)source); + return(node); + } else if (source instanceof XInvokePos) { + XInvokePos node = createXInvokePos(); + node.setup((XInvokePos)source); + return(node); + } else if (source instanceof XInvokeArg) { + XInvokeArg node = createXInvokeArg(); + node.setup((XInvokeArg)source); + return(node); + } else if (source instanceof XInvokeVarg) { + XInvokeVarg node = createXInvokeVarg(); + node.setup((XInvokeVarg)source); + return(node); + } else if (source instanceof XInvoke) { + XInvoke node = createXInvoke(); + node.setup((XInvoke)source); + return(node); + } else if (source instanceof XInclude) { + XInclude node = createXInclude(); + node.setup((XInclude)source); + return(node); + } else if (source instanceof XModule) { + XModule node = createXModule(); + node.setup((XModule)source); + return(node); + } else if (source instanceof XBody) { + XBody node = createXBody(); + node.setup((XBody)source); + return(node); + } else if (source instanceof XStartGlyphElement) { + XStartGlyphElement node = createXStartGlyphElement(); + node.setup((XStartGlyphElement)source); + return(node); + } else if (source instanceof XControlPoint) { + XControlPoint node = createXControlPoint(); + node.setup((XControlPoint)source); + return(node); + } else if (source instanceof XHint) { + XHint node = createXHint(); + node.setup((XHint)source); + return(node); + } else if (source instanceof XContourPoint) { + XContourPoint node = createXContourPoint(); + node.setup((XContourPoint)source); + return(node); + } else { + return (null); + } + } + + /** + * Creates a Object by the Document doc. + * This method is a template method for concrete classes. + * + * @param doc + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return Object + */ + public Object create(Document doc) throws IOException, SAXException, ParserConfigurationException { + Object node = create(doc.getDocumentElement()); + return (node); + } + + /** + * Creates a Object by the Element element. + * This method is a template method for concrete classes. + * + * @param element + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return Object + */ + public Object create(Element element) throws IOException, SAXException, ParserConfigurationException { + if (XParamListParam.isMatch(element)) { + XParamListParam node = createXParamListParam(); + node.setup(element); + return(node); + } else if (XHeadGlobal.isMatch(element)) { + XHeadGlobal node = createXHeadGlobal(); + node.setup(element); + return(node); + } else if (XHeadLocal.isMatch(element)) { + XHeadLocal node = createXHeadLocal(); + node.setup(element); + return(node); + } else if (XHead.isMatch(element)) { + XHead node = createXHead(); + node.setup(element); + return(node); + } else if (XGlyphFile.isMatch(element)) { + XGlyphFile node = createXGlyphFile(); + node.setup(element); + return(node); + } else if (XContour.isMatch(element)) { + XContour node = createXContour(); + node.setup(element); + return(node); + } else if (XPoint2d.isMatch(element)) { + XPoint2d node = createXPoint2d(); + node.setup(element); + return(node); + } else if (XInvokePos.isMatch(element)) { + XInvokePos node = createXInvokePos(); + node.setup(element); + return(node); + } else if (XInvokeArg.isMatch(element)) { + XInvokeArg node = createXInvokeArg(); + node.setup(element); + return(node); + } else if (XInvokeVarg.isMatch(element)) { + XInvokeVarg node = createXInvokeVarg(); + node.setup(element); + return(node); + } else if (XInvoke.isMatch(element)) { + XInvoke node = createXInvoke(); + node.setup(element); + return(node); + } else if (XInclude.isMatch(element)) { + XInclude node = createXInclude(); + node.setup(element); + return(node); + } else if (XModule.isMatch(element)) { + XModule node = createXModule(); + node.setup(element); + return(node); + } else if (XBody.isMatch(element)) { + XBody node = createXBody(); + node.setup(element); + return(node); + } else if (XStartGlyphElement.isMatch(element)) { + XStartGlyphElement node = createXStartGlyphElement(); + node.setup(element); + return(node); + } else if (XControlPoint.isMatch(element)) { + XControlPoint node = createXControlPoint(); + node.setup(element); + return(node); + } else if (XHint.isMatch(element)) { + XHint node = createXHint(); + node.setup(element); + return(node); + } else if (XContourPoint.isMatch(element)) { + XContourPoint node = createXContourPoint(); + node.setup(element); + return(node); + } else { + return (null); + } + } + + /** + * Creates a XParamListParam by the File file. + * This method is a template method for concrete classes. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XParamListParam + */ + public XParamListParam createXParamListParam(File file) throws IOException, SAXException, ParserConfigurationException { + XParamListParam xParamListParam_ = createXParamListParam(); + xParamListParam_.setup(UJAXP.getDocument(file, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xParamListParam_); + } + + /** + * Creates a XHeadGlobal by the File file. + * This method is a template method for concrete classes. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHeadGlobal + */ + public XHeadGlobal createXHeadGlobal(File file) throws IOException, SAXException, ParserConfigurationException { + XHeadGlobal xHeadGlobal_ = createXHeadGlobal(); + xHeadGlobal_.setup(UJAXP.getDocument(file, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xHeadGlobal_); + } + + /** + * Creates a XHeadLocal by the File file. + * This method is a template method for concrete classes. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHeadLocal + */ + public XHeadLocal createXHeadLocal(File file) throws IOException, SAXException, ParserConfigurationException { + XHeadLocal xHeadLocal_ = createXHeadLocal(); + xHeadLocal_.setup(UJAXP.getDocument(file, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xHeadLocal_); + } + + /** + * Creates a XHead by the File file. + * This method is a template method for concrete classes. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHead + */ + public XHead createXHead(File file) throws IOException, SAXException, ParserConfigurationException { + XHead xHead_ = createXHead(); + xHead_.setup(UJAXP.getDocument(file, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xHead_); + } + + /** + * Creates a XGlyphFile by the File file. + * This method is a template method for concrete classes. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XGlyphFile + */ + public XGlyphFile createXGlyphFile(File file) throws IOException, SAXException, ParserConfigurationException { + XGlyphFile xGlyphFile_ = createXGlyphFile(); + xGlyphFile_.setup(UJAXP.getDocument(file, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xGlyphFile_); + } + + /** + * Creates a XContour by the File file. + * This method is a template method for concrete classes. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XContour + */ + public XContour createXContour(File file) throws IOException, SAXException, ParserConfigurationException { + XContour xContour_ = createXContour(); + xContour_.setup(UJAXP.getDocument(file, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xContour_); + } + + /** + * Creates a XPoint2d by the File file. + * This method is a template method for concrete classes. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XPoint2d + */ + public XPoint2d createXPoint2d(File file) throws IOException, SAXException, ParserConfigurationException { + XPoint2d xPoint2d_ = createXPoint2d(); + xPoint2d_.setup(UJAXP.getDocument(file, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xPoint2d_); + } + + /** + * Creates a XInvokePos by the File file. + * This method is a template method for concrete classes. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokePos + */ + public XInvokePos createXInvokePos(File file) throws IOException, SAXException, ParserConfigurationException { + XInvokePos xInvokePos_ = createXInvokePos(); + xInvokePos_.setup(UJAXP.getDocument(file, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xInvokePos_); + } + + /** + * Creates a XInvokeArg by the File file. + * This method is a template method for concrete classes. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokeArg + */ + public XInvokeArg createXInvokeArg(File file) throws IOException, SAXException, ParserConfigurationException { + XInvokeArg xInvokeArg_ = createXInvokeArg(); + xInvokeArg_.setup(UJAXP.getDocument(file, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xInvokeArg_); + } + + /** + * Creates a XInvokeVarg by the File file. + * This method is a template method for concrete classes. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokeVarg + */ + public XInvokeVarg createXInvokeVarg(File file) throws IOException, SAXException, ParserConfigurationException { + XInvokeVarg xInvokeVarg_ = createXInvokeVarg(); + xInvokeVarg_.setup(UJAXP.getDocument(file, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xInvokeVarg_); + } + + /** + * Creates a XInvoke by the File file. + * This method is a template method for concrete classes. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvoke + */ + public XInvoke createXInvoke(File file) throws IOException, SAXException, ParserConfigurationException { + XInvoke xInvoke_ = createXInvoke(); + xInvoke_.setup(UJAXP.getDocument(file, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xInvoke_); + } + + /** + * Creates a XInclude by the File file. + * This method is a template method for concrete classes. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInclude + */ + public XInclude createXInclude(File file) throws IOException, SAXException, ParserConfigurationException { + XInclude xInclude_ = createXInclude(); + xInclude_.setup(UJAXP.getDocument(file, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xInclude_); + } + + /** + * Creates a XModule by the File file. + * This method is a template method for concrete classes. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XModule + */ + public XModule createXModule(File file) throws IOException, SAXException, ParserConfigurationException { + XModule xModule_ = createXModule(); + xModule_.setup(UJAXP.getDocument(file, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xModule_); + } + + /** + * Creates a XBody by the File file. + * This method is a template method for concrete classes. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XBody + */ + public XBody createXBody(File file) throws IOException, SAXException, ParserConfigurationException { + XBody xBody_ = createXBody(); + xBody_.setup(UJAXP.getDocument(file, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xBody_); + } + + /** + * Creates a XStartGlyphElement by the File file. + * This method is a template method for concrete classes. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XStartGlyphElement + */ + public XStartGlyphElement createXStartGlyphElement(File file) throws IOException, SAXException, ParserConfigurationException { + XStartGlyphElement xStartGlyphElement_ = createXStartGlyphElement(); + xStartGlyphElement_.setup(UJAXP.getDocument(file, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xStartGlyphElement_); + } + + /** + * Creates a XControlPoint by the File file. + * This method is a template method for concrete classes. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XControlPoint + */ + public XControlPoint createXControlPoint(File file) throws IOException, SAXException, ParserConfigurationException { + XControlPoint xControlPoint_ = createXControlPoint(); + xControlPoint_.setup(UJAXP.getDocument(file, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xControlPoint_); + } + + /** + * Creates a XHint by the File file. + * This method is a template method for concrete classes. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHint + */ + public XHint createXHint(File file) throws IOException, SAXException, ParserConfigurationException { + XHint xHint_ = createXHint(); + xHint_.setup(UJAXP.getDocument(file, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xHint_); + } + + /** + * Creates a XContourPoint by the File file. + * This method is a template method for concrete classes. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XContourPoint + */ + public XContourPoint createXContourPoint(File file) throws IOException, SAXException, ParserConfigurationException { + XContourPoint xContourPoint_ = createXContourPoint(); + xContourPoint_.setup(UJAXP.getDocument(file, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xContourPoint_); + } + + /** + * Creates a XParamListParam + * by the String representation of URI uri. + * This method is a template method for concrete classes. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XParamListParam + */ + public XParamListParam createXParamListParam(String uri) throws IOException, SAXException, ParserConfigurationException { + XParamListParam xParamListParam_ = createXParamListParam(); + xParamListParam_.setup(UJAXP.getDocument(uri, baseUri, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xParamListParam_); + } + + /** + * Creates a XHeadGlobal + * by the String representation of URI uri. + * This method is a template method for concrete classes. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHeadGlobal + */ + public XHeadGlobal createXHeadGlobal(String uri) throws IOException, SAXException, ParserConfigurationException { + XHeadGlobal xHeadGlobal_ = createXHeadGlobal(); + xHeadGlobal_.setup(UJAXP.getDocument(uri, baseUri, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xHeadGlobal_); + } + + /** + * Creates a XHeadLocal + * by the String representation of URI uri. + * This method is a template method for concrete classes. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHeadLocal + */ + public XHeadLocal createXHeadLocal(String uri) throws IOException, SAXException, ParserConfigurationException { + XHeadLocal xHeadLocal_ = createXHeadLocal(); + xHeadLocal_.setup(UJAXP.getDocument(uri, baseUri, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xHeadLocal_); + } + + /** + * Creates a XHead + * by the String representation of URI uri. + * This method is a template method for concrete classes. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHead + */ + public XHead createXHead(String uri) throws IOException, SAXException, ParserConfigurationException { + XHead xHead_ = createXHead(); + xHead_.setup(UJAXP.getDocument(uri, baseUri, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xHead_); + } + + /** + * Creates a XGlyphFile + * by the String representation of URI uri. + * This method is a template method for concrete classes. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XGlyphFile + */ + public XGlyphFile createXGlyphFile(String uri) throws IOException, SAXException, ParserConfigurationException { + XGlyphFile xGlyphFile_ = createXGlyphFile(); + xGlyphFile_.setup(UJAXP.getDocument(uri, baseUri, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xGlyphFile_); + } + + /** + * Creates a XContour + * by the String representation of URI uri. + * This method is a template method for concrete classes. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XContour + */ + public XContour createXContour(String uri) throws IOException, SAXException, ParserConfigurationException { + XContour xContour_ = createXContour(); + xContour_.setup(UJAXP.getDocument(uri, baseUri, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xContour_); + } + + /** + * Creates a XPoint2d + * by the String representation of URI uri. + * This method is a template method for concrete classes. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XPoint2d + */ + public XPoint2d createXPoint2d(String uri) throws IOException, SAXException, ParserConfigurationException { + XPoint2d xPoint2d_ = createXPoint2d(); + xPoint2d_.setup(UJAXP.getDocument(uri, baseUri, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xPoint2d_); + } + + /** + * Creates a XInvokePos + * by the String representation of URI uri. + * This method is a template method for concrete classes. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokePos + */ + public XInvokePos createXInvokePos(String uri) throws IOException, SAXException, ParserConfigurationException { + XInvokePos xInvokePos_ = createXInvokePos(); + xInvokePos_.setup(UJAXP.getDocument(uri, baseUri, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xInvokePos_); + } + + /** + * Creates a XInvokeArg + * by the String representation of URI uri. + * This method is a template method for concrete classes. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokeArg + */ + public XInvokeArg createXInvokeArg(String uri) throws IOException, SAXException, ParserConfigurationException { + XInvokeArg xInvokeArg_ = createXInvokeArg(); + xInvokeArg_.setup(UJAXP.getDocument(uri, baseUri, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xInvokeArg_); + } + + /** + * Creates a XInvokeVarg + * by the String representation of URI uri. + * This method is a template method for concrete classes. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokeVarg + */ + public XInvokeVarg createXInvokeVarg(String uri) throws IOException, SAXException, ParserConfigurationException { + XInvokeVarg xInvokeVarg_ = createXInvokeVarg(); + xInvokeVarg_.setup(UJAXP.getDocument(uri, baseUri, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xInvokeVarg_); + } + + /** + * Creates a XInvoke + * by the String representation of URI uri. + * This method is a template method for concrete classes. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvoke + */ + public XInvoke createXInvoke(String uri) throws IOException, SAXException, ParserConfigurationException { + XInvoke xInvoke_ = createXInvoke(); + xInvoke_.setup(UJAXP.getDocument(uri, baseUri, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xInvoke_); + } + + /** + * Creates a XInclude + * by the String representation of URI uri. + * This method is a template method for concrete classes. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInclude + */ + public XInclude createXInclude(String uri) throws IOException, SAXException, ParserConfigurationException { + XInclude xInclude_ = createXInclude(); + xInclude_.setup(UJAXP.getDocument(uri, baseUri, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xInclude_); + } + + /** + * Creates a XModule + * by the String representation of URI uri. + * This method is a template method for concrete classes. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XModule + */ + public XModule createXModule(String uri) throws IOException, SAXException, ParserConfigurationException { + XModule xModule_ = createXModule(); + xModule_.setup(UJAXP.getDocument(uri, baseUri, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xModule_); + } + + /** + * Creates a XBody + * by the String representation of URI uri. + * This method is a template method for concrete classes. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XBody + */ + public XBody createXBody(String uri) throws IOException, SAXException, ParserConfigurationException { + XBody xBody_ = createXBody(); + xBody_.setup(UJAXP.getDocument(uri, baseUri, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xBody_); + } + + /** + * Creates a XStartGlyphElement + * by the String representation of URI uri. + * This method is a template method for concrete classes. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XStartGlyphElement + */ + public XStartGlyphElement createXStartGlyphElement(String uri) throws IOException, SAXException, ParserConfigurationException { + XStartGlyphElement xStartGlyphElement_ = createXStartGlyphElement(); + xStartGlyphElement_.setup(UJAXP.getDocument(uri, baseUri, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xStartGlyphElement_); + } + + /** + * Creates a XControlPoint + * by the String representation of URI uri. + * This method is a template method for concrete classes. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XControlPoint + */ + public XControlPoint createXControlPoint(String uri) throws IOException, SAXException, ParserConfigurationException { + XControlPoint xControlPoint_ = createXControlPoint(); + xControlPoint_.setup(UJAXP.getDocument(uri, baseUri, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xControlPoint_); + } + + /** + * Creates a XHint + * by the String representation of URI uri. + * This method is a template method for concrete classes. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHint + */ + public XHint createXHint(String uri) throws IOException, SAXException, ParserConfigurationException { + XHint xHint_ = createXHint(); + xHint_.setup(UJAXP.getDocument(uri, baseUri, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xHint_); + } + + /** + * Creates a XContourPoint + * by the String representation of URI uri. + * This method is a template method for concrete classes. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XContourPoint + */ + public XContourPoint createXContourPoint(String uri) throws IOException, SAXException, ParserConfigurationException { + XContourPoint xContourPoint_ = createXContourPoint(); + xContourPoint_.setup(UJAXP.getDocument(uri, baseUri, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xContourPoint_); + } + + /** + * Creates a XParamListParam by the URL url. + * This method is a template method for concrete classes. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XParamListParam + */ + public XParamListParam createXParamListParam(URL url) throws IOException, SAXException, ParserConfigurationException { + XParamListParam xParamListParam_ = createXParamListParam(); + xParamListParam_.setup(UJAXP.getDocument(url, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xParamListParam_); + } + + /** + * Creates a XHeadGlobal by the URL url. + * This method is a template method for concrete classes. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHeadGlobal + */ + public XHeadGlobal createXHeadGlobal(URL url) throws IOException, SAXException, ParserConfigurationException { + XHeadGlobal xHeadGlobal_ = createXHeadGlobal(); + xHeadGlobal_.setup(UJAXP.getDocument(url, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xHeadGlobal_); + } + + /** + * Creates a XHeadLocal by the URL url. + * This method is a template method for concrete classes. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHeadLocal + */ + public XHeadLocal createXHeadLocal(URL url) throws IOException, SAXException, ParserConfigurationException { + XHeadLocal xHeadLocal_ = createXHeadLocal(); + xHeadLocal_.setup(UJAXP.getDocument(url, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xHeadLocal_); + } + + /** + * Creates a XHead by the URL url. + * This method is a template method for concrete classes. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHead + */ + public XHead createXHead(URL url) throws IOException, SAXException, ParserConfigurationException { + XHead xHead_ = createXHead(); + xHead_.setup(UJAXP.getDocument(url, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xHead_); + } + + /** + * Creates a XGlyphFile by the URL url. + * This method is a template method for concrete classes. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XGlyphFile + */ + public XGlyphFile createXGlyphFile(URL url) throws IOException, SAXException, ParserConfigurationException { + XGlyphFile xGlyphFile_ = createXGlyphFile(); + xGlyphFile_.setup(UJAXP.getDocument(url, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xGlyphFile_); + } + + /** + * Creates a XContour by the URL url. + * This method is a template method for concrete classes. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XContour + */ + public XContour createXContour(URL url) throws IOException, SAXException, ParserConfigurationException { + XContour xContour_ = createXContour(); + xContour_.setup(UJAXP.getDocument(url, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xContour_); + } + + /** + * Creates a XPoint2d by the URL url. + * This method is a template method for concrete classes. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XPoint2d + */ + public XPoint2d createXPoint2d(URL url) throws IOException, SAXException, ParserConfigurationException { + XPoint2d xPoint2d_ = createXPoint2d(); + xPoint2d_.setup(UJAXP.getDocument(url, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xPoint2d_); + } + + /** + * Creates a XInvokePos by the URL url. + * This method is a template method for concrete classes. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokePos + */ + public XInvokePos createXInvokePos(URL url) throws IOException, SAXException, ParserConfigurationException { + XInvokePos xInvokePos_ = createXInvokePos(); + xInvokePos_.setup(UJAXP.getDocument(url, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xInvokePos_); + } + + /** + * Creates a XInvokeArg by the URL url. + * This method is a template method for concrete classes. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokeArg + */ + public XInvokeArg createXInvokeArg(URL url) throws IOException, SAXException, ParserConfigurationException { + XInvokeArg xInvokeArg_ = createXInvokeArg(); + xInvokeArg_.setup(UJAXP.getDocument(url, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xInvokeArg_); + } + + /** + * Creates a XInvokeVarg by the URL url. + * This method is a template method for concrete classes. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokeVarg + */ + public XInvokeVarg createXInvokeVarg(URL url) throws IOException, SAXException, ParserConfigurationException { + XInvokeVarg xInvokeVarg_ = createXInvokeVarg(); + xInvokeVarg_.setup(UJAXP.getDocument(url, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xInvokeVarg_); + } + + /** + * Creates a XInvoke by the URL url. + * This method is a template method for concrete classes. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvoke + */ + public XInvoke createXInvoke(URL url) throws IOException, SAXException, ParserConfigurationException { + XInvoke xInvoke_ = createXInvoke(); + xInvoke_.setup(UJAXP.getDocument(url, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xInvoke_); + } + + /** + * Creates a XInclude by the URL url. + * This method is a template method for concrete classes. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInclude + */ + public XInclude createXInclude(URL url) throws IOException, SAXException, ParserConfigurationException { + XInclude xInclude_ = createXInclude(); + xInclude_.setup(UJAXP.getDocument(url, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xInclude_); + } + + /** + * Creates a XModule by the URL url. + * This method is a template method for concrete classes. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XModule + */ + public XModule createXModule(URL url) throws IOException, SAXException, ParserConfigurationException { + XModule xModule_ = createXModule(); + xModule_.setup(UJAXP.getDocument(url, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xModule_); + } + + /** + * Creates a XBody by the URL url. + * This method is a template method for concrete classes. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XBody + */ + public XBody createXBody(URL url) throws IOException, SAXException, ParserConfigurationException { + XBody xBody_ = createXBody(); + xBody_.setup(UJAXP.getDocument(url, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xBody_); + } + + /** + * Creates a XStartGlyphElement by the URL url. + * This method is a template method for concrete classes. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XStartGlyphElement + */ + public XStartGlyphElement createXStartGlyphElement(URL url) throws IOException, SAXException, ParserConfigurationException { + XStartGlyphElement xStartGlyphElement_ = createXStartGlyphElement(); + xStartGlyphElement_.setup(UJAXP.getDocument(url, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xStartGlyphElement_); + } + + /** + * Creates a XControlPoint by the URL url. + * This method is a template method for concrete classes. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XControlPoint + */ + public XControlPoint createXControlPoint(URL url) throws IOException, SAXException, ParserConfigurationException { + XControlPoint xControlPoint_ = createXControlPoint(); + xControlPoint_.setup(UJAXP.getDocument(url, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xControlPoint_); + } + + /** + * Creates a XHint by the URL url. + * This method is a template method for concrete classes. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHint + */ + public XHint createXHint(URL url) throws IOException, SAXException, ParserConfigurationException { + XHint xHint_ = createXHint(); + xHint_.setup(UJAXP.getDocument(url, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xHint_); + } + + /** + * Creates a XContourPoint by the URL url. + * This method is a template method for concrete classes. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XContourPoint + */ + public XContourPoint createXContourPoint(URL url) throws IOException, SAXException, ParserConfigurationException { + XContourPoint xContourPoint_ = createXContourPoint(); + xContourPoint_.setup(UJAXP.getDocument(url, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xContourPoint_); + } + + /** + * Creates a XParamListParam by the InputStream in. + * This method is a template method for concrete classes. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XParamListParam + */ + public XParamListParam createXParamListParam(InputStream in) throws IOException, SAXException, ParserConfigurationException { + XParamListParam xParamListParam_ = createXParamListParam(); + xParamListParam_.setup(UJAXP.getDocument(in, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xParamListParam_); + } + + /** + * Creates a XHeadGlobal by the InputStream in. + * This method is a template method for concrete classes. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHeadGlobal + */ + public XHeadGlobal createXHeadGlobal(InputStream in) throws IOException, SAXException, ParserConfigurationException { + XHeadGlobal xHeadGlobal_ = createXHeadGlobal(); + xHeadGlobal_.setup(UJAXP.getDocument(in, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xHeadGlobal_); + } + + /** + * Creates a XHeadLocal by the InputStream in. + * This method is a template method for concrete classes. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHeadLocal + */ + public XHeadLocal createXHeadLocal(InputStream in) throws IOException, SAXException, ParserConfigurationException { + XHeadLocal xHeadLocal_ = createXHeadLocal(); + xHeadLocal_.setup(UJAXP.getDocument(in, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xHeadLocal_); + } + + /** + * Creates a XHead by the InputStream in. + * This method is a template method for concrete classes. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHead + */ + public XHead createXHead(InputStream in) throws IOException, SAXException, ParserConfigurationException { + XHead xHead_ = createXHead(); + xHead_.setup(UJAXP.getDocument(in, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xHead_); + } + + /** + * Creates a XGlyphFile by the InputStream in. + * This method is a template method for concrete classes. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XGlyphFile + */ + public XGlyphFile createXGlyphFile(InputStream in) throws IOException, SAXException, ParserConfigurationException { + XGlyphFile xGlyphFile_ = createXGlyphFile(); + xGlyphFile_.setup(UJAXP.getDocument(in, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xGlyphFile_); + } + + /** + * Creates a XContour by the InputStream in. + * This method is a template method for concrete classes. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XContour + */ + public XContour createXContour(InputStream in) throws IOException, SAXException, ParserConfigurationException { + XContour xContour_ = createXContour(); + xContour_.setup(UJAXP.getDocument(in, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xContour_); + } + + /** + * Creates a XPoint2d by the InputStream in. + * This method is a template method for concrete classes. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XPoint2d + */ + public XPoint2d createXPoint2d(InputStream in) throws IOException, SAXException, ParserConfigurationException { + XPoint2d xPoint2d_ = createXPoint2d(); + xPoint2d_.setup(UJAXP.getDocument(in, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xPoint2d_); + } + + /** + * Creates a XInvokePos by the InputStream in. + * This method is a template method for concrete classes. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokePos + */ + public XInvokePos createXInvokePos(InputStream in) throws IOException, SAXException, ParserConfigurationException { + XInvokePos xInvokePos_ = createXInvokePos(); + xInvokePos_.setup(UJAXP.getDocument(in, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xInvokePos_); + } + + /** + * Creates a XInvokeArg by the InputStream in. + * This method is a template method for concrete classes. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokeArg + */ + public XInvokeArg createXInvokeArg(InputStream in) throws IOException, SAXException, ParserConfigurationException { + XInvokeArg xInvokeArg_ = createXInvokeArg(); + xInvokeArg_.setup(UJAXP.getDocument(in, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xInvokeArg_); + } + + /** + * Creates a XInvokeVarg by the InputStream in. + * This method is a template method for concrete classes. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokeVarg + */ + public XInvokeVarg createXInvokeVarg(InputStream in) throws IOException, SAXException, ParserConfigurationException { + XInvokeVarg xInvokeVarg_ = createXInvokeVarg(); + xInvokeVarg_.setup(UJAXP.getDocument(in, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xInvokeVarg_); + } + + /** + * Creates a XInvoke by the InputStream in. + * This method is a template method for concrete classes. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvoke + */ + public XInvoke createXInvoke(InputStream in) throws IOException, SAXException, ParserConfigurationException { + XInvoke xInvoke_ = createXInvoke(); + xInvoke_.setup(UJAXP.getDocument(in, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xInvoke_); + } + + /** + * Creates a XInclude by the InputStream in. + * This method is a template method for concrete classes. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInclude + */ + public XInclude createXInclude(InputStream in) throws IOException, SAXException, ParserConfigurationException { + XInclude xInclude_ = createXInclude(); + xInclude_.setup(UJAXP.getDocument(in, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xInclude_); + } + + /** + * Creates a XModule by the InputStream in. + * This method is a template method for concrete classes. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XModule + */ + public XModule createXModule(InputStream in) throws IOException, SAXException, ParserConfigurationException { + XModule xModule_ = createXModule(); + xModule_.setup(UJAXP.getDocument(in, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xModule_); + } + + /** + * Creates a XBody by the InputStream in. + * This method is a template method for concrete classes. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XBody + */ + public XBody createXBody(InputStream in) throws IOException, SAXException, ParserConfigurationException { + XBody xBody_ = createXBody(); + xBody_.setup(UJAXP.getDocument(in, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xBody_); + } + + /** + * Creates a XStartGlyphElement by the InputStream in. + * This method is a template method for concrete classes. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XStartGlyphElement + */ + public XStartGlyphElement createXStartGlyphElement(InputStream in) throws IOException, SAXException, ParserConfigurationException { + XStartGlyphElement xStartGlyphElement_ = createXStartGlyphElement(); + xStartGlyphElement_.setup(UJAXP.getDocument(in, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xStartGlyphElement_); + } + + /** + * Creates a XControlPoint by the InputStream in. + * This method is a template method for concrete classes. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XControlPoint + */ + public XControlPoint createXControlPoint(InputStream in) throws IOException, SAXException, ParserConfigurationException { + XControlPoint xControlPoint_ = createXControlPoint(); + xControlPoint_.setup(UJAXP.getDocument(in, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xControlPoint_); + } + + /** + * Creates a XHint by the InputStream in. + * This method is a template method for concrete classes. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHint + */ + public XHint createXHint(InputStream in) throws IOException, SAXException, ParserConfigurationException { + XHint xHint_ = createXHint(); + xHint_.setup(UJAXP.getDocument(in, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xHint_); + } + + /** + * Creates a XContourPoint by the InputStream in. + * This method is a template method for concrete classes. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XContourPoint + */ + public XContourPoint createXContourPoint(InputStream in) throws IOException, SAXException, ParserConfigurationException { + XContourPoint xContourPoint_ = createXContourPoint(); + xContourPoint_.setup(UJAXP.getDocument(in, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xContourPoint_); + } + + /** + * Creates a XParamListParam by the InputSource is. + * This method is a template method for concrete classes. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XParamListParam + */ + public XParamListParam createXParamListParam(InputSource is) throws IOException, SAXException, ParserConfigurationException { + XParamListParam xParamListParam_ = createXParamListParam(); + xParamListParam_.setup(UJAXP.getDocument(is, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xParamListParam_); + } + + /** + * Creates a XHeadGlobal by the InputSource is. + * This method is a template method for concrete classes. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHeadGlobal + */ + public XHeadGlobal createXHeadGlobal(InputSource is) throws IOException, SAXException, ParserConfigurationException { + XHeadGlobal xHeadGlobal_ = createXHeadGlobal(); + xHeadGlobal_.setup(UJAXP.getDocument(is, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xHeadGlobal_); + } + + /** + * Creates a XHeadLocal by the InputSource is. + * This method is a template method for concrete classes. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHeadLocal + */ + public XHeadLocal createXHeadLocal(InputSource is) throws IOException, SAXException, ParserConfigurationException { + XHeadLocal xHeadLocal_ = createXHeadLocal(); + xHeadLocal_.setup(UJAXP.getDocument(is, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xHeadLocal_); + } + + /** + * Creates a XHead by the InputSource is. + * This method is a template method for concrete classes. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHead + */ + public XHead createXHead(InputSource is) throws IOException, SAXException, ParserConfigurationException { + XHead xHead_ = createXHead(); + xHead_.setup(UJAXP.getDocument(is, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xHead_); + } + + /** + * Creates a XGlyphFile by the InputSource is. + * This method is a template method for concrete classes. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XGlyphFile + */ + public XGlyphFile createXGlyphFile(InputSource is) throws IOException, SAXException, ParserConfigurationException { + XGlyphFile xGlyphFile_ = createXGlyphFile(); + xGlyphFile_.setup(UJAXP.getDocument(is, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xGlyphFile_); + } + + /** + * Creates a XContour by the InputSource is. + * This method is a template method for concrete classes. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XContour + */ + public XContour createXContour(InputSource is) throws IOException, SAXException, ParserConfigurationException { + XContour xContour_ = createXContour(); + xContour_.setup(UJAXP.getDocument(is, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xContour_); + } + + /** + * Creates a XPoint2d by the InputSource is. + * This method is a template method for concrete classes. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XPoint2d + */ + public XPoint2d createXPoint2d(InputSource is) throws IOException, SAXException, ParserConfigurationException { + XPoint2d xPoint2d_ = createXPoint2d(); + xPoint2d_.setup(UJAXP.getDocument(is, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xPoint2d_); + } + + /** + * Creates a XInvokePos by the InputSource is. + * This method is a template method for concrete classes. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokePos + */ + public XInvokePos createXInvokePos(InputSource is) throws IOException, SAXException, ParserConfigurationException { + XInvokePos xInvokePos_ = createXInvokePos(); + xInvokePos_.setup(UJAXP.getDocument(is, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xInvokePos_); + } + + /** + * Creates a XInvokeArg by the InputSource is. + * This method is a template method for concrete classes. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokeArg + */ + public XInvokeArg createXInvokeArg(InputSource is) throws IOException, SAXException, ParserConfigurationException { + XInvokeArg xInvokeArg_ = createXInvokeArg(); + xInvokeArg_.setup(UJAXP.getDocument(is, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xInvokeArg_); + } + + /** + * Creates a XInvokeVarg by the InputSource is. + * This method is a template method for concrete classes. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokeVarg + */ + public XInvokeVarg createXInvokeVarg(InputSource is) throws IOException, SAXException, ParserConfigurationException { + XInvokeVarg xInvokeVarg_ = createXInvokeVarg(); + xInvokeVarg_.setup(UJAXP.getDocument(is, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xInvokeVarg_); + } + + /** + * Creates a XInvoke by the InputSource is. + * This method is a template method for concrete classes. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvoke + */ + public XInvoke createXInvoke(InputSource is) throws IOException, SAXException, ParserConfigurationException { + XInvoke xInvoke_ = createXInvoke(); + xInvoke_.setup(UJAXP.getDocument(is, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xInvoke_); + } + + /** + * Creates a XInclude by the InputSource is. + * This method is a template method for concrete classes. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInclude + */ + public XInclude createXInclude(InputSource is) throws IOException, SAXException, ParserConfigurationException { + XInclude xInclude_ = createXInclude(); + xInclude_.setup(UJAXP.getDocument(is, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xInclude_); + } + + /** + * Creates a XModule by the InputSource is. + * This method is a template method for concrete classes. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XModule + */ + public XModule createXModule(InputSource is) throws IOException, SAXException, ParserConfigurationException { + XModule xModule_ = createXModule(); + xModule_.setup(UJAXP.getDocument(is, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xModule_); + } + + /** + * Creates a XBody by the InputSource is. + * This method is a template method for concrete classes. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XBody + */ + public XBody createXBody(InputSource is) throws IOException, SAXException, ParserConfigurationException { + XBody xBody_ = createXBody(); + xBody_.setup(UJAXP.getDocument(is, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xBody_); + } + + /** + * Creates a XStartGlyphElement by the InputSource is. + * This method is a template method for concrete classes. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XStartGlyphElement + */ + public XStartGlyphElement createXStartGlyphElement(InputSource is) throws IOException, SAXException, ParserConfigurationException { + XStartGlyphElement xStartGlyphElement_ = createXStartGlyphElement(); + xStartGlyphElement_.setup(UJAXP.getDocument(is, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xStartGlyphElement_); + } + + /** + * Creates a XControlPoint by the InputSource is. + * This method is a template method for concrete classes. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XControlPoint + */ + public XControlPoint createXControlPoint(InputSource is) throws IOException, SAXException, ParserConfigurationException { + XControlPoint xControlPoint_ = createXControlPoint(); + xControlPoint_.setup(UJAXP.getDocument(is, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xControlPoint_); + } + + /** + * Creates a XHint by the InputSource is. + * This method is a template method for concrete classes. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHint + */ + public XHint createXHint(InputSource is) throws IOException, SAXException, ParserConfigurationException { + XHint xHint_ = createXHint(); + xHint_.setup(UJAXP.getDocument(is, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xHint_); + } + + /** + * Creates a XContourPoint by the InputSource is. + * This method is a template method for concrete classes. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XContourPoint + */ + public XContourPoint createXContourPoint(InputSource is) throws IOException, SAXException, ParserConfigurationException { + XContourPoint xContourPoint_ = createXContourPoint(); + xContourPoint_.setup(UJAXP.getDocument(is, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xContourPoint_); + } + + /** + * Creates a XParamListParam by the Reader reader. + * This method is a template method for concrete classes. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XParamListParam + */ + public XParamListParam createXParamListParam(Reader reader) throws IOException, SAXException, ParserConfigurationException { + XParamListParam xParamListParam_ = createXParamListParam(); + xParamListParam_.setup(UJAXP.getDocument(reader, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xParamListParam_); + } + + /** + * Creates a XHeadGlobal by the Reader reader. + * This method is a template method for concrete classes. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHeadGlobal + */ + public XHeadGlobal createXHeadGlobal(Reader reader) throws IOException, SAXException, ParserConfigurationException { + XHeadGlobal xHeadGlobal_ = createXHeadGlobal(); + xHeadGlobal_.setup(UJAXP.getDocument(reader, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xHeadGlobal_); + } + + /** + * Creates a XHeadLocal by the Reader reader. + * This method is a template method for concrete classes. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHeadLocal + */ + public XHeadLocal createXHeadLocal(Reader reader) throws IOException, SAXException, ParserConfigurationException { + XHeadLocal xHeadLocal_ = createXHeadLocal(); + xHeadLocal_.setup(UJAXP.getDocument(reader, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xHeadLocal_); + } + + /** + * Creates a XHead by the Reader reader. + * This method is a template method for concrete classes. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHead + */ + public XHead createXHead(Reader reader) throws IOException, SAXException, ParserConfigurationException { + XHead xHead_ = createXHead(); + xHead_.setup(UJAXP.getDocument(reader, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xHead_); + } + + /** + * Creates a XGlyphFile by the Reader reader. + * This method is a template method for concrete classes. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XGlyphFile + */ + public XGlyphFile createXGlyphFile(Reader reader) throws IOException, SAXException, ParserConfigurationException { + XGlyphFile xGlyphFile_ = createXGlyphFile(); + xGlyphFile_.setup(UJAXP.getDocument(reader, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xGlyphFile_); + } + + /** + * Creates a XContour by the Reader reader. + * This method is a template method for concrete classes. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XContour + */ + public XContour createXContour(Reader reader) throws IOException, SAXException, ParserConfigurationException { + XContour xContour_ = createXContour(); + xContour_.setup(UJAXP.getDocument(reader, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xContour_); + } + + /** + * Creates a XPoint2d by the Reader reader. + * This method is a template method for concrete classes. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XPoint2d + */ + public XPoint2d createXPoint2d(Reader reader) throws IOException, SAXException, ParserConfigurationException { + XPoint2d xPoint2d_ = createXPoint2d(); + xPoint2d_.setup(UJAXP.getDocument(reader, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xPoint2d_); + } + + /** + * Creates a XInvokePos by the Reader reader. + * This method is a template method for concrete classes. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokePos + */ + public XInvokePos createXInvokePos(Reader reader) throws IOException, SAXException, ParserConfigurationException { + XInvokePos xInvokePos_ = createXInvokePos(); + xInvokePos_.setup(UJAXP.getDocument(reader, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xInvokePos_); + } + + /** + * Creates a XInvokeArg by the Reader reader. + * This method is a template method for concrete classes. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokeArg + */ + public XInvokeArg createXInvokeArg(Reader reader) throws IOException, SAXException, ParserConfigurationException { + XInvokeArg xInvokeArg_ = createXInvokeArg(); + xInvokeArg_.setup(UJAXP.getDocument(reader, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xInvokeArg_); + } + + /** + * Creates a XInvokeVarg by the Reader reader. + * This method is a template method for concrete classes. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokeVarg + */ + public XInvokeVarg createXInvokeVarg(Reader reader) throws IOException, SAXException, ParserConfigurationException { + XInvokeVarg xInvokeVarg_ = createXInvokeVarg(); + xInvokeVarg_.setup(UJAXP.getDocument(reader, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xInvokeVarg_); + } + + /** + * Creates a XInvoke by the Reader reader. + * This method is a template method for concrete classes. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvoke + */ + public XInvoke createXInvoke(Reader reader) throws IOException, SAXException, ParserConfigurationException { + XInvoke xInvoke_ = createXInvoke(); + xInvoke_.setup(UJAXP.getDocument(reader, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xInvoke_); + } + + /** + * Creates a XInclude by the Reader reader. + * This method is a template method for concrete classes. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInclude + */ + public XInclude createXInclude(Reader reader) throws IOException, SAXException, ParserConfigurationException { + XInclude xInclude_ = createXInclude(); + xInclude_.setup(UJAXP.getDocument(reader, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xInclude_); + } + + /** + * Creates a XModule by the Reader reader. + * This method is a template method for concrete classes. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XModule + */ + public XModule createXModule(Reader reader) throws IOException, SAXException, ParserConfigurationException { + XModule xModule_ = createXModule(); + xModule_.setup(UJAXP.getDocument(reader, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xModule_); + } + + /** + * Creates a XBody by the Reader reader. + * This method is a template method for concrete classes. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XBody + */ + public XBody createXBody(Reader reader) throws IOException, SAXException, ParserConfigurationException { + XBody xBody_ = createXBody(); + xBody_.setup(UJAXP.getDocument(reader, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xBody_); + } + + /** + * Creates a XStartGlyphElement by the Reader reader. + * This method is a template method for concrete classes. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XStartGlyphElement + */ + public XStartGlyphElement createXStartGlyphElement(Reader reader) throws IOException, SAXException, ParserConfigurationException { + XStartGlyphElement xStartGlyphElement_ = createXStartGlyphElement(); + xStartGlyphElement_.setup(UJAXP.getDocument(reader, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xStartGlyphElement_); + } + + /** + * Creates a XControlPoint by the Reader reader. + * This method is a template method for concrete classes. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XControlPoint + */ + public XControlPoint createXControlPoint(Reader reader) throws IOException, SAXException, ParserConfigurationException { + XControlPoint xControlPoint_ = createXControlPoint(); + xControlPoint_.setup(UJAXP.getDocument(reader, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xControlPoint_); + } + + /** + * Creates a XHint by the Reader reader. + * This method is a template method for concrete classes. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHint + */ + public XHint createXHint(Reader reader) throws IOException, SAXException, ParserConfigurationException { + XHint xHint_ = createXHint(); + xHint_.setup(UJAXP.getDocument(reader, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xHint_); + } + + /** + * Creates a XContourPoint by the Reader reader. + * This method is a template method for concrete classes. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XContourPoint + */ + public XContourPoint createXContourPoint(Reader reader) throws IOException, SAXException, ParserConfigurationException { + XContourPoint xContourPoint_ = createXContourPoint(); + xContourPoint_.setup(UJAXP.getDocument(reader, UJAXP.FLAG_NONE, errorHandler, entityResolver)); + return (xContourPoint_); + } + + /** + * Creates a XParamListParam by the object source. + * This method is a template method for concrete classes. + * + * @param source + * @return XParamListParam + */ + public XParamListParam createXParamListParam(XParamListParam source) { + XParamListParam xParamListParam_ = createXParamListParam(); + xParamListParam_.setup(source); + return (xParamListParam_); + } + + /** + * Creates a XHeadGlobal by the object source. + * This method is a template method for concrete classes. + * + * @param source + * @return XHeadGlobal + */ + public XHeadGlobal createXHeadGlobal(XHeadGlobal source) { + XHeadGlobal xHeadGlobal_ = createXHeadGlobal(); + xHeadGlobal_.setup(source); + return (xHeadGlobal_); + } + + /** + * Creates a XHeadLocal by the object source. + * This method is a template method for concrete classes. + * + * @param source + * @return XHeadLocal + */ + public XHeadLocal createXHeadLocal(XHeadLocal source) { + XHeadLocal xHeadLocal_ = createXHeadLocal(); + xHeadLocal_.setup(source); + return (xHeadLocal_); + } + + /** + * Creates a XHead by the object source. + * This method is a template method for concrete classes. + * + * @param source + * @return XHead + */ + public XHead createXHead(XHead source) { + XHead xHead_ = createXHead(); + xHead_.setup(source); + return (xHead_); + } + + /** + * Creates a XGlyphFile by the object source. + * This method is a template method for concrete classes. + * + * @param source + * @return XGlyphFile + */ + public XGlyphFile createXGlyphFile(XGlyphFile source) { + XGlyphFile xGlyphFile_ = createXGlyphFile(); + xGlyphFile_.setup(source); + return (xGlyphFile_); + } + + /** + * Creates a XContour by the object source. + * This method is a template method for concrete classes. + * + * @param source + * @return XContour + */ + public XContour createXContour(XContour source) { + XContour xContour_ = createXContour(); + xContour_.setup(source); + return (xContour_); + } + + /** + * Creates a XPoint2d by the object source. + * This method is a template method for concrete classes. + * + * @param source + * @return XPoint2d + */ + public XPoint2d createXPoint2d(XPoint2d source) { + XPoint2d xPoint2d_ = createXPoint2d(); + xPoint2d_.setup(source); + return (xPoint2d_); + } + + /** + * Creates a XInvokePos by the object source. + * This method is a template method for concrete classes. + * + * @param source + * @return XInvokePos + */ + public XInvokePos createXInvokePos(XInvokePos source) { + XInvokePos xInvokePos_ = createXInvokePos(); + xInvokePos_.setup(source); + return (xInvokePos_); + } + + /** + * Creates a XInvokeArg by the object source. + * This method is a template method for concrete classes. + * + * @param source + * @return XInvokeArg + */ + public XInvokeArg createXInvokeArg(XInvokeArg source) { + XInvokeArg xInvokeArg_ = createXInvokeArg(); + xInvokeArg_.setup(source); + return (xInvokeArg_); + } + + /** + * Creates a XInvokeVarg by the object source. + * This method is a template method for concrete classes. + * + * @param source + * @return XInvokeVarg + */ + public XInvokeVarg createXInvokeVarg(XInvokeVarg source) { + XInvokeVarg xInvokeVarg_ = createXInvokeVarg(); + xInvokeVarg_.setup(source); + return (xInvokeVarg_); + } + + /** + * Creates a XInvoke by the object source. + * This method is a template method for concrete classes. + * + * @param source + * @return XInvoke + */ + public XInvoke createXInvoke(XInvoke source) { + XInvoke xInvoke_ = createXInvoke(); + xInvoke_.setup(source); + return (xInvoke_); + } + + /** + * Creates a XInclude by the object source. + * This method is a template method for concrete classes. + * + * @param source + * @return XInclude + */ + public XInclude createXInclude(XInclude source) { + XInclude xInclude_ = createXInclude(); + xInclude_.setup(source); + return (xInclude_); + } + + /** + * Creates a XModule by the object source. + * This method is a template method for concrete classes. + * + * @param source + * @return XModule + */ + public XModule createXModule(XModule source) { + XModule xModule_ = createXModule(); + xModule_.setup(source); + return (xModule_); + } + + /** + * Creates a XBody by the object source. + * This method is a template method for concrete classes. + * + * @param source + * @return XBody + */ + public XBody createXBody(XBody source) { + XBody xBody_ = createXBody(); + xBody_.setup(source); + return (xBody_); + } + + /** + * Creates a XStartGlyphElement by the object source. + * This method is a template method for concrete classes. + * + * @param source + * @return XStartGlyphElement + */ + public XStartGlyphElement createXStartGlyphElement(XStartGlyphElement source) { + XStartGlyphElement xStartGlyphElement_ = createXStartGlyphElement(); + xStartGlyphElement_.setup(source); + return (xStartGlyphElement_); + } + + /** + * Creates a XControlPoint by the object source. + * This method is a template method for concrete classes. + * + * @param source + * @return XControlPoint + */ + public XControlPoint createXControlPoint(XControlPoint source) { + XControlPoint xControlPoint_ = createXControlPoint(); + xControlPoint_.setup(source); + return (xControlPoint_); + } + + /** + * Creates a XHint by the object source. + * This method is a template method for concrete classes. + * + * @param source + * @return XHint + */ + public XHint createXHint(XHint source) { + XHint xHint_ = createXHint(); + xHint_.setup(source); + return (xHint_); + } + + /** + * Creates a XContourPoint by the object source. + * This method is a template method for concrete classes. + * + * @param source + * @return XContourPoint + */ + public XContourPoint createXContourPoint(XContourPoint source) { + XContourPoint xContourPoint_ = createXContourPoint(); + xContourPoint_.setup(source); + return (xContourPoint_); + } + + /** + * Creates a XParamListParam by the Document doc. + * This method is a template method for concrete classes. + * + * @param doc + * @return XParamListParam + */ + public XParamListParam createXParamListParam(Document doc) { + XParamListParam xParamListParam_ = createXParamListParam(); + xParamListParam_.setup(doc); + return (xParamListParam_); + } + + /** + * Creates a XHeadGlobal by the Document doc. + * This method is a template method for concrete classes. + * + * @param doc + * @return XHeadGlobal + */ + public XHeadGlobal createXHeadGlobal(Document doc) { + XHeadGlobal xHeadGlobal_ = createXHeadGlobal(); + xHeadGlobal_.setup(doc); + return (xHeadGlobal_); + } + + /** + * Creates a XHeadLocal by the Document doc. + * This method is a template method for concrete classes. + * + * @param doc + * @return XHeadLocal + */ + public XHeadLocal createXHeadLocal(Document doc) { + XHeadLocal xHeadLocal_ = createXHeadLocal(); + xHeadLocal_.setup(doc); + return (xHeadLocal_); + } + + /** + * Creates a XHead by the Document doc. + * This method is a template method for concrete classes. + * + * @param doc + * @return XHead + */ + public XHead createXHead(Document doc) { + XHead xHead_ = createXHead(); + xHead_.setup(doc); + return (xHead_); + } + + /** + * Creates a XGlyphFile by the Document doc. + * This method is a template method for concrete classes. + * + * @param doc + * @return XGlyphFile + */ + public XGlyphFile createXGlyphFile(Document doc) { + XGlyphFile xGlyphFile_ = createXGlyphFile(); + xGlyphFile_.setup(doc); + return (xGlyphFile_); + } + + /** + * Creates a XContour by the Document doc. + * This method is a template method for concrete classes. + * + * @param doc + * @return XContour + */ + public XContour createXContour(Document doc) { + XContour xContour_ = createXContour(); + xContour_.setup(doc); + return (xContour_); + } + + /** + * Creates a XPoint2d by the Document doc. + * This method is a template method for concrete classes. + * + * @param doc + * @return XPoint2d + */ + public XPoint2d createXPoint2d(Document doc) { + XPoint2d xPoint2d_ = createXPoint2d(); + xPoint2d_.setup(doc); + return (xPoint2d_); + } + + /** + * Creates a XInvokePos by the Document doc. + * This method is a template method for concrete classes. + * + * @param doc + * @return XInvokePos + */ + public XInvokePos createXInvokePos(Document doc) { + XInvokePos xInvokePos_ = createXInvokePos(); + xInvokePos_.setup(doc); + return (xInvokePos_); + } + + /** + * Creates a XInvokeArg by the Document doc. + * This method is a template method for concrete classes. + * + * @param doc + * @return XInvokeArg + */ + public XInvokeArg createXInvokeArg(Document doc) { + XInvokeArg xInvokeArg_ = createXInvokeArg(); + xInvokeArg_.setup(doc); + return (xInvokeArg_); + } + + /** + * Creates a XInvokeVarg by the Document doc. + * This method is a template method for concrete classes. + * + * @param doc + * @return XInvokeVarg + */ + public XInvokeVarg createXInvokeVarg(Document doc) { + XInvokeVarg xInvokeVarg_ = createXInvokeVarg(); + xInvokeVarg_.setup(doc); + return (xInvokeVarg_); + } + + /** + * Creates a XInvoke by the Document doc. + * This method is a template method for concrete classes. + * + * @param doc + * @return XInvoke + */ + public XInvoke createXInvoke(Document doc) { + XInvoke xInvoke_ = createXInvoke(); + xInvoke_.setup(doc); + return (xInvoke_); + } + + /** + * Creates a XInclude by the Document doc. + * This method is a template method for concrete classes. + * + * @param doc + * @return XInclude + */ + public XInclude createXInclude(Document doc) { + XInclude xInclude_ = createXInclude(); + xInclude_.setup(doc); + return (xInclude_); + } + + /** + * Creates a XModule by the Document doc. + * This method is a template method for concrete classes. + * + * @param doc + * @return XModule + */ + public XModule createXModule(Document doc) { + XModule xModule_ = createXModule(); + xModule_.setup(doc); + return (xModule_); + } + + /** + * Creates a XBody by the Document doc. + * This method is a template method for concrete classes. + * + * @param doc + * @return XBody + */ + public XBody createXBody(Document doc) { + XBody xBody_ = createXBody(); + xBody_.setup(doc); + return (xBody_); + } + + /** + * Creates a XStartGlyphElement by the Document doc. + * This method is a template method for concrete classes. + * + * @param doc + * @return XStartGlyphElement + */ + public XStartGlyphElement createXStartGlyphElement(Document doc) { + XStartGlyphElement xStartGlyphElement_ = createXStartGlyphElement(); + xStartGlyphElement_.setup(doc); + return (xStartGlyphElement_); + } + + /** + * Creates a XControlPoint by the Document doc. + * This method is a template method for concrete classes. + * + * @param doc + * @return XControlPoint + */ + public XControlPoint createXControlPoint(Document doc) { + XControlPoint xControlPoint_ = createXControlPoint(); + xControlPoint_.setup(doc); + return (xControlPoint_); + } + + /** + * Creates a XHint by the Document doc. + * This method is a template method for concrete classes. + * + * @param doc + * @return XHint + */ + public XHint createXHint(Document doc) { + XHint xHint_ = createXHint(); + xHint_.setup(doc); + return (xHint_); + } + + /** + * Creates a XContourPoint by the Document doc. + * This method is a template method for concrete classes. + * + * @param doc + * @return XContourPoint + */ + public XContourPoint createXContourPoint(Document doc) { + XContourPoint xContourPoint_ = createXContourPoint(); + xContourPoint_.setup(doc); + return (xContourPoint_); + } + + /** + * Creates a XParamListParam by the Element element. + * This method is a template method for concrete classes. + * + * @param element + * @return XParamListParam + */ + public XParamListParam createXParamListParam(Element element) { + XParamListParam xParamListParam_ = createXParamListParam(); + xParamListParam_.setup(element); + return (xParamListParam_); + } + + /** + * Creates a XHeadGlobal by the Element element. + * This method is a template method for concrete classes. + * + * @param element + * @return XHeadGlobal + */ + public XHeadGlobal createXHeadGlobal(Element element) { + XHeadGlobal xHeadGlobal_ = createXHeadGlobal(); + xHeadGlobal_.setup(element); + return (xHeadGlobal_); + } + + /** + * Creates a XHeadLocal by the Element element. + * This method is a template method for concrete classes. + * + * @param element + * @return XHeadLocal + */ + public XHeadLocal createXHeadLocal(Element element) { + XHeadLocal xHeadLocal_ = createXHeadLocal(); + xHeadLocal_.setup(element); + return (xHeadLocal_); + } + + /** + * Creates a XHead by the Element element. + * This method is a template method for concrete classes. + * + * @param element + * @return XHead + */ + public XHead createXHead(Element element) { + XHead xHead_ = createXHead(); + xHead_.setup(element); + return (xHead_); + } + + /** + * Creates a XGlyphFile by the Element element. + * This method is a template method for concrete classes. + * + * @param element + * @return XGlyphFile + */ + public XGlyphFile createXGlyphFile(Element element) { + XGlyphFile xGlyphFile_ = createXGlyphFile(); + xGlyphFile_.setup(element); + return (xGlyphFile_); + } + + /** + * Creates a XContour by the Element element. + * This method is a template method for concrete classes. + * + * @param element + * @return XContour + */ + public XContour createXContour(Element element) { + XContour xContour_ = createXContour(); + xContour_.setup(element); + return (xContour_); + } + + /** + * Creates a XPoint2d by the Element element. + * This method is a template method for concrete classes. + * + * @param element + * @return XPoint2d + */ + public XPoint2d createXPoint2d(Element element) { + XPoint2d xPoint2d_ = createXPoint2d(); + xPoint2d_.setup(element); + return (xPoint2d_); + } + + /** + * Creates a XInvokePos by the Element element. + * This method is a template method for concrete classes. + * + * @param element + * @return XInvokePos + */ + public XInvokePos createXInvokePos(Element element) { + XInvokePos xInvokePos_ = createXInvokePos(); + xInvokePos_.setup(element); + return (xInvokePos_); + } + + /** + * Creates a XInvokeArg by the Element element. + * This method is a template method for concrete classes. + * + * @param element + * @return XInvokeArg + */ + public XInvokeArg createXInvokeArg(Element element) { + XInvokeArg xInvokeArg_ = createXInvokeArg(); + xInvokeArg_.setup(element); + return (xInvokeArg_); + } + + /** + * Creates a XInvokeVarg by the Element element. + * This method is a template method for concrete classes. + * + * @param element + * @return XInvokeVarg + */ + public XInvokeVarg createXInvokeVarg(Element element) { + XInvokeVarg xInvokeVarg_ = createXInvokeVarg(); + xInvokeVarg_.setup(element); + return (xInvokeVarg_); + } + + /** + * Creates a XInvoke by the Element element. + * This method is a template method for concrete classes. + * + * @param element + * @return XInvoke + */ + public XInvoke createXInvoke(Element element) { + XInvoke xInvoke_ = createXInvoke(); + xInvoke_.setup(element); + return (xInvoke_); + } + + /** + * Creates a XInclude by the Element element. + * This method is a template method for concrete classes. + * + * @param element + * @return XInclude + */ + public XInclude createXInclude(Element element) { + XInclude xInclude_ = createXInclude(); + xInclude_.setup(element); + return (xInclude_); + } + + /** + * Creates a XModule by the Element element. + * This method is a template method for concrete classes. + * + * @param element + * @return XModule + */ + public XModule createXModule(Element element) { + XModule xModule_ = createXModule(); + xModule_.setup(element); + return (xModule_); + } + + /** + * Creates a XBody by the Element element. + * This method is a template method for concrete classes. + * + * @param element + * @return XBody + */ + public XBody createXBody(Element element) { + XBody xBody_ = createXBody(); + xBody_.setup(element); + return (xBody_); + } + + /** + * Creates a XStartGlyphElement by the Element element. + * This method is a template method for concrete classes. + * + * @param element + * @return XStartGlyphElement + */ + public XStartGlyphElement createXStartGlyphElement(Element element) { + XStartGlyphElement xStartGlyphElement_ = createXStartGlyphElement(); + xStartGlyphElement_.setup(element); + return (xStartGlyphElement_); + } + + /** + * Creates a XControlPoint by the Element element. + * This method is a template method for concrete classes. + * + * @param element + * @return XControlPoint + */ + public XControlPoint createXControlPoint(Element element) { + XControlPoint xControlPoint_ = createXControlPoint(); + xControlPoint_.setup(element); + return (xControlPoint_); + } + + /** + * Creates a XHint by the Element element. + * This method is a template method for concrete classes. + * + * @param element + * @return XHint + */ + public XHint createXHint(Element element) { + XHint xHint_ = createXHint(); + xHint_.setup(element); + return (xHint_); + } + + /** + * Creates a XContourPoint by the Element element. + * This method is a template method for concrete classes. + * + * @param element + * @return XContourPoint + */ + public XContourPoint createXContourPoint(Element element) { + XContourPoint xContourPoint_ = createXContourPoint(); + xContourPoint_.setup(element); + return (xContourPoint_); + } + + /** + * Creates a XParamListParam by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * This method is a template method for concrete classes. + * + * @param stack + * @return XParamListParam + */ + public XParamListParam createXParamListParam(RStack stack) { + XParamListParam xParamListParam_ = createXParamListParam(); + xParamListParam_.setup(stack); + return (xParamListParam_); + } + + /** + * Creates a XHeadGlobal by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * This method is a template method for concrete classes. + * + * @param stack + * @return XHeadGlobal + */ + public XHeadGlobal createXHeadGlobal(RStack stack) { + XHeadGlobal xHeadGlobal_ = createXHeadGlobal(); + xHeadGlobal_.setup(stack); + return (xHeadGlobal_); + } + + /** + * Creates a XHeadLocal by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * This method is a template method for concrete classes. + * + * @param stack + * @return XHeadLocal + */ + public XHeadLocal createXHeadLocal(RStack stack) { + XHeadLocal xHeadLocal_ = createXHeadLocal(); + xHeadLocal_.setup(stack); + return (xHeadLocal_); + } + + /** + * Creates a XHead by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * This method is a template method for concrete classes. + * + * @param stack + * @return XHead + */ + public XHead createXHead(RStack stack) { + XHead xHead_ = createXHead(); + xHead_.setup(stack); + return (xHead_); + } + + /** + * Creates a XGlyphFile by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * This method is a template method for concrete classes. + * + * @param stack + * @return XGlyphFile + */ + public XGlyphFile createXGlyphFile(RStack stack) { + XGlyphFile xGlyphFile_ = createXGlyphFile(); + xGlyphFile_.setup(stack); + return (xGlyphFile_); + } + + /** + * Creates a XContour by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * This method is a template method for concrete classes. + * + * @param stack + * @return XContour + */ + public XContour createXContour(RStack stack) { + XContour xContour_ = createXContour(); + xContour_.setup(stack); + return (xContour_); + } + + /** + * Creates a XPoint2d by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * This method is a template method for concrete classes. + * + * @param stack + * @return XPoint2d + */ + public XPoint2d createXPoint2d(RStack stack) { + XPoint2d xPoint2d_ = createXPoint2d(); + xPoint2d_.setup(stack); + return (xPoint2d_); + } + + /** + * Creates a XInvokePos by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * This method is a template method for concrete classes. + * + * @param stack + * @return XInvokePos + */ + public XInvokePos createXInvokePos(RStack stack) { + XInvokePos xInvokePos_ = createXInvokePos(); + xInvokePos_.setup(stack); + return (xInvokePos_); + } + + /** + * Creates a XInvokeArg by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * This method is a template method for concrete classes. + * + * @param stack + * @return XInvokeArg + */ + public XInvokeArg createXInvokeArg(RStack stack) { + XInvokeArg xInvokeArg_ = createXInvokeArg(); + xInvokeArg_.setup(stack); + return (xInvokeArg_); + } + + /** + * Creates a XInvokeVarg by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * This method is a template method for concrete classes. + * + * @param stack + * @return XInvokeVarg + */ + public XInvokeVarg createXInvokeVarg(RStack stack) { + XInvokeVarg xInvokeVarg_ = createXInvokeVarg(); + xInvokeVarg_.setup(stack); + return (xInvokeVarg_); + } + + /** + * Creates a XInvoke by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * This method is a template method for concrete classes. + * + * @param stack + * @return XInvoke + */ + public XInvoke createXInvoke(RStack stack) { + XInvoke xInvoke_ = createXInvoke(); + xInvoke_.setup(stack); + return (xInvoke_); + } + + /** + * Creates a XInclude by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * This method is a template method for concrete classes. + * + * @param stack + * @return XInclude + */ + public XInclude createXInclude(RStack stack) { + XInclude xInclude_ = createXInclude(); + xInclude_.setup(stack); + return (xInclude_); + } + + /** + * Creates a XModule by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * This method is a template method for concrete classes. + * + * @param stack + * @return XModule + */ + public XModule createXModule(RStack stack) { + XModule xModule_ = createXModule(); + xModule_.setup(stack); + return (xModule_); + } + + /** + * Creates a XBody by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * This method is a template method for concrete classes. + * + * @param stack + * @return XBody + */ + public XBody createXBody(RStack stack) { + XBody xBody_ = createXBody(); + xBody_.setup(stack); + return (xBody_); + } + + /** + * Creates a XStartGlyphElement by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * This method is a template method for concrete classes. + * + * @param stack + * @return XStartGlyphElement + */ + public XStartGlyphElement createXStartGlyphElement(RStack stack) { + XStartGlyphElement xStartGlyphElement_ = createXStartGlyphElement(); + xStartGlyphElement_.setup(stack); + return (xStartGlyphElement_); + } + + /** + * Creates a XControlPoint by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * This method is a template method for concrete classes. + * + * @param stack + * @return XControlPoint + */ + public XControlPoint createXControlPoint(RStack stack) { + XControlPoint xControlPoint_ = createXControlPoint(); + xControlPoint_.setup(stack); + return (xControlPoint_); + } + + /** + * Creates a XHint by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * This method is a template method for concrete classes. + * + * @param stack + * @return XHint + */ + public XHint createXHint(RStack stack) { + XHint xHint_ = createXHint(); + xHint_.setup(stack); + return (xHint_); + } + + /** + * Creates a XContourPoint by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * This method is a template method for concrete classes. + * + * @param stack + * @return XContourPoint + */ + public XContourPoint createXContourPoint(RStack stack) { + XContourPoint xContourPoint_ = createXContourPoint(); + xContourPoint_.setup(stack); + return (xContourPoint_); + } + + /** + * Creates a XParamList by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * This method is a template method for concrete classes. + * + * @param stack + * @return XParamList + */ + public XParamList createXParamList(RStack stack) { + XParamList xParamList_ = createXParamList(); + xParamList_.setup(stack); + return (xParamList_); + } + + /** + * Creates a XParamList by the object source. + * This method is a template method for concrete classes. + * + * @param source + * @return XParamList + */ + public XParamList createXParamList(XParamList source) { + XParamList xParamList_ = createXParamList(); + xParamList_.setup(source); + return (xParamList_); + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/xml/DefaultGlyphFactory.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/xml/DefaultGlyphFactory.java new file mode 100644 index 000000000..bf2d11249 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/xml/DefaultGlyphFactory.java @@ -0,0 +1,394 @@ +/* + * The Relaxer artifact + * Copyright (c) 2000-2004, ASAMI Tomoharu, All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package org.doubletype.ossa.xml; + +/** + * DefaultGlyphFactory is generated by Relaxer based on glyph.rng. + * + * @version glyph.rng 1.0 (Tue Nov 09 20:22:48 EST 2004) + * @author Relaxer 1.1b (http://www.relaxer.org) + */ +public class DefaultGlyphFactory extends AbstractGlyphFactory { + + /** + * Gets a Class of XParamListParam. + * + * @return Class + */ + public Class getXParamListParamClass() { + return (XParamListParam.class); + } + + /** + * Gets a Class of XHeadGlobal. + * + * @return Class + */ + public Class getXHeadGlobalClass() { + return (XHeadGlobal.class); + } + + /** + * Gets a Class of XHeadLocal. + * + * @return Class + */ + public Class getXHeadLocalClass() { + return (XHeadLocal.class); + } + + /** + * Gets a Class of XHead. + * + * @return Class + */ + public Class getXHeadClass() { + return (XHead.class); + } + + /** + * Gets a Class of XGlyphFile. + * + * @return Class + */ + public Class getXGlyphFileClass() { + return (XGlyphFile.class); + } + + /** + * Gets a Class of XContour. + * + * @return Class + */ + public Class getXContourClass() { + return (XContour.class); + } + + /** + * Gets a Class of XPoint2d. + * + * @return Class + */ + public Class getXPoint2dClass() { + return (XPoint2d.class); + } + + /** + * Gets a Class of XInvokePos. + * + * @return Class + */ + public Class getXInvokePosClass() { + return (XInvokePos.class); + } + + /** + * Gets a Class of XInvokeArg. + * + * @return Class + */ + public Class getXInvokeArgClass() { + return (XInvokeArg.class); + } + + /** + * Gets a Class of XInvokeVarg. + * + * @return Class + */ + public Class getXInvokeVargClass() { + return (XInvokeVarg.class); + } + + /** + * Gets a Class of XInvoke. + * + * @return Class + */ + public Class getXInvokeClass() { + return (XInvoke.class); + } + + /** + * Gets a Class of XInclude. + * + * @return Class + */ + public Class getXIncludeClass() { + return (XInclude.class); + } + + /** + * Gets a Class of XModule. + * + * @return Class + */ + public Class getXModuleClass() { + return (XModule.class); + } + + /** + * Gets a Class of XBody. + * + * @return Class + */ + public Class getXBodyClass() { + return (XBody.class); + } + + /** + * Gets a Class of XStartGlyphElement. + * + * @return Class + */ + public Class getXStartGlyphElementClass() { + return (XStartGlyphElement.class); + } + + /** + * Gets a Class of XControlPoint. + * + * @return Class + */ + public Class getXControlPointClass() { + return (XControlPoint.class); + } + + /** + * Gets a Class of XHint. + * + * @return Class + */ + public Class getXHintClass() { + return (XHint.class); + } + + /** + * Gets a Class of XContourPoint. + * + * @return Class + */ + public Class getXContourPointClass() { + return (XContourPoint.class); + } + + /** + * Gets a Class of XParamList. + * + * @return Class + */ + public Class getXParamListClass() { + return (XParamList.class); + } + + /** + * Creates a default XParamListParam. + * This method is a hook method of the AbstractGlyphFactory. + * + * @return XParamListParam + */ + public XParamListParam createXParamListParam() { + return (new XParamListParam()); + } + + /** + * Creates a default XHeadGlobal. + * This method is a hook method of the AbstractGlyphFactory. + * + * @return XHeadGlobal + */ + public XHeadGlobal createXHeadGlobal() { + return (new XHeadGlobal()); + } + + /** + * Creates a default XHeadLocal. + * This method is a hook method of the AbstractGlyphFactory. + * + * @return XHeadLocal + */ + public XHeadLocal createXHeadLocal() { + return (new XHeadLocal()); + } + + /** + * Creates a default XHead. + * This method is a hook method of the AbstractGlyphFactory. + * + * @return XHead + */ + public XHead createXHead() { + return (new XHead()); + } + + /** + * Creates a default XGlyphFile. + * This method is a hook method of the AbstractGlyphFactory. + * + * @return XGlyphFile + */ + public XGlyphFile createXGlyphFile() { + return (new XGlyphFile()); + } + + /** + * Creates a default XContour. + * This method is a hook method of the AbstractGlyphFactory. + * + * @return XContour + */ + public XContour createXContour() { + return (new XContour()); + } + + /** + * Creates a default XPoint2d. + * This method is a hook method of the AbstractGlyphFactory. + * + * @return XPoint2d + */ + public XPoint2d createXPoint2d() { + return (new XPoint2d()); + } + + /** + * Creates a default XInvokePos. + * This method is a hook method of the AbstractGlyphFactory. + * + * @return XInvokePos + */ + public XInvokePos createXInvokePos() { + return (new XInvokePos()); + } + + /** + * Creates a default XInvokeArg. + * This method is a hook method of the AbstractGlyphFactory. + * + * @return XInvokeArg + */ + public XInvokeArg createXInvokeArg() { + return (new XInvokeArg()); + } + + /** + * Creates a default XInvokeVarg. + * This method is a hook method of the AbstractGlyphFactory. + * + * @return XInvokeVarg + */ + public XInvokeVarg createXInvokeVarg() { + return (new XInvokeVarg()); + } + + /** + * Creates a default XInvoke. + * This method is a hook method of the AbstractGlyphFactory. + * + * @return XInvoke + */ + public XInvoke createXInvoke() { + return (new XInvoke()); + } + + /** + * Creates a default XInclude. + * This method is a hook method of the AbstractGlyphFactory. + * + * @return XInclude + */ + public XInclude createXInclude() { + return (new XInclude()); + } + + /** + * Creates a default XModule. + * This method is a hook method of the AbstractGlyphFactory. + * + * @return XModule + */ + public XModule createXModule() { + return (new XModule()); + } + + /** + * Creates a default XBody. + * This method is a hook method of the AbstractGlyphFactory. + * + * @return XBody + */ + public XBody createXBody() { + return (new XBody()); + } + + /** + * Creates a default XStartGlyphElement. + * This method is a hook method of the AbstractGlyphFactory. + * + * @return XStartGlyphElement + */ + public XStartGlyphElement createXStartGlyphElement() { + return (new XStartGlyphElement()); + } + + /** + * Creates a default XControlPoint. + * This method is a hook method of the AbstractGlyphFactory. + * + * @return XControlPoint + */ + public XControlPoint createXControlPoint() { + return (new XControlPoint()); + } + + /** + * Creates a default XHint. + * This method is a hook method of the AbstractGlyphFactory. + * + * @return XHint + */ + public XHint createXHint() { + return (new XHint()); + } + + /** + * Creates a default XContourPoint. + * This method is a hook method of the AbstractGlyphFactory. + * + * @return XContourPoint + */ + public XContourPoint createXContourPoint() { + return (new XContourPoint()); + } + + /** + * Creates a default XParamList. + * This method is a hook method of the AbstractGlyphFactory. + * + * @return XParamList + */ + public XParamList createXParamList() { + return (new XParamList()); + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/xml/GlyphFactory.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/xml/GlyphFactory.java new file mode 100644 index 000000000..b9c5ae8bf --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/xml/GlyphFactory.java @@ -0,0 +1,55 @@ +/* + * The Relaxer artifact + * Copyright (c) 2000-2004, ASAMI Tomoharu, All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package org.doubletype.ossa.xml; + +/** + * GlyphFactory is generated by Relaxer based on glyph.rng. + * + * @version glyph.rng 1.0 (Tue Nov 09 20:22:48 EST 2004) + * @author Relaxer 1.1b (http://www.relaxer.org) + */ +public class GlyphFactory { + private static IGlyphFactory factory; + + /** + * Sets a factory. + * + * @param newFactory + */ + public static void setFactory(IGlyphFactory newFactory) { + factory = newFactory; + } + + /** + * Gets the factory. + * + * @return IGlyphFactory + */ + public static IGlyphFactory getFactory() { + if (factory == null) { + factory = new DefaultGlyphFactory(); + } + return (factory); + } +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/xml/IGlyphFactory.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/xml/IGlyphFactory.java new file mode 100644 index 000000000..36547070c --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/xml/IGlyphFactory.java @@ -0,0 +1,2279 @@ +/* + * The Relaxer artifact + * Copyright (c) 2000-2004, ASAMI Tomoharu, All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package org.doubletype.ossa.xml; + +import java.io.*; +import java.net.URL; +import javax.xml.parsers.*; +import org.w3c.dom.*; +import org.xml.sax.*; + +/** + * IGlyphFactory is generated by Relaxer based on glyph.rng. + * + * @version glyph.rng 1.0 (Tue Nov 09 20:22:48 EST 2004) + * @author Relaxer 1.1b (http://www.relaxer.org) + */ +public interface IGlyphFactory { + /** + * Gets a Class of XParamListParam. + * + * @return Class + */ + Class getXParamListParamClass(); + + /** + * Gets a Class of XHeadGlobal. + * + * @return Class + */ + Class getXHeadGlobalClass(); + + /** + * Gets a Class of XHeadLocal. + * + * @return Class + */ + Class getXHeadLocalClass(); + + /** + * Gets a Class of XHead. + * + * @return Class + */ + Class getXHeadClass(); + + /** + * Gets a Class of XGlyphFile. + * + * @return Class + */ + Class getXGlyphFileClass(); + + /** + * Gets a Class of XContour. + * + * @return Class + */ + Class getXContourClass(); + + /** + * Gets a Class of XPoint2d. + * + * @return Class + */ + Class getXPoint2dClass(); + + /** + * Gets a Class of XInvokePos. + * + * @return Class + */ + Class getXInvokePosClass(); + + /** + * Gets a Class of XInvokeArg. + * + * @return Class + */ + Class getXInvokeArgClass(); + + /** + * Gets a Class of XInvokeVarg. + * + * @return Class + */ + Class getXInvokeVargClass(); + + /** + * Gets a Class of XInvoke. + * + * @return Class + */ + Class getXInvokeClass(); + + /** + * Gets a Class of XInclude. + * + * @return Class + */ + Class getXIncludeClass(); + + /** + * Gets a Class of XModule. + * + * @return Class + */ + Class getXModuleClass(); + + /** + * Gets a Class of XBody. + * + * @return Class + */ + Class getXBodyClass(); + + /** + * Gets a Class of XStartGlyphElement. + * + * @return Class + */ + Class getXStartGlyphElementClass(); + + /** + * Gets a Class of XControlPoint. + * + * @return Class + */ + Class getXControlPointClass(); + + /** + * Gets a Class of XHint. + * + * @return Class + */ + Class getXHintClass(); + + /** + * Gets a Class of XContourPoint. + * + * @return Class + */ + Class getXContourPointClass(); + + /** + * Gets a Class of XParamList. + * + * @return Class + */ + Class getXParamListClass(); + + /** + * Sets a errorHandler. + * + * @param errorHandler + */ + void setErrorHandler(org.xml.sax.ErrorHandler errorHandler); + + /** + * Gets a errorHandler. + * + * @return org.xml.sax.ErrorHandler + */ + org.xml.sax.ErrorHandler getErrorHandler(); + + /** + * Sets a entityResolver. + * + * @param entityResolver + */ + void setEntityResolver(org.xml.sax.EntityResolver entityResolver); + + /** + * Gets a entityResolver. + * + * @return org.xml.sax.EntityResolver + */ + org.xml.sax.EntityResolver getEntityResolver(); + + /** + * Sets a baseUri. + * + * @param baseUri + */ + void setBaseUri(String baseUri); + + /** + * Gets a baseUri. + * + * @return String + */ + String getBaseUri(); + + /** + * Creates a Object by the File file. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return Object + */ + Object create(File file) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a Object by the String representation of URI uri. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return Object + */ + Object create(String uri) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a Object by the URL url. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return Object + */ + Object create(URL url) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a Object by the InputStream in. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return Object + */ + Object create(InputStream in) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a Object by the InputSource is. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return Object + */ + Object create(InputSource is) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a Object by the Reader reader. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return Object + */ + Object create(Reader reader) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a Object by the Object source. + * + * @param source + * @return Object + */ + Object create(Object source); + + /** + * Creates a Object by the Document dom. + * + * @param doc + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return Object + */ + Object create(Document doc) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a Object by the Element element. + * + * @param element + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return Object + */ + Object create(Element element) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XParamListParam by the File file. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XParamListParam + */ + XParamListParam createXParamListParam(File file) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XHeadGlobal by the File file. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHeadGlobal + */ + XHeadGlobal createXHeadGlobal(File file) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XHeadLocal by the File file. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHeadLocal + */ + XHeadLocal createXHeadLocal(File file) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XHead by the File file. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHead + */ + XHead createXHead(File file) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XGlyphFile by the File file. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XGlyphFile + */ + XGlyphFile createXGlyphFile(File file) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XContour by the File file. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XContour + */ + XContour createXContour(File file) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XPoint2d by the File file. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XPoint2d + */ + XPoint2d createXPoint2d(File file) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XInvokePos by the File file. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokePos + */ + XInvokePos createXInvokePos(File file) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XInvokeArg by the File file. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokeArg + */ + XInvokeArg createXInvokeArg(File file) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XInvokeVarg by the File file. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokeVarg + */ + XInvokeVarg createXInvokeVarg(File file) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XInvoke by the File file. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvoke + */ + XInvoke createXInvoke(File file) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XInclude by the File file. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInclude + */ + XInclude createXInclude(File file) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XModule by the File file. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XModule + */ + XModule createXModule(File file) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XBody by the File file. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XBody + */ + XBody createXBody(File file) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XStartGlyphElement by the File file. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XStartGlyphElement + */ + XStartGlyphElement createXStartGlyphElement(File file) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XControlPoint by the File file. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XControlPoint + */ + XControlPoint createXControlPoint(File file) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XHint by the File file. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHint + */ + XHint createXHint(File file) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XContourPoint by the File file. + * + * @param file + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XContourPoint + */ + XContourPoint createXContourPoint(File file) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XParamListParam + * by the String representation of URI uri. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XParamListParam + */ + XParamListParam createXParamListParam(String uri) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XHeadGlobal + * by the String representation of URI uri. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHeadGlobal + */ + XHeadGlobal createXHeadGlobal(String uri) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XHeadLocal + * by the String representation of URI uri. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHeadLocal + */ + XHeadLocal createXHeadLocal(String uri) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XHead + * by the String representation of URI uri. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHead + */ + XHead createXHead(String uri) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XGlyphFile + * by the String representation of URI uri. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XGlyphFile + */ + XGlyphFile createXGlyphFile(String uri) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XContour + * by the String representation of URI uri. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XContour + */ + XContour createXContour(String uri) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XPoint2d + * by the String representation of URI uri. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XPoint2d + */ + XPoint2d createXPoint2d(String uri) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XInvokePos + * by the String representation of URI uri. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokePos + */ + XInvokePos createXInvokePos(String uri) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XInvokeArg + * by the String representation of URI uri. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokeArg + */ + XInvokeArg createXInvokeArg(String uri) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XInvokeVarg + * by the String representation of URI uri. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokeVarg + */ + XInvokeVarg createXInvokeVarg(String uri) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XInvoke + * by the String representation of URI uri. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvoke + */ + XInvoke createXInvoke(String uri) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XInclude + * by the String representation of URI uri. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInclude + */ + XInclude createXInclude(String uri) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XModule + * by the String representation of URI uri. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XModule + */ + XModule createXModule(String uri) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XBody + * by the String representation of URI uri. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XBody + */ + XBody createXBody(String uri) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XStartGlyphElement + * by the String representation of URI uri. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XStartGlyphElement + */ + XStartGlyphElement createXStartGlyphElement(String uri) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XControlPoint + * by the String representation of URI uri. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XControlPoint + */ + XControlPoint createXControlPoint(String uri) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XHint + * by the String representation of URI uri. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHint + */ + XHint createXHint(String uri) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XContourPoint + * by the String representation of URI uri. + * + * @param uri + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XContourPoint + */ + XContourPoint createXContourPoint(String uri) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XParamListParam by the URL url. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XParamListParam + */ + XParamListParam createXParamListParam(URL url) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XHeadGlobal by the URL url. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHeadGlobal + */ + XHeadGlobal createXHeadGlobal(URL url) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XHeadLocal by the URL url. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHeadLocal + */ + XHeadLocal createXHeadLocal(URL url) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XHead by the URL url. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHead + */ + XHead createXHead(URL url) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XGlyphFile by the URL url. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XGlyphFile + */ + XGlyphFile createXGlyphFile(URL url) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XContour by the URL url. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XContour + */ + XContour createXContour(URL url) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XPoint2d by the URL url. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XPoint2d + */ + XPoint2d createXPoint2d(URL url) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XInvokePos by the URL url. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokePos + */ + XInvokePos createXInvokePos(URL url) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XInvokeArg by the URL url. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokeArg + */ + XInvokeArg createXInvokeArg(URL url) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XInvokeVarg by the URL url. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokeVarg + */ + XInvokeVarg createXInvokeVarg(URL url) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XInvoke by the URL url. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvoke + */ + XInvoke createXInvoke(URL url) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XInclude by the URL url. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInclude + */ + XInclude createXInclude(URL url) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XModule by the URL url. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XModule + */ + XModule createXModule(URL url) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XBody by the URL url. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XBody + */ + XBody createXBody(URL url) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XStartGlyphElement by the URL url. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XStartGlyphElement + */ + XStartGlyphElement createXStartGlyphElement(URL url) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XControlPoint by the URL url. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XControlPoint + */ + XControlPoint createXControlPoint(URL url) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XHint by the URL url. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHint + */ + XHint createXHint(URL url) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XContourPoint by the URL url. + * + * @param url + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XContourPoint + */ + XContourPoint createXContourPoint(URL url) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XParamListParam by the InputStream in. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XParamListParam + */ + XParamListParam createXParamListParam(InputStream in) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XHeadGlobal by the InputStream in. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHeadGlobal + */ + XHeadGlobal createXHeadGlobal(InputStream in) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XHeadLocal by the InputStream in. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHeadLocal + */ + XHeadLocal createXHeadLocal(InputStream in) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XHead by the InputStream in. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHead + */ + XHead createXHead(InputStream in) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XGlyphFile by the InputStream in. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XGlyphFile + */ + XGlyphFile createXGlyphFile(InputStream in) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XContour by the InputStream in. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XContour + */ + XContour createXContour(InputStream in) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XPoint2d by the InputStream in. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XPoint2d + */ + XPoint2d createXPoint2d(InputStream in) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XInvokePos by the InputStream in. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokePos + */ + XInvokePos createXInvokePos(InputStream in) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XInvokeArg by the InputStream in. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokeArg + */ + XInvokeArg createXInvokeArg(InputStream in) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XInvokeVarg by the InputStream in. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokeVarg + */ + XInvokeVarg createXInvokeVarg(InputStream in) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XInvoke by the InputStream in. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvoke + */ + XInvoke createXInvoke(InputStream in) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XInclude by the InputStream in. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInclude + */ + XInclude createXInclude(InputStream in) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XModule by the InputStream in. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XModule + */ + XModule createXModule(InputStream in) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XBody by the InputStream in. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XBody + */ + XBody createXBody(InputStream in) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XStartGlyphElement by the InputStream in. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XStartGlyphElement + */ + XStartGlyphElement createXStartGlyphElement(InputStream in) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XControlPoint by the InputStream in. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XControlPoint + */ + XControlPoint createXControlPoint(InputStream in) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XHint by the InputStream in. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHint + */ + XHint createXHint(InputStream in) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XContourPoint by the InputStream in. + * + * @param in + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XContourPoint + */ + XContourPoint createXContourPoint(InputStream in) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XParamListParam by the InputSource is. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XParamListParam + */ + XParamListParam createXParamListParam(InputSource is) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XHeadGlobal by the InputSource is. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHeadGlobal + */ + XHeadGlobal createXHeadGlobal(InputSource is) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XHeadLocal by the InputSource is. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHeadLocal + */ + XHeadLocal createXHeadLocal(InputSource is) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XHead by the InputSource is. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHead + */ + XHead createXHead(InputSource is) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XGlyphFile by the InputSource is. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XGlyphFile + */ + XGlyphFile createXGlyphFile(InputSource is) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XContour by the InputSource is. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XContour + */ + XContour createXContour(InputSource is) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XPoint2d by the InputSource is. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XPoint2d + */ + XPoint2d createXPoint2d(InputSource is) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XInvokePos by the InputSource is. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokePos + */ + XInvokePos createXInvokePos(InputSource is) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XInvokeArg by the InputSource is. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokeArg + */ + XInvokeArg createXInvokeArg(InputSource is) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XInvokeVarg by the InputSource is. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokeVarg + */ + XInvokeVarg createXInvokeVarg(InputSource is) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XInvoke by the InputSource is. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvoke + */ + XInvoke createXInvoke(InputSource is) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XInclude by the InputSource is. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInclude + */ + XInclude createXInclude(InputSource is) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XModule by the InputSource is. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XModule + */ + XModule createXModule(InputSource is) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XBody by the InputSource is. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XBody + */ + XBody createXBody(InputSource is) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XStartGlyphElement by the InputSource is. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XStartGlyphElement + */ + XStartGlyphElement createXStartGlyphElement(InputSource is) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XControlPoint by the InputSource is. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XControlPoint + */ + XControlPoint createXControlPoint(InputSource is) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XHint by the InputSource is. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHint + */ + XHint createXHint(InputSource is) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XContourPoint by the InputSource is. + * + * @param is + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XContourPoint + */ + XContourPoint createXContourPoint(InputSource is) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XParamListParam by the Reader reader. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XParamListParam + */ + XParamListParam createXParamListParam(Reader reader) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XHeadGlobal by the Reader reader. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHeadGlobal + */ + XHeadGlobal createXHeadGlobal(Reader reader) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XHeadLocal by the Reader reader. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHeadLocal + */ + XHeadLocal createXHeadLocal(Reader reader) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XHead by the Reader reader. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHead + */ + XHead createXHead(Reader reader) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XGlyphFile by the Reader reader. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XGlyphFile + */ + XGlyphFile createXGlyphFile(Reader reader) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XContour by the Reader reader. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XContour + */ + XContour createXContour(Reader reader) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XPoint2d by the Reader reader. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XPoint2d + */ + XPoint2d createXPoint2d(Reader reader) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XInvokePos by the Reader reader. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokePos + */ + XInvokePos createXInvokePos(Reader reader) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XInvokeArg by the Reader reader. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokeArg + */ + XInvokeArg createXInvokeArg(Reader reader) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XInvokeVarg by the Reader reader. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvokeVarg + */ + XInvokeVarg createXInvokeVarg(Reader reader) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XInvoke by the Reader reader. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInvoke + */ + XInvoke createXInvoke(Reader reader) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XInclude by the Reader reader. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XInclude + */ + XInclude createXInclude(Reader reader) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XModule by the Reader reader. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XModule + */ + XModule createXModule(Reader reader) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XBody by the Reader reader. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XBody + */ + XBody createXBody(Reader reader) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XStartGlyphElement by the Reader reader. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XStartGlyphElement + */ + XStartGlyphElement createXStartGlyphElement(Reader reader) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XControlPoint by the Reader reader. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XControlPoint + */ + XControlPoint createXControlPoint(Reader reader) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XHint by the Reader reader. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XHint + */ + XHint createXHint(Reader reader) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XContourPoint by the Reader reader. + * + * @param reader + * @exception IOException + * @exception SAXException + * @exception ParserConfigurationException + * @return XContourPoint + */ + XContourPoint createXContourPoint(Reader reader) throws IOException, SAXException, ParserConfigurationException; + + /** + * Creates a XParamListParam. + * + * @return XParamListParam + */ + XParamListParam createXParamListParam(); + + /** + * Creates a XHeadGlobal. + * + * @return XHeadGlobal + */ + XHeadGlobal createXHeadGlobal(); + + /** + * Creates a XHeadLocal. + * + * @return XHeadLocal + */ + XHeadLocal createXHeadLocal(); + + /** + * Creates a XHead. + * + * @return XHead + */ + XHead createXHead(); + + /** + * Creates a XGlyphFile. + * + * @return XGlyphFile + */ + XGlyphFile createXGlyphFile(); + + /** + * Creates a XContour. + * + * @return XContour + */ + XContour createXContour(); + + /** + * Creates a XPoint2d. + * + * @return XPoint2d + */ + XPoint2d createXPoint2d(); + + /** + * Creates a XInvokePos. + * + * @return XInvokePos + */ + XInvokePos createXInvokePos(); + + /** + * Creates a XInvokeArg. + * + * @return XInvokeArg + */ + XInvokeArg createXInvokeArg(); + + /** + * Creates a XInvokeVarg. + * + * @return XInvokeVarg + */ + XInvokeVarg createXInvokeVarg(); + + /** + * Creates a XInvoke. + * + * @return XInvoke + */ + XInvoke createXInvoke(); + + /** + * Creates a XInclude. + * + * @return XInclude + */ + XInclude createXInclude(); + + /** + * Creates a XModule. + * + * @return XModule + */ + XModule createXModule(); + + /** + * Creates a XBody. + * + * @return XBody + */ + XBody createXBody(); + + /** + * Creates a XStartGlyphElement. + * + * @return XStartGlyphElement + */ + XStartGlyphElement createXStartGlyphElement(); + + /** + * Creates a XControlPoint. + * + * @return XControlPoint + */ + XControlPoint createXControlPoint(); + + /** + * Creates a XHint. + * + * @return XHint + */ + XHint createXHint(); + + /** + * Creates a XContourPoint. + * + * @return XContourPoint + */ + XContourPoint createXContourPoint(); + + /** + * Creates a XParamListParam by the XParamListParam source. + * + * @param source + * @return XParamListParam + */ + XParamListParam createXParamListParam(XParamListParam source); + + /** + * Creates a XHeadGlobal by the XHeadGlobal source. + * + * @param source + * @return XHeadGlobal + */ + XHeadGlobal createXHeadGlobal(XHeadGlobal source); + + /** + * Creates a XHeadLocal by the XHeadLocal source. + * + * @param source + * @return XHeadLocal + */ + XHeadLocal createXHeadLocal(XHeadLocal source); + + /** + * Creates a XHead by the XHead source. + * + * @param source + * @return XHead + */ + XHead createXHead(XHead source); + + /** + * Creates a XGlyphFile by the XGlyphFile source. + * + * @param source + * @return XGlyphFile + */ + XGlyphFile createXGlyphFile(XGlyphFile source); + + /** + * Creates a XContour by the XContour source. + * + * @param source + * @return XContour + */ + XContour createXContour(XContour source); + + /** + * Creates a XPoint2d by the XPoint2d source. + * + * @param source + * @return XPoint2d + */ + XPoint2d createXPoint2d(XPoint2d source); + + /** + * Creates a XInvokePos by the XInvokePos source. + * + * @param source + * @return XInvokePos + */ + XInvokePos createXInvokePos(XInvokePos source); + + /** + * Creates a XInvokeArg by the XInvokeArg source. + * + * @param source + * @return XInvokeArg + */ + XInvokeArg createXInvokeArg(XInvokeArg source); + + /** + * Creates a XInvokeVarg by the XInvokeVarg source. + * + * @param source + * @return XInvokeVarg + */ + XInvokeVarg createXInvokeVarg(XInvokeVarg source); + + /** + * Creates a XInvoke by the XInvoke source. + * + * @param source + * @return XInvoke + */ + XInvoke createXInvoke(XInvoke source); + + /** + * Creates a XInclude by the XInclude source. + * + * @param source + * @return XInclude + */ + XInclude createXInclude(XInclude source); + + /** + * Creates a XModule by the XModule source. + * + * @param source + * @return XModule + */ + XModule createXModule(XModule source); + + /** + * Creates a XBody by the XBody source. + * + * @param source + * @return XBody + */ + XBody createXBody(XBody source); + + /** + * Creates a XStartGlyphElement by the XStartGlyphElement source. + * + * @param source + * @return XStartGlyphElement + */ + XStartGlyphElement createXStartGlyphElement(XStartGlyphElement source); + + /** + * Creates a XControlPoint by the XControlPoint source. + * + * @param source + * @return XControlPoint + */ + XControlPoint createXControlPoint(XControlPoint source); + + /** + * Creates a XHint by the XHint source. + * + * @param source + * @return XHint + */ + XHint createXHint(XHint source); + + /** + * Creates a XContourPoint by the XContourPoint source. + * + * @param source + * @return XContourPoint + */ + XContourPoint createXContourPoint(XContourPoint source); + + /** + * Creates a XParamListParam by the Document doc. + * + * @param doc + * @return XParamListParam + */ + XParamListParam createXParamListParam(Document doc); + + /** + * Creates a XHeadGlobal by the Document doc. + * + * @param doc + * @return XHeadGlobal + */ + XHeadGlobal createXHeadGlobal(Document doc); + + /** + * Creates a XHeadLocal by the Document doc. + * + * @param doc + * @return XHeadLocal + */ + XHeadLocal createXHeadLocal(Document doc); + + /** + * Creates a XHead by the Document doc. + * + * @param doc + * @return XHead + */ + XHead createXHead(Document doc); + + /** + * Creates a XGlyphFile by the Document doc. + * + * @param doc + * @return XGlyphFile + */ + XGlyphFile createXGlyphFile(Document doc); + + /** + * Creates a XContour by the Document doc. + * + * @param doc + * @return XContour + */ + XContour createXContour(Document doc); + + /** + * Creates a XPoint2d by the Document doc. + * + * @param doc + * @return XPoint2d + */ + XPoint2d createXPoint2d(Document doc); + + /** + * Creates a XInvokePos by the Document doc. + * + * @param doc + * @return XInvokePos + */ + XInvokePos createXInvokePos(Document doc); + + /** + * Creates a XInvokeArg by the Document doc. + * + * @param doc + * @return XInvokeArg + */ + XInvokeArg createXInvokeArg(Document doc); + + /** + * Creates a XInvokeVarg by the Document doc. + * + * @param doc + * @return XInvokeVarg + */ + XInvokeVarg createXInvokeVarg(Document doc); + + /** + * Creates a XInvoke by the Document doc. + * + * @param doc + * @return XInvoke + */ + XInvoke createXInvoke(Document doc); + + /** + * Creates a XInclude by the Document doc. + * + * @param doc + * @return XInclude + */ + XInclude createXInclude(Document doc); + + /** + * Creates a XModule by the Document doc. + * + * @param doc + * @return XModule + */ + XModule createXModule(Document doc); + + /** + * Creates a XBody by the Document doc. + * + * @param doc + * @return XBody + */ + XBody createXBody(Document doc); + + /** + * Creates a XStartGlyphElement by the Document doc. + * + * @param doc + * @return XStartGlyphElement + */ + XStartGlyphElement createXStartGlyphElement(Document doc); + + /** + * Creates a XControlPoint by the Document doc. + * + * @param doc + * @return XControlPoint + */ + XControlPoint createXControlPoint(Document doc); + + /** + * Creates a XHint by the Document doc. + * + * @param doc + * @return XHint + */ + XHint createXHint(Document doc); + + /** + * Creates a XContourPoint by the Document doc. + * + * @param doc + * @return XContourPoint + */ + XContourPoint createXContourPoint(Document doc); + + /** + * Creates a XParamListParam by the Element element. + * + * @param element + * @return XParamListParam + */ + XParamListParam createXParamListParam(Element element); + + /** + * Creates a XHeadGlobal by the Element element. + * + * @param element + * @return XHeadGlobal + */ + XHeadGlobal createXHeadGlobal(Element element); + + /** + * Creates a XHeadLocal by the Element element. + * + * @param element + * @return XHeadLocal + */ + XHeadLocal createXHeadLocal(Element element); + + /** + * Creates a XHead by the Element element. + * + * @param element + * @return XHead + */ + XHead createXHead(Element element); + + /** + * Creates a XGlyphFile by the Element element. + * + * @param element + * @return XGlyphFile + */ + XGlyphFile createXGlyphFile(Element element); + + /** + * Creates a XContour by the Element element. + * + * @param element + * @return XContour + */ + XContour createXContour(Element element); + + /** + * Creates a XPoint2d by the Element element. + * + * @param element + * @return XPoint2d + */ + XPoint2d createXPoint2d(Element element); + + /** + * Creates a XInvokePos by the Element element. + * + * @param element + * @return XInvokePos + */ + XInvokePos createXInvokePos(Element element); + + /** + * Creates a XInvokeArg by the Element element. + * + * @param element + * @return XInvokeArg + */ + XInvokeArg createXInvokeArg(Element element); + + /** + * Creates a XInvokeVarg by the Element element. + * + * @param element + * @return XInvokeVarg + */ + XInvokeVarg createXInvokeVarg(Element element); + + /** + * Creates a XInvoke by the Element element. + * + * @param element + * @return XInvoke + */ + XInvoke createXInvoke(Element element); + + /** + * Creates a XInclude by the Element element. + * + * @param element + * @return XInclude + */ + XInclude createXInclude(Element element); + + /** + * Creates a XModule by the Element element. + * + * @param element + * @return XModule + */ + XModule createXModule(Element element); + + /** + * Creates a XBody by the Element element. + * + * @param element + * @return XBody + */ + XBody createXBody(Element element); + + /** + * Creates a XStartGlyphElement by the Element element. + * + * @param element + * @return XStartGlyphElement + */ + XStartGlyphElement createXStartGlyphElement(Element element); + + /** + * Creates a XControlPoint by the Element element. + * + * @param element + * @return XControlPoint + */ + XControlPoint createXControlPoint(Element element); + + /** + * Creates a XHint by the Element element. + * + * @param element + * @return XHint + */ + XHint createXHint(Element element); + + /** + * Creates a XContourPoint by the Element element. + * + * @param element + * @return XContourPoint + */ + XContourPoint createXContourPoint(Element element); + + /** + * Creates a XParamListParam by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * + * @param stack + * @return XParamListParam + */ + XParamListParam createXParamListParam(RStack stack); + + /** + * Creates a XHeadGlobal by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * + * @param stack + * @return XHeadGlobal + */ + XHeadGlobal createXHeadGlobal(RStack stack); + + /** + * Creates a XHeadLocal by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * + * @param stack + * @return XHeadLocal + */ + XHeadLocal createXHeadLocal(RStack stack); + + /** + * Creates a XHead by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * + * @param stack + * @return XHead + */ + XHead createXHead(RStack stack); + + /** + * Creates a XGlyphFile by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * + * @param stack + * @return XGlyphFile + */ + XGlyphFile createXGlyphFile(RStack stack); + + /** + * Creates a XContour by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * + * @param stack + * @return XContour + */ + XContour createXContour(RStack stack); + + /** + * Creates a XPoint2d by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * + * @param stack + * @return XPoint2d + */ + XPoint2d createXPoint2d(RStack stack); + + /** + * Creates a XInvokePos by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * + * @param stack + * @return XInvokePos + */ + XInvokePos createXInvokePos(RStack stack); + + /** + * Creates a XInvokeArg by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * + * @param stack + * @return XInvokeArg + */ + XInvokeArg createXInvokeArg(RStack stack); + + /** + * Creates a XInvokeVarg by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * + * @param stack + * @return XInvokeVarg + */ + XInvokeVarg createXInvokeVarg(RStack stack); + + /** + * Creates a XInvoke by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * + * @param stack + * @return XInvoke + */ + XInvoke createXInvoke(RStack stack); + + /** + * Creates a XInclude by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * + * @param stack + * @return XInclude + */ + XInclude createXInclude(RStack stack); + + /** + * Creates a XModule by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * + * @param stack + * @return XModule + */ + XModule createXModule(RStack stack); + + /** + * Creates a XBody by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * + * @param stack + * @return XBody + */ + XBody createXBody(RStack stack); + + /** + * Creates a XStartGlyphElement by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * + * @param stack + * @return XStartGlyphElement + */ + XStartGlyphElement createXStartGlyphElement(RStack stack); + + /** + * Creates a XControlPoint by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * + * @param stack + * @return XControlPoint + */ + XControlPoint createXControlPoint(RStack stack); + + /** + * Creates a XHint by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * + * @param stack + * @return XHint + */ + XHint createXHint(RStack stack); + + /** + * Creates a XContourPoint by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * + * @param stack + * @return XContourPoint + */ + XContourPoint createXContourPoint(RStack stack); + + /** + * Creates a XParamList by the Element element. + * + * @return XParamList + */ + XParamList createXParamList(); + + /** + * Creates a XParamList by the Stack stack. + * This mehtod is supposed to be used internally + * by the Relaxer system. + * + * @param stack + * @return XParamList + */ + XParamList createXParamList(RStack stack); + + /** + * Creates a XParamList by the object source. + * This method is a template method for concrete classes. + * + * @param source + * @return XParamList + */ + XParamList createXParamList(XParamList source); +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/xml/IRNode.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/xml/IRNode.java new file mode 100644 index 000000000..2e513627e --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/xml/IRNode.java @@ -0,0 +1,51 @@ +/* + * The Relaxer artifact + * Copyright (c) 2000-2004, ASAMI Tomoharu, All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package org.doubletype.ossa.xml; + +/** + * @version glyph.rng 1.0 (Tue Nov 09 20:22:48 EST 2004) + * @author Relaxer 1.1b (http://www.relaxer.org) + */ +public interface IRNode { + /** + * Sets parent RNode. + * + * @param parent + */ + void rSetParentRNode(IRNode parent); + + /** + * Gets parent RNode. + * + * @return IRNode + */ + IRNode rGetParentRNode(); + + /** + * Gets child RNodes. + * + * @return IRNode[] + */ + IRNode[] rGetRNodes(); +} diff --git a/trunk/libsrc/ttf/src/org/doubletype/ossa/xml/RInterleave.java b/trunk/libsrc/ttf/src/org/doubletype/ossa/xml/RInterleave.java new file mode 100644 index 000000000..5abbc2c00 --- /dev/null +++ b/trunk/libsrc/ttf/src/org/doubletype/ossa/xml/RInterleave.java @@ -0,0 +1,757 @@ +/* + * The Relaxer artifact + * Copyright (c) 2000-2004, ASAMI Tomoharu, All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package org.doubletype.ossa.xml; + +import java.util.*; +import java.net.URL; +import java.math.*; +import java.lang.reflect.*; +import java.sql.Time; +import java.sql.Timestamp; +import org.w3c.dom.*; + +/** + * RInterleave + * + * @since May. 13, 2002 + * @version Oct. 22, 2003 + * @author ASAMI, Tomoharu (asami@relaxer.org) + */ +@SuppressWarnings("all") +public final class RInterleave { + private RStack rstack_; + private List entries_ = new ArrayList<>(); + private Map entryByStateClass_ = new HashMap<>(); + private Map entryByElementName_ = new HashMap<>(); + private Boolean isMatch_ = null; + + public RInterleave(RStack rstack) { + rstack_ = rstack; + } + + public Object getProperty(Class stateClass) { + StateClassEntry entry = _getEntryByStateClass(stateClass); + return (entry.getObject()); + } + + public Object[] getPropertyList(Class stateClass) { + StateClassEntry entry = _getEntryByStateClass(stateClass); + return (entry.getObjects()); + } + + public String getElementPropertyAsString(String elementName) { + Element element = _getElementByElementName(elementName); + if (element == null) { + return (null); + } + return (URelaxer.getElementPropertyAsString(element)); + } + + public boolean getElementPropertyAsBoolean(String elementName) { + Element element = _getElementByElementName(elementName); + if (element == null) { + return (false); + } + return (URelaxer.getElementPropertyAsBoolean(element)); + } + + public Boolean getElementPropertyAsBooleanObject(String elementName) { + Element element = _getElementByElementName(elementName); + if (element == null) { + return (null); + } + return (URelaxer.getElementPropertyAsBooleanObject(element)); + } + + public byte getElementPropertyAsByte(String elementName) { + Element element = _getElementByElementName(elementName); + if (element == null) { + return (-1); + } + return (URelaxer.getElementPropertyAsByte(element)); + } + + public Byte getElementPropertyAsByteObject(String elementName) { + Element element = _getElementByElementName(elementName); + if (element == null) { + return (null); + } + return (URelaxer.getElementPropertyAsByteObject(element)); + } + + public short getElementPropertyAsShort(String elementName) { + Element element = _getElementByElementName(elementName); + if (element == null) { + return (-1); + } + return (URelaxer.getElementPropertyAsShort(element)); + } + + public Short getElementPropertyAsShortObject(String elementName) { + Element element = _getElementByElementName(elementName); + if (element == null) { + return (null); + } + return (URelaxer.getElementPropertyAsShortObject(element)); + } + + public int getElementPropertyAsInt(String elementName) { + Element element = _getElementByElementName(elementName); + if (element == null) { + return (-1); + } + return (URelaxer.getElementPropertyAsInt(element)); + } + + public Integer getElementPropertyAsIntObject(String elementName) { + Element element = _getElementByElementName(elementName); + if (element == null) { + return (null); + } + return (URelaxer.getElementPropertyAsIntObject(element)); + } + + public long getElementPropertyAsLong(String elementName) { + Element element = _getElementByElementName(elementName); + if (element == null) { + return (-1); + } + return (URelaxer.getElementPropertyAsLong(element)); + } + + public Long getElementPropertyAsLongObject(String elementName) { + Element element = _getElementByElementName(elementName); + if (element == null) { + return (null); + } + return (URelaxer.getElementPropertyAsLongObject(element)); + } + + public float getElementPropertyAsFloat(String elementName) { + Element element = _getElementByElementName(elementName); + if (element == null) { + return (Float.NaN); + } + return (URelaxer.getElementPropertyAsFloat(element)); + } + + public Float getElementPropertyAsFloatObject(String elementName) { + Element element = _getElementByElementName(elementName); + if (element == null) { + return (null); + } + return (URelaxer.getElementPropertyAsFloatObject(element)); + } + + public double getElementPropertyAsDouble(String elementName) { + Element element = _getElementByElementName(elementName); + if (element == null) { + return (Double.NaN); + } + return (URelaxer.getElementPropertyAsDouble(element)); + } + + public Double getElementPropertyAsDoubleObject(String elementName) { + Element element = _getElementByElementName(elementName); + if (element == null) { + return (null); + } + return (URelaxer.getElementPropertyAsDoubleObject(element)); + } + + public BigDecimal getElementPropertyAsBigDecimal(String elementName) { + Element element = _getElementByElementName(elementName); + if (element == null) { + return (null); + } + return (URelaxer.getElementPropertyAsBigDecimal(element)); + } + + public BigInteger getElementPropertyAsBigInteger(String elementName) { + Element element = _getElementByElementName(elementName); + if (element == null) { + return (null); + } + return (URelaxer.getElementPropertyAsBigInteger(element)); + } + + public Date getElementPropertyAsDate(String elementName) { + Element element = _getElementByElementName(elementName); + if (element == null) { + return (null); + } + return (URelaxer.getElementPropertyAsDate(element)); + } + + public Locale getElementPropertyAsLocale(String elementName) { + Element element = _getElementByElementName(elementName); + if (element == null) { + return (null); + } + return (URelaxer.getElementPropertyAsLocale(element)); + } + + public URL getElementPropertyAsURL(String elementName) { + Element element = _getElementByElementName(elementName); + if (element == null) { + return (null); + } + return (URelaxer.getElementPropertyAsURL(element)); + } + + public java.sql.Timestamp getElementPropertyAsSQLTimestamp( + String elementName + ) { + Element element = _getElementByElementName(elementName); + if (element == null) { + return (null); + } + return (URelaxer.getElementPropertyAsSQLTimestamp(element)); + } + + public java.sql.Time getElementPropertyAsSQLTime( + String elementName + ) { + Element element = _getElementByElementName(elementName); + if (element == null) { + return (null); + } + return (URelaxer.getElementPropertyAsSQLTime(element)); + } + + public java.sql.Date getElementPropertyAsSQLDate( + String elementName + ) { + Element element = _getElementByElementName(elementName); + if (element == null) { + return (null); + } + return (URelaxer.getElementPropertyAsSQLDate(element)); + } + + public byte[] getElementPropertyAsBinaryBASE64( + String elementName + ) { + Element element = _getElementByElementName(elementName); + if (element == null) { + return (null); + } + return (URelaxer.getElementPropertyAsBinaryBASE64(element)); + } + + public byte[] getElementPropertyAsBinaryHEX( + String elementName + ) { + Element element = _getElementByElementName(elementName); + if (element == null) { + return (null); + } + return (URelaxer.getElementPropertyAsBinaryHEX(element)); + } + + public List getElementPropertyAsStringList(String elementName) { + List list = _getElementListByElementName(elementName); + int size = list.size(); + List result = new ArrayList<>(); + for (int i = 0;i < size;i++) { + Element element = (Element)list.get(i); + result.add(URelaxer.getElementPropertyAsString(element)); + } + return (result); + } + + public List getElementPropertyAsBooleanList(String elementName) { + List list = _getElementListByElementName(elementName); + int size = list.size(); + List result = new ArrayList<>(); + for (int i = 0;i < size;i++) { + Element element = (Element)list.get(i); + result.add(URelaxer.getElementPropertyAsBooleanObject(element)); + } + return (result); + } + + public List getElementPropertyAsByteList(String elementName) { + List list = _getElementListByElementName(elementName); + int size = list.size(); + List result = new ArrayList<>(); + for (int i = 0;i < size;i++) { + Element element = (Element)list.get(i); + result.add(URelaxer.getElementPropertyAsByteObject(element)); + } + return (result); + } + + public List getElementPropertyAsShortList(String elementName) { + List list = _getElementListByElementName(elementName); + int size = list.size(); + List result = new ArrayList<>(); + for (int i = 0;i < size;i++) { + Element element = (Element)list.get(i); + result.add(URelaxer.getElementPropertyAsShortObject(element)); + } + return (result); + } + + public List getElementPropertyAsIntList(String elementName) { + List list = _getElementListByElementName(elementName); + int size = list.size(); + List result = new ArrayList<>(); + for (int i = 0;i < size;i++) { + Element element = (Element)list.get(i); + result.add(URelaxer.getElementPropertyAsIntObject(element)); + } + return (result); + } + + public List getElementPropertyAsLongList(String elementName) { + List list = _getElementListByElementName(elementName); + int size = list.size(); + List result = new ArrayList<>(); + for (int i = 0;i < size;i++) { + Element element = (Element)list.get(i); + result.add(URelaxer.getElementPropertyAsLongObject(element)); + } + return (result); + } + + public List getElementPropertyAsFloatList(String elementName) { + List list = _getElementListByElementName(elementName); + int size = list.size(); + List result = new ArrayList<>(); + for (int i = 0;i < size;i++) { + Element element = (Element)list.get(i); + result.add(URelaxer.getElementPropertyAsFloatObject(element)); + } + return (result); + } + + public List getElementPropertyAsDoubleList(String elementName) { + List list = _getElementListByElementName(elementName); + int size = list.size(); + List result = new ArrayList<>(); + for (int i = 0;i < size;i++) { + Element element = (Element)list.get(i); + result.add(URelaxer.getElementPropertyAsDoubleObject(element)); + } + return (result); + } + + public List getElementPropertyAsBigDecimalList(String elementName) { + List list = _getElementListByElementName(elementName); + int size = list.size(); + List result = new ArrayList<>(); + for (int i = 0;i < size;i++) { + Element element = (Element)list.get(i); + result.add(URelaxer.getElementPropertyAsBigDecimal(element)); + } + return (result); + } + + public List getElementPropertyAsBigIntegerList(String elementName) { + List list = _getElementListByElementName(elementName); + int size = list.size(); + List result = new ArrayList<>(); + for (int i = 0;i < size;i++) { + Element element = (Element)list.get(i); + result.add(URelaxer.getElementPropertyAsBigInteger(element)); + } + return (result); + } + + public List getElementPropertyAsDateList(String elementName) { + List list = _getElementListByElementName(elementName); + int size = list.size(); + List result = new ArrayList<>(); + for (int i = 0;i < size;i++) { + Element element = (Element)list.get(i); + result.add(URelaxer.getElementPropertyAsDate(element)); + } + return (result); + } + + public List getElementPropertyAsLocaleList(String elementName) { + List list = _getElementListByElementName(elementName); + int size = list.size(); + List result = new ArrayList<>(); + for (int i = 0;i < size;i++) { + Element element = (Element)list.get(i); + result.add(URelaxer.getElementPropertyAsLocale(element)); + } + return (result); + } + + public List getElementPropertyAsURLList(String elementName) { + List list = _getElementListByElementName(elementName); + int size = list.size(); + List result = new ArrayList<>(); + for (int i = 0;i < size;i++) { + Element element = (Element)list.get(i); + result.add(URelaxer.getElementPropertyAsURL(element)); + } + return (result); + } + + public List getElementPropertyAsSQLTimestampList( + String elementName + ) { + List list = _getElementListByElementName(elementName); + int size = list.size(); + List result = new ArrayList<>(); + for (int i = 0;i < size;i++) { + Element element = (Element)list.get(i); + result.add(URelaxer.getElementPropertyAsSQLTimestamp(element)); + } + return (result); + } + + public List