These are the first bits of code for the automatic gridfitter for
Classpath's TrueType implementation. This is going to be an adaption of
FreeTypes autofitter, in pure Java. Nothing working yet, only some
skeleton classes and basically one method (Latin.initWidths() )
implemented. The plan is to get something finished until the end of the
year.
2006-11-14 Roman Kennke <[EMAIL PROTECTED]>
* gnu/java/awt/font/autofit/AxisHints.java,
* gnu/java/awt/font/autofit/Constants.java,
* gnu/java/awt/font/autofit/GlyphHints.java,
* nu/java/awt/font/autofit/Latin.java,
* nu/java/awt/font/autofit/LatinAxis.java,
* gnu/java/awt/font/autofit/LatinMetrics.java,
* gnu/java/awt/font/autofit/Scaler.java,
* gnu/java/awt/font/autofit/Script.java,
* gnu/java/awt/font/autofit/ScriptMetrics.java,
* gnu/java/awt/font/autofit/Segment.java,
* gnu/java/awt/font/autofit/Width.java:
New classes. This is some skeleton stuff for the FreeType-alike
auto-gridfitter.
* gnu/java/awt/font/opentype/CharGlyphMap.java: Made class public.
* gnu/java/awt/font/opentype/OpenTypeFont.java
(unitsPerEm): Made field public.
(getRawGlyphOutline): New method. Fetches the raw outline.
* gnu/java/awt/font/opentype/Scaler.java
(getRawGlyphOutline): New method. Fetches the raw outline.
* gnu/java/awt/font/opentype/truetype/GlyphLoader.java
(loadGlyph): New method. This is used to load raw outlines.
* gnu/java/awt/font/opentype/truetype/TrueTypeScaler.java
(getRawOutline): New method. Fetches the raw outline.
* gnu/java/awt/font/opentype/truetype/Zone.java:
Made class public.
/Roman
Index: gnu/java/awt/font/autofit/AxisHints.java
===================================================================
RCS file: gnu/java/awt/font/autofit/AxisHints.java
diff -N gnu/java/awt/font/autofit/AxisHints.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/java/awt/font/autofit/AxisHints.java 14 Nov 2006 15:17:32 -0000
@@ -0,0 +1,45 @@
+/* AxisHints.java -- FIXME: briefly describe file purpose
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.awt.font.autofit;
+
+class AxisHints
+{
+
+ Segment[] segments;
+}
Index: gnu/java/awt/font/autofit/Constants.java
===================================================================
RCS file: gnu/java/awt/font/autofit/Constants.java
diff -N gnu/java/awt/font/autofit/Constants.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/java/awt/font/autofit/Constants.java 14 Nov 2006 15:17:32 -0000
@@ -0,0 +1,61 @@
+/* Constants.java -- Some constants used in the autofitter
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.awt.font.autofit;
+
+/**
+ * Some constants used in the autofitter.
+ */
+interface Constants
+{
+
+ /**
+ * The horizontal dimension.
+ */
+ static final int DIMENSION_HORZ = 0;
+
+ /**
+ * The vertical dimension.
+ */
+ static final int DIMENSION_VERT = 1;
+
+ /**
+ * The number of dimensions.
+ */
+ static final int DIMENSION_MAX = 2;
+}
Index: gnu/java/awt/font/autofit/GlyphHints.java
===================================================================
RCS file: gnu/java/awt/font/autofit/GlyphHints.java
diff -N gnu/java/awt/font/autofit/GlyphHints.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/java/awt/font/autofit/GlyphHints.java 14 Nov 2006 15:17:32 -0000
@@ -0,0 +1,75 @@
+/* GlyphHints.java -- Data and methods for actual hinting
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.awt.font.autofit;
+
+import gnu.java.awt.font.opentype.truetype.Zone;
+
+/**
+ * The data and methods used for the actual hinting process.
+ */
+class GlyphHints
+{
+
+ int xScale;
+ int xDelta;
+ int yScale;
+ int yDelta;
+
+ AxisHints[] axis;
+
+ void rescale(ScriptMetrics metrics)
+ {
+ // TODO: Implement.
+ }
+
+ void reload(Zone outline)
+ {
+ // TODO: Implement.
+ }
+
+ void computeSegments(int dim)
+ {
+ // TODO: Implement.
+ }
+
+ void linkSegments(int dim)
+ {
+ // TODO: Implement.
+ }
+}
Index: gnu/java/awt/font/autofit/Latin.java
===================================================================
RCS file: gnu/java/awt/font/autofit/Latin.java
diff -N gnu/java/awt/font/autofit/Latin.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/java/awt/font/autofit/Latin.java 14 Nov 2006 15:17:32 -0000
@@ -0,0 +1,177 @@
+/* Latin.java -- Latin specific glyph handling
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.awt.font.autofit;
+
+import java.awt.geom.AffineTransform;
+
+import gnu.java.awt.font.opentype.OpenTypeFont;
+import gnu.java.awt.font.opentype.truetype.Zone;
+
+/**
+ * Implements Latin specific glyph handling.
+ */
+class Latin
+ implements Script, Constants
+{
+
+ private static final int MAX_WIDTHS = 16;
+
+ public void applyHints(GlyphHints hints, ScriptMetrics metrics)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void doneMetrics(ScriptMetrics metrics)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * Initializes the <code>hints</code> object.
+ *
+ * @param hints the hints to initialize
+ * @param metrics the metrics to use
+ */
+ public void initHints(GlyphHints hints, ScriptMetrics metrics)
+ {
+ hints.rescale(metrics);
+ LatinMetrics lm = (LatinMetrics) metrics;
+ hints.xScale = lm.axis[DIMENSION_HORZ].scale;
+ hints.xDelta = lm.axis[DIMENSION_HORZ].delta;
+ hints.yScale = lm.axis[DIMENSION_VERT].scale;
+ hints.yDelta = lm.axis[DIMENSION_VERT].delta;
+ // TODO: Set the scaler and other flags.
+ }
+
+ /**
+ * Initializes the script metrics.
+ *
+ * @param metrics the script metrics to initialize
+ * @param face the font
+ */
+ public void initMetrics(ScriptMetrics metrics, OpenTypeFont face)
+ {
+ assert metrics instanceof LatinMetrics;
+ LatinMetrics lm = (LatinMetrics) metrics;
+ lm.unitsPerEm = face.unitsPerEm;
+
+ // TODO: Check for latin charmap.
+
+ initWidths(lm, face, 'o');
+ initBlues(lm, face);
+ }
+
+ public void scaleMetrics(ScriptMetrics metrics)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * Determines the standard stem widths.
+ *
+ * @param metrics the metrics to use
+ * @param face the font face
+ * @param ch the character that is used for getting the widths
+ */
+ private void initWidths(LatinMetrics metrics, OpenTypeFont face, char ch)
+ {
+ GlyphHints hints = new GlyphHints();
+ metrics.axis[DIMENSION_HORZ].widthCount = 0;
+ metrics.axis[DIMENSION_VERT].widthCount = 0;
+ int glyphIndex = face.getGlyph(ch);
+ // TODO: Avoid that AffineTransform constructor and change
+ // getRawGlyphOutline() to accept null or remove that parameter altogether.
+ // Consider this when the thing is done and we know what we need that for.
+ Zone outline = face.getRawGlyphOutline(glyphIndex, new AffineTransform());
+ LatinMetrics dummy = new LatinMetrics();
+ Scaler scaler = dummy.scaler;
+ dummy.unitsPerEm = metrics.unitsPerEm;
+ scaler.xScale = scaler.yScale = 10000;
+ scaler.xDelta = scaler.yDelta = 0;
+ scaler.face = face;
+ hints.rescale(dummy);
+ hints.reload(outline);
+ for (int dim = 0; dim < DIMENSION_MAX; dim++)
+ {
+ LatinAxis axis = metrics.axis[dim];
+ AxisHints axHints = hints.axis[dim];
+ int numWidths = 0;
+ hints.computeSegments(dim);
+ hints.linkSegments(dim);
+ Segment[] segs = axHints.segments;
+ for (int i = 0; i < segs.length; i++)
+ {
+ Segment seg = segs[i];
+ Segment link = seg.link;
+ if (link != null && link.link == seg && link.index > i)
+ {
+ int dist = Math.abs(seg.pos - link.pos);
+ if (numWidths < MAX_WIDTHS)
+ axis.widths[numWidths++].org = dist;
+ }
+ }
+ }
+ for (int dim = 0; dim < DIMENSION_MAX; dim++)
+ {
+ LatinAxis axis = metrics.axis[dim];
+ int stdw = axis.widthCount > 0 ? axis.widths[0].org
+ : constant(metrics, 50);
+ axis.edgeDistanceTreshold= stdw / 5;
+ }
+ }
+
+ /**
+ * Initializes the blue zones of the font.
+ *
+ * @param metrics the metrics to use
+ * @param face the font face to analyze
+ */
+ private void initBlues(LatinMetrics metrics, OpenTypeFont face)
+ {
+ // TODO: Implement.
+ }
+
+ private int constant(LatinMetrics metrics, int c)
+ {
+ return c * (metrics.unitsPerEm / 2048);
+ }
+}
Index: gnu/java/awt/font/autofit/LatinAxis.java
===================================================================
RCS file: gnu/java/awt/font/autofit/LatinAxis.java
diff -N gnu/java/awt/font/autofit/LatinAxis.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/java/awt/font/autofit/LatinAxis.java 14 Nov 2006 15:17:32 -0000
@@ -0,0 +1,53 @@
+/* LatinAxis.java -- Axis specific data
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.awt.font.autofit;
+
+/**
+ * Some axis specific data.
+ */
+class LatinAxis
+{
+
+ int scale;
+ int delta;
+
+ int widthCount;
+ Width[] widths;
+ float edgeDistanceTreshold;
+}
Index: gnu/java/awt/font/autofit/LatinMetrics.java
===================================================================
RCS file: gnu/java/awt/font/autofit/LatinMetrics.java
diff -N gnu/java/awt/font/autofit/LatinMetrics.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/java/awt/font/autofit/LatinMetrics.java 14 Nov 2006 15:17:32 -0000
@@ -0,0 +1,51 @@
+/* LatinMetrics.java -- Latin specific metrics data
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.awt.font.autofit;
+
+/**
+ * Latin specific metrics data.
+ */
+class LatinMetrics
+ extends ScriptMetrics
+{
+
+ LatinAxis[] axis;
+
+ int unitsPerEm;
+}
Index: gnu/java/awt/font/autofit/Scaler.java
===================================================================
RCS file: gnu/java/awt/font/autofit/Scaler.java
diff -N gnu/java/awt/font/autofit/Scaler.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/java/awt/font/autofit/Scaler.java 14 Nov 2006 15:17:32 -0000
@@ -0,0 +1,52 @@
+/* Scaler.java -- FIXME: briefly describe file purpose
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.awt.font.autofit;
+
+import gnu.java.awt.font.opentype.OpenTypeFont;
+
+class Scaler
+{
+
+ int xScale;
+ int xDelta;
+ int yScale;
+ int yDelta;
+ OpenTypeFont face;
+
+}
Index: gnu/java/awt/font/autofit/Script.java
===================================================================
RCS file: gnu/java/awt/font/autofit/Script.java
diff -N gnu/java/awt/font/autofit/Script.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/java/awt/font/autofit/Script.java 14 Nov 2006 15:17:32 -0000
@@ -0,0 +1,62 @@
+/* Script.java -- Defines script specific interface to the autofitter
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.awt.font.autofit;
+
+import gnu.java.awt.font.opentype.OpenTypeFont;
+
+/**
+ * Defines script specific methods for the auto fitter.
+ */
+interface Script
+{
+
+ /**
+ * Initializes the metrics.
+ */
+ void initMetrics(ScriptMetrics metrics, OpenTypeFont face);
+
+ void scaleMetrics(ScriptMetrics metrics/* , scaler, map this */);
+
+ void doneMetrics(ScriptMetrics metrics);
+
+ void initHints(GlyphHints hints, ScriptMetrics metrics);
+
+ void applyHints(GlyphHints hints, /* some outline object, */
+ ScriptMetrics metrics);
+}
Index: gnu/java/awt/font/autofit/ScriptMetrics.java
===================================================================
RCS file: gnu/java/awt/font/autofit/ScriptMetrics.java
diff -N gnu/java/awt/font/autofit/ScriptMetrics.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/java/awt/font/autofit/ScriptMetrics.java 14 Nov 2006 15:17:32 -0000
@@ -0,0 +1,49 @@
+/* ScriptMetrics.java -- Script specific metrics data
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.awt.font.autofit;
+
+/**
+ * Script specific metrics data.
+ */
+class ScriptMetrics
+{
+
+ Script script;
+ Scaler scaler;
+}
Index: gnu/java/awt/font/autofit/Segment.java
===================================================================
RCS file: gnu/java/awt/font/autofit/Segment.java
diff -N gnu/java/awt/font/autofit/Segment.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/java/awt/font/autofit/Segment.java 14 Nov 2006 15:17:32 -0000
@@ -0,0 +1,47 @@
+/* Segment.java -- FIXME: briefly describe file purpose
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.awt.font.autofit;
+
+class Segment
+{
+
+ Segment link;
+ int index;
+ int pos;
+}
Index: gnu/java/awt/font/autofit/Width.java
===================================================================
RCS file: gnu/java/awt/font/autofit/Width.java
diff -N gnu/java/awt/font/autofit/Width.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/java/awt/font/autofit/Width.java 14 Nov 2006 15:17:32 -0000
@@ -0,0 +1,46 @@
+/* Width.java -- FIXME: briefly describe file purpose
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath 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, or (at your option)
+any later version.
+
+GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.awt.font.autofit;
+
+public class Width
+{
+ int org;
+ int cur;
+ int fit;
+}
Index: gnu/java/awt/font/opentype/CharGlyphMap.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/font/opentype/CharGlyphMap.java,v
retrieving revision 1.1
diff -u -1 -5 -r1.1 CharGlyphMap.java
--- gnu/java/awt/font/opentype/CharGlyphMap.java 30 Apr 2006 09:45:11 -0000 1.1
+++ gnu/java/awt/font/opentype/CharGlyphMap.java 14 Nov 2006 15:17:33 -0000
@@ -49,31 +49,31 @@
* does not perform any re-ordering or decomposition, so it
* is not everything that is needed to support Unicode.
*
* <p>This class manages the <code>cmap</code> table of
* OpenType and TrueType fonts.
*
* @see <a href="http://partners.adobe.com/asn/tech/type/opentype/cmap.jsp">
* the <code>cmap</code> part of Adobe’ OpenType Specification</a>
*
* @see <a href="http://developer.apple.com/fonts/TTRefMan/RM06/Chap6cmap.html">
* the <code>cmap</code> section of Apple’s TrueType Reference
* Manual</a>
*
* @author Sascha Brawer ([EMAIL PROTECTED])
*/
-abstract class CharGlyphMap
+public abstract class CharGlyphMap
{
private static final int PLATFORM_UNICODE = 0;
private static final int PLATFORM_MACINTOSH = 1;
private static final int PLATFORM_MICROSOFT = 3;
/**
* Determines the glyph index for a given Unicode codepoint. Users
* should be aware that the character-to-glyph mapping not not
* everything that is needed for full Unicode support. For example,
* the <code>cmap</code> table is not able to synthesize accented
* glyphs from the canonical decomposition sequence, even if the
* font would contain a glyph for the composed form.
*
* @param ucs4 the Unicode codepoint in UCS-4 encoding. Surrogates
Index: gnu/java/awt/font/opentype/OpenTypeFont.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/font/opentype/OpenTypeFont.java,v
retrieving revision 1.1
diff -u -1 -5 -r1.1 OpenTypeFont.java
--- gnu/java/awt/font/opentype/OpenTypeFont.java 30 Apr 2006 09:45:11 -0000 1.1
+++ gnu/java/awt/font/opentype/OpenTypeFont.java 14 Nov 2006 15:17:33 -0000
@@ -40,30 +40,31 @@
import java.awt.Font;
import java.awt.FontFormatException;
import java.awt.font.FontRenderContext;
import java.awt.font.GlyphVector;
import java.awt.font.OpenType;
import java.awt.geom.AffineTransform;
import java.awt.geom.GeneralPath;
import java.awt.geom.Point2D;
import java.nio.ByteBuffer;
import java.text.CharacterIterator;
import java.util.Locale;
import gnu.java.awt.font.FontDelegate;
import gnu.java.awt.font.GNUGlyphVector;
import gnu.java.awt.font.opentype.truetype.TrueTypeScaler;
+import gnu.java.awt.font.opentype.truetype.Zone;
/**
* A font that takes its data from OpenType or TrueType font tables.
*
* <p>OpenType is an extension of the TrueType font format. In addition
* to tables for names, kerning or layout, it also stores the shapes
* of individual glyphs. Three formats are recognized for glyphs:
* Quadratic splines (classic TrueType), cubic splines (PostScript),
* and bitmaps.
*
* @see <a
* href="http://partners.adobe.com/asn/tech/type/opentype/">Adobe’s
* OpenType specification</a>
*
@@ -105,31 +106,31 @@
* The version of the font in 16.16 fixed-point encoding, for
* example 0x00010000 for version 1.0. There are also two special
* version IDs used by fonts for Apple Macintosh, namely 'true'
* (0x74727565) and 'typ1'. OpenType fonts sometimes have 'OTTO' as
* their version.
*/
private int version;
/**
* The number of font units per em. For fonts with TrueType
* outlines, this is usually a power of two (such as 2048). For
* OpenType fonts with PostScript outlines, other values are
* acceptable (such as 1000).
*/
- private int unitsPerEm;
+ public int unitsPerEm;
/**
* A factor to convert font units into ems. This value is <code>1 /
* unitsPerEm</code>.
*/
private float emsPerUnit;
/**
* The scaler to which the actual scaling work is delegated.
*/
private Scaler scaler;
@@ -685,30 +686,44 @@
* glyph, or <code>null</code> for bitmap fonts.
*/
public synchronized GeneralPath getGlyphOutline(int glyph,
float pointSize,
AffineTransform transform,
boolean antialias,
boolean fractionalMetrics)
{
/* The synchronization is needed because the scaler is not
* synchronized.
*/
return scaler.getOutline(glyph, pointSize, transform,
antialias, fractionalMetrics);
}
+ /**
+ * Fetches the raw glyph outline for the specified glyph index. This is used
+ * for the autofitter only ATM and is otherwise not usable for outside code.
+ *
+ * @param glyph the glyph index to fetch
+ * @param transform the transform to apply
+ *
+ * @return the raw outline of that glyph
+ */
+ public synchronized Zone getRawGlyphOutline(int glyph,
+ AffineTransform transform)
+ {
+ return scaler.getRawOutline(glyph, transform);
+ }
/**
* Returns a name for the specified glyph. This is useful for
* generating PostScript or PDF files that embed some glyphs of a
* font.
*
* <p><b>Names are not unique:</b> Under some rare circumstances,
* the same name can be returned for different glyphs. It is
* therefore recommended that printer drivers check whether the same
* name has already been returned for antoher glyph, and make the
* name unique by adding the string ".alt" followed by the glyph
* index.</p>
*
* <p>This situation would occur for an OpenType or TrueType font
* that has a <code>post</code> table of format 3 and provides a
Index: gnu/java/awt/font/opentype/Scaler.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/font/opentype/Scaler.java,v
retrieving revision 1.1
diff -u -1 -5 -r1.1 Scaler.java
--- gnu/java/awt/font/opentype/Scaler.java 30 Apr 2006 09:45:11 -0000 1.1
+++ gnu/java/awt/font/opentype/Scaler.java 14 Nov 2006 15:17:33 -0000
@@ -25,30 +25,32 @@
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package gnu.java.awt.font.opentype;
+import gnu.java.awt.font.opentype.truetype.Zone;
+
import java.awt.geom.AffineTransform;
import java.awt.geom.GeneralPath;
import java.awt.geom.Point2D;
/**
* An common superclass for all font scalers. The main task of font
* scaler is to retrieve a scaled and hinted outline for a glyph.
*
* <p>To make text more legible, high-quality fonts contain
* instructions (sometimes also called “hints”) for
* moving the scaled control points towards the coordinate grid of the
* display device.
*
* <p><b>Lack of Thread Safety:</b> Font scalers are intentionally
@@ -177,16 +179,26 @@
* this parameter may indeed affect the result.
*
* @param fractionalMetrics <code>true</code> for fractional metrics,
* <code>false</code> for rounding the result to a pixel boundary.
*
* @param horizontal <code>true</code> for horizontal line layout,
* <code>false</code> for vertical line layout.
*
* @return the descent, which usually is a nagative number.
*/
public abstract float getDescent(float pointSize,
AffineTransform transform,
boolean antialiased,
boolean fractionalMetrics,
boolean horizontal);
+
+ /**
+ * Returns the raw outline data. This is used for the autofitter atm.
+ *
+ * @param glyph the glyph index
+ * @param transform the transform to apply
+ *
+ * @return the raw glyph outline
+ */
+ public abstract Zone getRawOutline(int glyph, AffineTransform transform);
}
Index: gnu/java/awt/font/opentype/truetype/GlyphLoader.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/font/opentype/truetype/GlyphLoader.java,v
retrieving revision 1.1
diff -u -1 -5 -r1.1 GlyphLoader.java
--- gnu/java/awt/font/opentype/truetype/GlyphLoader.java 30 Apr 2006 09:45:11 -0000 1.1
+++ gnu/java/awt/font/opentype/truetype/GlyphLoader.java 14 Nov 2006 15:17:33 -0000
@@ -107,30 +107,35 @@
/**
* @param glyphIndex the number of the glyph whose outlines are to be
* retrieved.
*/
public void loadGlyph(int glyphIndex,
double pointSize,
AffineTransform transform,
boolean antialias,
Zone glyphZone)
{
glyphZone.setNumPoints(4);
loadSubGlyph(glyphIndex, pointSize, transform, antialias, glyphZone,
0, 0);
}
+ public void loadGlyph(int glyphIndex, AffineTransform transform,
+ Zone glyphZone)
+ {
+ loadGlyph(glyphIndex, unitsPerEm, transform, false, glyphZone);
+ }
private void loadSubGlyph(int glyphIndex,
double pointSize,
AffineTransform transform,
boolean antialias,
Zone glyphZone,
int preTranslateX,
int preTranslateY)
{
ByteBuffer glyph;
int numContours;
int xMin, yMin, xMax, yMax;
byte flag;
glyph = glyphLocator.getGlyphData(glyphIndex);
Index: gnu/java/awt/font/opentype/truetype/TrueTypeScaler.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/font/opentype/truetype/TrueTypeScaler.java,v
retrieving revision 1.1
diff -u -1 -5 -r1.1 TrueTypeScaler.java
--- gnu/java/awt/font/opentype/truetype/TrueTypeScaler.java 30 Apr 2006 09:45:11 -0000 1.1
+++ gnu/java/awt/font/opentype/truetype/TrueTypeScaler.java 14 Nov 2006 15:17:33 -0000
@@ -186,30 +186,36 @@
*
* @param fractionalMetrics <code>false</code> for adjusting glyph
* positions to the raster grid of device space.
*/
public GeneralPath getOutline(int glyphIndex,
float pointSize,
AffineTransform deviceTransform,
boolean antialias,
boolean fractionalMetrics)
{
glyphLoader.loadGlyph(glyphIndex, pointSize, deviceTransform,
antialias, glyphZone);
return glyphZone.getPath();
}
+ public Zone getRawOutline(int glyphIndex, AffineTransform transform)
+ {
+ Zone zone = new Zone(glyphZone.getCapacity());
+ glyphLoader.loadGlyph(glyphIndex, transform, zone);
+ return zone;
+ }
/**
* Determines the advance width and height for a glyph.
*
* @param glyphIndex the glyph whose advance width and height is to
* be determined.
*
* @param pointSize the point size of the font.
*
* @param transform a transform that is applied in addition to
* scaling to the specified point size. This is often used for
* scaling according to the device resolution. Those who lack any
* aesthetic sense may also use the transform to slant or stretch
* glyphs.
*
Index: gnu/java/awt/font/opentype/truetype/Zone.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/font/opentype/truetype/Zone.java,v
retrieving revision 1.1
diff -u -1 -5 -r1.1 Zone.java
--- gnu/java/awt/font/opentype/truetype/Zone.java 30 Apr 2006 09:45:11 -0000 1.1
+++ gnu/java/awt/font/opentype/truetype/Zone.java 14 Nov 2006 15:17:33 -0000
@@ -33,31 +33,31 @@
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package gnu.java.awt.font.opentype.truetype;
import java.awt.geom.AffineTransform;
import java.awt.geom.GeneralPath;
import java.awt.geom.PathIterator;
/**
* A collection of points with some additional information.
*/
-final class Zone
+public final class Zone
{
private final int[] pos;
private final int[] origPos;
private final byte[] flags;
private int numPoints;
private static final int FLAG_TOUCHED_X = 1;
private static final int FLAG_TOUCHED_Y = 2;
private static final int FLAG_ON_CURVE = 4;
private static final int FLAG_CONTOUR_END = 8;
public Zone(int maxNumPoints)
{
origPos = new int[maxNumPoints * 2];
pos = new int[maxNumPoints * 2];