From 2d37d31dcc6a0664181edf47ed978583af9e39e0 Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Sun, 29 Mar 2015 15:16:00 +0200 Subject: [PATCH] reformat ttf source --- lib/ttf.jar | Bin 138651 -> 138375 bytes libsrc/ttf/src/fontastic/FContour.java | 94 +- libsrc/ttf/src/fontastic/FGlyph.java | 147 ++- libsrc/ttf/src/fontastic/FPoint.java | 108 +- libsrc/ttf/src/fontastic/Fontastic.java | 62 +- libsrc/ttf/src/fontatest/FontaTest.java | 22 +- .../ttf/src/org/doubletype/ossa/Engine.java | 357 ++++--- .../doubletype/ossa/OutOfRangeException.java | 98 +- .../doubletype/ossa/adapter/CubicSegment.java | 102 +- .../org/doubletype/ossa/adapter/EContour.java | 82 +- .../ossa/adapter/EContourPoint.java | 134 +-- .../ossa/adapter/EControlPoint.java | 42 +- .../org/doubletype/ossa/adapter/EPoint.java | 89 +- .../ossa/adapter/QuadraticSegment.java | 123 +-- .../org/doubletype/ossa/module/GlyphFile.java | 509 +++++---- .../doubletype/ossa/module/TypefaceFile.java | 966 +++++++++--------- .../doubletype/ossa/truetype/CmapWriter.java | 571 ++++++----- .../ossa/truetype/FontFileWriter.java | 510 ++++----- .../ossa/truetype/FontFormatWriter.java | 275 ++--- .../doubletype/ossa/truetype/GlyfWriter.java | 330 +++--- .../doubletype/ossa/truetype/HdmxWriter.java | 159 +-- .../doubletype/ossa/truetype/HeadWriter.java | 243 ++--- .../doubletype/ossa/truetype/HheaWriter.java | 139 +-- .../doubletype/ossa/truetype/HmtxWriter.java | 102 +- .../doubletype/ossa/truetype/LocaWriter.java | 55 +- .../doubletype/ossa/truetype/MaxpWriter.java | 217 ++-- .../doubletype/ossa/truetype/NameWriter.java | 301 +++--- .../doubletype/ossa/truetype/OS2Writer.java | 459 +++++---- .../doubletype/ossa/truetype/PostWriter.java | 77 +- .../doubletype/ossa/truetype/TTCodePage.java | 273 +++-- .../org/doubletype/ossa/truetype/TTGlyph.java | 755 +++++++------- .../org/doubletype/ossa/truetype/TTName.java | 198 ++-- .../doubletype/ossa/truetype/TTPixelSize.java | 209 ++-- .../ossa/truetype/TTUnicodeRange.java | 673 ++++++------ 34 files changed, 4330 insertions(+), 4151 deletions(-) diff --git a/lib/ttf.jar b/lib/ttf.jar index 4c9f4963a5da204eef70497fbd77073971489d76..e07d1e1f4a129ffd5a1a21f4346b4578f774495e 100644 GIT binary patch delta 27016 zcmb__2YgjU)A!7|xw$2Wkc1QxNF$_>LMMN# zhW*OSxosEU%AHhvQaNaGB$E%NP-RNhX8Dc_sf|<}r0P-})kCZ_Vgl0@zyGL*=o?GZ4c=h zSPyj6CzToiLPOweq*+3H1~x`+6LL@n`BNrUp{ClX(9t2ykeiLN%~3W7Wm`}bX#66y zm!l0?sVzCFoz^a_m!kvP)e&VnX}iL@aA)8N(bTGem4vKy6E98}QIlwdmRz-#Ym<{E z&`k%8r_Uw$LV_=y2yWTvzfSTs-`%#;GADgSUpwg=`ql|vekZ~AHu}LvKRSW!rk#G0 z=g*S=i^P6)g7n`c`MaI|5Ri8S_+17)n~?mZWx46?^F+gXvP1$EiSL2+!gv9FzN z0^v8*WV;_b*y+c9tV&SH#{N!9=E?#hK!QL?206J32TLr(#-TP2bAr1!?OYX44tG#J zj<9hx8&`KwV~%u580DlU9PLCbMv}2ovW9?(6R0(v9M1_7O9UyLBtb2qG+BZad66nX znv?_e5zG?QmY|LVbtMRvxAkmX-$7q-13NdAbR(w=jZJrQV{YQ4E}S8mnRad}&n!DP zvvamYo7*`@o-OR$($1|U+FF7((#*CJ1PgE4NvyrZawX^>oI@|faYqR{3AuR^%eQf7 z8+T!{k1OsGahBP)xO(+e4($q#+PIs^Hj_yxsSSucuB~bpqUA;%v({${o}yhi9$Fk3 z9nSo=);Q)%-mS&PjtQGbt5ljnGgX>QQ&gHmvsGG2tMv2DxoYH8dcelrRqnw(ZQM)c z0`9GHA@@Ps^#1U|&K@Rhmn)wedBg zD@~+HDi0=?O8aS#_E?P^*RxW#KMzr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%gcD1tdCN#mEto+-#@Z3>X zY2#|NzNMl@YqkI)7 zf0gp()jZ0d3~|w4#gAL1{Fnrzy!dtX@K9IrO1I*@#J`wsf`_9qKz}q`Q4J9hx0k*q z6dmTl`<2nKOC-ktC$5usyl~GRzpCIKnk?mO>)U)`(zFbBHCo&yhv5Q~U)A!* zr@P9}MEO6_!$zaUS)d;cN23qSGxI<6L%y5mRo1yxc>c#~qr9wp^{x>v^s*Qk0aE2x z6@Bl=P4KNB2lx#j*FY}|4E<~b&|?R~XwH>A$ajlu6{ETe`WYw8@(*RORnM>K!Y@|I z2NrN2zxXQU9dDTBdpg1RqZQ@Fw%F`TB)^7L$|t{TmfzX~R>!cbsMI;w)hC!^cioD` d*LCqrsZy!NS4Jhdu&a-+rG)ql^H)&d{{U|vs+9l$ diff --git a/libsrc/ttf/src/fontastic/FContour.java b/libsrc/ttf/src/fontastic/FContour.java index 38745865c..2bdb30997 100644 --- a/libsrc/ttf/src/fontastic/FContour.java +++ b/libsrc/ttf/src/fontastic/FContour.java @@ -1,6 +1,6 @@ package fontastic; -/** +/* * Fontastic * A font file writer to create TTF and WOFF (Webfonts). * http://code.andreaskoller.com/libraries/fontastic @@ -11,69 +11,65 @@ package fontastic; * 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 + * 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) + * 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; + List points; - FContour() { - this.points = new ArrayList<>(); - } - - FContour(FPoint[] points) { - this.points = new ArrayList<>(); - for (FPoint p : points) { - this.points.add(p); - } - } - - FContour(FPoint[] points, FPoint[] controlpoints) { - this.points = new ArrayList<>(); - for (int i=0; i getPoints() { - return points; - } - - public FPoint[] getPointsArray() { - FPoint[] pointsArray = points.toArray(new FPoint[points.size()]); - return pointsArray; - } - - public void setPoints(FPoint[] points) { - this.points = new ArrayList<>(); - for (FPoint p : points) { - this.points.add(p); - } - } + FContour() { + this.points = new ArrayList<>(); + } -} \ No newline at end of file + FContour(FPoint[] points) { + this.points = new ArrayList<>(); + for (FPoint p : points) { + this.points.add(p); + } + } + + FContour(FPoint[] points, FPoint[] controlpoints) { + this.points = new ArrayList<>(); + for (int i = 0; i < points.length; i++) { + this.points.add(new FPoint(points[i], controlpoints[i])); + } + } + + public List getPoints() { + return points; + } + + public FPoint[] getPointsArray() { + FPoint[] pointsArray = points.toArray(new FPoint[points.size()]); + return pointsArray; + } + + public void setPoints(FPoint[] points) { + this.points = new ArrayList<>(); + for (FPoint p : points) { + this.points.add(p); + } + } +} diff --git a/libsrc/ttf/src/fontastic/FGlyph.java b/libsrc/ttf/src/fontastic/FGlyph.java index e5dacaf7b..817f40533 100644 --- a/libsrc/ttf/src/fontastic/FGlyph.java +++ b/libsrc/ttf/src/fontastic/FGlyph.java @@ -1,6 +1,6 @@ package fontastic; -/** +/* * Fontastic * A font file writer to create TTF and WOFF (Webfonts). * http://code.andreaskoller.com/libraries/fontastic @@ -11,98 +11,97 @@ package fontastic; * 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 + * 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) + * 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; + private final char glyphChar; - FGlyph(char c) { - glyphChar = c; - this.contours = new ArrayList<>(); - } + private final List contours; - public void addContour() { - contours.add(new FContour()); - } - - public void addContour(FPoint[] points) { - contours.add(new FContour(points)); - } + private int advanceWidth = 512; - public void addContour(FPoint[] points, FPoint[] controlPoints) { - contours.add(new FContour(points, controlPoints)); - } - - public void addContour(FContour contour) { - contours.add(contour); - } + FGlyph(char c) { + glyphChar = c; + this.contours = new ArrayList<>(); + } - public void setAdvanceWidth(int advanceWidth) { - this.advanceWidth = advanceWidth; - } - - public char getGlyphChar() { - return glyphChar; - } - - public int getAdvanceWidth() { - return advanceWidth; - } - - public List getContours() { - return contours; - } + public void addContour() { + contours.add(new FContour()); + } - 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, FPoint[] points) { - contours.set(index, new FContour(points)); - } + public void addContour(FPoint[] points) { + contours.add(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 + public void addContour(FPoint[] points, FPoint[] 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, 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(); + } +} diff --git a/libsrc/ttf/src/fontastic/FPoint.java b/libsrc/ttf/src/fontastic/FPoint.java index c6d98b023..d3538250b 100644 --- a/libsrc/ttf/src/fontastic/FPoint.java +++ b/libsrc/ttf/src/fontastic/FPoint.java @@ -1,6 +1,6 @@ package fontastic; -/** +/* * Fontastic * A font file writer to create TTF and WOFF (Webfonts). * http://code.andreaskoller.com/libraries/fontastic @@ -11,75 +11,71 @@ package fontastic; * 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 + * 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) + * 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. - * + * + * Stores a point with x and y coordinates and optional PVector controlPoint1 + * and controlPoint2. + * */ public class FPoint { - public double x; - public double y; + public double x; - public FPoint controlPoint; - - private boolean hasControlPoint; + public double y; - public FPoint() { - } - - public FPoint(FPoint point) { - this.x = point.x; - this.y = point.y; - this.hasControlPoint = false; - } - - public FPoint(double x, double y) { - this.x = x; - this.y = y; - this.hasControlPoint = false; - } - - - public FPoint(FPoint point, FPoint controlPoint) { - this.x = point.x; - this.y = point.y; - this.controlPoint = controlPoint; - this.hasControlPoint = true; - } - - public void setControlPoint(FPoint controlPoint1) { - this.controlPoint = controlPoint1; - this.hasControlPoint = true; - } + public FPoint controlPoint; - public void setControlPoint(float x, float y) { - this.controlPoint = new FPoint(x, y); - this.hasControlPoint = true; - } + private boolean hasControlPoint; - - public boolean hasControlPoint1() { - return hasControlPoint; - } + public FPoint() { + } -} \ No newline at end of file + public FPoint(FPoint point) { + this.x = point.x; + this.y = point.y; + this.hasControlPoint = false; + } + + public FPoint(double x, double y) { + this.x = x; + this.y = y; + this.hasControlPoint = false; + } + + public FPoint(FPoint point, FPoint controlPoint) { + this.x = point.x; + this.y = point.y; + this.controlPoint = controlPoint; + this.hasControlPoint = true; + } + + public void setControlPoint(FPoint controlPoint1) { + this.controlPoint = controlPoint1; + this.hasControlPoint = true; + } + + public void setControlPoint(float x, float y) { + this.controlPoint = new FPoint(x, y); + this.hasControlPoint = true; + } + + public boolean hasControlPoint1() { + return hasControlPoint; + } +} diff --git a/libsrc/ttf/src/fontastic/Fontastic.java b/libsrc/ttf/src/fontastic/Fontastic.java index 45f5106f9..8e62b2030 100644 --- a/libsrc/ttf/src/fontastic/Fontastic.java +++ b/libsrc/ttf/src/fontastic/Fontastic.java @@ -1,4 +1,4 @@ -/** +/* * Fontastic A font file writer to create TTF * http://code.andreaskoller.com/libraries/fontastic * @@ -21,18 +21,21 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * @author Andreas Koller http://andreaskoller.com - * @modified 03/16/2014 JPEXS - removed Woff + * @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.io.File; +import java.io.IOException; import java.util.ArrayList; import java.util.List; +import org.doubletype.ossa.Engine; +import org.doubletype.ossa.OutOfRangeException; +import org.doubletype.ossa.adapter.EContour; +import org.doubletype.ossa.adapter.EContourPoint; +import org.doubletype.ossa.module.GlyphFile; +import org.doubletype.ossa.module.TypefaceFile; /** * Fontastic A font file writer to create TTF and WOFF (Webfonts). @@ -50,7 +53,9 @@ public class Fontastic { private int advanceWidth = 512; private File ttfFile; + private File outFile; + private File tempDir; /** @@ -83,12 +88,10 @@ public class Fontastic { 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()); } @@ -103,10 +106,10 @@ public class Fontastic { private void intitialiseFont() throws IOException { tempDir = createTempDirectory(); - + m_engine = new Engine(); 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 @@ -139,21 +142,21 @@ public class Fontastic { for (FPoint point : contour.points) { - EContourPoint e = new EContourPoint(point.x, point.y, true); + 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); - */ + 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); - } */ + /* + if (point.hasControlPoint2()) { + EControlPoint cp2 = new EControlPoint(false, + point.controlPoint2.x, point.controlPoint2.y); + e.setControlPoint2(cp2); + } */ econtour.addContourPoint(e); } @@ -162,11 +165,11 @@ public class Fontastic { } } - m_engine.getTypeface().addRequiredGlyphs(); + m_engine.getTypeface().addRequiredGlyphs(); m_engine.buildTrueType(); // End TTF creation - if(outFile.exists()){ + if (outFile.exists()) { outFile.delete(); } ttfFile.renameTo(outFile); @@ -214,13 +217,6 @@ public class Fontastic { m_engine.setFontFamilyName(fontFamilyName); } - /** - * Sets the sub family of the font. - */ - public void setSubFamily(String subFamily) { - 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/") @@ -329,7 +325,7 @@ public class Fontastic { */ public FGlyph addGlyph(char c) { - FGlyph glyph = new FGlyph(c); + FGlyph glyph = new FGlyph(c); glyph.setAdvanceWidth(advanceWidth); glyphs.add(glyph); return glyph; diff --git a/libsrc/ttf/src/fontatest/FontaTest.java b/libsrc/ttf/src/fontatest/FontaTest.java index 3753646f5..462e66aef 100644 --- a/libsrc/ttf/src/fontatest/FontaTest.java +++ b/libsrc/ttf/src/fontatest/FontaTest.java @@ -5,26 +5,24 @@ import fontastic.Fontastic; 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 file = new File("example.ttf"); file.delete(); - Fontastic f = new Fontastic("ExampleFont",file); + Fontastic f = new Fontastic("ExampleFont", file); f.setAuthor("Nobody"); - FPoint[] points = new FPoint[]{ // Define a FPoint array containing the points of the shape - new FPoint(0, 0), - new FPoint(512,0), - //new FPoint(256, 1024), - new FPoint(new FPoint(256,1024), new FPoint(512,512)), - new FPoint(0, 0) - }; + FPoint[] points = new FPoint[]{ // Define a FPoint array containing the points of the shape + new FPoint(0, 0), + new FPoint(512, 0), + //new FPoint(256, 1024), + new FPoint(new FPoint(256, 1024), new FPoint(512, 512)), + new FPoint(0, 0) + }; f.addGlyph('P').addContour(points); // Assign contour to character A - f.buildFont(); + f.buildFont(); } - } diff --git a/libsrc/ttf/src/org/doubletype/ossa/Engine.java b/libsrc/ttf/src/org/doubletype/ossa/Engine.java index 768b428f4..a3f2d6499 100644 --- a/libsrc/ttf/src/org/doubletype/ossa/Engine.java +++ b/libsrc/ttf/src/org/doubletype/ossa/Engine.java @@ -1,8 +1,8 @@ /* * $Id: Engine.java,v 1.84 2004/12/27 04:56:03 eed3si9n Exp $ - * + * * $Copyright: copyright (c) 2003, e.e d3si9n $ - * $License: + * $License: * This source code is part of DoubleType. * DoubleType is a graphical typeface designer. * @@ -25,232 +25,231 @@ * 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 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 java.io.FileNotFoundException; import java.text.DateFormat; import java.text.SimpleDateFormat; -import java.util.*; -import java.io.*; +import java.util.Date; import java.util.logging.Level; import java.util.logging.Logger; - -import org.doubletype.ossa.module.*; -import org.doubletype.ossa.truetype.*; +import org.doubletype.ossa.module.GlyphFile; +import org.doubletype.ossa.module.TypefaceFile; +import org.doubletype.ossa.truetype.TTCodePage; +import org.doubletype.ossa.truetype.TTUnicodeRange; /** * @author e.e */ public class Engine { - private TypefaceFile m_typeface; - private GlyphFile m_root; - // -------------------------------------------------------------- + private TypefaceFile m_typeface; - public Engine() { - } - - public void setAdvanceWidth(int a_value) { - if (m_root == null) - return; + private GlyphFile m_root; - m_root.setAdvanceWidth(a_value); - } - - public void buildNewTypeface(String a_name, File a_dir) throws FileNotFoundException { - if (a_name == null || a_name.equals("")) { - return; - } - - 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()); + // -------------------------------------------------------------- + public Engine() { + } - setTypeface(typeface); - } + public void setAdvanceWidth(int a_value) { + if (m_root == null) { + return; + } - public void addDefaultGlyphs() { - m_typeface.addRequiredGlyphs(); - m_typeface.addBasicLatinGlyphs(); - } + m_root.setAdvanceWidth(a_value); + } - public void setTypeface(TypefaceFile a_typeface) { - m_typeface = a_typeface; - } + public void buildNewTypeface(String a_name, File a_dir) throws FileNotFoundException { + if (a_name == null || a_name.equals("")) { + return; + } - /** - * Create glyph out of given unicode, and add it to the typeface. - * @param a_unicode - */ - public GlyphFile addNewGlyph(long a_unicode) { - GlyphFile retval; + 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.addCodePage(TTCodePage.US_ASCII.toString()); + typeface.addCodePage(TTCodePage.Latin_1.toString()); - retval = m_typeface.createGlyph(a_unicode); - addGlyphToTypeface(retval); + setTypeface(typeface); + } - return retval; - } + public void addDefaultGlyphs() { + m_typeface.addRequiredGlyphs(); + m_typeface.addBasicLatinGlyphs(); + } - public void checkUnicodeBlock(long a_unicode) { - TTUnicodeRange range = TTUnicodeRange.of(a_unicode); - if (range == null){ - return; - } + public void setTypeface(TypefaceFile a_typeface) { + m_typeface = a_typeface; + } - if (m_typeface.containsUnicodeRange(range.toString())){ - return; - } - m_typeface.addUnicodeRange(range.toString()); - } + /** + * Create glyph out of given unicode, and add it to the typeface. + * + * @param a_unicode + */ + public GlyphFile addNewGlyph(long a_unicode) { + GlyphFile retval; - private void addGlyphToTypeface(GlyphFile a_file) { - m_typeface.addGlyph(a_file); + retval = m_typeface.createGlyph(a_unicode); + addGlyphToTypeface(retval); - setRoot(a_file); - } + return retval; + } - public void buildTrueType() { - if (m_typeface == null) - return; + public void checkUnicodeBlock(long a_unicode) { + 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) { + m_typeface.addGlyph(a_file); - try { - m_typeface.buildTTF(); - m_typeface.getFont(); - } catch (Exception e) { - Logger.getLogger(Engine.class.getName()).log(Level.SEVERE, null,e); - } // try-catch + setRoot(a_file); + } - return; - } + public void buildTrueType() { + if (m_typeface == null) { + return; + } - public TypefaceFile getTypeface() { - return m_typeface; - } + try { + m_typeface.buildTTF(); + m_typeface.getFont(); + } catch (Exception e) { + Logger.getLogger(Engine.class.getName()).log(Level.SEVERE, null, e); + } - public File getGlyphPath() { - return m_typeface.getGlyphPath(); - } - + return; + } - public GlyphFile getRoot() { - return m_root; - } + public TypefaceFile getTypeface() { + return m_typeface; + } - public void setRoot(GlyphFile a_file) { - m_root = a_file; - } + public File getGlyphPath() { + return m_typeface.getGlyphPath(); + } - public void addCodePage(String a_codePage) { - if (m_typeface == null) { - return; - } + public GlyphFile getRoot() { + return m_root; + } - m_typeface.addCodePage(a_codePage); - } + public void setRoot(GlyphFile a_file) { + m_root = a_file; + } - public void removeCodePage(String a_codePage) { - if (m_typeface == null) { - return; - } + public void addCodePage(String a_codePage) { + if (m_typeface == null) { + return; + } - m_typeface.removeCodePage(a_codePage); - } + m_typeface.addCodePage(a_codePage); + } - public void setAuthor(String a_value) { - if (m_typeface == null) { - return; - } + public void removeCodePage(String a_codePage) { + if (m_typeface == null) { + return; + } - m_typeface.setAuthor(a_value); - } + m_typeface.removeCodePage(a_codePage); + } - public void setCopyrightYear(String a_value) { - if (m_typeface == null) { - return; - } + public void setAuthor(String a_value) { + if (m_typeface == null) { + return; + } - m_typeface.setCopyrightYear(a_value); - } + m_typeface.setAuthor(a_value); + } - public void setFontFamilyName(String a_value) { - if (m_typeface == null) { - return; - } + public void setCopyrightYear(String a_value) { + if (m_typeface == null) { + return; + } - m_typeface.setFontFamilyName(a_value); - } + m_typeface.setCopyrightYear(a_value); + } - public void setTypefaceLicense(String a_value) { - if (m_typeface == null) { - return; - } + public void setFontFamilyName(String a_value) { + if (m_typeface == null) { + return; + } - m_typeface.setLicense(a_value); - } + m_typeface.setFontFamilyName(a_value); + } - public void setBaseline(double a_value) { - if (m_typeface == null) { - return; - } - - double min = m_typeface.getBottomSideBearing(); - double max = m_typeface.getMeanline(); - - if (a_value < min) { - a_value = min; - } - - if (a_value > max) { - a_value = max; - } - - 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 - } - - public void setMeanline(double a_value) { - if (m_typeface == null) { - return; - } - - double min = m_typeface.getBaseline(); - double max = m_typeface.getEm() - - m_typeface.getTopSideBearing(); - - if (a_value < min) { - a_value = min; - } - - if (a_value > max) { - a_value = max; - } - - try { - m_typeface.setXHeight(a_value - min); - } - catch (OutOfRangeException e) { - e.printStackTrace(); - } // try-catch - } + public void setTypefaceLicense(String a_value) { + if (m_typeface == null) { + return; + } + + m_typeface.setLicense(a_value); + } + + public void setBaseline(double a_value) { + if (m_typeface == null) { + return; + } + + double min = m_typeface.getBottomSideBearing(); + double max = m_typeface.getMeanline(); + + if (a_value < min) { + a_value = min; + } + + if (a_value > max) { + a_value = max; + } + + 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(); + } + } + + public void setMeanline(double a_value) { + if (m_typeface == null) { + return; + } + + double min = m_typeface.getBaseline(); + double max = m_typeface.getEm() + - m_typeface.getTopSideBearing(); + + if (a_value < min) { + a_value = min; + } + + if (a_value > max) { + a_value = max; + } + + try { + m_typeface.setXHeight(a_value - min); + } catch (OutOfRangeException e) { + e.printStackTrace(); + } + } } diff --git a/libsrc/ttf/src/org/doubletype/ossa/OutOfRangeException.java b/libsrc/ttf/src/org/doubletype/ossa/OutOfRangeException.java index 4016eabe9..5fff226d6 100644 --- a/libsrc/ttf/src/org/doubletype/ossa/OutOfRangeException.java +++ b/libsrc/ttf/src/org/doubletype/ossa/OutOfRangeException.java @@ -1,49 +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; - } -} +/* + * $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 final double value; + + public OutOfRangeException(double value) { + super(); + + this.value = value; + } +} diff --git a/libsrc/ttf/src/org/doubletype/ossa/adapter/CubicSegment.java b/libsrc/ttf/src/org/doubletype/ossa/adapter/CubicSegment.java index fd6c14485..43696488e 100644 --- a/libsrc/ttf/src/org/doubletype/ossa/adapter/CubicSegment.java +++ b/libsrc/ttf/src/org/doubletype/ossa/adapter/CubicSegment.java @@ -1,8 +1,8 @@ /* * $Id: CubicSegment.java,v 1.2 2004/12/27 04:56:02 eed3si9n Exp $ - * + * * $Copyright: copyright (c) 2004, e.e d3si9n $ - * $License: + * $License: * This source code is part of DoubleType. * DoubleType is a graphical typeface designer. * @@ -13,95 +13,99 @@ * * 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 + * 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 + * 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 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 java.awt.geom.Point2D; +import java.util.ArrayList; /** * @author e.e */ public class CubicSegment { + public static final int LINE = 0; + public static final int CURVE = 1; - + /** * converts cubic contour into cubic segments. + * * @param a_contour * @return */ public static ArrayList toSegments(EContour a_contour) { ArrayList retval = new ArrayList<>(); ArrayList points = a_contour.getContourPoints(); - if (points.size() < 2) { - return retval; - } - - EContourPoint startPoint = (EContourPoint) points.get(points.size() - 1); - for (int i = 0; i < points.size(); i++) { - EContourPoint endPoint = (EContourPoint) points.get(i); - retval.add(new CubicSegment(startPoint, endPoint)); - startPoint = endPoint; - } // for - + if (points.size() < 2) { + return retval; + } + + EContourPoint startPoint = (EContourPoint) points.get(points.size() - 1); + for (int i = 0; i < points.size(); i++) { + EContourPoint endPoint = (EContourPoint) points.get(i); + retval.add(new CubicSegment(startPoint, endPoint)); + startPoint = endPoint; + } // for + 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 (a_startPoint.hasControlPoint2() || a_endPoint.hasControlPoint1()) { m_type = CURVE; - + if (a_startPoint.hasControlPoint2()) { m_controlPoint1 = a_startPoint.getControlPoint2().getContourPoint(); } else { m_controlPoint1 = a_startPoint; } - + if (a_endPoint.hasControlPoint1()) { m_controlPoint2 = a_endPoint.getControlPoint1().getContourPoint(); } else { m_controlPoint1 = a_endPoint; - } + } } } - - public CubicSegment(EContourPoint a_startPoint, EContourPoint a_controlPoint1, + + public CubicSegment(EContourPoint a_startPoint, EContourPoint a_controlPoint1, EContourPoint a_controlPoint2, EContourPoint a_endPoint) { m_startPoint = a_startPoint; m_controlPoint1 = a_controlPoint1; @@ -109,18 +113,18 @@ public class CubicSegment { m_endPoint = a_endPoint; m_type = CURVE; } - - public ArrayList toQuadraticSegments() { + + public ArrayList toQuadraticSegments() { ArrayList retval = new ArrayList<>(); - + if (m_type == LINE) { retval.add(new QuadraticSegment(m_startPoint, null, m_endPoint)); return retval; } - + 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); @@ -135,6 +139,7 @@ public class CubicSegment { 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"); @@ -180,21 +185,20 @@ public class CubicSegment { {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<>(); - - 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); - } + + 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); + } return retval; } } diff --git a/libsrc/ttf/src/org/doubletype/ossa/adapter/EContour.java b/libsrc/ttf/src/org/doubletype/ossa/adapter/EContour.java index 6e2c1b84a..cd6bfdee9 100644 --- a/libsrc/ttf/src/org/doubletype/ossa/adapter/EContour.java +++ b/libsrc/ttf/src/org/doubletype/ossa/adapter/EContour.java @@ -1,8 +1,8 @@ /* * $Id: EContour.java,v 1.11 2004/12/17 04:13:17 eed3si9n Exp $ - * + * * $Copyright: copyright (c) 2003-2004, e.e d3si9n $ - * $License: + * $License: * This source code is part of DoubleType. * DoubleType is a graphical typeface designer. * @@ -13,26 +13,25 @@ * * 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 + * 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 + * 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 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.ArrayList; @@ -41,46 +40,45 @@ import java.util.ArrayList; * @author e.e */ public class EContour { - public static final String k_quadratic = "quadratic"; - public static final String k_cubic = "cubic"; - - private String type; - private ArrayList m_contourPoints = new ArrayList<>(); - - // -------------------------------------------------------------- - - public EContour() { - setType(k_quadratic); - } - - public boolean isCubic() { - return type.equals(k_cubic); - } - - public void setType(String a_type) { - type = a_type; - } - - public void addContourPoint(EContourPoint a_point) { - m_contourPoints.add(a_point); - } - - public ArrayList getContourPoints() { - return m_contourPoints; - } - // -------------------------------------------------------------- - + public static final String k_quadratic = "quadratic"; + + public static final String k_cubic = "cubic"; + + private String type; + + private ArrayList m_contourPoints = new ArrayList<>(); + + public EContour() { + setType(k_quadratic); + } + + public boolean isCubic() { + return type.equals(k_cubic); + } + + public void setType(String a_type) { + type = a_type; + } + + public void addContourPoint(EContourPoint a_point) { + m_contourPoints.add(a_point); + } + + public ArrayList getContourPoints() { + return m_contourPoints; + } + public EContour toQuadratic() { if (!isCubic()) { return this; } - - ArrayList quadraticSegments = new ArrayList<>(); - for (CubicSegment segment: CubicSegment.toSegments(this)) { - quadraticSegments.addAll(segment.toQuadraticSegments()); - } - + + ArrayList quadraticSegments = new ArrayList<>(); + for (CubicSegment segment : CubicSegment.toSegments(this)) { + quadraticSegments.addAll(segment.toQuadraticSegments()); + } + return QuadraticSegment.toContour(quadraticSegments); } } diff --git a/libsrc/ttf/src/org/doubletype/ossa/adapter/EContourPoint.java b/libsrc/ttf/src/org/doubletype/ossa/adapter/EContourPoint.java index 07563d1a1..c75ec21aa 100644 --- a/libsrc/ttf/src/org/doubletype/ossa/adapter/EContourPoint.java +++ b/libsrc/ttf/src/org/doubletype/ossa/adapter/EContourPoint.java @@ -1,8 +1,8 @@ /* * $Id: EContourPoint.java,v 1.10 2004/12/27 04:56:02 eed3si9n Exp $ - * + * * $Copyright: copyright (c) 2004, e.e d3si9n $ - * $License: + * $License: * This source code is part of DoubleType. * DoubleType is a graphical typeface designer. * @@ -13,88 +13,92 @@ * * 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 + * 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 + * 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 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 class EContourPoint implements EPoint { - private boolean isOn; - private double x; - private double y; - private EControlPoint controlPoint1; - private EControlPoint controlPoint2; - - public EContourPoint() { - super(); - } - - public EContourPoint(double a_x, double a_y, boolean a_isOn) { - x = a_x; - y = a_y; - - setOn(a_isOn); - } - - public static final int k_defaultPixelSize = 16; +public final class EContourPoint implements EPoint { - public double getX() { - return x; - } - - public double getY() { - return y; - } + private boolean isOn; - public EControlPoint getControlPoint1() { - return controlPoint1; - } - - public EControlPoint getControlPoint2() { - return controlPoint2; - } - - public void setControlPoint1(EControlPoint a_point) { - controlPoint1 = a_point; - } - - public void setControlPoint2(EControlPoint a_point) { - controlPoint2 = a_point; - } - - public boolean hasControlPoint1() { - return getControlPoint1() != null; - } - - public boolean hasControlPoint2() { - return getControlPoint2() != null; - } - - public boolean isOn() { - return isOn; - } - - public void setOn(boolean a_isOnCurve) { - isOn = a_isOnCurve; - } -} \ No newline at end of file + private double x; + + private double y; + + private EControlPoint controlPoint1; + + private EControlPoint controlPoint2; + + public EContourPoint() { + super(); + } + + public EContourPoint(double a_x, double a_y, boolean a_isOn) { + x = a_x; + y = a_y; + + setOn(a_isOn); + } + + public static final int k_defaultPixelSize = 16; + + public double getX() { + return x; + } + + public double getY() { + return y; + } + + public EControlPoint getControlPoint1() { + return controlPoint1; + } + + public EControlPoint getControlPoint2() { + return controlPoint2; + } + + public void setControlPoint1(EControlPoint a_point) { + controlPoint1 = a_point; + } + + public void setControlPoint2(EControlPoint a_point) { + controlPoint2 = a_point; + } + + public boolean hasControlPoint1() { + return getControlPoint1() != null; + } + + public boolean hasControlPoint2() { + return getControlPoint2() != null; + } + + public boolean isOn() { + return isOn; + } + + public void setOn(boolean a_isOnCurve) { + isOn = a_isOnCurve; + } +} diff --git a/libsrc/ttf/src/org/doubletype/ossa/adapter/EControlPoint.java b/libsrc/ttf/src/org/doubletype/ossa/adapter/EControlPoint.java index d4c3e59f2..c28850583 100644 --- a/libsrc/ttf/src/org/doubletype/ossa/adapter/EControlPoint.java +++ b/libsrc/ttf/src/org/doubletype/ossa/adapter/EControlPoint.java @@ -1,8 +1,8 @@ /* * $Id: EControlPoint.java,v 1.6 2004/12/27 04:56:02 eed3si9n Exp $ - * + * * $Copyright: copyright (c) 2003-2004, e.e d3si9n $ - * $License: + * $License: * This source code is part of DoubleType. * DoubleType is a graphical typeface designer. * @@ -25,43 +25,35 @@ * 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 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.Shape; -import java.awt.geom.AffineTransform; - /** * @author e.e */ public class EControlPoint implements EPoint { - + private EContourPoint contourPoint; - - /** - * - */ + public EControlPoint(double x, double y) { contourPoint = new EContourPoint(x, y, false); } - public double getX() { - return contourPoint.getX(); - } - - public double getY() { - return contourPoint.getY(); - } - - public EContourPoint getContourPoint() { - return contourPoint; - } -} + public double getX() { + return contourPoint.getX(); + } + public double getY() { + return contourPoint.getY(); + } + + public EContourPoint getContourPoint() { + return contourPoint; + } +} diff --git a/libsrc/ttf/src/org/doubletype/ossa/adapter/EPoint.java b/libsrc/ttf/src/org/doubletype/ossa/adapter/EPoint.java index 4a59fb58a..dce362dc6 100644 --- a/libsrc/ttf/src/org/doubletype/ossa/adapter/EPoint.java +++ b/libsrc/ttf/src/org/doubletype/ossa/adapter/EPoint.java @@ -1,44 +1,45 @@ -/* - * $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(); -} +/* + * $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/libsrc/ttf/src/org/doubletype/ossa/adapter/QuadraticSegment.java b/libsrc/ttf/src/org/doubletype/ossa/adapter/QuadraticSegment.java index 6ab69facd..9ff1b6f91 100644 --- a/libsrc/ttf/src/org/doubletype/ossa/adapter/QuadraticSegment.java +++ b/libsrc/ttf/src/org/doubletype/ossa/adapter/QuadraticSegment.java @@ -1,8 +1,8 @@ /* * $Id: QuadraticSegment.java,v 1.1 2004/12/15 11:54:18 eed3si9n Exp $ - * + * * $Copyright: copyright (c) 2004, e.e d3si9n $ - * $License: + * $License: * This source code is part of DoubleType. * DoubleType is a graphical typeface designer. * @@ -25,42 +25,44 @@ * 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 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.util.ArrayList; /** * @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; } - + 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)); @@ -71,117 +73,122 @@ public class QuadraticSegment { retval.add(new QuadraticSegment(startPoint, offCurvePoint, nextPoint)); } } - + 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) { + + for (QuadraticSegment segment : a_segments) { EContourPoint p = segment.m_startPoint; EContourPoint startPoint = new EContourPoint(p.getX(), p.getY(), p.isOn()); startPoint.setControlPoint1(null); startPoint.setControlPoint2(null); - + if (segment.m_type == LINE) { retval.addContourPoint(startPoint); - + } else { retval.addContourPoint(startPoint); retval.addContourPoint(segment.m_offCurvePoint); } } - + 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<>(); - + ArrayList points = a_contour.getContourPoints(); - if (points.size() < 3) - return retval; - - EContourPoint fromPoint = (EContourPoint) points.get(points.size() - 1); - for (EContourPoint 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)); - } - - retval.add(toPoint); - fromPoint = toPoint; - } - - // 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); - } - - retval.add(retval.get(0)); - + if (points.size() < 3) { + return retval; + } + + EContourPoint fromPoint = (EContourPoint) points.get(points.size() - 1); + for (EContourPoint 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)); + } + + retval.add(toPoint); + fromPoint = toPoint; + } + + // 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); + } + + 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) { + EContourPoint a_endPoint) { m_startPoint = a_startPoint; m_offCurvePoint = a_offCurvePoint; m_endPoint = a_endPoint; - + if (m_offCurvePoint != null) { m_type = CURVE; } } - + /** * Convert quadratic segment to cubic. + * * @param a_segment * @return */ - public CubicSegment toCubicSegment() { + public CubicSegment toCubicSegment() { // if the segment is a line if (m_type == LINE) { return new CubicSegment(m_startPoint, m_endPoint); } - + 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); - } + return new CubicSegment(m_startPoint, controlPoint1, controlPoint2, m_endPoint); + } } diff --git a/libsrc/ttf/src/org/doubletype/ossa/module/GlyphFile.java b/libsrc/ttf/src/org/doubletype/ossa/module/GlyphFile.java index fa55c4126..0a34ae5cc 100644 --- a/libsrc/ttf/src/org/doubletype/ossa/module/GlyphFile.java +++ b/libsrc/ttf/src/org/doubletype/ossa/module/GlyphFile.java @@ -1,6 +1,6 @@ - /* +/* * $Copyright: copyright (c) 2003-2008, e.e d3si9n $ - * $License: + * $License: * This source code is part of DoubleType. * DoubleType is a graphical typeface designer. * @@ -11,281 +11,280 @@ * * 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 + * 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 + * 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 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.truetype.*; - -import java.io.*; -import java.awt.*; - -import java.util.*; +import java.awt.Point; +import java.io.File; +import java.util.ArrayList; import java.util.List; +import org.doubletype.ossa.adapter.EContour; +import org.doubletype.ossa.adapter.EContourPoint; +import org.doubletype.ossa.truetype.TTGlyph; +import org.doubletype.ossa.truetype.TTUnicodeRange; /** * @author e.e */ public class GlyphFile { - private long m_unicode; - private String m_author; - private String m_copyrightYear; - private String m_license; - private Integer m_advanceWidth = null; - private List contours = new ArrayList<>(); - - // -------------------------------------------------------------- - - protected long m_modifiedTime = 0; - protected long m_savedTime = 0; - - private final int k_halfWidth = 512; - private final int k_fullWidth = 1024; - - // -------------------------------------------------------------- - - /** - * creates new file - */ - public GlyphFile(File a_dir, long a_unicode) { - super(); - - init(); - setUnicode(a_unicode); - - setAdvanceWidth(k_fullWidth); - } - - /** - * creates new file - * @param a_dir parent dir - */ - public GlyphFile(File a_dir) { - super(); - init(); - } - - private void init() { - m_savedTime = m_modifiedTime; - } - - /** - * initialize .notdef - */ - public void initNotDef(int a_advanceWidth) { - 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); - } - - public void initNullGlyph() { - setAdvanceWidth(0); - } - - public void initSpace(int a_advanceWidth) { - setAdvanceWidth(a_advanceWidth); - } - - public void beforePush() { - } - - // -------------------------------------------------------------- - - public boolean hasUnsavedChange() { - return (m_savedTime != m_modifiedTime); - } - - public void setAuthor(String a_value) { - m_author = a_value; - } - - public String getAuthor() { - return m_author; - } - - public void setCopyrightYear(String a_value) { - m_copyrightYear = a_value; - } - - public String getCopyrightYear() { - return m_copyrightYear; - } - - public void setAdvanceWidth(int a_width) { - m_advanceWidth = a_width; - } - - public int getAdvanceWidth() { - if (m_advanceWidth == null) { - return k_halfWidth; - } - - return m_advanceWidth; - } - - - // -------------------------------------------------------------- - - public static final int k_defaultPixelSize = 16; //PPM - - // -------------------------------------------------------------- - - /** - * Generates array of XContour from local contours and modules. - * Used for TTF building. - */ - private EContour [] toContours() { - EContour [] retval; - ArrayList list = new ArrayList<>(); - for (EContour contour : contours) { - list.add(contour.toQuadratic()); - } - - if (list.size() == 0) - return null; - - retval = new EContour[list.size()]; - for (int i = 0; i < list.size(); i++) { - retval[i] = list.get(i); - } - - return retval; - } - - // -------------------------------------------------------------- - - /** add contour from clipboard or ContourAction - * @param a_contour - */ - public void addContour(EContour a_contour) { - contours.add(a_contour); - } - + private long m_unicode; - // -------------------------------------------------------------- - - - public long getUnicode() { - return m_unicode; - } - - protected void setUnicode(long a_unicode) { - m_unicode = a_unicode; - } - - public boolean isSimple() { - return true; - } - - public boolean isWhiteSpace() { - long unicode = getUnicode(); - - if (unicode == 0x0020 - || unicode == 0x00a0 - || unicode == 0x200b - || unicode == 0x2060 - || unicode == 0x3000 - || unicode == 0xfeff) - { - return true; - } - - return false; - } - - public void setLicense(String a_value) { - m_license = a_value; - } - - public String getLicense() { - return m_license; - } - - public boolean isRequiredGlyph() { - long unicode = getUnicode(); - - 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 - EContour [] contours = toContours(); - if ((contours == null) && (!isRequiredGlyph())) { - return null; - } - - TTGlyph retval = new TTGlyph(); - retval.setSimple(true); - retval.setAdvanceWidth(getAdvanceWidth()); - - if (contours == null) { - return retval; - } - - ArrayList points = new ArrayList<>(); - for (int i = 0; i < contours.length; i++) { - EContour contour = contours[i]; - ArrayList contourPoints = contour.getContourPoints(); - for (int j = 0; j < contourPoints.size(); j++) { - points.add((EContourPoint) contourPoints.get(j)); - } // for j - retval.addEndPoint(points.size() - 1); - } - - for (EContourPoint point: points) { - loadContourPoint(retval, point); - } // for point - - 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; - } - - a_glyph.addPoint(p); - a_glyph.addFlag(flag); - } -} \ No newline at end of file + private String m_author; + + private String m_copyrightYear; + + private String m_license; + + private Integer m_advanceWidth = null; + + private List m_contours = new ArrayList<>(); + + // -------------------------------------------------------------- + protected long m_modifiedTime = 0; + + protected long m_savedTime = 0; + + private final int k_halfWidth = 512; + + private final int k_fullWidth = 1024; + + // -------------------------------------------------------------- + /** + * creates new file + */ + public GlyphFile(File a_dir, long a_unicode) { + super(); + + init(); + setUnicode(a_unicode); + + setAdvanceWidth(k_fullWidth); + } + + /** + * creates new file + * + * @param a_dir parent dir + */ + public GlyphFile(File a_dir) { + super(); + init(); + } + + private void init() { + m_savedTime = m_modifiedTime; + } + + /** + * initialize .notdef + */ + public void initNotDef(int a_advanceWidth) { + 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); + } + + public void initNullGlyph() { + setAdvanceWidth(0); + } + + public void initSpace(int a_advanceWidth) { + setAdvanceWidth(a_advanceWidth); + } + + public void beforePush() { + } + + // -------------------------------------------------------------- + public boolean hasUnsavedChange() { + return (m_savedTime != m_modifiedTime); + } + + public void setAuthor(String a_value) { + m_author = a_value; + } + + public String getAuthor() { + return m_author; + } + + public void setCopyrightYear(String a_value) { + m_copyrightYear = a_value; + } + + public String getCopyrightYear() { + return m_copyrightYear; + } + + public void setAdvanceWidth(int a_width) { + m_advanceWidth = a_width; + } + + public int getAdvanceWidth() { + if (m_advanceWidth == null) { + return k_halfWidth; + } + + return m_advanceWidth; + } + + // -------------------------------------------------------------- + public static final int k_defaultPixelSize = 16; //PPM + + // -------------------------------------------------------------- + /** + * Generates array of XContour from local contours and modules. + * Used for TTF building. + */ + private EContour[] toContours() { + EContour[] retval; + ArrayList list = new ArrayList<>(); + for (EContour contour : m_contours) { + list.add(contour.toQuadratic()); + } + + if (list.size() == 0) { + return null; + } + + retval = new EContour[list.size()]; + for (int i = 0; i < list.size(); i++) { + retval[i] = list.get(i); + } + + return retval; + } + + // -------------------------------------------------------------- + /** + * add contour from clipboard or ContourAction + * + * @param a_contour + */ + public void addContour(EContour a_contour) { + m_contours.add(a_contour); + } + + // -------------------------------------------------------------- + public long getUnicode() { + return m_unicode; + } + + protected void setUnicode(long a_unicode) { + m_unicode = a_unicode; + } + + public boolean isSimple() { + return true; + } + + public boolean isWhiteSpace() { + long unicode = getUnicode(); + + if (unicode == 0x0020 + || unicode == 0x00a0 + || unicode == 0x200b + || unicode == 0x2060 + || unicode == 0x3000 + || unicode == 0xfeff) { + return true; + } + + return false; + } + + public void setLicense(String a_value) { + m_license = a_value; + } + + public String getLicense() { + return m_license; + } + + public boolean isRequiredGlyph() { + long unicode = getUnicode(); + + 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 + EContour[] contours = toContours(); + if ((contours == null) && (!isRequiredGlyph())) { + return null; + } + + TTGlyph retval = new TTGlyph(); + retval.setSimple(true); + retval.setAdvanceWidth(getAdvanceWidth()); + + if (contours == null) { + return retval; + } + + ArrayList points = new ArrayList<>(); + for (int i = 0; i < contours.length; i++) { + EContour contour = contours[i]; + ArrayList contourPoints = contour.getContourPoints(); + for (int j = 0; j < contourPoints.size(); j++) { + points.add((EContourPoint) contourPoints.get(j)); + } // for j + retval.addEndPoint(points.size() - 1); + } + + for (EContourPoint point : points) { + loadContourPoint(retval, point); + } // for point + + 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; + } + + a_glyph.addPoint(p); + a_glyph.addFlag(flag); + } +} diff --git a/libsrc/ttf/src/org/doubletype/ossa/module/TypefaceFile.java b/libsrc/ttf/src/org/doubletype/ossa/module/TypefaceFile.java index fe5e3824a..11b32267e 100644 --- a/libsrc/ttf/src/org/doubletype/ossa/module/TypefaceFile.java +++ b/libsrc/ttf/src/org/doubletype/ossa/module/TypefaceFile.java @@ -1,6 +1,6 @@ /* * $Copyright: copyright (c) 2003-2008, e.e d3si9n $ - * $License: + * $License: * This source code is part of DoubleType. * DoubleType is a graphical typeface designer. * @@ -23,346 +23,370 @@ * 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 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.truetype.*; -import java.awt.*; +import java.awt.Font; +import java.awt.Point; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.RandomAccessFile; +import java.util.ArrayList; import java.util.List; +import java.util.UUID; +import org.doubletype.ossa.OutOfRangeException; +import org.doubletype.ossa.truetype.FontFileWriter; +import org.doubletype.ossa.truetype.TTCodePage; +import org.doubletype.ossa.truetype.TTGlyph; +import org.doubletype.ossa.truetype.TTUnicodeRange; /** * @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_dotTtf = ".ttf"; - - private File m_dir; - private File m_ttfFile; - private Font m_font = null; - private List m_glyphFiles = new ArrayList<>(); - private List m_unicodeRanges = new ArrayList<>(); - private List m_codePages = new ArrayList<>(); - private String m_fontFamilyName; - private String m_subFamily; - private String m_version; - private Double m_topSideBearing = null; - private Double m_ascender = null; - private Double m_xHeight = null; - private Double m_descender = null; - private Double m_bottomSideBearing = null; - private String m_name; - - public TypefaceFile(String a_name, File a_dir) throws FileNotFoundException { - super(a_dir); - - m_dir = a_dir; - m_name = a_name; - initFileName(); - } - - public TypefaceFile(File a_file) { - super(a_file); - - m_dir = a_file.getParentFile(); - m_name = a_file.getName(); - - initFileName(); - } - - private void initFileName() { - - String fileName = m_name + k_dotTtf; - m_ttfFile = new File(m_dir, fileName); - } - - public GlyphFile createGlyph(long a_unicode) { - return new GlyphFile(getGlyphPath(), a_unicode); - } - - private GlyphFile getGlyphFileByUnicode(long code) { - for (GlyphFile glyphFile : m_glyphFiles) { - if (glyphFile.getUnicode() == code) { - return glyphFile; - } - } - - return null; - } - - public boolean addRequiredGlyphs() { - boolean retval = false; - - if (getGlyphFileByUnicode(TTUnicodeRange.k_notDef) == null) { - GlyphFile glyph = new GlyphFile(getGlyphPath(), TTUnicodeRange.k_notDef); - glyph.initNotDef(k_defaultAdvanceWidth); - addGlyph(0, glyph); - retval = true; - } - - if (getGlyphFileByUnicode(TTUnicodeRange.k_null) == null) { - GlyphFile glyph = new GlyphFile(getGlyphPath(), TTUnicodeRange.k_null); - glyph.initNullGlyph(); - addGlyph(1, glyph); - retval = true; - } - - if (getGlyphFileByUnicode(TTUnicodeRange.k_cr) == null) { - GlyphFile glyph = new GlyphFile(getGlyphPath(), TTUnicodeRange.k_cr); - glyph.initSpace(k_defaultAdvanceWidth); - addGlyph(2, glyph); - retval = true; - } - - if (getGlyphFileByUnicode(TTUnicodeRange.k_space) == null) { - GlyphFile glyph = new GlyphFile(getGlyphPath(), TTUnicodeRange.k_space); - glyph.initSpace(k_defaultAdvanceWidth); - addGlyph(3, glyph); - retval = true; - } - - return retval; - } - - public void addBasicLatinGlyphs() { - 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)); - } - } - } - - public File getGlyphPath() { - return m_dir; - } - - /** - * change glyph's unicode mapping. - * @param a_glyphFile - * @param a_unicode - */ - public void setGlyphUnicode(GlyphFile a_glyphFile, long a_unicode) { - a_glyphFile.setUnicode(a_unicode); - } - - public void addGlyph(GlyphFile a_file) { - m_glyphFiles.add(a_file); - } - - public void addGlyph(int a_index, GlyphFile a_file) { - m_glyphFiles.add(a_index, a_file); - } - - public Object [] getCodePages() { - int i; - Object [] retval; - retval = new Object[0]; - - return retval; - } - - public boolean containsUnicodeRange(String a_unicodeRange) { - return m_unicodeRanges.contains(a_unicodeRange); - } - - public void addUnicodeRange(String a_unicodeRange) { - if (containsUnicodeRange(a_unicodeRange)) { - return; - } - - m_unicodeRanges.add(a_unicodeRange); - } - - public boolean containsCodePage(String a_codePage) { - return m_codePages.contains(a_codePage); - } - - public void addCodePage(String a_codePage) { - if (containsCodePage(a_codePage)) { - return; - } - - m_codePages.add(a_codePage); - } - - public void removeCodePage(String a_codePage) { - if (!containsCodePage(a_codePage)) { - return; - } - - m_codePages.remove(a_codePage); - } - - public void setFontFamilyName(String a_value) { - m_fontFamilyName = a_value; - } - - public String getFontFamilyName() { - return m_fontFamilyName; - } - - public String getVersion() { - return m_version == null ? "0.1" : m_version; - } - - public void setVersion(String a_value) { - m_version = a_value; - } - - public void setSubFamily(String a_value) { - m_subFamily = a_value; - } - - public void setDefaultMetrics() { - m_topSideBearing = k_defaultTopSideBearing; - m_ascender = k_defaultAscender; - m_xHeight = k_defaultXHeight; - m_descender = k_defaultDescender; - m_bottomSideBearing = k_defaultBottomSideBearing; - } - - public double getEm() { - return k_em; - } - - public double getBaseline() { - return getBottomSideBearing() + getDescender(); - } - - public double getMeanline() { - return getBottomSideBearing() - + getDescender() + getXHeight(); - } - - public double getBodyBottom() { - return getBottomSideBearing(); - } - - public double getBodyTop() { - return getEm() - getTopSideBearing(); - } - - public double getTopSideBearing() { - if (m_topSideBearing == null) { - setDefaultMetrics(); - } - - return m_topSideBearing; - } - - public double getAscender() { - if (m_ascender == null) { - setDefaultMetrics(); - } - - return m_ascender; - } - - public double getXHeight() { - if (m_xHeight == null) { - setDefaultMetrics(); - } - - return m_xHeight; - } - - public double getDescender() { - if (m_descender == null) { - setDefaultMetrics(); - } - - return m_descender; - } - - public double getBottomSideBearing() { - if (m_bottomSideBearing == null) { - setDefaultMetrics(); - } - - return m_bottomSideBearing; - } - - public void setTopSideBearing(double a_value) throws OutOfRangeException { - checkBoundary(a_value); - m_topSideBearing = a_value; - } - - private void checkBoundary(double a_value) throws OutOfRangeException { - if (a_value > k_em || a_value < 0) { - throw new OutOfRangeException(a_value); - } - } - - public void setAscender(double a_value) throws OutOfRangeException { - checkBoundary(a_value); - m_ascender = a_value; - } +public class TypefaceFile extends GlyphFile { - public void setXHeight(double a_value) throws OutOfRangeException { - checkBoundary(a_value); - if (a_value > getAscender()) { - throw new OutOfRangeException(a_value); - } - - m_xHeight = a_value; - } - - public void setDescender(double a_value) throws OutOfRangeException { - checkBoundary(a_value); - m_descender = a_value; - } - - public void setBottomSideBearing(double a_value) throws OutOfRangeException { - checkBoundary(a_value); - m_bottomSideBearing = a_value; - } - - public double getBodyHeight() { - return k_em - getTopSideBearing() - getBottomSideBearing(); - } - -// -------------------------------------------------------------------- - - /** - * Calls FontFileWriter to produce TrueType font file. - */ - public void buildTTF() throws Exception { - String randomString = UUID.randomUUID().toString().substring(0, 4); - - File tempFile = new File(m_dir, - m_name + "_" + randomString + k_dotTtf); - File target; - String fontFamilyName; - - target = m_ttfFile; - fontFamilyName = getFontFamilyName(); - - target.delete(); - FontFileWriter writer; + 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_dotTtf = ".ttf"; + + private File m_dir; + + private File m_ttfFile; + + private Font m_font = null; + + private List m_glyphFiles = new ArrayList<>(); + + private List m_unicodeRanges = new ArrayList<>(); + + private List m_codePages = new ArrayList<>(); + + private String m_fontFamilyName; + + private String m_version; + + private Double m_topSideBearing = null; + + private Double m_ascender = null; + + private Double m_xHeight = null; + + private Double m_descender = null; + + private Double m_bottomSideBearing = null; + + private String m_name; + + public TypefaceFile(String a_name, File a_dir) throws FileNotFoundException { + super(a_dir); + + m_dir = a_dir; + m_name = a_name; + initFileName(); + } + + public TypefaceFile(File a_file) { + super(a_file); + + m_dir = a_file.getParentFile(); + m_name = a_file.getName(); + + initFileName(); + } + + private void initFileName() { + + String fileName = m_name + k_dotTtf; + m_ttfFile = new File(m_dir, fileName); + } + + public GlyphFile createGlyph(long a_unicode) { + return new GlyphFile(getGlyphPath(), a_unicode); + } + + private GlyphFile getGlyphFileByUnicode(long code) { + for (GlyphFile glyphFile : m_glyphFiles) { + if (glyphFile.getUnicode() == code) { + return glyphFile; + } + } + + return null; + } + + public boolean addRequiredGlyphs() { + boolean retval = false; + + if (getGlyphFileByUnicode(TTUnicodeRange.k_notDef) == null) { + GlyphFile glyph = new GlyphFile(getGlyphPath(), TTUnicodeRange.k_notDef); + glyph.initNotDef(k_defaultAdvanceWidth); + addGlyph(0, glyph); + retval = true; + } + + if (getGlyphFileByUnicode(TTUnicodeRange.k_null) == null) { + GlyphFile glyph = new GlyphFile(getGlyphPath(), TTUnicodeRange.k_null); + glyph.initNullGlyph(); + addGlyph(1, glyph); + retval = true; + } + + if (getGlyphFileByUnicode(TTUnicodeRange.k_cr) == null) { + GlyphFile glyph = new GlyphFile(getGlyphPath(), TTUnicodeRange.k_cr); + glyph.initSpace(k_defaultAdvanceWidth); + addGlyph(2, glyph); + retval = true; + } + + if (getGlyphFileByUnicode(TTUnicodeRange.k_space) == null) { + GlyphFile glyph = new GlyphFile(getGlyphPath(), TTUnicodeRange.k_space); + glyph.initSpace(k_defaultAdvanceWidth); + addGlyph(3, glyph); + retval = true; + } + + return retval; + } + + public void addBasicLatinGlyphs() { + 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)); + } + } + } + + public File getGlyphPath() { + return m_dir; + } + + /** + * change glyph's unicode mapping. + * + * @param a_glyphFile + * @param a_unicode + */ + public void setGlyphUnicode(GlyphFile a_glyphFile, long a_unicode) { + a_glyphFile.setUnicode(a_unicode); + } + + public void addGlyph(GlyphFile a_file) { + m_glyphFiles.add(a_file); + } + + public void addGlyph(int a_index, GlyphFile a_file) { + m_glyphFiles.add(a_index, a_file); + } + + public Object[] getCodePages() { + int i; + Object[] retval; + retval = new Object[0]; + + return retval; + } + + public boolean containsUnicodeRange(String a_unicodeRange) { + return m_unicodeRanges.contains(a_unicodeRange); + } + + public void addUnicodeRange(String a_unicodeRange) { + if (containsUnicodeRange(a_unicodeRange)) { + return; + } + + m_unicodeRanges.add(a_unicodeRange); + } + + public boolean containsCodePage(String a_codePage) { + return m_codePages.contains(a_codePage); + } + + public void addCodePage(String a_codePage) { + if (containsCodePage(a_codePage)) { + return; + } + + m_codePages.add(a_codePage); + } + + public void removeCodePage(String a_codePage) { + if (!containsCodePage(a_codePage)) { + return; + } + + m_codePages.remove(a_codePage); + } + + public void setFontFamilyName(String a_value) { + m_fontFamilyName = a_value; + } + + public String getFontFamilyName() { + return m_fontFamilyName; + } + + public String getVersion() { + return m_version == null ? "0.1" : m_version; + } + + public void setVersion(String a_value) { + m_version = a_value; + } + + public void setDefaultMetrics() { + m_topSideBearing = k_defaultTopSideBearing; + m_ascender = k_defaultAscender; + m_xHeight = k_defaultXHeight; + m_descender = k_defaultDescender; + m_bottomSideBearing = k_defaultBottomSideBearing; + } + + public double getEm() { + return k_em; + } + + public double getBaseline() { + return getBottomSideBearing() + getDescender(); + } + + public double getMeanline() { + return getBottomSideBearing() + + getDescender() + getXHeight(); + } + + public double getBodyBottom() { + return getBottomSideBearing(); + } + + public double getBodyTop() { + return getEm() - getTopSideBearing(); + } + + public double getTopSideBearing() { + if (m_topSideBearing == null) { + setDefaultMetrics(); + } + + return m_topSideBearing; + } + + public double getAscender() { + if (m_ascender == null) { + setDefaultMetrics(); + } + + return m_ascender; + } + + public double getXHeight() { + if (m_xHeight == null) { + setDefaultMetrics(); + } + + return m_xHeight; + } + + public double getDescender() { + if (m_descender == null) { + setDefaultMetrics(); + } + + return m_descender; + } + + public double getBottomSideBearing() { + if (m_bottomSideBearing == null) { + setDefaultMetrics(); + } + + return m_bottomSideBearing; + } + + public void setTopSideBearing(double a_value) throws OutOfRangeException { + checkBoundary(a_value); + m_topSideBearing = a_value; + } + + private void checkBoundary(double a_value) throws OutOfRangeException { + if (a_value > k_em || a_value < 0) { + throw new OutOfRangeException(a_value); + } + } + + public void setAscender(double a_value) throws OutOfRangeException { + checkBoundary(a_value); + m_ascender = a_value; + } + + public void setXHeight(double a_value) throws OutOfRangeException { + checkBoundary(a_value); + if (a_value > getAscender()) { + throw new OutOfRangeException(a_value); + } + + m_xHeight = a_value; + } + + public void setDescender(double a_value) throws OutOfRangeException { + checkBoundary(a_value); + m_descender = a_value; + } + + public void setBottomSideBearing(double a_value) throws OutOfRangeException { + checkBoundary(a_value); + m_bottomSideBearing = a_value; + } + + public double getBodyHeight() { + return k_em - getTopSideBearing() - getBottomSideBearing(); + } + + // -------------------------------------------------------------------- + /** + * Calls FontFileWriter to produce TrueType font file. + */ + public void buildTTF() throws Exception { + String randomString = UUID.randomUUID().toString().substring(0, 4); + + File tempFile = new File(m_dir, + m_name + "_" + randomString + k_dotTtf); + File target; + String fontFamilyName; + + target = m_ttfFile; + fontFamilyName = getFontFamilyName(); + + target.delete(); + FontFileWriter writer; try (RandomAccessFile randomAccessFile = new RandomAccessFile(target, "rw")) { writer = new FontFileWriter(randomAccessFile); - + writer.setFontFamilyName(fontFamilyName); writer.setCopyrightYear(getCopyrightYear()); writer.setFontVersion(getVersion()); @@ -371,154 +395,154 @@ public class TypefaceFile extends GlyphFile { writer.setXHeight((int) getXHeight()); writer.setDescent((int) getDescender()); writer.setLineGap((int) (getTopSideBearing() + getBottomSideBearing())); - + loadCodePages(writer); loadUnicodeRanges(writer); loadGlyphs(writer); writer.write(); } - if (target.exists()) { - copyFile(target, tempFile); - } - - FileInputStream in = new FileInputStream(tempFile); - m_font = Font.createFont(Font.TRUETYPE_FONT, - (InputStream) in); - in.close(); - } - - 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_codePages) { - TTCodePage codePage = TTCodePage.forName(codePageName); - if (codePage == null) { - continue; - } - - a_writer.setCodeRangeFlag(codePage.getOsTwoFlag()); - } // for codePageName - } - - private void loadUnicodeRanges(FontFileWriter a_writer) { - for (String unicodeRange : m_unicodeRanges) { - if (!TTUnicodeRange.find(unicodeRange)) { - continue; - } - - a_writer.addUnicodeRange(TTUnicodeRange.getLastFound()); - } - } - - private void loadGlyphs(FontFileWriter a_writer) throws Exception { - for (GlyphFile glyphFile : m_glyphFiles) { - loadGlyph(glyphFile, a_writer); - } - } - - /** - * load the glyph into FontFileWriter. - * @param a_fileName - * @param a_writer - * @throws Exception - */ - private void loadGlyph(GlyphFile a_glyphFile, FontFileWriter a_writer) throws Exception { - TTGlyph glyph = null; - - if (a_glyphFile.isSimple()) { - // glyph will be null if it is empty - glyph = a_glyphFile.toSimpleGlyph(); - } else { - glyph = createCompoundGlyph(a_glyphFile, a_writer); - } - - if (glyph == null && a_glyphFile.isWhiteSpace()) { - glyph = new TTGlyph(); - } - - if (glyph == null) { - return; - } - - int glyphIndex = a_writer.addGlyph(glyph); - long unicode = a_glyphFile.getUnicode(); - - if (unicode != -1) { - long existingIndex = a_writer.getCharacterMapping(unicode); - if (existingIndex != 0) { - throw new Exception(Long.toHexString(unicode) + " is mapped already."); - } - - a_writer.addCharacterMapping(unicode, glyphIndex); - } - } - - 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); - } - - int i = 0; - - 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(); - } - - retval.addGlyfIndex(glyfIndex); - if (i < indeces.size() - 1) { - retval.addFlag(flag | TTGlyph.MORE_COMPONENTS); - } else { - retval.addFlag(flag); - } - - 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; - } + if (target.exists()) { + copyFile(target, tempFile); + } + + FileInputStream in = new FileInputStream(tempFile); + m_font = Font.createFont(Font.TRUETYPE_FONT, + (InputStream) in); + in.close(); + } + + 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_codePages) { + TTCodePage codePage = TTCodePage.forName(codePageName); + if (codePage == null) { + continue; + } + + a_writer.setCodeRangeFlag(codePage.getOsTwoFlag()); + } // for codePageName + } + + private void loadUnicodeRanges(FontFileWriter a_writer) { + for (String unicodeRange : m_unicodeRanges) { + if (!TTUnicodeRange.find(unicodeRange)) { + continue; + } + + a_writer.addUnicodeRange(TTUnicodeRange.getLastFound()); + } + } + + private void loadGlyphs(FontFileWriter a_writer) throws Exception { + for (GlyphFile glyphFile : m_glyphFiles) { + loadGlyph(glyphFile, a_writer); + } + } + + /** + * load the glyph into FontFileWriter. + * + * @param a_fileName + * @param a_writer + * @throws Exception + */ + private void loadGlyph(GlyphFile a_glyphFile, FontFileWriter a_writer) throws Exception { + TTGlyph glyph = null; + + if (a_glyphFile.isSimple()) { + // glyph will be null if it is empty + glyph = a_glyphFile.toSimpleGlyph(); + } else { + glyph = createCompoundGlyph(a_glyphFile, a_writer); + } + + if (glyph == null && a_glyphFile.isWhiteSpace()) { + glyph = new TTGlyph(); + } + + if (glyph == null) { + return; + } + + int glyphIndex = a_writer.addGlyph(glyph); + long unicode = a_glyphFile.getUnicode(); + + if (unicode != -1) { + long existingIndex = a_writer.getCharacterMapping(unicode); + if (existingIndex != 0) { + throw new Exception(Long.toHexString(unicode) + " is mapped already."); + } + + a_writer.addCharacterMapping(unicode, glyphIndex); + } + } + + 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); + } + + int i = 0; + + 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(); + } + + retval.addGlyfIndex(glyfIndex); + if (i < indeces.size() - 1) { + retval.addFlag(flag | TTGlyph.MORE_COMPONENTS); + } else { + retval.addFlag(flag); + } + + 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/libsrc/ttf/src/org/doubletype/ossa/truetype/CmapWriter.java b/libsrc/ttf/src/org/doubletype/ossa/truetype/CmapWriter.java index b76c0721e..4b32d7788 100644 --- a/libsrc/ttf/src/org/doubletype/ossa/truetype/CmapWriter.java +++ b/libsrc/ttf/src/org/doubletype/ossa/truetype/CmapWriter.java @@ -1,8 +1,8 @@ /* * $Id: CmapWriter.java,v 1.8 2004/01/27 00:35:08 eed3si9n Exp $ - * + * * $Copyright: copyright (c) 2003, e.e d3si9n $ - * $License: + * $License: * This source code is part of DoubleType. * DoubleType is a graphical typeface designer. * @@ -25,291 +25,308 @@ * 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 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.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * @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; - } - - 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 - } - - 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(); - } - 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); - } - - writeUInt16(TTName.k_microsoft); - writeUInt16(TTName.k_winUnicodeEncode); - int version4Offset = size() + 4; - if (m_isIncludeVersion0) { - version4Offset += m_version0.length; - } - writeUInt32(version4Offset); - - if (m_isIncludeVersion0) { - m_buffer.write(m_version0); - } - - m_buffer.write(m_version4); - pad(); - } - - private int getNumOfEncoding() { - if (m_isIncludeVersion0) { - return 2; - } - - 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); - } - - 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)); - } - } - } - - 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()); - } - - // reserverdPad - writeUInt16(0); - - // startCount - for (i = 0; i < segCount; i++) { - Long n = m_startCodes.get(i); - writeUInt16(n.intValue()); - } - - // idDelta - for (i = 0; i < segCount; i++) { - Long n = m_idDeltas.get(i); - writeInt16(n.intValue()); - } - - // 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)); - } - - 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)); - } - } - - /** - * 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; - } + + 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 Map m_unicode2glyph = new HashMap<>(); + + 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; + } + + 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 + } + + 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(); + } + 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); + } + + writeUInt16(TTName.k_microsoft); + writeUInt16(TTName.k_winUnicodeEncode); + int version4Offset = size() + 4; + if (m_isIncludeVersion0) { + version4Offset += m_version0.length; + } + writeUInt32(version4Offset); + + if (m_isIncludeVersion0) { + m_buffer.write(m_version0); + } + + m_buffer.write(m_version4); + pad(); + } + + private int getNumOfEncoding() { + if (m_isIncludeVersion0) { + return 2; + } + + 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); + } + + 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)); + } + } + } + + 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()); + } + + // reserverdPad + writeUInt16(0); + + // startCount + for (i = 0; i < segCount; i++) { + Long n = m_startCodes.get(i); + writeUInt16(n.intValue()); + } + + // idDelta + for (i = 0; i < segCount; i++) { + Long n = m_idDeltas.get(i); + writeInt16(n.intValue()); + } + + // 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)); + } + + 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)); + } + } + + /** + * 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/libsrc/ttf/src/org/doubletype/ossa/truetype/FontFileWriter.java b/libsrc/ttf/src/org/doubletype/ossa/truetype/FontFileWriter.java index 4d182d965..5a56238e1 100644 --- a/libsrc/ttf/src/org/doubletype/ossa/truetype/FontFileWriter.java +++ b/libsrc/ttf/src/org/doubletype/ossa/truetype/FontFileWriter.java @@ -1,8 +1,8 @@ /* * $Id: FontFileWriter.java,v 1.15 2004/10/04 02:25:39 eed3si9n Exp $ - * + * * $Copyright: copyright (c) 2003, e.e d3si9n $ - * $License: + * $License: * This source code is part of DoubleType. * DoubleType is a graphical typeface designer. * @@ -25,262 +25,278 @@ * 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 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.io.IOException; +import java.io.RandomAccessFile; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; /** * @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 + + 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); - } - } - - 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; - } + 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); + } + } + + 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/libsrc/ttf/src/org/doubletype/ossa/truetype/FontFormatWriter.java b/libsrc/ttf/src/org/doubletype/ossa/truetype/FontFormatWriter.java index c4f3dd3e0..8091c6784 100644 --- a/libsrc/ttf/src/org/doubletype/ossa/truetype/FontFormatWriter.java +++ b/libsrc/ttf/src/org/doubletype/ossa/truetype/FontFormatWriter.java @@ -1,8 +1,8 @@ /* * $Id: FontFormatWriter.java,v 1.6 2004/01/28 11:44:08 eed3si9n Exp $ - * + * * $Copyright: copyright (c) 2003, e.e d3si9n $ - * $License: + * $License: * This source code is part of DoubleType. * DoubleType is a graphical typeface designer. * @@ -25,149 +25,154 @@ * 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 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.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.util.Date; /** * @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++; - } - - 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)); - } - } - - 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; - } - - return retval; - } - - protected void pad() throws IOException { - int align = 4; - int numOfPad = align - m_bytes.size() % align; - if (numOfPad == align) - return; - - int i; - for (i = 0; i < numOfPad; i++) { - writeUInt8(0); - } - } - - public int getOffset() { - return m_offset; - } - - public void setOffset(int a_value) { - m_offset = a_value; - } + + 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++; + } + + 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)); + } + } + + 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; + } + + return retval; + } + + protected void pad() throws IOException { + int align = 4; + int numOfPad = align - m_bytes.size() % align; + if (numOfPad == align) { + return; + } + + for (int i = 0; i < numOfPad; i++) { + writeUInt8(0); + } + } + + public int getOffset() { + return m_offset; + } + + public void setOffset(int a_value) { + m_offset = a_value; + } } diff --git a/libsrc/ttf/src/org/doubletype/ossa/truetype/GlyfWriter.java b/libsrc/ttf/src/org/doubletype/ossa/truetype/GlyfWriter.java index 16b9ca46f..bb373e13d 100644 --- a/libsrc/ttf/src/org/doubletype/ossa/truetype/GlyfWriter.java +++ b/libsrc/ttf/src/org/doubletype/ossa/truetype/GlyfWriter.java @@ -1,8 +1,8 @@ /* * $Id: GlyfWriter.java,v 1.17 2004/09/23 07:47:39 eed3si9n Exp $ - * + * * $Copyright: copyright (c) 2003, e.e d3si9n $ - * $License: + * $License: * This source code is part of DoubleType. * DoubleType is a graphical typeface designer. * @@ -25,180 +25,182 @@ * 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 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.*; +import java.awt.Point; +import java.io.IOException; +import java.util.ArrayList; /** * @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++) { - TTGlyph glyph = m_glyphs.get(i); - writeGlyph(glyph); - m_hdmx.updatePixelWidth(i, glyph); - } - - 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 (a_glyph.isSimple()) { - writeSimpleGlyph(a_glyph); - } else { - writeCompoundGlyph(a_glyph); - } - - pad(); - } - - /** - * @param a_glyph - * @throws IOException - */ - private void writeSimpleGlyph(TTGlyph a_glyph) throws IOException { - if (a_glyph.getNumOfContours() == 0) { - return; - } - - 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)); - } - - int numOfInst = a_glyph.getNumOfInstructions(); - m_maxp.updateSizeOfInstructions(numOfInst); - - writeUInt16(numOfInst); - for (i = 0; i < numOfInst; i++) { - writeUInt8(a_glyph.getInstruction(i)); - } - - for (i = 0; i < a_glyph.getNumOfFlags(); i++) { - int flag = a_glyph.getFlag(i); - writeUInt8(flag); - } - - // 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; - } - - int lastY = 0; - for (i = 0; i < a_glyph.getNumOfPoints(); i++) { - Point point = a_glyph.getPoint(i); - - writeInt16(point.y - lastY); - lastY = point.y; - } - } - - /** - * @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)); - } - } - /** - * @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); - } + private ArrayList m_glyphs; - protected String getTag() { - return "glyf"; - } + 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++) { + TTGlyph glyph = m_glyphs.get(i); + writeGlyph(glyph); + m_hdmx.updatePixelWidth(i, glyph); + } + + 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 (a_glyph.isSimple()) { + writeSimpleGlyph(a_glyph); + } else { + writeCompoundGlyph(a_glyph); + } + + pad(); + } + + /** + * @param a_glyph + * @throws IOException + */ + private void writeSimpleGlyph(TTGlyph a_glyph) throws IOException { + if (a_glyph.getNumOfContours() == 0) { + return; + } + + 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)); + } + + int numOfInst = a_glyph.getNumOfInstructions(); + m_maxp.updateSizeOfInstructions(numOfInst); + + writeUInt16(numOfInst); + for (i = 0; i < numOfInst; i++) { + writeUInt8(a_glyph.getInstruction(i)); + } + + for (i = 0; i < a_glyph.getNumOfFlags(); i++) { + int flag = a_glyph.getFlag(i); + writeUInt8(flag); + } + + // 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; + } + + int lastY = 0; + for (i = 0; i < a_glyph.getNumOfPoints(); i++) { + Point point = a_glyph.getPoint(i); + + writeInt16(point.y - lastY); + lastY = point.y; + } + } + + /** + * @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)); + } + } + + /** + * @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/libsrc/ttf/src/org/doubletype/ossa/truetype/HdmxWriter.java b/libsrc/ttf/src/org/doubletype/ossa/truetype/HdmxWriter.java index 83561fd20..04cc95ef9 100644 --- a/libsrc/ttf/src/org/doubletype/ossa/truetype/HdmxWriter.java +++ b/libsrc/ttf/src/org/doubletype/ossa/truetype/HdmxWriter.java @@ -1,6 +1,6 @@ /* * $Copyright: copyright (c) 2003-2008, e.e d3si9n $ - * $License: + * $License: * This source code is part of DoubleType. * DoubleType is a graphical typeface designer. * @@ -23,95 +23,96 @@ * 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 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.io.IOException; +import java.util.ArrayList; /** * 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; - } - int size = m_numGlyphs + 2 + numOfPads; // 2 comes from the ppem and max - - // format version number - writeInt16(0); - - // number of device records - writeInt16(getNumOfPixelSizes()); +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; + } + 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"; - } + // 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/libsrc/ttf/src/org/doubletype/ossa/truetype/HeadWriter.java b/libsrc/ttf/src/org/doubletype/ossa/truetype/HeadWriter.java index 80c13c4f6..4716deebf 100644 --- a/libsrc/ttf/src/org/doubletype/ossa/truetype/HeadWriter.java +++ b/libsrc/ttf/src/org/doubletype/ossa/truetype/HeadWriter.java @@ -1,8 +1,8 @@ /* * $Id: HeadWriter.java,v 1.7 2004/09/26 09:15:48 eed3si9n Exp $ - * + * * $Copyright: copyright (c) 2003, e.e d3si9n $ - * $License: + * $License: * This source code is part of DoubleType. * DoubleType is a graphical typeface designer. * @@ -25,132 +25,139 @@ * 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 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.*; +import java.awt.Point; +import java.io.IOException; +import java.util.Date; /** * @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 (a_value.y < m_min.y) { - m_min.y = a_value.y; - } - } - - public void updateMax(Point a_value) { - if (a_value.x > m_max.x) { - m_max.x = a_value.x; - } - - if (a_value.y > m_max.y) { - m_max.y = a_value.y; - } - } - - 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"; - } + + 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 (a_value.y < m_min.y) { + m_min.y = a_value.y; + } + } + + public void updateMax(Point a_value) { + if (a_value.x > m_max.x) { + m_max.x = a_value.x; + } + + if (a_value.y > m_max.y) { + m_max.y = a_value.y; + } + } + + 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/libsrc/ttf/src/org/doubletype/ossa/truetype/HheaWriter.java b/libsrc/ttf/src/org/doubletype/ossa/truetype/HheaWriter.java index 8320314fe..9b96b71e5 100644 --- a/libsrc/ttf/src/org/doubletype/ossa/truetype/HheaWriter.java +++ b/libsrc/ttf/src/org/doubletype/ossa/truetype/HheaWriter.java @@ -1,8 +1,8 @@ /* * $Id: HheaWriter.java,v 1.5 2004/09/26 09:15:48 eed3si9n Exp $ - * + * * $Copyright: copyright (c) 2003, e.e d3si9n $ - * $License: + * $License: * This source code is part of DoubleType. * DoubleType is a graphical typeface designer. * @@ -25,84 +25,87 @@ * 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 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.io.IOException; /** * HheaWriter depends on HtmxWriter. + * * @author e.e */ -public class HheaWriter extends FontFormatWriter { +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); - } - - writeInt16(0); - - int numOfHMetrics = m_glyf.numOfGlyph(); - writeUInt16(numOfHMetrics); - - pad(); - } - - protected String getTag() { - return "hhea"; - } + + 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); + } + + writeInt16(0); + + int numOfHMetrics = m_glyf.numOfGlyph(); + writeUInt16(numOfHMetrics); + + pad(); + } + + protected String getTag() { + return "hhea"; + } } diff --git a/libsrc/ttf/src/org/doubletype/ossa/truetype/HmtxWriter.java b/libsrc/ttf/src/org/doubletype/ossa/truetype/HmtxWriter.java index f74bab3d2..c9e9f342b 100644 --- a/libsrc/ttf/src/org/doubletype/ossa/truetype/HmtxWriter.java +++ b/libsrc/ttf/src/org/doubletype/ossa/truetype/HmtxWriter.java @@ -1,8 +1,8 @@ /* * $Id: HmtxWriter.java,v 1.10 2004/10/04 02:25:39 eed3si9n Exp $ - * + * * $Copyright: copyright (c) 2003, e.e d3si9n $ - * $License: + * $License: * This source code is part of DoubleType. * DoubleType is a graphical typeface designer. * @@ -25,65 +25,65 @@ * 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 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.io.IOException; /** * 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 (glyph.getRightSideBearing() < minRightSideBearing) { - minRightSideBearing = glyph.getRightSideBearing(); - } - - writeUFWord(glyph.getAdvanceWidth()); - writeFWord(glyph.getLeftSideBearing()); - } - - writeFWord(0); - - m_hhea.setMaxAdvanceWidth(maxWidth); - m_hhea.setMinRightSideBearing(minRightSideBearing); - - pad(); - } - - protected String getTag() { - return "hmtx"; - } +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 (glyph.getRightSideBearing() < minRightSideBearing) { + minRightSideBearing = glyph.getRightSideBearing(); + } + + writeUFWord(glyph.getAdvanceWidth()); + writeFWord(glyph.getLeftSideBearing()); + } + + writeFWord(0); + + m_hhea.setMaxAdvanceWidth(maxWidth); + m_hhea.setMinRightSideBearing(minRightSideBearing); + + pad(); + } + + protected String getTag() { + return "hmtx"; + } } diff --git a/libsrc/ttf/src/org/doubletype/ossa/truetype/LocaWriter.java b/libsrc/ttf/src/org/doubletype/ossa/truetype/LocaWriter.java index 857634e6b..bd44ec497 100644 --- a/libsrc/ttf/src/org/doubletype/ossa/truetype/LocaWriter.java +++ b/libsrc/ttf/src/org/doubletype/ossa/truetype/LocaWriter.java @@ -1,8 +1,8 @@ /* * $Id: LocaWriter.java,v 1.3 2004/01/15 07:06:27 eed3si9n Exp $ - * + * * $Copyright: copyright (c) 2003, e.e d3si9n $ - * $License: + * $License: * This source code is part of DoubleType. * DoubleType is a graphical typeface designer. * @@ -25,43 +25,42 @@ * 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 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.io.IOException; +import java.util.ArrayList; /** * @author e.e */ public class LocaWriter extends FontFormatWriter { - public ArrayList m_offsets = new ArrayList<>(); - - public LocaWriter() { - super(); - } - - public void write() throws IOException { + + 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)); - } - - pad(); - } - - protected String getTag() { - return "loca"; - } + // and offsets are stored in m_offsets + + int i; + for (i = 0; i < m_offsets.size(); i++) { + writeUInt32(m_offsets.get(i)); + } + + pad(); + } + + protected String getTag() { + return "loca"; + } } diff --git a/libsrc/ttf/src/org/doubletype/ossa/truetype/MaxpWriter.java b/libsrc/ttf/src/org/doubletype/ossa/truetype/MaxpWriter.java index b82b035b1..a537352f3 100644 --- a/libsrc/ttf/src/org/doubletype/ossa/truetype/MaxpWriter.java +++ b/libsrc/ttf/src/org/doubletype/ossa/truetype/MaxpWriter.java @@ -1,8 +1,8 @@ /* * $Id: MaxpWriter.java,v 1.11 2004/06/27 07:26:46 eed3si9n Exp $ - * + * * $Copyright: copyright (c) 2003, e.e d3si9n $ - * $License: + * $License: * This source code is part of DoubleType. * DoubleType is a graphical typeface designer. * @@ -25,113 +25,132 @@ * 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 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.io.IOException; /** * @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; - } - } - - /** update points in non-compound glyph */ - public void updateNumOfContours(int a_value) { - if (a_value > m_maxContours) { - m_maxContours = a_value; - } - } - - public void updateNumOfCompositePoints(int a_value) { - if (a_value > m_maxCompositePoints) { - m_maxCompositePoints = a_value; - } - } - - public void updateNumOfCompositeContours(int a_value) { - if (a_value > m_maxCompositeContours) { - m_maxCompositeContours = a_value; - } - } - - /** update byte count for glyph instructions */ - public void updateSizeOfInstructions(int a_value) { - if (a_value > m_maxSizeOfInstructions) { - m_maxSizeOfInstructions = a_value; - } - } - - public void updateNumOfComponentElements(int a_value) { - if (a_value > m_maxComponentElements) { - m_maxComponentElements = a_value; - } - } - - public void updateComponentDepth(int a_value) { - if (a_value > m_maxComponentDepth) { - m_maxComponentDepth = a_value; - } - } +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; + } + } + + /** + * update points in non-compound glyph + */ + public void updateNumOfContours(int a_value) { + if (a_value > m_maxContours) { + m_maxContours = a_value; + } + } + + public void updateNumOfCompositePoints(int a_value) { + if (a_value > m_maxCompositePoints) { + m_maxCompositePoints = a_value; + } + } + + public void updateNumOfCompositeContours(int a_value) { + if (a_value > m_maxCompositeContours) { + m_maxCompositeContours = a_value; + } + } + + /** + * update byte count for glyph instructions + */ + public void updateSizeOfInstructions(int a_value) { + if (a_value > m_maxSizeOfInstructions) { + m_maxSizeOfInstructions = a_value; + } + } + + public void updateNumOfComponentElements(int a_value) { + if (a_value > m_maxComponentElements) { + m_maxComponentElements = a_value; + } + } + + public void updateComponentDepth(int a_value) { + if (a_value > m_maxComponentDepth) { + m_maxComponentDepth = a_value; + } + } } diff --git a/libsrc/ttf/src/org/doubletype/ossa/truetype/NameWriter.java b/libsrc/ttf/src/org/doubletype/ossa/truetype/NameWriter.java index cfe93a533..71dd048fe 100644 --- a/libsrc/ttf/src/org/doubletype/ossa/truetype/NameWriter.java +++ b/libsrc/ttf/src/org/doubletype/ossa/truetype/NameWriter.java @@ -1,8 +1,8 @@ /* * $Id: NameWriter.java,v 1.9 2004/06/16 07:02:52 eed3si9n Exp $ - * + * * $Copyright: copyright (c) 2003, e.e d3si9n $ - * $License: + * $License: * This source code is part of DoubleType. * DoubleType is a graphical typeface designer. * @@ -25,159 +25,168 @@ * 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 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.io.IOException; +import java.util.ArrayList; /** * @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"; - } - - 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 (TTName name: m_names) { - m_buffer.write(name.getBytes()); - } - - pad(); - } - - protected String getTag() { - return "name"; - } +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"; + } + + 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(); + } + } + + 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 (TTName name : m_names) { + m_buffer.write(name.getBytes()); + } + + pad(); + } + + protected String getTag() { + return "name"; + } } diff --git a/libsrc/ttf/src/org/doubletype/ossa/truetype/OS2Writer.java b/libsrc/ttf/src/org/doubletype/ossa/truetype/OS2Writer.java index c846bff26..a1f7e3c20 100644 --- a/libsrc/ttf/src/org/doubletype/ossa/truetype/OS2Writer.java +++ b/libsrc/ttf/src/org/doubletype/ossa/truetype/OS2Writer.java @@ -1,8 +1,8 @@ /* * $Id: OS2Writer.java,v 1.11 2004/10/04 02:25:39 eed3si9n Exp $ - * + * * $Copyright: copyright (c) 2003, e.e d3si9n $ - * $License: + * $License: * This source code is part of DoubleType. * DoubleType is a graphical typeface designer. * @@ -25,218 +25,267 @@ * 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 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.io.IOException; /** * @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; - } - - // 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 "; - } +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; + } + + // 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/libsrc/ttf/src/org/doubletype/ossa/truetype/PostWriter.java b/libsrc/ttf/src/org/doubletype/ossa/truetype/PostWriter.java index b7ac25959..e7eee79ab 100644 --- a/libsrc/ttf/src/org/doubletype/ossa/truetype/PostWriter.java +++ b/libsrc/ttf/src/org/doubletype/ossa/truetype/PostWriter.java @@ -1,8 +1,8 @@ /* * $Id: PostWriter.java,v 1.3 2004/01/11 13:14:45 eed3si9n Exp $ - * + * * $Copyright: copyright (c) 2003, e.e d3si9n $ - * $License: + * $License: * This source code is part of DoubleType. * DoubleType is a graphical typeface designer. * @@ -25,52 +25,51 @@ * 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 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.io.IOException; /** * @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); - } - - // vm memory stuff - writeUInt32(0); - writeUInt32(0); - writeUInt32(0); - writeUInt32(0); - - pad(); - } - - protected String getTag() { - return "post"; - } +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); + } + + // vm memory stuff + writeUInt32(0); + writeUInt32(0); + writeUInt32(0); + writeUInt32(0); + + pad(); + } + + protected String getTag() { + return "post"; + } } diff --git a/libsrc/ttf/src/org/doubletype/ossa/truetype/TTCodePage.java b/libsrc/ttf/src/org/doubletype/ossa/truetype/TTCodePage.java index b619a1e1c..9d3dd14ee 100644 --- a/libsrc/ttf/src/org/doubletype/ossa/truetype/TTCodePage.java +++ b/libsrc/ttf/src/org/doubletype/ossa/truetype/TTCodePage.java @@ -1,8 +1,8 @@ /* * $Id: TTCodePage.java,v 1.3 2004/05/16 12:59:07 eed3si9n Exp $ - * + * * $Copyright: copyright (c) 2003-2004, e.e d3si9n $ - * $License: + * $License: * This source code is part of DoubleType. * DoubleType is a graphical typeface designer. * @@ -25,165 +25,136 @@ * 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 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.*; +import java.nio.charset.Charset; +import java.util.ArrayList; /** * @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(); - } - - 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 (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); - } - - 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; - } + + 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(); + } + + 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 (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); + } + + 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/libsrc/ttf/src/org/doubletype/ossa/truetype/TTGlyph.java b/libsrc/ttf/src/org/doubletype/ossa/truetype/TTGlyph.java index 775f0a977..996bbd561 100644 --- a/libsrc/ttf/src/org/doubletype/ossa/truetype/TTGlyph.java +++ b/libsrc/ttf/src/org/doubletype/ossa/truetype/TTGlyph.java @@ -1,6 +1,6 @@ /* * $Copyright: copyright (c) 2003-2008, e.e d3si9n $ - * $License: + * $License: * This source code is part of DoubleType. * DoubleType is a graphical typeface designer. * @@ -23,369 +23,418 @@ * 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 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.*; +import java.awt.Point; +import java.util.ArrayList; /** * @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"); - } - - 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; - } - - 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"); - } - - int selector = 0; - if (a_step > 0) { - selector = a_step + 7; - } else { - selector = a_step + 8; - } - - 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; - } - } - - 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); - } - - return m_max; - } - public Point getMin() { - if (m_min == null) { - m_min = new Point(0, 0); - } - - 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 (m_min == null) { - m_min = new Point(a_value); - } - - if (a_value.x > m_max.x) { - m_max.x = a_value.x; - } - - if (a_value.x < m_min.x) { - m_min.x = a_value.x; - } - - if (a_value.y > m_max.y) { - m_max.y = a_value.y; - } - - if (a_value.y < m_min.y) { - m_min.y = a_value.y; - } - } - - 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; - } - } - - public void setNumOfCompositeContours(int a_value) { - m_numOfCompositeContours = a_value; - } - - public int getComponentDepth() { - if (isSimple()) { - return 0; - } else { - return m_componentDepth; - } - } - - public void setComponentDepth(int a_value) { - m_componentDepth = a_value; - } - - public int getLeftSideBearing() { - return getMin().x; - } - - public int getRightSideBearing() { - return getAdvanceWidth() - getMax().x; - } + // -------------------------------------------------------------- + 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"); + } + + 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; + } + + 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"); + } + + int selector = 0; + if (a_step > 0) { + selector = a_step + 7; + } else { + selector = a_step + 8; + } + + 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; + } + } + + 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); + } + + return m_max; + } + + public Point getMin() { + if (m_min == null) { + m_min = new Point(0, 0); + } + + 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 (m_min == null) { + m_min = new Point(a_value); + } + + if (a_value.x > m_max.x) { + m_max.x = a_value.x; + } + + if (a_value.x < m_min.x) { + m_min.x = a_value.x; + } + + if (a_value.y > m_max.y) { + m_max.y = a_value.y; + } + + if (a_value.y < m_min.y) { + m_min.y = a_value.y; + } + } + + 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; + } + } + + public void setNumOfCompositeContours(int a_value) { + m_numOfCompositeContours = a_value; + } + + public int getComponentDepth() { + if (isSimple()) { + return 0; + } else { + return m_componentDepth; + } + } + + 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/libsrc/ttf/src/org/doubletype/ossa/truetype/TTName.java b/libsrc/ttf/src/org/doubletype/ossa/truetype/TTName.java index 659712f16..4fe4be223 100644 --- a/libsrc/ttf/src/org/doubletype/ossa/truetype/TTName.java +++ b/libsrc/ttf/src/org/doubletype/ossa/truetype/TTName.java @@ -1,93 +1,105 @@ -/* - * $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; - } -} +/* + * $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/libsrc/ttf/src/org/doubletype/ossa/truetype/TTPixelSize.java b/libsrc/ttf/src/org/doubletype/ossa/truetype/TTPixelSize.java index a417d40f3..1e731507d 100644 --- a/libsrc/ttf/src/org/doubletype/ossa/truetype/TTPixelSize.java +++ b/libsrc/ttf/src/org/doubletype/ossa/truetype/TTPixelSize.java @@ -3,105 +3,112 @@ 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; - } - } - - public int [] getPixelWidths() { - return m_pixelWidths; - } - - public int getPixelWidth(int a_glyphIndex) { - return m_pixelWidths[a_glyphIndex]; - } - - public int getMaxPixelWidth() { - return m_maxPixelWidth; - } + + 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; + } + } + + 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/libsrc/ttf/src/org/doubletype/ossa/truetype/TTUnicodeRange.java b/libsrc/ttf/src/org/doubletype/ossa/truetype/TTUnicodeRange.java index 95e5c8df1..2e4e0a0e3 100644 --- a/libsrc/ttf/src/org/doubletype/ossa/truetype/TTUnicodeRange.java +++ b/libsrc/ttf/src/org/doubletype/ossa/truetype/TTUnicodeRange.java @@ -1,8 +1,8 @@ /* * $Id: TTUnicodeRange.java,v 1.1 2004/01/25 11:00:10 eed3si9n Exp $ - * + * * $Copyright: copyright (c) 2003-2004, e.e d3si9n $ - * $License: + * $License: * This source code is part of DoubleType. * DoubleType is a graphical typeface designer. * @@ -25,356 +25,357 @@ * 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 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; +import java.util.ArrayList; /** * @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; - } - } - - 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)); - + + 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; + } + } + + 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)); - + 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)); + // 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)); + 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; - } - } - - 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(TTUnicodeRange a_object) { - TTUnicodeRange object = 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; - } + // 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; + } + } + + 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(TTUnicodeRange a_object) { + TTUnicodeRange object = 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; + } }