foray-commit Mailing List for FOray (Page 14)
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
(139) |
Apr
(98) |
May
(250) |
Jun
(394) |
Jul
(84) |
Aug
(13) |
Sep
(420) |
Oct
(186) |
Nov
(1) |
Dec
(3) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(108) |
Feb
(202) |
Mar
(291) |
Apr
(247) |
May
(374) |
Jun
(227) |
Jul
(231) |
Aug
(60) |
Sep
(31) |
Oct
(45) |
Nov
(18) |
Dec
|
| 2008 |
Jan
(38) |
Feb
(71) |
Mar
(142) |
Apr
|
May
(59) |
Jun
(6) |
Jul
(10) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2009 |
Jan
(12) |
Feb
(4) |
Mar
(88) |
Apr
(121) |
May
(17) |
Jun
(30) |
Jul
|
Aug
(5) |
Sep
|
Oct
(1) |
Nov
|
Dec
|
| 2010 |
Jan
(11) |
Feb
(76) |
Mar
(11) |
Apr
|
May
(11) |
Jun
|
Jul
|
Aug
(44) |
Sep
(14) |
Oct
(7) |
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(9) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(10) |
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(3) |
Jul
(4) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(168) |
| 2017 |
Jan
(77) |
Feb
(11) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
(6) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
|
Feb
(88) |
Mar
(118) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(6) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(141) |
| 2021 |
Jan
(170) |
Feb
(20) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(62) |
Nov
(189) |
Dec
(162) |
| 2022 |
Jan
(201) |
Feb
(118) |
Mar
(8) |
Apr
|
May
(2) |
Jun
(47) |
Jul
(19) |
Aug
(14) |
Sep
(3) |
Oct
|
Nov
(28) |
Dec
(235) |
| 2023 |
Jan
(112) |
Feb
(23) |
Mar
(2) |
Apr
(2) |
May
|
Jun
(1) |
Jul
|
Aug
(70) |
Sep
(92) |
Oct
(20) |
Nov
(1) |
Dec
(1) |
| 2024 |
Jan
|
Feb
|
Mar
(1) |
Apr
(1) |
May
(14) |
Jun
(11) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2025 |
Jan
(10) |
Feb
(29) |
Mar
|
Apr
(162) |
May
(245) |
Jun
(83) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <vic...@us...> - 2025-05-01 12:24:45
|
Revision: 13553
http://sourceforge.net/p/foray/code/13553
Author: victormote
Date: 2025-05-01 12:24:24 +0000 (Thu, 01 May 2025)
Log Message:
-----------
Steps toward GSUB table parsing in new scheme.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubTable.java
Added Paths:
-----------
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubTableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubTableHandler.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-05-01 11:20:09 UTC (rev 13552)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-05-01 12:24:24 UTC (rev 13553)
@@ -405,6 +405,10 @@
dirEntry = ttfTableDir.getTableDirectoryEntry("GSUB");
if (dirEntry != null) {
font.gsubTable = GsubTable.parse(dirEntry, raInput);
+// final ParserKit<GsubTable, GsubTableHandler> contentHandler = GsubTable.createContentHandler();
+// final GsubTableParser parser = new GsubTableParser();
+// parser.parse(raInput, dirEntry.getOffset(), contentHandler.getHandler());
+// font.gsubTable = contentHandler.getTable();
}
dirEntry = ttfTableDir.getTableDirectoryEntry("JSTF");
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubTable.java 2025-05-01 11:20:09 UTC (rev 13552)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubTable.java 2025-05-01 12:24:24 UTC (rev 13553)
@@ -30,8 +30,10 @@
import org.foray.font.ttf.OtfFeature;
import org.foray.font.ttf.OtfScript;
+import org.foray.font.ttf.ParserKit;
import org.foray.font.ttf.TtfOffsetTableRecord;
import org.foray.fontParse.ttf.TtfRandomAccessInput;
+import org.foray.fontParse.ttfHandler.GsubTableHandler;
import org.foray.primitive.sequence.IntArrayBuilder;
import org.axsl.font.FontContext;
@@ -48,6 +50,32 @@
*/
public class GsubTable extends AbstractOtfLayoutTable {
+ /**
+ * The handler of events from the parser.
+ */
+ private final class ContentHandler implements GsubTableHandler {
+
+ /** The table instance being created. */
+ @SuppressWarnings("unused")
+ private GsubTable table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final GsubTable table) {
+ this.table = table;
+ }
+ }
+
+
+
+
+
+
+
+
+
/** The lookup list. */
private List<GsubLookup> lookupList;
@@ -61,6 +89,16 @@
}
/**
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
+ */
+ public static ParserKit<GsubTable, GsubTableHandler> createContentHandler() {
+ final GsubTable table = new GsubTable(null, null);
+ final GsubTableHandler handler = table.new ContentHandler(table);
+ return new ParserKit<GsubTable, GsubTableHandler>(table, handler);
+ }
+
+ /**
* Parse the table from the table content.
* @param offsetRecord The parent offset table record.
* @param raInput The input which is being parsed.
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubTableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubTableParser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubTableParser.java 2025-05-01 12:24:24 UTC (rev 13553)
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.GsubTableHandler;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+
+/**
+ * Parses a TTF "GSUB" table.
+ */
+public class GsubTableParser extends TableParser<GsubTableHandler> {
+
+ /** Constant for the version 1.1 cutoff. */
+ private static final BigDecimal VERSION_1_1 = new BigDecimal("1.1");
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final GsubTableHandler handler)
+ throws IOException {
+ input.seek(offset);
+
+ /* GSUB Header, Version 1.0. */
+ final short majorVersion = input.read_uint16();
+ handler.majorVersion(majorVersion);
+ final short minorVersion = input.read_uint16();
+ handler.minorVersion(minorVersion);
+ final BigDecimal version = new BigDecimal(majorVersion + "." + minorVersion);
+
+ final short scriptListOffset = input.read_Offset16();
+ handler.scriptListOffset(scriptListOffset);
+ final short featureListOffset = input.read_Offset16();
+ handler.featureListOffset(featureListOffset);
+ final short lookupListOffset = input.read_Offset16();
+ handler.lookupListOffset(lookupListOffset);
+
+
+ /* GSUB Header, Version 1.1. */
+ @SuppressWarnings("unused")
+ final int featureVariationsOffset;
+ if (version.compareTo(VERSION_1_1) >= 0) {
+ featureVariationsOffset = input.readUnsignedShort();
+ } else {
+ featureVariationsOffset = -1;
+ }
+
+ /* TODO: Complete this. */
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubTableParser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubTableHandler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubTableHandler.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubTableHandler.java 2025-05-01 12:24:24 UTC (rev 13553)
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttfHandler;
+
+import org.foray.fontParse.FontContentHandler;
+import org.foray.fontParse.ttf.GsubTableParser;
+
+import org.checkerframework.checker.signedness.qual.Unsigned;
+
+/**
+ * Implementations catch and handle the output from {@link GsubTableParser}.
+ */
+public interface GsubTableHandler extends FontContentHandler {
+
+ default void majorVersion(@Unsigned short value) { return; }
+ default void minorVersion(@Unsigned short value) { return; }
+ default void scriptListOffset(@Unsigned short value) { return; }
+ default void featureListOffset(@Unsigned short value) { return; }
+ default void lookupListOffset(@Unsigned short value) { return; }
+
+ default void featureVariationsOffset(@Unsigned int value) { return; }
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubTableHandler.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-01 11:20:43
|
Revision: 13552
http://sourceforge.net/p/foray/code/13552
Author: victormote
Date: 2025-05-01 11:20:09 +0000 (Thu, 01 May 2025)
Log Message:
-----------
Fix error in parsing of coverage. Complete conversion of GSUB Type 4 parsing to new parsing scheme.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup04x01.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup04x01Parser.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup.java 2025-05-01 10:49:57 UTC (rev 13551)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup.java 2025-05-01 11:20:09 UTC (rev 13552)
@@ -33,6 +33,7 @@
import org.foray.fontParse.ttf.GsubLookup01x02Parser;
import org.foray.fontParse.ttf.GsubLookup02x01Parser;
import org.foray.fontParse.ttf.GsubLookup03x01Parser;
+import org.foray.fontParse.ttf.GsubLookup04x01Parser;
import org.foray.fontParse.ttf.GsubLookup05x01Parser;
import org.foray.fontParse.ttf.GsubLookup05x02Parser;
import org.foray.fontParse.ttf.GsubLookup05x03Parser;
@@ -46,6 +47,7 @@
import org.foray.fontParse.ttfHandler.GsubLookup01x02Handler;
import org.foray.fontParse.ttfHandler.GsubLookup02x01Handler;
import org.foray.fontParse.ttfHandler.GsubLookup03x01Handler;
+import org.foray.fontParse.ttfHandler.GsubLookup04x01Handler;
import org.foray.fontParse.ttfHandler.GsubLookup05x01Handler;
import org.foray.fontParse.ttfHandler.GsubLookup05x02Handler;
import org.foray.fontParse.ttfHandler.GsubLookup05x03Handler;
@@ -227,11 +229,10 @@
case LIGATURE:
switch (formatId) {
case FORMAT_1: {
- return GsubLookup04x01.parse(raInput, offset);
-// final ParserKit<GsubLookup04x01, GsubLookup04x01Handler> kit = GsubLookup04x01.createContentHandler();
-// final GsubLookup04x01Parser parser = new GsubLookup04x01Parser();
-// parser.parse(raInput, offset, kit.getHandler());
-// return kit.getTable();
+ final ParserKit<GsubLookup04x01, GsubLookup04x01Handler> kit = GsubLookup04x01.createContentHandler();
+ final GsubLookup04x01Parser parser = new GsubLookup04x01Parser();
+ parser.parse(raInput, offset, kit.getHandler());
+ return kit.getTable();
}
default: throw new UnsupportedOperationException("Unrecognized GSUB lookup type 4: " + formatId);
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup04x01.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup04x01.java 2025-05-01 10:49:57 UTC (rev 13551)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup04x01.java 2025-05-01 11:20:09 UTC (rev 13552)
@@ -28,10 +28,7 @@
package org.foray.font.ttf.table;
-import org.foray.common.RandomAccessInput;
import org.foray.font.ttf.ParserKit;
-import org.foray.fontParse.ttf.TtfRandomAccessInput;
-import org.foray.fontParse.ttf.TtfType;
import org.foray.fontParse.ttfHandler.Coverage01TableHandler;
import org.foray.fontParse.ttfHandler.Coverage02TableHandler;
import org.foray.fontParse.ttfHandler.GsubLookup04x01Handler;
@@ -41,8 +38,6 @@
import org.checkerframework.checker.signedness.qual.Unsigned;
-import java.io.IOException;
-
/**
* A Ligature Substitution Format 1 GSUB Subtable.
*/
@@ -226,92 +221,6 @@
}
/**
- * Parses a lookup.
- * @param raInput The input from which the subtable is being parsed.
- * @param offset The offset in {@code raInput} for the start of the subtable.
- * @return The parsed subtable instance.
- * @throws IOException For I/O errors during parsing.
- */
- public static GsubLookup04x01 parse(final TtfRandomAccessInput raInput, final int offset) throws IOException {
- raInput.seek(offset);
- final GsubLookup04x01 subtable = new GsubLookup04x01();
- /* Skip the format identifier. We already parsed it to get here. */
- raInput.skipBytes(TtfType.uint16.getQtyBytes());
- final int coverageOffset = raInput.readUnsignedShort();
- final int ligSetCount = raInput.readUnsignedShort();
- final int[] ligSetOffsets = new int[ligSetCount];
- for (int index = 0; index < ligSetCount; index ++) {
- ligSetOffsets[index] = raInput.readUnsignedShort();
- }
-
- subtable.coverage = CoverageTable.parse(raInput, offset + coverageOffset);
-
- subtable.ligatureSets = new LigatureSet[ligSetCount];
- for (int index = 0; index < ligSetCount; index ++) {
- /* The Microsoft OTF documentation says that the offset to a LigatureSet table is "from beginning of
- * "Substitution table". This might be interpreted as from the beginning of the GSUB table itself.
- * However, by trial-and-error, we think it means "from beginning of the Substitution subtable, i.e.
- * the main thing being parsed by this method. */
- final int ligSetOffset = offset + ligSetOffsets[index];
- final LigatureSet ligSet = parseLigatureSet(raInput, ligSetOffset, subtable);
- subtable.ligatureSets[index] = ligSet;
- }
- return subtable;
- }
-
- /**
- * Parse one ligature set.
- * @param raInput The input from which the subtable is being parsed.
- * @param offset The offset to the start of the ligature set to be parsed.
- * @param subtable The subtable instance being parsed.
- * @return The parsed LigatureSet instance.
- * @throws IOException For I/O errors during parsing.
- */
- private static LigatureSet parseLigatureSet(final RandomAccessInput raInput, final int offset,
- final GsubLookup04x01 subtable) throws IOException {
- raInput.seek(offset);
- final LigatureSet ligSet = subtable.new LigatureSet();
- final int ligatureCount = raInput.readUnsignedShort();
-
- final int[] ligatureOffsets = new int[ligatureCount];
- for (int ligIndex = 0; ligIndex < ligatureOffsets.length; ligIndex ++) {
- ligatureOffsets[ligIndex] = raInput.readUnsignedShort();
- }
-
- ligSet.ligatures = new Ligature[ligatureCount];
- for (int ligIndex = 0; ligIndex < ligSet.ligatures.length; ligIndex ++) {
- final int ligatureOffset = offset + ligatureOffsets[ligIndex];
- ligSet.ligatures[ligIndex] = parseLigature(raInput, ligatureOffset, subtable);
- }
-
- return ligSet;
- }
-
- /**
- * Parses one ligature.
- * @param raInput The input from which the subtable is being parsed.
- * @param offset The offset to the start of the ligature to be parsed.
- * @param subtable The subtable instance being parsed.
- * @return The parsed Ligature instance.
- * @throws IOException For I/O errors during parsing.
- */
- private static Ligature parseLigature(final RandomAccessInput raInput, final int offset,
- final GsubLookup04x01 subtable) throws IOException {
- raInput.seek(offset);
- final Ligature ligature = subtable.new Ligature();
- ligature.ligGlyph = raInput.readChar();
- final int componentCount = raInput.readUnsignedShort();
-
- /* The number of components is equal to the ligatureCount - 1, because the first component glyph index is
- * specified in the Coverage table. */
- ligature.components = new char[componentCount - 1];
- for (int componentIndex = 0; componentIndex < ligature.components.length; componentIndex ++) {
- ligature.components[componentIndex] = raInput.readChar();
- }
- return ligature;
- }
-
- /**
* Returns the coverage for this subtable.
* @return The coverage.
*/
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup04x01Parser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup04x01Parser.java 2025-05-01 10:49:57 UTC (rev 13551)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup04x01Parser.java 2025-05-01 11:20:09 UTC (rev 13552)
@@ -63,19 +63,20 @@
/* Parse the Coverage table. */
- input.seek(offset + Short.toUnsignedInt(coverageOffset));
+ final int absoluteCoverageOffset = offset + Short.toUnsignedInt(coverageOffset);
+ input.seek(absoluteCoverageOffset);
final short coverageType = input.read_uint16();
switch (coverageType) {
case 1: {
final Coverage01TableHandler coverage01Handler = handler.startCoverage01Table();
final Coverage01TableParser parser = new Coverage01TableParser();
- parser.parse(input, coverageOffset, coverage01Handler);
+ parser.parse(input, absoluteCoverageOffset, coverage01Handler);
break;
}
case 2: {
final Coverage02TableHandler coverage02Handler = handler.startCoverage02Table();
final Coverage02TableParser parser = new Coverage02TableParser();
- parser.parse(input, coverageOffset, coverage02Handler);
+ parser.parse(input, absoluteCoverageOffset, coverage02Handler);
break;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-01 10:50:17
|
Revision: 13551
http://sourceforge.net/p/foray/code/13551
Author: victormote
Date: 2025-05-01 10:49:57 +0000 (Thu, 01 May 2025)
Log Message:
-----------
More fixes to GSUB Type 4 parsing.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Coverage01Table.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup04x01.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Coverage01TableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Coverage02TableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup04x01Parser.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Coverage01Table.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Coverage01Table.java 2025-05-01 09:48:16 UTC (rev 13550)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Coverage01Table.java 2025-05-01 10:49:57 UTC (rev 13551)
@@ -57,8 +57,11 @@
}
@Override
- public void glyphIdArray(final short[] value) {
- this.table.glyphArray = value;
+ public void glyphIdArray(final @Unsigned short[] value) {
+ this.table.glyphArray = new char[value.length];
+ for (int index = 0; index < value.length; index ++) {
+ this.table.glyphArray[index] = (char) value[index];
+ }
}
}
@@ -71,8 +74,9 @@
- /** Array of glyph indexes that define this coverage. */
- private @Unsigned short[] glyphArray;
+ /** Array of glyph indexes that define this coverage. Using char is our stand-in for unsigned short, allowing us to
+ * sort and search. */
+ private @Unsigned char[] glyphArray;
/**
* Creates a table instance and a content handler for that instance.
@@ -88,13 +92,13 @@
* Returns the array of glyph indexes that define this coverage.
* @return The array of glyph indexes that define this coverage.
*/
- public @Unsigned short[] getGlyphArray() {
+ public @Unsigned char[] getGlyphArray() {
return this.glyphArray;
}
@Override
public int coverageIndex(final int glyphIndex) {
- return Arrays.binarySearch(this.glyphArray, (short) glyphIndex);
+ return Arrays.binarySearch(this.glyphArray, (char) glyphIndex);
}
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup.java 2025-05-01 09:48:16 UTC (rev 13550)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup.java 2025-05-01 10:49:57 UTC (rev 13551)
@@ -226,7 +226,13 @@
}
case LIGATURE:
switch (formatId) {
- case FORMAT_1: return GsubLookup04x01.parse(raInput, offset);
+ case FORMAT_1: {
+ return GsubLookup04x01.parse(raInput, offset);
+// final ParserKit<GsubLookup04x01, GsubLookup04x01Handler> kit = GsubLookup04x01.createContentHandler();
+// final GsubLookup04x01Parser parser = new GsubLookup04x01Parser();
+// parser.parse(raInput, offset, kit.getHandler());
+// return kit.getTable();
+ }
default: throw new UnsupportedOperationException("Unrecognized GSUB lookup type 4: " + formatId);
}
case CONTEXT:
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup04x01.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup04x01.java 2025-05-01 09:48:16 UTC (rev 13550)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup04x01.java 2025-05-01 10:49:57 UTC (rev 13551)
@@ -29,13 +29,18 @@
package org.foray.font.ttf.table;
import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.ParserKit;
import org.foray.fontParse.ttf.TtfRandomAccessInput;
import org.foray.fontParse.ttf.TtfType;
+import org.foray.fontParse.ttfHandler.Coverage01TableHandler;
+import org.foray.fontParse.ttfHandler.Coverage02TableHandler;
import org.foray.fontParse.ttfHandler.GsubLookup04x01Handler;
import org.foray.primitive.sequence.IntArrayBuilder;
import org.axsl.font.FontContext;
+import org.checkerframework.checker.signedness.qual.Unsigned;
+
import java.io.IOException;
/**
@@ -49,9 +54,23 @@
private final class ContentHandler implements GsubLookup04x01Handler {
/** The table instance being created. */
- @SuppressWarnings("unused")
private GsubLookup04x01 table;
+ /** The index to the ligature set currently being parsed. */
+ private int currentLigatureSetIndex = -1;
+
+ /** The ligature set currently being parsed. */
+ private LigatureSet currentLigatureSet;
+
+ /** The index to the ligature set currently being parsed. */
+ private int currentLigatureIndex = -1;
+
+ /** The ligature currently being parsed. */
+ private Ligature currentLigature;
+
+ /** The index to the component set currently being parsed. */
+ private int currentComponentIndex = -1;
+
/**
* Constructor.
* @param table The table instance being created.
@@ -59,6 +78,54 @@
private ContentHandler(final GsubLookup04x01 table) {
this.table = table;
}
+
+ @Override
+ public Coverage01TableHandler startCoverage01Table() {
+ final ParserKit<Coverage01Table, Coverage01TableHandler> kit = Coverage01Table.createContentHandler();
+ this.table.coverage = kit.getTable();
+ return kit.getHandler();
+ }
+
+ @Override
+ public Coverage02TableHandler startCoverage02Table() {
+ final ParserKit<Coverage02Table, Coverage02TableHandler> kit = Coverage02Table.createContentHandler();
+ this.table.coverage = kit.getTable();
+ return kit.getHandler();
+ }
+
+ @Override
+ public void ligatureSetCount(final @Unsigned short value) {
+ this.table.ligatureSets = new LigatureSet[Short.toUnsignedInt(value)];
+ }
+
+ @Override
+ public void ligatureCount(final @Unsigned short value) {
+ this.currentLigatureSetIndex ++;
+ this.currentLigatureSet = new LigatureSet();
+ this.table.ligatureSets[this.currentLigatureSetIndex] = this.currentLigatureSet;
+ this.currentLigatureSet.ligatures = new Ligature[value];
+ this.currentLigatureIndex = -1;
+ }
+
+ @Override
+ public void ligatureGlyph(final @Unsigned short value) {
+ this.currentLigatureIndex ++;
+ this.currentLigature = new Ligature();
+ this.currentLigatureSet.ligatures[this.currentLigatureIndex] = this.currentLigature;
+ this.currentLigature.ligGlyph = (char) value;
+ }
+
+ @Override
+ public void componentCount(final @Unsigned short value) {
+ this.currentLigature.components = new char[Short.toUnsignedInt(value) - 1];
+ this.currentComponentIndex = -1;
+ }
+
+ @Override
+ public void componentGlyphID(final @Unsigned short value) {
+ this.currentComponentIndex ++;
+ this.currentLigature.components[this.currentComponentIndex] = (char) value;
+ }
}
@@ -149,9 +216,13 @@
private LigatureSet[] ligatureSets;
/**
- * Constructor.
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
*/
- public GsubLookup04x01() {
+ public static ParserKit<GsubLookup04x01, GsubLookup04x01Handler> createContentHandler() {
+ final GsubLookup04x01 table = new GsubLookup04x01();
+ final GsubLookup04x01Handler handler = table.new ContentHandler(table);
+ return new ParserKit<GsubLookup04x01, GsubLookup04x01Handler>(table, handler);
}
/**
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Coverage01TableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Coverage01TableParser.java 2025-05-01 09:48:16 UTC (rev 13550)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Coverage01TableParser.java 2025-05-01 10:49:57 UTC (rev 13551)
@@ -31,6 +31,8 @@
import org.foray.fontParse.TableParser;
import org.foray.fontParse.ttfHandler.Coverage01TableHandler;
+import org.checkerframework.checker.signedness.qual.Unsigned;
+
import java.io.IOException;
/**
@@ -45,12 +47,12 @@
input.seek(offset);
handler.format(input.read_uint16());
- final short glyphCount = input.read_uint16();
+ final @Unsigned short glyphCount = input.read_uint16();
handler.glyphCount(glyphCount);
- final short[] glyphIdArray = new short[Short.toUnsignedInt(glyphCount)];
- for (int index = 0; index < glyphCount; index ++) {
- final short glyphId = input.read_uint16();
+ final @Unsigned short[] glyphIdArray = new @Unsigned short[Short.toUnsignedInt(glyphCount)];
+ for (int index = 0; index < Short.toUnsignedInt(glyphCount); index ++) {
+ final @Unsigned short glyphId = input.read_uint16();
handler.glyphId(glyphId);
glyphIdArray[index] = glyphId;
}
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Coverage02TableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Coverage02TableParser.java 2025-05-01 09:48:16 UTC (rev 13550)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Coverage02TableParser.java 2025-05-01 10:49:57 UTC (rev 13551)
@@ -31,6 +31,8 @@
import org.foray.fontParse.TableParser;
import org.foray.fontParse.ttfHandler.Coverage02TableHandler;
+import org.checkerframework.checker.signedness.qual.Unsigned;
+
import java.io.IOException;
/**
@@ -45,10 +47,10 @@
input.seek(offset);
handler.format(input.read_uint16());
- final int rangeCount = input.read_uint16();
- handler.rangeCount((short) rangeCount);
+ final @Unsigned short rangeCount = input.read_uint16();
+ handler.rangeCount(rangeCount);
- for (int index = 0; index < rangeCount; index ++) {
+ for (int index = 0; index < Short.toUnsignedInt(rangeCount); index ++) {
handler.startGlyphID(input.read_uint16());
handler.endGlyphID(input.read_uint16());
handler.startCoverageIndex(input.read_uint16());
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup04x01Parser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup04x01Parser.java 2025-05-01 09:48:16 UTC (rev 13550)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup04x01Parser.java 2025-05-01 10:49:57 UTC (rev 13551)
@@ -54,7 +54,7 @@
handler.ligatureSetCount(ligatureSetCount);
final @Unsigned short[] ligSetOffsets = new @Unsigned short[ligatureSetCount];
- for (int setIndex = 0; setIndex < ligatureSetCount; setIndex ++) {
+ for (int setIndex = 0; setIndex < Short.toUnsignedInt(ligatureSetCount); setIndex ++) {
final short ligatureSetOffset = input.read_Offset16(); // 2 bytes @
handler.ligatureSetOffset(ligatureSetOffset);
ligSetOffsets[setIndex] = ligatureSetOffset;
@@ -63,7 +63,7 @@
/* Parse the Coverage table. */
- input.seek(offset + coverageOffset);
+ input.seek(offset + Short.toUnsignedInt(coverageOffset));
final short coverageType = input.read_uint16();
switch (coverageType) {
case 1: {
@@ -80,22 +80,18 @@
}
}
- for (int index = 0; index < ligatureSetCount; index ++) {
- handler.ligatureSetOffset(input.read_Offset16());
- }
-
/* Parse Ligature sets. */ // *** Restart Count ***
for (int setIndex = 0; setIndex < ligatureSetCount; setIndex ++) {
- final int ligatureSetOffset = offset + ligSetOffsets[setIndex];
+ final int ligatureSetOffset = offset + Short.toUnsignedInt(ligSetOffsets[setIndex]);
input.seek(ligatureSetOffset);
final short ligatureCount = input.read_uint16(); // 2 bytes, total 2
handler.ligatureCount(ligatureCount);
/* Read the offsets to the ligatures. */
- final short[] ligatureOffsets = new short[ligatureCount];
- for (int ligIndex = 0; ligIndex < ligatureCount; ligIndex ++) {
+ final @Unsigned short[] ligatureOffsets = new @Unsigned short[ligatureCount];
+ for (int ligIndex = 0; ligIndex < Short.toUnsignedInt(ligatureCount); ligIndex ++) {
final short ligatureOffset = input.read_Offset16(); // 2 bytes, total 4
handler.ligatureOffset(ligatureOffset);
ligatureOffsets[ligIndex] = ligatureOffset;
@@ -102,13 +98,14 @@
}
/* Parse each ligature. */
- for (int ligIndex = 0; ligIndex < ligatureCount; ligIndex ++) {
- final int ligatureOffset = ligatureSetOffset + ligatureOffsets[ligIndex];
+ for (int ligIndex = 0; ligIndex < Short.toUnsignedInt(ligatureCount); ligIndex ++) {
+ final int ligatureOffset = ligatureSetOffset + Short.toUnsignedInt(ligatureOffsets[ligIndex]);
input.seek(ligatureOffset);
handler.ligatureGlyph(input.read_uint16());
final @Unsigned short componentCount = input.read_uint16();
handler.componentCount(componentCount);
- for (int componentIndex = 0; componentIndex < componentCount - 1; componentIndex ++) {
+ for (int componentIndex = 0; componentIndex < Short.toUnsignedInt(componentCount) - 1;
+ componentIndex ++) {
handler.componentGlyphID(input.read_uint16());
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-05-01 09:48:34
|
Revision: 13550
http://sourceforge.net/p/foray/code/13550
Author: victormote
Date: 2025-05-01 09:48:16 +0000 (Thu, 01 May 2025)
Log Message:
-----------
Various fixes to GSUB Type 4 parsing.
Modified Paths:
--------------
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Coverage01TableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup04x01Parser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup04x01Handler.java
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Coverage01TableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Coverage01TableParser.java 2025-04-30 20:11:38 UTC (rev 13549)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Coverage01TableParser.java 2025-05-01 09:48:16 UTC (rev 13550)
@@ -45,10 +45,10 @@
input.seek(offset);
handler.format(input.read_uint16());
- final int glyphCount = input.read_uint16();
- handler.glyphCount((short) glyphCount);
+ final short glyphCount = input.read_uint16();
+ handler.glyphCount(glyphCount);
- final short[] glyphIdArray = new short[glyphCount];
+ final short[] glyphIdArray = new short[Short.toUnsignedInt(glyphCount)];
for (int index = 0; index < glyphCount; index ++) {
final short glyphId = input.read_uint16();
handler.glyphId(glyphId);
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup04x01Parser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup04x01Parser.java 2025-04-30 20:11:38 UTC (rev 13549)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup04x01Parser.java 2025-05-01 09:48:16 UTC (rev 13550)
@@ -63,7 +63,7 @@
/* Parse the Coverage table. */
- input.seek(coverageOffset);
+ input.seek(offset + coverageOffset);
final short coverageType = input.read_uint16();
switch (coverageType) {
case 1: {
@@ -88,7 +88,8 @@
/* Parse Ligature sets. */ // *** Restart Count ***
for (int setIndex = 0; setIndex < ligatureSetCount; setIndex ++) {
- input.seek(ligSetOffsets[setIndex]);
+ final int ligatureSetOffset = offset + ligSetOffsets[setIndex];
+ input.seek(ligatureSetOffset);
final short ligatureCount = input.read_uint16(); // 2 bytes, total 2
handler.ligatureCount(ligatureCount);
@@ -102,11 +103,13 @@
/* Parse each ligature. */
for (int ligIndex = 0; ligIndex < ligatureCount; ligIndex ++) {
+ final int ligatureOffset = ligatureSetOffset + ligatureOffsets[ligIndex];
+ input.seek(ligatureOffset);
handler.ligatureGlyph(input.read_uint16());
final @Unsigned short componentCount = input.read_uint16();
handler.componentCount(componentCount);
- for (int componentIndex = 0; componentIndex < componentCount; componentIndex ++) {
- handler.componentGlyphId(componentCount);
+ for (int componentIndex = 0; componentIndex < componentCount - 1; componentIndex ++) {
+ handler.componentGlyphID(input.read_uint16());
}
}
}
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup04x01Handler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup04x01Handler.java 2025-04-30 20:11:38 UTC (rev 13549)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup04x01Handler.java 2025-05-01 09:48:16 UTC (rev 13550)
@@ -52,6 +52,6 @@
default void ligatureGlyph(@Unsigned short value) { return; }
default void componentCount(@Unsigned short value) { return; }
- default void componentGlyphId(@Unsigned short value) { return; }
+ default void componentGlyphID(@Unsigned short value) { return; }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-30 20:11:56
|
Revision: 13549
http://sourceforge.net/p/foray/code/13549
Author: victormote
Date: 2025-04-30 20:11:38 +0000 (Wed, 30 Apr 2025)
Log Message:
-----------
Steps toward conversion GSUB Type 4 to new parsing scheme.
Modified Paths:
--------------
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup04x01Parser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup04x01Handler.java
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup04x01Parser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup04x01Parser.java 2025-04-30 15:09:38 UTC (rev 13548)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup04x01Parser.java 2025-04-30 20:11:38 UTC (rev 13549)
@@ -29,6 +29,8 @@
package org.foray.fontParse.ttf;
import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.Coverage01TableHandler;
+import org.foray.fontParse.ttfHandler.Coverage02TableHandler;
import org.foray.fontParse.ttfHandler.GsubLookup04x01Handler;
import org.checkerframework.checker.signedness.qual.Unsigned;
@@ -46,16 +48,68 @@
input.seek(offset);
handler.format(input.read_uint16()); // 2 bytes, total 2
- handler.coverageOffset(input.read_Offset16()); // 2 bytes, total 4
+ final @Unsigned short coverageOffset = input.read_Offset16(); // 2 bytes, total 4
+ handler.coverageOffset(coverageOffset);
final @Unsigned short ligatureSetCount = input.read_uint16(); // 2 bytes, total 6
handler.ligatureSetCount(ligatureSetCount);
+ final @Unsigned short[] ligSetOffsets = new @Unsigned short[ligatureSetCount];
+ for (int setIndex = 0; setIndex < ligatureSetCount; setIndex ++) {
+ final short ligatureSetOffset = input.read_Offset16(); // 2 bytes @
+ handler.ligatureSetOffset(ligatureSetOffset);
+ ligSetOffsets[setIndex] = ligatureSetOffset;
+ }
+
+
+
+ /* Parse the Coverage table. */
+ input.seek(coverageOffset);
+ final short coverageType = input.read_uint16();
+ switch (coverageType) {
+ case 1: {
+ final Coverage01TableHandler coverage01Handler = handler.startCoverage01Table();
+ final Coverage01TableParser parser = new Coverage01TableParser();
+ parser.parse(input, coverageOffset, coverage01Handler);
+ break;
+ }
+ case 2: {
+ final Coverage02TableHandler coverage02Handler = handler.startCoverage02Table();
+ final Coverage02TableParser parser = new Coverage02TableParser();
+ parser.parse(input, coverageOffset, coverage02Handler);
+ break;
+ }
+ }
+
for (int index = 0; index < ligatureSetCount; index ++) {
handler.ligatureSetOffset(input.read_Offset16());
}
- /* TODO: Complete this. */
+
+ /* Parse Ligature sets. */ // *** Restart Count ***
+ for (int setIndex = 0; setIndex < ligatureSetCount; setIndex ++) {
+ input.seek(ligSetOffsets[setIndex]);
+ final short ligatureCount = input.read_uint16(); // 2 bytes, total 2
+ handler.ligatureCount(ligatureCount);
+
+ /* Read the offsets to the ligatures. */
+ final short[] ligatureOffsets = new short[ligatureCount];
+ for (int ligIndex = 0; ligIndex < ligatureCount; ligIndex ++) {
+ final short ligatureOffset = input.read_Offset16(); // 2 bytes, total 4
+ handler.ligatureOffset(ligatureOffset);
+ ligatureOffsets[ligIndex] = ligatureOffset;
+ }
+
+ /* Parse each ligature. */
+ for (int ligIndex = 0; ligIndex < ligatureCount; ligIndex ++) {
+ handler.ligatureGlyph(input.read_uint16());
+ final @Unsigned short componentCount = input.read_uint16();
+ handler.componentCount(componentCount);
+ for (int componentIndex = 0; componentIndex < componentCount; componentIndex ++) {
+ handler.componentGlyphId(componentCount);
+ }
+ }
+ }
}
}
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup04x01Handler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup04x01Handler.java 2025-04-30 15:09:38 UTC (rev 13548)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup04x01Handler.java 2025-04-30 20:11:38 UTC (rev 13549)
@@ -40,8 +40,18 @@
default void format(@Unsigned short value) { return; }
default void coverageOffset(@Unsigned short value) { return; }
+
default void ligatureSetCount(@Unsigned short value) { return; }
-
default void ligatureSetOffset(@Unsigned short value) { return; }
+ default Coverage01TableHandler startCoverage01Table() { return null; }
+ default Coverage02TableHandler startCoverage02Table() { return null; }
+
+ default void ligatureCount(@Unsigned short value) { return; }
+ default void ligatureOffset(@Unsigned short value) { return; }
+
+ default void ligatureGlyph(@Unsigned short value) { return; }
+ default void componentCount(@Unsigned short value) { return; }
+ default void componentGlyphId(@Unsigned short value) { return; }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-30 15:10:03
|
Revision: 13548
http://sourceforge.net/p/foray/code/13548
Author: victormote
Date: 2025-04-30 15:09:38 +0000 (Wed, 30 Apr 2025)
Log Message:
-----------
Convert Covarage tables to new parsing scheme.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Coverage01Table.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Coverage02Table.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CoverageTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup04x01.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Coverage01TableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Coverage02TableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CoverageTableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Coverage01TableHandler.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Coverage02TableHandler.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/CoverageTableHandler.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java 2025-04-30 11:47:30 UTC (rev 13547)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java 2025-04-30 15:09:38 UTC (rev 13548)
@@ -70,30 +70,30 @@
@Override
public Cmap00TableHandler startCmap00Table() {
- final ParserKit<Cmap00Table, Cmap00TableHandler> handler = Cmap00Table.createContentHandler();
- this.table.unicodeCMap.add(handler.getTable());
- return handler.getHandler();
+ final ParserKit<Cmap00Table, Cmap00TableHandler> kit = Cmap00Table.createContentHandler();
+ this.table.unicodeCMap.add(kit.getTable());
+ return kit.getHandler();
}
@Override
public Cmap04TableHandler startCmap04Table() {
- final ParserKit<Cmap04Table, Cmap04TableHandler> handler = Cmap04Table.createContentHandler();
- this.table.unicodeCMap.add(handler.getTable());
- return handler.getHandler();
+ final ParserKit<Cmap04Table, Cmap04TableHandler> kit = Cmap04Table.createContentHandler();
+ this.table.unicodeCMap.add(kit.getTable());
+ return kit.getHandler();
}
@Override
public Cmap06TableHandler startCmap06Table() {
- final ParserKit<Cmap06Table, Cmap06TableHandler> handler = Cmap06Table.createContentHandler();
- this.table.unicodeCMap.add(handler.getTable());
- return handler.getHandler();
+ final ParserKit<Cmap06Table, Cmap06TableHandler> kit = Cmap06Table.createContentHandler();
+ this.table.unicodeCMap.add(kit.getTable());
+ return kit.getHandler();
}
@Override
public Cmap12TableHandler startCmap12Table() {
- final ParserKit<Cmap12Table, Cmap12TableHandler> handler = Cmap12Table.createContentHandler();
- this.table.unicodeCMap.add(handler.getTable());
- return handler.getHandler();
+ final ParserKit<Cmap12Table, Cmap12TableHandler> kit = Cmap12Table.createContentHandler();
+ this.table.unicodeCMap.add(kit.getTable());
+ return kit.getHandler();
}
@Override
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Coverage01Table.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Coverage01Table.java 2025-04-30 11:47:30 UTC (rev 13547)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Coverage01Table.java 2025-04-30 15:09:38 UTC (rev 13548)
@@ -28,10 +28,11 @@
package org.foray.font.ttf.table;
-import org.foray.common.RandomAccessInput;
-import org.foray.font.ttf.RoTable;
+import org.foray.font.ttf.ParserKit;
+import org.foray.fontParse.ttfHandler.Coverage01TableHandler;
-import java.io.IOException;
+import org.checkerframework.checker.signedness.qual.Unsigned;
+
import java.util.Arrays;
/**
@@ -39,41 +40,61 @@
*/
public class Coverage01Table extends CoverageTable {
- /** Array of glyph indexes that define this coverage. */
- private char[] glyphArray;
-
/**
- * Parses a coverage.
- * @param raInput The input from which the coverage is being parsed.
- * @param offset The offset in {@code raInput} for the start of the coverage.
- * @return The parsed coverage instance.
- * @throws IOException For I/O errors during parsing.
+ * The handler of events from the parser.
*/
- public static Coverage01Table parse(final RandomAccessInput raInput, final int offset) throws IOException {
- raInput.seek(offset);
- final Coverage01Table coverage = new Coverage01Table();
+ private final class ContentHandler implements Coverage01TableHandler {
- /* Skip reading the CoverageFormat. We already read it when deciding to come here. */
- raInput.skipBytes(RoTable.USHORT_BYTES);
- final int glyphCount = raInput.readUnsignedShort();
- coverage.glyphArray = new char[glyphCount];
- for (int index = 0; index < coverage.glyphArray.length; index ++) {
- coverage.glyphArray[index] = raInput.readChar();
+ /** The table instance being created. */
+ private Coverage01Table table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final Coverage01Table table) {
+ this.table = table;
}
- return coverage;
+
+ @Override
+ public void glyphIdArray(final short[] value) {
+ this.table.glyphArray = value;
+ }
}
+
+
+
+
+
+
+
+
+
+ /** Array of glyph indexes that define this coverage. */
+ private @Unsigned short[] glyphArray;
+
/**
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
+ */
+ public static ParserKit<Coverage01Table, Coverage01TableHandler> createContentHandler() {
+ final Coverage01Table table = new Coverage01Table();
+ final Coverage01TableHandler handler = table.new ContentHandler(table);
+ return new ParserKit<Coverage01Table, Coverage01TableHandler>(table, handler);
+ }
+
+ /**
* Returns the array of glyph indexes that define this coverage.
* @return The array of glyph indexes that define this coverage.
*/
- public char[] getGlyphArray() {
+ public @Unsigned short[] getGlyphArray() {
return this.glyphArray;
}
@Override
public int coverageIndex(final int glyphIndex) {
- return Arrays.binarySearch(this.glyphArray, (char) glyphIndex);
+ return Arrays.binarySearch(this.glyphArray, (short) glyphIndex);
}
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Coverage02Table.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Coverage02Table.java 2025-04-30 11:47:30 UTC (rev 13547)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Coverage02Table.java 2025-04-30 15:09:38 UTC (rev 13548)
@@ -28,10 +28,10 @@
package org.foray.font.ttf.table;
-import org.foray.common.RandomAccessInput;
-import org.foray.font.ttf.RoTable;
+import org.foray.font.ttf.ParserKit;
+import org.foray.fontParse.ttfHandler.Coverage02TableHandler;
-import java.io.IOException;
+import org.checkerframework.checker.signedness.qual.Unsigned;
/**
* A coverage using Format 2 (List of glyph index ranges).
@@ -39,25 +39,74 @@
public class Coverage02Table extends CoverageTable {
/**
+ * The handler of events from the parser.
+ */
+ private final class ContentHandler implements Coverage02TableHandler {
+
+ /** The table instance being created. */
+ private Coverage02Table table;
+
+ /** The index to the range record currently being parsed. */
+ private int rangeRecordIndex = -1;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final Coverage02Table table) {
+ this.table = table;
+ }
+
+ @Override
+ public void rangeCount(final short value) {
+ this.table.ranges = new RangeRecord[value];
+ }
+
+ @Override
+ public void startGlyphID(final short value) {
+ this.rangeRecordIndex ++;
+ this.table.ranges[this.rangeRecordIndex] = new RangeRecord();
+
+ this.table.ranges[this.rangeRecordIndex].start = value;
+ }
+ @Override
+ public void endGlyphID(final short value) {
+ this.table.ranges[this.rangeRecordIndex].end = value;
+ }
+ @Override
+ public void startCoverageIndex(final short value) {
+ this.table.ranges[this.rangeRecordIndex].startCoverageIndex = value;
+ }
+
+ }
+
+
+
+
+
+
+
+
+ /**
* A range in this coverage.
*/
public class RangeRecord {
/** The first glyph index in the range. */
- private char start;
+ private @Unsigned short start;
/** The last glyph index in the range. */
- private char end;
+ private @Unsigned short end;
/** The coverage index of the first glyph index in the range. */
- private char startCoverageIndex;
+ private @Unsigned short startCoverageIndex;
/**
* Returns the first glyph index in the range.
* @return The first glyph index in the range.
*/
- protected char getStart() {
- return this.start;
+ protected int getStart() {
+ return Short.toUnsignedInt(this.start);
}
/**
@@ -64,8 +113,8 @@
* Returns the last glyph index in the range.
* @return The last glyph index in the range.
*/
- protected char getEnd() {
- return this.end;
+ protected int getEnd() {
+ return Short.toUnsignedInt(this.end);
}
/**
@@ -72,8 +121,8 @@
* Returns the coverage index of the first glyph index in the range.
* @return The coverage index of the first glyph index in the range.
*/
- protected char getStartCoverageIndex() {
- return this.startCoverageIndex;
+ protected int getStartCoverageIndex() {
+ return Short.toUnsignedInt(this.startCoverageIndex);
}
}
@@ -82,30 +131,16 @@
private RangeRecord[] ranges;
/**
- * Parses a coverage.
- * @param raInput The input from which the coverage is being parsed.
- * @param offset The offset in {@code raInput} for the start of the coverage.
- * @return The parsed coverage instance.
- * @throws IOException For I/O errors during parsing.
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
*/
- public static Coverage02Table parse(final RandomAccessInput raInput, final int offset) throws IOException {
- raInput.seek(offset);
- final Coverage02Table coverage = new Coverage02Table();
-
- /* Skip reading the CoverageFormat. We already read it when deciding to come here. */
- raInput.skipBytes(RoTable.USHORT_BYTES);
- final int rangeCount = raInput.readUnsignedShort();
- coverage.ranges = new RangeRecord[rangeCount];
- for (int index = 0; index < coverage.ranges.length; index ++) {
- final RangeRecord range = coverage.new RangeRecord();
- range.start = raInput.readChar();
- range.end = raInput.readChar();
- range.startCoverageIndex = raInput.readChar();
- coverage.ranges[index] = range;
- }
- return coverage;
+ public static ParserKit<Coverage02Table, Coverage02TableHandler> createContentHandler() {
+ final Coverage02Table table = new Coverage02Table();
+ final Coverage02TableHandler handler = table.new ContentHandler(table);
+ return new ParserKit<Coverage02Table, Coverage02TableHandler>(table, handler);
}
+
/**
* Returns the ranges in this coverage.
* @return The ranges.
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CoverageTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CoverageTable.java 2025-04-30 11:47:30 UTC (rev 13547)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CoverageTable.java 2025-04-30 15:09:38 UTC (rev 13548)
@@ -28,7 +28,13 @@
package org.foray.font.ttf.table;
-import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.ParserKit;
+import org.foray.font.ttf.RoTable;
+import org.foray.fontParse.ttf.Coverage01TableParser;
+import org.foray.fontParse.ttf.Coverage02TableParser;
+import org.foray.fontParse.ttf.TtfRandomAccessInput;
+import org.foray.fontParse.ttfHandler.Coverage01TableHandler;
+import org.foray.fontParse.ttfHandler.Coverage02TableHandler;
import java.io.IOException;
@@ -35,7 +41,7 @@
/**
* Abstract superclass for coverage types.
*/
-public abstract class CoverageTable {
+public abstract class CoverageTable extends RoTable {
/**
* Parses a coverage.
@@ -44,15 +50,21 @@
* @return The parsed coverage instance.
* @throws IOException For I/O errors during parsing.
*/
- public static CoverageTable parse(final RandomAccessInput raInput, final int offset) throws IOException {
+ public static CoverageTable parse(final TtfRandomAccessInput raInput, final int offset) throws IOException {
raInput.seek(offset);
final int coverageFormat = raInput.readUnsignedShort();
switch (coverageFormat) {
case 1: {
- return Coverage01Table.parse(raInput, offset);
+ final ParserKit<Coverage01Table, Coverage01TableHandler> kit = Coverage01Table.createContentHandler();
+ final Coverage01TableParser parser = new Coverage01TableParser();
+ parser.parse(raInput, offset, kit.getHandler());
+ return kit.getTable();
}
case 2: {
- return Coverage02Table.parse(raInput, offset);
+ final ParserKit<Coverage02Table, Coverage02TableHandler> kit = Coverage02Table.createContentHandler();
+ final Coverage02TableParser parser = new Coverage02TableParser();
+ parser.parse(raInput, offset, kit.getHandler());
+ return kit.getTable();
}
default: throw new UnsupportedOperationException("Unrecognized Coverage Format: " + coverageFormat);
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup04x01.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup04x01.java 2025-04-30 11:47:30 UTC (rev 13547)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup04x01.java 2025-04-30 15:09:38 UTC (rev 13548)
@@ -29,6 +29,7 @@
package org.foray.font.ttf.table;
import org.foray.common.RandomAccessInput;
+import org.foray.fontParse.ttf.TtfRandomAccessInput;
import org.foray.fontParse.ttf.TtfType;
import org.foray.fontParse.ttfHandler.GsubLookup04x01Handler;
import org.foray.primitive.sequence.IntArrayBuilder;
@@ -160,7 +161,7 @@
* @return The parsed subtable instance.
* @throws IOException For I/O errors during parsing.
*/
- public static GsubLookup04x01 parse(final RandomAccessInput raInput, final int offset) throws IOException {
+ public static GsubLookup04x01 parse(final TtfRandomAccessInput raInput, final int offset) throws IOException {
raInput.seek(offset);
final GsubLookup04x01 subtable = new GsubLookup04x01();
/* Skip the format identifier. We already parsed it to get here. */
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Coverage01TableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Coverage01TableParser.java 2025-04-30 11:47:30 UTC (rev 13547)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Coverage01TableParser.java 2025-04-30 15:09:38 UTC (rev 13548)
@@ -44,7 +44,17 @@
throws IOException {
input.seek(offset);
- /* TODO: Complete this. */
+ handler.format(input.read_uint16());
+ final int glyphCount = input.read_uint16();
+ handler.glyphCount((short) glyphCount);
+
+ final short[] glyphIdArray = new short[glyphCount];
+ for (int index = 0; index < glyphCount; index ++) {
+ final short glyphId = input.read_uint16();
+ handler.glyphId(glyphId);
+ glyphIdArray[index] = glyphId;
+ }
+ handler.glyphIdArray(glyphIdArray);
}
}
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Coverage02TableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Coverage02TableParser.java 2025-04-30 11:47:30 UTC (rev 13547)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Coverage02TableParser.java 2025-04-30 15:09:38 UTC (rev 13548)
@@ -44,7 +44,15 @@
throws IOException {
input.seek(offset);
- /* TODO: Complete this. */
+ handler.format(input.read_uint16());
+ final int rangeCount = input.read_uint16();
+ handler.rangeCount((short) rangeCount);
+
+ for (int index = 0; index < rangeCount; index ++) {
+ handler.startGlyphID(input.read_uint16());
+ handler.endGlyphID(input.read_uint16());
+ handler.startCoverageIndex(input.read_uint16());
+ }
}
}
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CoverageTableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CoverageTableParser.java 2025-04-30 11:47:30 UTC (rev 13547)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CoverageTableParser.java 2025-04-30 15:09:38 UTC (rev 13548)
@@ -29,8 +29,12 @@
package org.foray.fontParse.ttf;
import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.Coverage01TableHandler;
+import org.foray.fontParse.ttfHandler.Coverage02TableHandler;
import org.foray.fontParse.ttfHandler.CoverageTableHandler;
+import org.checkerframework.checker.signedness.qual.Unsigned;
+
import java.io.IOException;
/**
@@ -38,13 +42,31 @@
*/
public class CoverageTableParser extends TableParser<CoverageTableHandler> {
-
@Override
public void parse(final TtfRandomAccessInput input, final int offset, final CoverageTableHandler handler)
throws IOException {
input.seek(offset);
- /* TODO: Complete this. */
+ final @Unsigned short coverageFormat = input.read_uint16();
+ switch (coverageFormat) {
+ case 1: {
+ final Coverage01TableHandler coverage01Handler = handler.startCoverage01Table();
+ if (coverage01Handler != null) {
+ final Coverage01TableParser coverage01Parser = new Coverage01TableParser();
+ coverage01Parser.parse(input, offset, coverage01Handler);
+ }
+ break;
+ }
+ case 2: {
+ final Coverage02TableHandler coverage02Handler = handler.startCoverage02Table();
+ if (coverage02Handler != null) {
+ final Coverage02TableParser coverage02Parser = new Coverage02TableParser();
+ coverage02Parser.parse(input, offset, coverage02Handler);
+ }
+ break;
+ }
+ default: throw new UnsupportedOperationException("Unrecognized Coverage Format: " + coverageFormat);
+ }
}
}
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Coverage01TableHandler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Coverage01TableHandler.java 2025-04-30 11:47:30 UTC (rev 13547)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Coverage01TableHandler.java 2025-04-30 15:09:38 UTC (rev 13548)
@@ -36,6 +36,10 @@
*/
public interface Coverage01TableHandler extends FontContentHandler {
- /* TODO: Complete this. */
+ default void format(short value) { return; }
+ default void glyphCount(short value) { return; }
+ /* The content being the same, client code probably wants only one of glyphId or glyphIdArray. */
+ default void glyphId(short value) { return; }
+ default void glyphIdArray(short[] value) { return; }
}
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Coverage02TableHandler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Coverage02TableHandler.java 2025-04-30 11:47:30 UTC (rev 13547)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Coverage02TableHandler.java 2025-04-30 15:09:38 UTC (rev 13548)
@@ -36,6 +36,13 @@
*/
public interface Coverage02TableHandler extends FontContentHandler {
+ default void format(short value) { return; }
+ default void rangeCount(short value) { return; }
+
+ default void startGlyphID(short value) { return; }
+ default void endGlyphID(short value) { return; }
+ default void startCoverageIndex(short value) { return; }
+
/* TODO: Complete this. */
}
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/CoverageTableHandler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/CoverageTableHandler.java 2025-04-30 11:47:30 UTC (rev 13547)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/CoverageTableHandler.java 2025-04-30 15:09:38 UTC (rev 13548)
@@ -36,6 +36,7 @@
*/
public interface CoverageTableHandler extends FontContentHandler {
- /* TODO: Complete this. */
+ default Coverage01TableHandler startCoverage01Table() { return null; }
+ default Coverage02TableHandler startCoverage02Table() { return null; }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-30 11:47:55
|
Revision: 13547
http://sourceforge.net/p/foray/code/13547
Author: victormote
Date: 2025-04-30 11:47:30 +0000 (Wed, 30 Apr 2025)
Log Message:
-----------
Add verified tests of Cmap Type 4 parsing, and fix parsing logic to make those pass.
Modified Paths:
--------------
trunk/foray/foray-font/src/test/java/org/foray/font/ttf/TrueTypeFontParserTests.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cmap04TableParser.java
Modified: trunk/foray/foray-font/src/test/java/org/foray/font/ttf/TrueTypeFontParserTests.java
===================================================================
--- trunk/foray/foray-font/src/test/java/org/foray/font/ttf/TrueTypeFontParserTests.java 2025-04-30 02:52:43 UTC (rev 13546)
+++ trunk/foray/foray-font/src/test/java/org/foray/font/ttf/TrueTypeFontParserTests.java 2025-04-30 11:47:30 UTC (rev 13547)
@@ -37,6 +37,10 @@
import org.foray.font.ttf.table.BaseScriptTable;
import org.foray.font.ttf.table.BaseTable;
import org.foray.font.ttf.table.BaseValuesTable;
+import org.foray.font.ttf.table.Cmap04Table;
+import org.foray.font.ttf.table.Cmap06Table;
+import org.foray.font.ttf.table.Cmap12Table;
+import org.foray.font.ttf.table.CmapTable;
import org.foray.fontParse.ttf.TtfRandomAccessInput;
import org.axsl.font.FontException;
@@ -62,7 +66,29 @@
*/
public class TrueTypeFontParserTests {
+
/**
+ * Private helper method to read a TrueType Font file.
+ * @param path The path to the font file, relative to the test-resources directory.
+ * @return The parsed font instance.
+ * @throws IOException Not expected here.
+ * @throws FontException Not expected here.
+ */
+ public TrueTypeFont parseTruetypeFont(final String path) throws IOException, FontException {
+ final InputStream inputStream = getClass().getResourceAsStream(path);
+ assertNotNull(inputStream);
+ final FontServer4a fontServer = new FontServer4a();
+ final TtfRandomAccessInput bsp = new TtfRandomAccessInput.Impl(inputStream);
+ final FontParser parser = new FontParser(fontServer, bsp);
+
+ final FontContent fontContent = parser.parseFontFile();
+ assertTrue(fontContent instanceof TrueTypeSingle);
+ final TrueTypeSingle ttfSingle = (TrueTypeSingle) fontContent;
+ final TrueTypeFont ttfFont = ttfSingle.getTTFFont(null);
+ return ttfFont;
+ }
+
+ /**
* Make assertions about the data parsed from the DejaVu Sans Extra Light font.
* @param ttfFont The font instance to be tested.
* @throws FontException Not expected here.
@@ -246,4 +272,54 @@
assertNotNull(latnValuesTable);
}
+ /**
+ * Test Cmap results.
+ */
+ @Test
+ public void testCmapParsing() throws FontException, IOException {
+ /* This font was chosen because it uses a variety of encodings, including Type 4 tables with non-contiguous
+ * ranges. */
+ final String path = "/source-scholarsfonts.net/cardo104/Cardo104s.ttf";
+ final TrueTypeFont ttfFont = parseTruetypeFont(path);
+
+ /* The following cmap expected values were obtained from the Dutch Type Library OTMaster 8.9. */
+ final CmapTable cmapTable = ttfFont.getCmapTable();
+ assertNotNull(cmapTable);
+ assertEquals(4, cmapTable.getQtySubtables());
+ assertTrue(cmapTable.getEncoding(0) instanceof Cmap04Table);
+ assertTrue(cmapTable.getEncoding(1) instanceof Cmap06Table);
+ assertTrue(cmapTable.getEncoding(2) instanceof Cmap04Table);
+ assertTrue(cmapTable.getEncoding(3) instanceof Cmap12Table);
+
+ final Cmap04Table cmap04 = (Cmap04Table) cmapTable.getEncoding(0);
+ /* OTMaster shows 3115 encodings, but our parsing includes one at the end with start 0xFFFF and end 0xFFFF.
+ * This is standard in these fonts as a marker to indicate that reading should stop. It appears that OTMaster
+ * just ignores that last entry, which explains why our count is 3116. */
+ assertEquals(3116, cmap04.getQtyGlyphs());
+
+ /* In segments indexed 0 to 99, the following are non-contiguous: 2, 21, 27, 40, 41, 46, 56, 67, 73.
+ * The remainder are contiguous. *
+
+ /* Check some encodings from contiguous ranges. */
+ /* From segment 8. Start 407, End 407, Delta -82. */
+ assertEquals(325, cmap04.encode(407));
+
+ /* From segment 28. Start 900, End 906, Delta -197. */
+ assertEquals(703, cmap04.encode(900));
+ assertEquals(709, cmap04.encode(906));
+
+ /* Now check some encodings from a non-contiguous range. */
+ /* From segment 21. Start 546, End 555, Delta 0. */
+ assertEquals(389, cmap04.encode(546)); // code point 0x0222
+ assertEquals(390, cmap04.encode(547)); // code point 0x0223
+ assertEquals(391, cmap04.encode(548)); // code point 0x0224
+ assertEquals(392, cmap04.encode(549)); // code point 0x0225
+ assertEquals(393, cmap04.encode(550)); // code point 0x0226
+ assertEquals(394, cmap04.encode(551)); // code point 0x0227
+ assertEquals(395, cmap04.encode(552)); // code point 0x0228
+ assertEquals(396, cmap04.encode(553)); // code point 0x0229
+ assertEquals(3520, cmap04.encode(554)); // code point 0x022A
+ assertEquals(3521, cmap04.encode(555)); // code point 0x022B
+ }
+
}
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cmap04TableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cmap04TableParser.java 2025-04-30 02:52:43 UTC (rev 13546)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cmap04TableParser.java 2025-04-30 11:47:30 UTC (rev 13547)
@@ -83,7 +83,7 @@
final short[] idDeltaArray = new short[segCount];
for (int segmentIndex = 0; segmentIndex < segCount; segmentIndex ++) {
- final short idDelta = input.read_int16(); // 2 bytes @
+ final short idDelta = input.read_int16(); // 2 bytes @
handler.idDelta(idDelta);
idDeltaArray[segmentIndex] = idDelta;
}
@@ -97,7 +97,6 @@
}
handler.idRangeOffsetArray(idRangeOffsetArray);
- final int glyphIdArrayOffset = (int) input.getOffset();
final int glyphIdArraySize = length - HEADER_BYTES - (BYTES_PER_SEGMENT * segCount) - 2;
final short[] glyphIdArray = new short [glyphIdArraySize];
for (int index = 0; index < glyphIdArraySize; index ++) {
@@ -106,7 +105,11 @@
handler.glyphIdArray(glyphIdArray);
+
+ /* Users wanting the raw data will find it above. Since we don't need the memory access tricks used in the raw
+ * version, we can resolve the actual glyph ID values here by dividing the parsed glyph IDs above. */
final short[][] computedIndexesArray = new short[segCount][];
+ int index = 0;
for (int segmentIndex = 0; segmentIndex < segCount; segmentIndex ++) {
@Unsigned short[] computedIndexes = null;
if (idRangeOffsetArray[segmentIndex] == 0) {
@@ -114,24 +117,21 @@
} else {
final int startCodeAsInt = Short.toUnsignedInt(startCodeArray[segmentIndex]);
final int endCodeAsInt = Short.toUnsignedInt(endCodeArray[segmentIndex]);
- final int idRangeOffsetAsInt = Short.toUnsignedInt(idRangeOffsetArray[segmentIndex]);
computedIndexes = new @Unsigned short[endCodeAsInt - startCodeAsInt + 1];
for (int codePoint = startCodeAsInt; codePoint <= endCodeAsInt; codePoint++) {
- final int glyphOffset =
- glyphIdArrayOffset +
- ((idRangeOffsetAsInt / 2) +
- (codePoint - startCodeAsInt) +
- idRangeOffsetAsInt);
- input.seek(glyphOffset);
- final short glyphId = input.read_uint16();
- final short glyphIndex = (short) ((glyphId + idDeltaArray[segmentIndex]) % Character.MAX_VALUE);
- computedIndexes[codePoint - startCodeAsInt] = glyphIndex;
+ final short glyphId = glyphIdArray[index];
+ if (glyphId == 0) {
+ computedIndexes[codePoint - startCodeAsInt] = 0;
+ } else {
+ final int glyphIndex = (glyphId + idDeltaArray[segmentIndex]) % Character.MAX_VALUE;
+ computedIndexes[codePoint - startCodeAsInt] = (short) glyphIndex;
+ }
+ index ++;
}
}
computedIndexesArray[segmentIndex] = computedIndexes;
}
handler.computedGlyphIdArray(computedIndexesArray);
-
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-30 02:53:04
|
Revision: 13546
http://sourceforge.net/p/foray/code/13546
Author: victormote
Date: 2025-04-30 02:52:43 +0000 (Wed, 30 Apr 2025)
Log Message:
-----------
1. Fix sign problem. 2. Add method that counts the number of glyph indexes.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java 2025-04-29 21:01:37 UTC (rev 13545)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java 2025-04-30 02:52:43 UTC (rev 13546)
@@ -163,8 +163,7 @@
if (unsignedStartCode <= codePoint) {
if (this.noncontiguousIndexes[segmentIndex] == null) {
/* Contiguous range. */
- final int unsignedIdDelta = this.idDelta[segmentIndex];
- final int provisionalIndex = codePoint + unsignedIdDelta;
+ final int provisionalIndex = codePoint + this.idDelta[segmentIndex];
return provisionalIndex % Character.MAX_VALUE;
} else {
/* Non-contiguous range. */
@@ -235,4 +234,19 @@
return this.encode(codePoint) > -1;
}
+ /**
+ * Returns the number of glyphs encoded by this table.
+ * @return The number of glyphs encoded by this table.
+ */
+ public int getQtyGlyphs() {
+ int qtyGlyphs = 0;
+ for (int segmentIndex = 0; segmentIndex < this.endCode.length; segmentIndex ++) {
+ final int unsignedEndCode = Short.toUnsignedInt(this.endCode[segmentIndex]);
+ final int unsignedStartCode = Short.toUnsignedInt(this.startCode[segmentIndex]);
+ final int qtyGlyphsThisSegment = unsignedEndCode - unsignedStartCode + 1;
+ qtyGlyphs += qtyGlyphsThisSegment;
+ }
+ return qtyGlyphs;
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-29 21:01:55
|
Revision: 13545
http://sourceforge.net/p/foray/code/13545
Author: victormote
Date: 2025-04-29 21:01:37 +0000 (Tue, 29 Apr 2025)
Log Message:
-----------
Fix some signedness problems.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap00Table.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap06Table.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap00Table.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap00Table.java 2025-04-29 19:38:33 UTC (rev 13544)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap00Table.java 2025-04-29 21:01:37 UTC (rev 13545)
@@ -91,7 +91,7 @@
public int encode(final int codePoint) {
if (codePoint > -1
&& codePoint < this.glyphIdArray.length) {
- return this.glyphIdArray[codePoint];
+ return Byte.toUnsignedInt(this.glyphIdArray[codePoint]);
} else {
return -1;
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java 2025-04-29 19:38:33 UTC (rev 13544)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java 2025-04-29 21:01:37 UTC (rev 13545)
@@ -157,18 +157,19 @@
@Override
public int encode(final int codePoint) {
for (int segmentIndex = 0; segmentIndex < this.endCode.length; segmentIndex++) {
- if (Short.toUnsignedInt(this.endCode[segmentIndex]) >= codePoint) {
- if (this.startCode[segmentIndex] <= codePoint) {
+ final int unsignedEndCode = Short.toUnsignedInt(this.endCode[segmentIndex]);
+ if (unsignedEndCode >= codePoint) {
+ final int unsignedStartCode = Short.toUnsignedInt(this.startCode[segmentIndex]);
+ if (unsignedStartCode <= codePoint) {
if (this.noncontiguousIndexes[segmentIndex] == null) {
/* Contiguous range. */
- final int provisionalIndex =
- codePoint +
- this.idDelta[segmentIndex];
+ final int unsignedIdDelta = this.idDelta[segmentIndex];
+ final int provisionalIndex = codePoint + unsignedIdDelta;
return provisionalIndex % Character.MAX_VALUE;
} else {
/* Non-contiguous range. */
final short[] glyphIndexes = this.noncontiguousIndexes[segmentIndex];
- return glyphIndexes[codePoint - Short.toUnsignedInt(this.startCode[segmentIndex])];
+ return Short.toUnsignedInt(glyphIndexes[codePoint - unsignedStartCode]);
}
} else {
/* Since the segments are sorted by ending index, none of the remaining segments qualify. */
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap06Table.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap06Table.java 2025-04-29 19:38:33 UTC (rev 13544)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap06Table.java 2025-04-29 21:01:37 UTC (rev 13545)
@@ -102,10 +102,11 @@
@Override
public int encode(final int codePoint) {
- if (codePoint >= this.firstCode
- && codePoint < (this.firstCode + this.glyphIndexArray.length)) {
- final int index = codePoint + this.firstCode;
- return this.glyphIndexArray[index];
+ final int unsignedFirstCode = Short.toUnsignedInt(this.firstCode);
+ if (codePoint >= unsignedFirstCode
+ && codePoint < (unsignedFirstCode + this.glyphIndexArray.length)) {
+ final int index = codePoint + unsignedFirstCode;
+ return Short.toUnsignedInt(this.glyphIndexArray[index]);
} else {
return -1;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-29 19:38:52
|
Revision: 13544
http://sourceforge.net/p/foray/code/13544
Author: victormote
Date: 2025-04-29 19:38:33 +0000 (Tue, 29 Apr 2025)
Log Message:
-----------
Add support for parsing type 0 cmap tables.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CmapTableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/CmapTableHandler.java
Added Paths:
-----------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap00Table.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cmap00TableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Cmap00TableHandler.java
Added: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap00Table.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap00Table.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap00Table.java 2025-04-29 19:38:33 UTC (rev 13544)
@@ -0,0 +1,144 @@
+/*
+ * Copyright 2006 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.font.ttf.table;
+
+import org.foray.font.ttf.ParserKit;
+import org.foray.font.ttf.RoTable;
+import org.foray.fontParse.ttfHandler.Cmap00TableHandler;
+
+import org.axsl.ps.Encoding;
+
+import org.checkerframework.checker.signedness.qual.Unsigned;
+
+/**
+ * Class containing a one-to-one encoding of up to 256 characters.
+ */
+public class Cmap00Table extends RoTable implements Encoding {
+
+ /**
+ * The handler of events from the parser.
+ */
+ private final class ContentHandler implements Cmap00TableHandler {
+
+ /** The table instance being created. */
+ private Cmap00Table table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final Cmap00Table table) {
+ this.table = table;
+ }
+
+ @Override
+ public void glyphIdArray(final @Unsigned byte[] value) {
+ this.table.glyphIdArray = value;
+ }
+ }
+
+
+
+
+
+
+
+ /** The glyph indexes for this table. */
+ private @Unsigned byte[] glyphIdArray;
+
+ /**
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
+ */
+ public static ParserKit<Cmap00Table, Cmap00TableHandler> createContentHandler() {
+ final Cmap00Table table = new Cmap00Table();
+ final Cmap00TableHandler handler = table.new ContentHandler(table);
+ return new ParserKit<Cmap00Table, Cmap00TableHandler>(table, handler);
+ }
+
+ @Override
+ public String getName() {
+ return "internal";
+ }
+
+ @Override
+ public int encode(final int codePoint) {
+ if (codePoint > -1
+ && codePoint < this.glyphIdArray.length) {
+ return this.glyphIdArray[codePoint];
+ } else {
+ return -1;
+ }
+ }
+
+ @Override
+ public int decode(final int glyphIndex) {
+ for (int index = 0; index < this.glyphIdArray.length; index++) {
+ if (glyphIndex == Byte.toUnsignedInt(this.glyphIdArray[index])) {
+ return index;
+ }
+ }
+ return -1;
+ }
+
+ @Override
+ public String asPostScript(final org.axsl.ps.Encoding baseEncoding) {
+ return null;
+ }
+
+ @Override
+ public int getFirstIndex() {
+ return -1;
+ }
+
+ @Override
+ public int getLastIndex() {
+ return -1;
+ }
+
+ @Override
+ public boolean isBuiltInPs() {
+ /* TODO Make this class abstract and make a subclass that handled custom instances, so that we can keep the
+ * prebuilt instances separate, and return different values here. */
+ return false;
+ }
+
+ @Override
+ public boolean isBuiltInPdf() {
+ /* TODO Make this class abstract and make a subclass that handled custom instances, so that we can keep the
+ * prebuilt instances separate, and return different values here. */
+ return false;
+ }
+
+ @Override
+ public boolean canEncode(final int codePoint) {
+ return this.encode(codePoint) > -1;
+ }
+
+}
Property changes on: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap00Table.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java 2025-04-29 18:59:53 UTC (rev 13543)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java 2025-04-29 19:38:33 UTC (rev 13544)
@@ -30,6 +30,7 @@
import org.foray.font.ttf.ParserKit;
import org.foray.font.ttf.RoTable;
+import org.foray.fontParse.ttfHandler.Cmap00TableHandler;
import org.foray.fontParse.ttfHandler.Cmap04TableHandler;
import org.foray.fontParse.ttfHandler.Cmap06TableHandler;
import org.foray.fontParse.ttfHandler.Cmap12TableHandler;
@@ -68,6 +69,13 @@
}
@Override
+ public Cmap00TableHandler startCmap00Table() {
+ final ParserKit<Cmap00Table, Cmap00TableHandler> handler = Cmap00Table.createContentHandler();
+ this.table.unicodeCMap.add(handler.getTable());
+ return handler.getHandler();
+ }
+
+ @Override
public Cmap04TableHandler startCmap04Table() {
final ParserKit<Cmap04Table, Cmap04TableHandler> handler = Cmap04Table.createContentHandler();
this.table.unicodeCMap.add(handler.getTable());
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cmap00TableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cmap00TableParser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cmap00TableParser.java 2025-04-29 19:38:33 UTC (rev 13544)
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.Cmap00TableHandler;
+
+import org.axsl.constants.PrimitiveConstants;
+
+import java.io.IOException;
+
+/**
+ * Parses a TTF Cmap Type 00 subtable.
+ */
+public class Cmap00TableParser extends TableParser<Cmap00TableHandler> {
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final Cmap00TableHandler handler)
+ throws IOException {
+ input.seek(offset);
+
+ handler.format(input.read_uint16()); // 2 bytes, total 2
+ handler.length(input.read_uint16()); // 2 bytes, total 4
+ handler.language(input.read_uint16()); // 2 bytes, total 6
+
+ /* Parse each glyph Id. */
+ /* Array size is 256. */
+ final byte[] glyphIdArray = new byte[PrimitiveConstants.MAX_8_BIT_UNSIGNED_VALUES];
+ for (int index = 0; index < glyphIdArray.length; index ++) {
+ final byte glyphId = input.read_uint8();
+ handler.glyphId(glyphId);
+ glyphIdArray[index] = glyphId;
+ }
+ handler.glyphIdArray(glyphIdArray);
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cmap00TableParser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CmapTableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CmapTableParser.java 2025-04-29 18:59:53 UTC (rev 13543)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CmapTableParser.java 2025-04-29 19:38:33 UTC (rev 13544)
@@ -29,6 +29,7 @@
package org.foray.fontParse.ttf;
import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.Cmap00TableHandler;
import org.foray.fontParse.ttfHandler.Cmap04TableHandler;
import org.foray.fontParse.ttfHandler.Cmap06TableHandler;
import org.foray.fontParse.ttfHandler.Cmap12TableHandler;
@@ -88,22 +89,36 @@
/* Read the subtable. */
switch (format) {
+ case CMAP_FORMAT_0: {
+ final Cmap00TableHandler cmap00Handler = handler.startCmap00Table();
+ if (cmap00Handler != null) {
+ final Cmap00TableParser cmap04Parser = new Cmap00TableParser();
+ cmap04Parser.parse(input, absoluteSubtableOffset, cmap00Handler);
+ }
+ break;
+ }
case CMAP_FORMAT_4: {
final Cmap04TableHandler cmap04Handler = handler.startCmap04Table();
- final Cmap04TableParser cmap04Parser = new Cmap04TableParser();
- cmap04Parser.parse(input, absoluteSubtableOffset, cmap04Handler);
+ if (cmap04Handler != null) {
+ final Cmap04TableParser cmap04Parser = new Cmap04TableParser();
+ cmap04Parser.parse(input, absoluteSubtableOffset, cmap04Handler);
+ }
break;
}
case CMAP_FORMAT_6: {
final Cmap06TableHandler cmap06Handler = handler.startCmap06Table();
- final Cmap06TableParser cmap06Parser = new Cmap06TableParser();
- cmap06Parser.parse(input, absoluteSubtableOffset, cmap06Handler);
+ if (cmap06Handler != null) {
+ final Cmap06TableParser cmap06Parser = new Cmap06TableParser();
+ cmap06Parser.parse(input, absoluteSubtableOffset, cmap06Handler);
+ }
break;
}
case CMAP_FORMAT_12: {
final Cmap12TableHandler cmap12Handler = handler.startCmap12Table();
- final Cmap12TableParser cmap12Parser = new Cmap12TableParser();
- cmap12Parser.parse(input, absoluteSubtableOffset, cmap12Handler);
+ if (cmap12Handler != null) {
+ final Cmap12TableParser cmap12Parser = new Cmap12TableParser();
+ cmap12Parser.parse(input, absoluteSubtableOffset, cmap12Handler);
+ }
break;
}
default: handler.unsupportedSubtableFormat(format);
@@ -110,7 +125,7 @@
}
- /* Subtable has been read. Return to the bookmark so that the next */
+ /* Subtable has been read. Return to the bookmark so that the next one can be read. */
input.seek(bookmark);
}
}
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Cmap00TableHandler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Cmap00TableHandler.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Cmap00TableHandler.java 2025-04-29 19:38:33 UTC (rev 13544)
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttfHandler;
+
+import org.foray.fontParse.FontContentHandler;
+
+import org.checkerframework.checker.signedness.qual.Unsigned;
+
+/**
+ * Implementations catch and handle the output from {@link org.foray.fontParse.ttf.Cmap00TableParser}.
+ */
+public interface Cmap00TableHandler extends FontContentHandler {
+
+ default void format(@Unsigned short value) { return; }
+ default void length(@Unsigned int value) { return; }
+ default void language(@Unsigned int value) { return; }
+
+ /* Being the same value, implementations will probably want to use only one of either glyphId or glyphIdArray. */
+ default void glyphId(@Unsigned byte value) { return; }
+ default void glyphIdArray(@Unsigned byte[] value) { return; }
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Cmap00TableHandler.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/CmapTableHandler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/CmapTableHandler.java 2025-04-29 18:59:53 UTC (rev 13543)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/CmapTableHandler.java 2025-04-29 19:38:33 UTC (rev 13544)
@@ -49,6 +49,7 @@
* which subtable format they are parsing before they start parsing it. */
default void subtableFormat(@Unsigned short value) { return; }
+ default Cmap00TableHandler startCmap00Table() { return null; }
default Cmap04TableHandler startCmap04Table() { return null; }
default Cmap06TableHandler startCmap06Table() { return null; }
default Cmap12TableHandler startCmap12Table() { return null; }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-29 19:00:11
|
Revision: 13543
http://sourceforge.net/p/foray/code/13543
Author: victormote
Date: 2025-04-29 18:59:53 +0000 (Tue, 29 Apr 2025)
Log Message:
-----------
Move Coverage tables to the tables package.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup04x01.java
trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/OtfLookupGsubTests.java
Added Paths:
-----------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Coverage01Table.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Coverage02Table.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CoverageTable.java
Removed Paths:
-------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfCoverage.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfCoveragex01.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfCoveragex02.java
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfCoverage.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfCoverage.java 2025-04-29 18:56:13 UTC (rev 13542)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfCoverage.java 2025-04-29 18:59:53 UTC (rev 13543)
@@ -1,68 +0,0 @@
-/*
- * Copyright 2016 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.font.ttf;
-
-import org.foray.common.RandomAccessInput;
-
-import java.io.IOException;
-
-/**
- * Abstract superclass for coverage types.
- */
-public abstract class OtfCoverage {
-
- /**
- * Parses a coverage.
- * @param raInput The input from which the coverage is being parsed.
- * @param offset The offset in {@code raInput} for the start of the coverage.
- * @return The parsed coverage instance.
- * @throws IOException For I/O errors during parsing.
- */
- public static OtfCoverage parse(final RandomAccessInput raInput, final int offset) throws IOException {
- raInput.seek(offset);
- final int coverageFormat = raInput.readUnsignedShort();
- switch (coverageFormat) {
- case 1: {
- return OtfCoveragex01.parse(raInput, offset);
- }
- case 2: {
- return OtfCoveragex02.parse(raInput, offset);
- }
- default: throw new UnsupportedOperationException("Unrecognized Coverage Format: " + coverageFormat);
- }
- }
-
- /**
- * Returns the coverage index for a given glyph index.
- * @param glyphIndex The glyph index to be tested.
- * @return The coverage index, or a negative number if {@code glyphIndex} is not covered.
- */
- public abstract int coverageIndex(int glyphIndex);
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfCoveragex01.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfCoveragex01.java 2025-04-29 18:56:13 UTC (rev 13542)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfCoveragex01.java 2025-04-29 18:59:53 UTC (rev 13543)
@@ -1,78 +0,0 @@
-/*
- * Copyright 2016 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.font.ttf;
-
-import org.foray.common.RandomAccessInput;
-
-import java.io.IOException;
-import java.util.Arrays;
-
-/**
- * A coverage using Format 1 (List of glyph indexes).
- */
-public class OtfCoveragex01 extends OtfCoverage {
-
- /** Array of glyph indexes that define this coverage. */
- private char[] glyphArray;
-
- /**
- * Parses a coverage.
- * @param raInput The input from which the coverage is being parsed.
- * @param offset The offset in {@code raInput} for the start of the coverage.
- * @return The parsed coverage instance.
- * @throws IOException For I/O errors during parsing.
- */
- public static OtfCoveragex01 parse(final RandomAccessInput raInput, final int offset) throws IOException {
- raInput.seek(offset);
- final OtfCoveragex01 coverage = new OtfCoveragex01();
-
- /* Skip reading the CoverageFormat. We already read it when deciding to come here. */
- raInput.skipBytes(RoTable.USHORT_BYTES);
- final int glyphCount = raInput.readUnsignedShort();
- coverage.glyphArray = new char[glyphCount];
- for (int index = 0; index < coverage.glyphArray.length; index ++) {
- coverage.glyphArray[index] = raInput.readChar();
- }
- return coverage;
- }
-
- /**
- * Returns the array of glyph indexes that define this coverage.
- * @return The array of glyph indexes that define this coverage.
- */
- public char[] getGlyphArray() {
- return this.glyphArray;
- }
-
- @Override
- public int coverageIndex(final int glyphIndex) {
- return Arrays.binarySearch(this.glyphArray, (char) glyphIndex);
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfCoveragex02.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfCoveragex02.java 2025-04-29 18:56:13 UTC (rev 13542)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfCoveragex02.java 2025-04-29 18:59:53 UTC (rev 13543)
@@ -1,128 +0,0 @@
-/*
- * Copyright 2016 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.font.ttf;
-
-import org.foray.common.RandomAccessInput;
-
-import java.io.IOException;
-
-/**
- * A coverage using Format 2 (List of glyph index ranges).
- */
-public class OtfCoveragex02 extends OtfCoverage {
-
- /**
- * A range in this coverage.
- */
- public class RangeRecord {
-
- /** The first glyph index in the range. */
- private char start;
-
- /** The last glyph index in the range. */
- private char end;
-
- /** The coverage index of the first glyph index in the range. */
- private char startCoverageIndex;
-
- /**
- * Returns the first glyph index in the range.
- * @return The first glyph index in the range.
- */
- protected char getStart() {
- return this.start;
- }
-
- /**
- * Returns the last glyph index in the range.
- * @return The last glyph index in the range.
- */
- protected char getEnd() {
- return this.end;
- }
-
- /**
- * Returns the coverage index of the first glyph index in the range.
- * @return The coverage index of the first glyph index in the range.
- */
- protected char getStartCoverageIndex() {
- return this.startCoverageIndex;
- }
-
- }
-
- /** The ranges for this coverage, ordered by the start glyph index. */
- private RangeRecord[] ranges;
-
- /**
- * Parses a coverage.
- * @param raInput The input from which the coverage is being parsed.
- * @param offset The offset in {@code raInput} for the start of the coverage.
- * @return The parsed coverage instance.
- * @throws IOException For I/O errors during parsing.
- */
- public static OtfCoveragex02 parse(final RandomAccessInput raInput, final int offset) throws IOException {
- raInput.seek(offset);
- final OtfCoveragex02 coverage = new OtfCoveragex02();
-
- /* Skip reading the CoverageFormat. We already read it when deciding to come here. */
- raInput.skipBytes(RoTable.USHORT_BYTES);
- final int rangeCount = raInput.readUnsignedShort();
- coverage.ranges = new RangeRecord[rangeCount];
- for (int index = 0; index < coverage.ranges.length; index ++) {
- final RangeRecord range = coverage.new RangeRecord();
- range.start = raInput.readChar();
- range.end = raInput.readChar();
- range.startCoverageIndex = raInput.readChar();
- coverage.ranges[index] = range;
- }
- return coverage;
- }
-
- /**
- * Returns the ranges in this coverage.
- * @return The ranges.
- */
- RangeRecord[] getRanges() {
- return this.ranges;
- }
-
- @Override
- public int coverageIndex(final int glyphIndex) {
- for (int index = 0; index < this.ranges.length; index ++) {
- final RangeRecord rangeRecord = this.ranges[index];
- if (glyphIndex >= rangeRecord.start
- && glyphIndex <= rangeRecord.end) {
- return glyphIndex - rangeRecord.start + rangeRecord.startCoverageIndex;
- }
- }
- return -1;
- }
-
-}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Coverage01Table.java (from rev 13486, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfCoveragex01.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Coverage01Table.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Coverage01Table.java 2025-04-29 18:59:53 UTC (rev 13543)
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2016 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.font.ttf.table;
+
+import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.RoTable;
+
+import java.io.IOException;
+import java.util.Arrays;
+
+/**
+ * A coverage using Format 1 (List of glyph indexes).
+ */
+public class Coverage01Table extends CoverageTable {
+
+ /** Array of glyph indexes that define this coverage. */
+ private char[] glyphArray;
+
+ /**
+ * Parses a coverage.
+ * @param raInput The input from which the coverage is being parsed.
+ * @param offset The offset in {@code raInput} for the start of the coverage.
+ * @return The parsed coverage instance.
+ * @throws IOException For I/O errors during parsing.
+ */
+ public static Coverage01Table parse(final RandomAccessInput raInput, final int offset) throws IOException {
+ raInput.seek(offset);
+ final Coverage01Table coverage = new Coverage01Table();
+
+ /* Skip reading the CoverageFormat. We already read it when deciding to come here. */
+ raInput.skipBytes(RoTable.USHORT_BYTES);
+ final int glyphCount = raInput.readUnsignedShort();
+ coverage.glyphArray = new char[glyphCount];
+ for (int index = 0; index < coverage.glyphArray.length; index ++) {
+ coverage.glyphArray[index] = raInput.readChar();
+ }
+ return coverage;
+ }
+
+ /**
+ * Returns the array of glyph indexes that define this coverage.
+ * @return The array of glyph indexes that define this coverage.
+ */
+ public char[] getGlyphArray() {
+ return this.glyphArray;
+ }
+
+ @Override
+ public int coverageIndex(final int glyphIndex) {
+ return Arrays.binarySearch(this.glyphArray, (char) glyphIndex);
+ }
+
+}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Coverage02Table.java (from rev 13486, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfCoveragex02.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Coverage02Table.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Coverage02Table.java 2025-04-29 18:59:53 UTC (rev 13543)
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2016 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.font.ttf.table;
+
+import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.RoTable;
+
+import java.io.IOException;
+
+/**
+ * A coverage using Format 2 (List of glyph index ranges).
+ */
+public class Coverage02Table extends CoverageTable {
+
+ /**
+ * A range in this coverage.
+ */
+ public class RangeRecord {
+
+ /** The first glyph index in the range. */
+ private char start;
+
+ /** The last glyph index in the range. */
+ private char end;
+
+ /** The coverage index of the first glyph index in the range. */
+ private char startCoverageIndex;
+
+ /**
+ * Returns the first glyph index in the range.
+ * @return The first glyph index in the range.
+ */
+ protected char getStart() {
+ return this.start;
+ }
+
+ /**
+ * Returns the last glyph index in the range.
+ * @return The last glyph index in the range.
+ */
+ protected char getEnd() {
+ return this.end;
+ }
+
+ /**
+ * Returns the coverage index of the first glyph index in the range.
+ * @return The coverage index of the first glyph index in the range.
+ */
+ protected char getStartCoverageIndex() {
+ return this.startCoverageIndex;
+ }
+
+ }
+
+ /** The ranges for this coverage, ordered by the start glyph index. */
+ private RangeRecord[] ranges;
+
+ /**
+ * Parses a coverage.
+ * @param raInput The input from which the coverage is being parsed.
+ * @param offset The offset in {@code raInput} for the start of the coverage.
+ * @return The parsed coverage instance.
+ * @throws IOException For I/O errors during parsing.
+ */
+ public static Coverage02Table parse(final RandomAccessInput raInput, final int offset) throws IOException {
+ raInput.seek(offset);
+ final Coverage02Table coverage = new Coverage02Table();
+
+ /* Skip reading the CoverageFormat. We already read it when deciding to come here. */
+ raInput.skipBytes(RoTable.USHORT_BYTES);
+ final int rangeCount = raInput.readUnsignedShort();
+ coverage.ranges = new RangeRecord[rangeCount];
+ for (int index = 0; index < coverage.ranges.length; index ++) {
+ final RangeRecord range = coverage.new RangeRecord();
+ range.start = raInput.readChar();
+ range.end = raInput.readChar();
+ range.startCoverageIndex = raInput.readChar();
+ coverage.ranges[index] = range;
+ }
+ return coverage;
+ }
+
+ /**
+ * Returns the ranges in this coverage.
+ * @return The ranges.
+ */
+ RangeRecord[] getRanges() {
+ return this.ranges;
+ }
+
+ @Override
+ public int coverageIndex(final int glyphIndex) {
+ for (int index = 0; index < this.ranges.length; index ++) {
+ final RangeRecord rangeRecord = this.ranges[index];
+ if (glyphIndex >= rangeRecord.start
+ && glyphIndex <= rangeRecord.end) {
+ return glyphIndex - rangeRecord.start + rangeRecord.startCoverageIndex;
+ }
+ }
+ return -1;
+ }
+
+}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CoverageTable.java (from rev 13486, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfCoverage.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CoverageTable.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CoverageTable.java 2025-04-29 18:59:53 UTC (rev 13543)
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2016 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.font.ttf.table;
+
+import org.foray.common.RandomAccessInput;
+
+import java.io.IOException;
+
+/**
+ * Abstract superclass for coverage types.
+ */
+public abstract class CoverageTable {
+
+ /**
+ * Parses a coverage.
+ * @param raInput The input from which the coverage is being parsed.
+ * @param offset The offset in {@code raInput} for the start of the coverage.
+ * @return The parsed coverage instance.
+ * @throws IOException For I/O errors during parsing.
+ */
+ public static CoverageTable parse(final RandomAccessInput raInput, final int offset) throws IOException {
+ raInput.seek(offset);
+ final int coverageFormat = raInput.readUnsignedShort();
+ switch (coverageFormat) {
+ case 1: {
+ return Coverage01Table.parse(raInput, offset);
+ }
+ case 2: {
+ return Coverage02Table.parse(raInput, offset);
+ }
+ default: throw new UnsupportedOperationException("Unrecognized Coverage Format: " + coverageFormat);
+ }
+ }
+
+ /**
+ * Returns the coverage index for a given glyph index.
+ * @param glyphIndex The glyph index to be tested.
+ * @return The coverage index, or a negative number if {@code glyphIndex} is not covered.
+ */
+ public abstract int coverageIndex(int glyphIndex);
+
+}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup04x01.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup04x01.java 2025-04-29 18:56:13 UTC (rev 13542)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup04x01.java 2025-04-29 18:59:53 UTC (rev 13543)
@@ -29,7 +29,6 @@
package org.foray.font.ttf.table;
import org.foray.common.RandomAccessInput;
-import org.foray.font.ttf.OtfCoverage;
import org.foray.fontParse.ttf.TtfType;
import org.foray.fontParse.ttfHandler.GsubLookup04x01Handler;
import org.foray.primitive.sequence.IntArrayBuilder;
@@ -143,7 +142,7 @@
}
/** The coverage for this subtable. */
- private OtfCoverage coverage;
+ private CoverageTable coverage;
/** The ligature sets for this subtable. */
private LigatureSet[] ligatureSets;
@@ -173,7 +172,7 @@
ligSetOffsets[index] = raInput.readUnsignedShort();
}
- subtable.coverage = OtfCoverage.parse(raInput, offset + coverageOffset);
+ subtable.coverage = CoverageTable.parse(raInput, offset + coverageOffset);
subtable.ligatureSets = new LigatureSet[ligSetCount];
for (int index = 0; index < ligSetCount; index ++) {
@@ -244,7 +243,7 @@
* Returns the coverage for this subtable.
* @return The coverage.
*/
- protected OtfCoverage getCoverage() {
+ protected CoverageTable getCoverage() {
return this.coverage;
}
@@ -258,7 +257,7 @@
@Override
public void makeSubstitutions(final IntArrayBuilder glyphIndexes, final FontContext fontContext) {
- final OtfCoverage coverage = getCoverage();
+ final CoverageTable coverage = getCoverage();
final LigatureSet[] ligatureSets = getLigatureSets();
/* Only search through length - 1, as a ligature must apply to two or more glyphs. */
Modified: trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/OtfLookupGsubTests.java
===================================================================
--- trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/OtfLookupGsubTests.java 2025-04-29 18:56:13 UTC (rev 13542)
+++ trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/OtfLookupGsubTests.java 2025-04-29 18:59:53 UTC (rev 13543)
@@ -32,8 +32,6 @@
import org.foray.font.FontServer4a;
import org.foray.font.format.FontContent;
import org.foray.font.format.FontParser;
-import org.foray.font.ttf.OtfCoverage;
-import org.foray.font.ttf.OtfCoveragex01;
import org.foray.font.ttf.OtfFeature;
import org.foray.font.ttf.OtfLanguageSystem;
import org.foray.font.ttf.OtfScript;
@@ -53,7 +51,6 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
-
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
@@ -201,10 +198,10 @@
final GsubLookup04x01 ligatureSubtable = (GsubLookup04x01) ligatureLookupSubtable;
/* Tests of the Coverage in the ligature subtable. */
- final OtfCoverage coverage = ligatureSubtable.getCoverage();
+ final CoverageTable coverage = ligatureSubtable.getCoverage();
assertNotNull(coverage);
- assertTrue(coverage instanceof OtfCoveragex01);
- final OtfCoveragex01 coverage1 = (OtfCoveragex01) coverage;
+ assertTrue(coverage instanceof Coverage01Table);
+ final Coverage01Table coverage1 = (Coverage01Table) coverage;
assertEquals(1, coverage1.getGlyphArray().length);
/* Per examination of the font in FontLab Studio 5.0.4, the glyph index for a lowercase "f" is 73.
* All of the ligatures defined in this subtable will replace a set of glyphs that start with "f". */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-29 18:56:31
|
Revision: 13542
http://sourceforge.net/p/foray/code/13542
Author: victormote
Date: 2025-04-29 18:56:13 +0000 (Tue, 29 Apr 2025)
Log Message:
-----------
Progress on parsing GSUB ligatures with new scheme.
Modified Paths:
--------------
trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/OtfLookupGsubTests.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup04x01Parser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup04x01Handler.java
Added Paths:
-----------
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Coverage01TableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Coverage02TableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CoverageTableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Coverage01TableHandler.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Coverage02TableHandler.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/CoverageTableHandler.java
Modified: trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/OtfLookupGsubTests.java
===================================================================
--- trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/OtfLookupGsubTests.java 2025-04-29 18:03:15 UTC (rev 13541)
+++ trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/OtfLookupGsubTests.java 2025-04-29 18:56:13 UTC (rev 13542)
@@ -53,6 +53,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Coverage01TableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Coverage01TableParser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Coverage01TableParser.java 2025-04-29 18:56:13 UTC (rev 13542)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.Coverage01TableHandler;
+
+import java.io.IOException;
+
+/**
+ * Parses a Coverage table, format 1.
+ */
+public class Coverage01TableParser extends TableParser<Coverage01TableHandler> {
+
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final Coverage01TableHandler handler)
+ throws IOException {
+ input.seek(offset);
+
+ /* TODO: Complete this. */
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Coverage01TableParser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Coverage02TableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Coverage02TableParser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Coverage02TableParser.java 2025-04-29 18:56:13 UTC (rev 13542)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.Coverage02TableHandler;
+
+import java.io.IOException;
+
+/**
+ * Parses a Coverage table, format 2.
+ */
+public class Coverage02TableParser extends TableParser<Coverage02TableHandler> {
+
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final Coverage02TableHandler handler)
+ throws IOException {
+ input.seek(offset);
+
+ /* TODO: Complete this. */
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Coverage02TableParser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CoverageTableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CoverageTableParser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CoverageTableParser.java 2025-04-29 18:56:13 UTC (rev 13542)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.CoverageTableHandler;
+
+import java.io.IOException;
+
+/**
+ * Parses a Coverage table.
+ */
+public class CoverageTableParser extends TableParser<CoverageTableHandler> {
+
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final CoverageTableHandler handler)
+ throws IOException {
+ input.seek(offset);
+
+ /* TODO: Complete this. */
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CoverageTableParser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup04x01Parser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup04x01Parser.java 2025-04-29 18:03:15 UTC (rev 13541)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup04x01Parser.java 2025-04-29 18:56:13 UTC (rev 13542)
@@ -31,6 +31,8 @@
import org.foray.fontParse.TableParser;
import org.foray.fontParse.ttfHandler.GsubLookup04x01Handler;
+import org.checkerframework.checker.signedness.qual.Unsigned;
+
import java.io.IOException;
/**
@@ -43,6 +45,15 @@
throws IOException {
input.seek(offset);
+ handler.format(input.read_uint16()); // 2 bytes, total 2
+ handler.coverageOffset(input.read_Offset16()); // 2 bytes, total 4
+ final @Unsigned short ligatureSetCount = input.read_uint16(); // 2 bytes, total 6
+ handler.ligatureSetCount(ligatureSetCount);
+
+ for (int index = 0; index < ligatureSetCount; index ++) {
+ handler.ligatureSetOffset(input.read_Offset16());
+ }
+
/* TODO: Complete this. */
}
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Coverage01TableHandler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Coverage01TableHandler.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Coverage01TableHandler.java 2025-04-29 18:56:13 UTC (rev 13542)
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttfHandler;
+
+import org.foray.fontParse.FontContentHandler;
+import org.foray.fontParse.ttf.Coverage01TableParser;
+
+/**
+ * Implementations catch and handle the output from {@link Coverage01TableParser}.
+ */
+public interface Coverage01TableHandler extends FontContentHandler {
+
+ /* TODO: Complete this. */
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Coverage01TableHandler.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Coverage02TableHandler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Coverage02TableHandler.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Coverage02TableHandler.java 2025-04-29 18:56:13 UTC (rev 13542)
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttfHandler;
+
+import org.foray.fontParse.FontContentHandler;
+import org.foray.fontParse.ttf.Coverage02TableParser;
+
+/**
+ * Implementations catch and handle the output from {@link Coverage02TableParser}.
+ */
+public interface Coverage02TableHandler extends FontContentHandler {
+
+ /* TODO: Complete this. */
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Coverage02TableHandler.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/CoverageTableHandler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/CoverageTableHandler.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/CoverageTableHandler.java 2025-04-29 18:56:13 UTC (rev 13542)
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttfHandler;
+
+import org.foray.fontParse.FontContentHandler;
+import org.foray.fontParse.ttf.CoverageTableParser;
+
+/**
+ * Implementations catch and handle the output from {@link CoverageTableParser}.
+ */
+public interface CoverageTableHandler extends FontContentHandler {
+
+ /* TODO: Complete this. */
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/CoverageTableHandler.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup04x01Handler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup04x01Handler.java 2025-04-29 18:03:15 UTC (rev 13541)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup04x01Handler.java 2025-04-29 18:56:13 UTC (rev 13542)
@@ -29,11 +29,19 @@
package org.foray.fontParse.ttfHandler;
import org.foray.fontParse.FontContentHandler;
+import org.foray.fontParse.ttf.GsubLookup04x01Parser;
+import org.checkerframework.checker.signedness.qual.Unsigned;
+
/**
* Implementations catch and handle the output from {@link GsubLookup04x01Parser}.
*/
public interface GsubLookup04x01Handler extends FontContentHandler {
+ default void format(@Unsigned short value) { return; }
+ default void coverageOffset(@Unsigned short value) { return; }
+ default void ligatureSetCount(@Unsigned short value) { return; }
+ default void ligatureSetOffset(@Unsigned short value) { return; }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-29 18:03:36
|
Revision: 13541
http://sourceforge.net/p/foray/code/13541
Author: victormote
Date: 2025-04-29 18:03:15 +0000 (Tue, 29 Apr 2025)
Log Message:
-----------
Activate new parser scheme for most GSUB Lookups.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup01x01.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup01x02.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup02x01.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup03x01.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup04x01.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup05x01.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup05x02.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup05x03.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup06x01.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup06x02.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup06x03.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup07x01.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup08x01.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookupSubtable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubTable.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup.java 2025-04-29 16:49:17 UTC (rev 13540)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup.java 2025-04-29 18:03:15 UTC (rev 13541)
@@ -28,7 +28,32 @@
package org.foray.font.ttf.table;
-import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.ParserKit;
+import org.foray.fontParse.ttf.GsubLookup01x01Parser;
+import org.foray.fontParse.ttf.GsubLookup01x02Parser;
+import org.foray.fontParse.ttf.GsubLookup02x01Parser;
+import org.foray.fontParse.ttf.GsubLookup03x01Parser;
+import org.foray.fontParse.ttf.GsubLookup05x01Parser;
+import org.foray.fontParse.ttf.GsubLookup05x02Parser;
+import org.foray.fontParse.ttf.GsubLookup05x03Parser;
+import org.foray.fontParse.ttf.GsubLookup06x01Parser;
+import org.foray.fontParse.ttf.GsubLookup06x02Parser;
+import org.foray.fontParse.ttf.GsubLookup06x03Parser;
+import org.foray.fontParse.ttf.GsubLookup07x01Parser;
+import org.foray.fontParse.ttf.GsubLookup08x01Parser;
+import org.foray.fontParse.ttf.TtfRandomAccessInput;
+import org.foray.fontParse.ttfHandler.GsubLookup01x01Handler;
+import org.foray.fontParse.ttfHandler.GsubLookup01x02Handler;
+import org.foray.fontParse.ttfHandler.GsubLookup02x01Handler;
+import org.foray.fontParse.ttfHandler.GsubLookup03x01Handler;
+import org.foray.fontParse.ttfHandler.GsubLookup05x01Handler;
+import org.foray.fontParse.ttfHandler.GsubLookup05x02Handler;
+import org.foray.fontParse.ttfHandler.GsubLookup05x03Handler;
+import org.foray.fontParse.ttfHandler.GsubLookup06x01Handler;
+import org.foray.fontParse.ttfHandler.GsubLookup06x02Handler;
+import org.foray.fontParse.ttfHandler.GsubLookup06x03Handler;
+import org.foray.fontParse.ttfHandler.GsubLookup07x01Handler;
+import org.foray.fontParse.ttfHandler.GsubLookup08x01Handler;
import java.io.IOException;
@@ -123,7 +148,7 @@
* @return The parsed lookup table instance.
* @throws IOException For I/O errors during parsing.
*/
- public static GsubLookup parse(final RandomAccessInput raInput, final int offset) throws IOException {
+ public static GsubLookup parse(final TtfRandomAccessInput raInput, final int offset) throws IOException {
raInput.seek(offset);
final GsubLookup lookup = new GsubLookup();
final int lookupTypeInteger = raInput.readUnsignedShort();
@@ -155,7 +180,7 @@
* @return The parsed subtable instance.
* @throws IOException For I/O errors during parsing.
*/
- private static GsubLookupSubtable parseSubtable(final RandomAccessInput raInput, final int offset,
+ private static GsubLookupSubtable parseSubtable(final TtfRandomAccessInput raInput, final int offset,
final GsubLookup.LookupType lookupType) throws IOException {
raInput.seek(offset);
@@ -164,19 +189,39 @@
switch (lookupType) {
case SINGLE: {
switch (formatId) {
- case FORMAT_1: return GsubLookup01x01.parse(raInput, offset);
- case FORMAT_2: return GsubLookup01x02.parse(raInput, offset);
+ case FORMAT_1: {
+ final ParserKit<GsubLookup01x01, GsubLookup01x01Handler> kit = GsubLookup01x01.createContentHandler();
+ final GsubLookup01x01Parser parser = new GsubLookup01x01Parser();
+ parser.parse(raInput, offset, kit.getHandler());
+ return kit.getTable();
+ }
+ case FORMAT_2: {
+ final ParserKit<GsubLookup01x02, GsubLookup01x02Handler> kit = GsubLookup01x02.createContentHandler();
+ final GsubLookup01x02Parser parser = new GsubLookup01x02Parser();
+ parser.parse(raInput, offset, kit.getHandler());
+ return kit.getTable();
+ }
default: throw new UnsupportedOperationException("Unrecognized GSUB lookup type 1: " + formatId);
}
}
case MULTIPLE:
switch (formatId) {
- case FORMAT_1: return GsubLookup02x01.parse(raInput, offset);
+ case FORMAT_1: {
+ final ParserKit<GsubLookup02x01, GsubLookup02x01Handler> kit = GsubLookup02x01.createContentHandler();
+ final GsubLookup02x01Parser parser = new GsubLookup02x01Parser();
+ parser.parse(raInput, offset, kit.getHandler());
+ return kit.getTable();
+ }
default: throw new UnsupportedOperationException("Unrecognized GSUB lookup type 2: " + formatId);
}
case ALTERNATE:
switch (formatId) {
- case FORMAT_1: return GsubLookup03x01.parse(raInput, offset);
+ case FORMAT_1: {
+ final ParserKit<GsubLookup03x01, GsubLookup03x01Handler> kit = GsubLookup03x01.createContentHandler();
+ final GsubLookup03x01Parser parser = new GsubLookup03x01Parser();
+ parser.parse(raInput, offset, kit.getHandler());
+ return kit.getTable();
+ }
default: throw new UnsupportedOperationException("Unrecognized GSUB lookup type 3: " + formatId);
}
case LIGATURE:
@@ -186,26 +231,66 @@
}
case CONTEXT:
switch (formatId) {
- case FORMAT_1: return GsubLookup05x01.parse(raInput, offset);
- case FORMAT_2: return GsubLookup05x02.parse(raInput, offset);
- case FORMAT_3: return GsubLookup05x03.parse(raInput, offset);
+ case FORMAT_1: {
+ final ParserKit<GsubLookup05x01, GsubLookup05x01Handler> kit = GsubLookup05x01.createContentHandler();
+ final GsubLookup05x01Parser parser = new GsubLookup05x01Parser();
+ parser.parse(raInput, offset, kit.getHandler());
+ return kit.getTable();
+ }
+ case FORMAT_2: {
+ final ParserKit<GsubLookup05x02, GsubLookup05x02Handler> kit = GsubLookup05x02.createContentHandler();
+ final GsubLookup05x02Parser parser = new GsubLookup05x02Parser();
+ parser.parse(raInput, offset, kit.getHandler());
+ return kit.getTable();
+ }
+ case FORMAT_3: {
+ final ParserKit<GsubLookup05x03, GsubLookup05x03Handler> kit = GsubLookup05x03.createContentHandler();
+ final GsubLookup05x03Parser parser = new GsubLookup05x03Parser();
+ parser.parse(raInput, offset, kit.getHandler());
+ return kit.getTable();
+ }
default: throw new UnsupportedOperationException("Unrecognized GSUB lookup type 5: " + formatId);
}
case CHAINING_CONTEXT:
switch (formatId) {
- case FORMAT_1: return GsubLookup06x01.parse(raInput, offset);
- case FORMAT_2: return GsubLookup06x02.parse(raInput, offset);
- case FORMAT_3: return GsubLookup06x03.parse(raInput, offset);
+ case FORMAT_1: {
+ final ParserKit<GsubLookup06x01, GsubLookup06x01Handler> kit = GsubLookup06x01.createContentHandler();
+ final GsubLookup06x01Parser parser = new GsubLookup06x01Parser();
+ parser.parse(raInput, offset, kit.getHandler());
+ return kit.getTable();
+ }
+ case FORMAT_2: {
+ final ParserKit<GsubLookup06x02, GsubLookup06x02Handler> kit = GsubLookup06x02.createContentHandler();
+ final GsubLookup06x02Parser parser = new GsubLookup06x02Parser();
+ parser.parse(raInput, offset, kit.getHandler());
+ return kit.getTable();
+ }
+ case FORMAT_3: {
+ final ParserKit<GsubLookup06x03, GsubLookup06x03Handler> kit = GsubLookup06x03.createContentHandler();
+ final GsubLookup06x03Parser parser = new GsubLookup06x03Parser();
+ parser.parse(raInput, offset, kit.getHandler());
+ return kit.getTable();
+ }
default: throw new UnsupportedOperationException("Unrecognized GSUB lookup type 6: " + formatId);
}
case EXTENSION_SUBSTITUTION:
switch (formatId) {
- case FORMAT_1: return GsubLookup07x01.parse(raInput, offset);
+ case FORMAT_1: {
+ final ParserKit<GsubLookup07x01, GsubLookup07x01Handler> kit = GsubLookup07x01.createContentHandler();
+ final GsubLookup07x01Parser parser = new GsubLookup07x01Parser();
+ parser.parse(raInput, offset, kit.getHandler());
+ return kit.getTable();
+ }
default: throw new UnsupportedOperationException("Unrecognized GSUB lookup type 7: " + formatId);
}
case REVERSE_CHAINING_CONTEXT_SINGLE:
switch (formatId) {
- case FORMAT_1: return GsubLookup08x01.parse(raInput, offset);
+ case FORMAT_1: {
+ final ParserKit<GsubLookup08x01, GsubLookup08x01Handler> kit = GsubLookup08x01.createContentHandler();
+ final GsubLookup08x01Parser parser = new GsubLookup08x01Parser();
+ parser.parse(raInput, offset, kit.getHandler());
+ return kit.getTable();
+ }
default: throw new UnsupportedOperationException("Unrecognized GSUB lookup type 8: " + formatId);
}
default: {
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup01x01.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup01x01.java 2025-04-29 16:49:17 UTC (rev 13540)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup01x01.java 2025-04-29 18:03:15 UTC (rev 13541)
@@ -28,13 +28,12 @@
package org.foray.font.ttf.table;
-import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.ParserKit;
+import org.foray.fontParse.ttfHandler.GsubLookup01x01Handler;
import org.foray.primitive.sequence.IntArrayBuilder;
import org.axsl.font.FontContext;
-import java.io.IOException;
-
/**
* A Single Substitution Format 1 GSUB Subtable.
*/
@@ -41,22 +40,37 @@
public class GsubLookup01x01 extends GsubLookupSubtable {
/**
- * Constructor.
+ * The handler of events from the parser.
*/
- public GsubLookup01x01() {
+ private final class ContentHandler implements GsubLookup01x01Handler {
+
+ /** The table instance being created. */
+ @SuppressWarnings("unused")
+ private GsubLookup01x01 table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final GsubLookup01x01 table) {
+ this.table = table;
+ }
}
+
+
+
+
+
+
/**
- * Parses a lookup.
- * @param raInput The input from which the subtable is being parsed.
- * @param offset The offset in {@code raInput} for the start of the subtable.
- * @return The parsed subtable instance.
- * @throws IOException For I/O errors during parsing.
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
*/
- public static GsubLookup01x01 parse(final RandomAccessInput raInput, final int offset) throws IOException {
- raInput.seek(offset);
- final GsubLookup01x01 subtable = new GsubLookup01x01();
- return subtable;
+ public static ParserKit<GsubLookup01x01, GsubLookup01x01Handler> createContentHandler() {
+ final GsubLookup01x01 table = new GsubLookup01x01();
+ final GsubLookup01x01Handler handler = table.new ContentHandler(table);
+ return new ParserKit<GsubLookup01x01, GsubLookup01x01Handler>(table, handler);
}
@Override
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup01x02.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup01x02.java 2025-04-29 16:49:17 UTC (rev 13540)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup01x02.java 2025-04-29 18:03:15 UTC (rev 13541)
@@ -28,13 +28,12 @@
package org.foray.font.ttf.table;
-import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.ParserKit;
+import org.foray.fontParse.ttfHandler.GsubLookup01x02Handler;
import org.foray.primitive.sequence.IntArrayBuilder;
import org.axsl.font.FontContext;
-import java.io.IOException;
-
/**
* A Single Substitution Format 2 GSUB Subtable.
*/
@@ -41,22 +40,37 @@
public class GsubLookup01x02 extends GsubLookupSubtable {
/**
- * Constructor.
+ * The handler of events from the parser.
*/
- public GsubLookup01x02() {
+ private final class ContentHandler implements GsubLookup01x02Handler {
+
+ /** The table instance being created. */
+ @SuppressWarnings("unused")
+ private GsubLookup01x02 table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final GsubLookup01x02 table) {
+ this.table = table;
+ }
}
+
+
+
+
+
+
/**
- * Parses a lookup.
- * @param raInput The input from which the subtable is being parsed.
- * @param offset The offset in {@code raInput} for the start of the subtable.
- * @return The parsed subtable instance.
- * @throws IOException For I/O errors during parsing.
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
*/
- public static GsubLookup01x02 parse(final RandomAccessInput raInput, final int offset) throws IOException {
- raInput.seek(offset);
- final GsubLookup01x02 subtable = new GsubLookup01x02();
- return subtable;
+ public static ParserKit<GsubLookup01x02, GsubLookup01x02Handler> createContentHandler() {
+ final GsubLookup01x02 table = new GsubLookup01x02();
+ final GsubLookup01x02Handler handler = table.new ContentHandler(table);
+ return new ParserKit<GsubLookup01x02, GsubLookup01x02Handler>(table, handler);
}
@Override
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup02x01.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup02x01.java 2025-04-29 16:49:17 UTC (rev 13540)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup02x01.java 2025-04-29 18:03:15 UTC (rev 13541)
@@ -28,13 +28,12 @@
package org.foray.font.ttf.table;
-import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.ParserKit;
+import org.foray.fontParse.ttfHandler.GsubLookup02x01Handler;
import org.foray.primitive.sequence.IntArrayBuilder;
import org.axsl.font.FontContext;
-import java.io.IOException;
-
/**
* A Multiple Substitution Format 1 GSUB Subtable.
*/
@@ -41,22 +40,37 @@
public class GsubLookup02x01 extends GsubLookupSubtable {
/**
- * Constructor.
+ * The handler of events from the parser.
*/
- public GsubLookup02x01() {
+ private final class ContentHandler implements GsubLookup02x01Handler {
+
+ /** The table instance being created. */
+ @SuppressWarnings("unused")
+ private GsubLookup02x01 table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final GsubLookup02x01 table) {
+ this.table = table;
+ }
}
+
+
+
+
+
+
/**
- * Parses a lookup.
- * @param raInput The input from which the subtable is being parsed.
- * @param offset The offset in {@code raInput} for the start of the subtable.
- * @return The parsed subtable instance.
- * @throws IOException For I/O errors during parsing.
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
*/
- public static GsubLookup02x01 parse(final RandomAccessInput raInput, final int offset) throws IOException {
- raInput.seek(offset);
- final GsubLookup02x01 subtable = new GsubLookup02x01();
- return subtable;
+ public static ParserKit<GsubLookup02x01, GsubLookup02x01Handler> createContentHandler() {
+ final GsubLookup02x01 table = new GsubLookup02x01();
+ final GsubLookup02x01Handler handler = table.new ContentHandler(table);
+ return new ParserKit<GsubLookup02x01, GsubLookup02x01Handler>(table, handler);
}
@Override
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup03x01.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup03x01.java 2025-04-29 16:49:17 UTC (rev 13540)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup03x01.java 2025-04-29 18:03:15 UTC (rev 13541)
@@ -28,13 +28,12 @@
package org.foray.font.ttf.table;
-import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.ParserKit;
+import org.foray.fontParse.ttfHandler.GsubLookup03x01Handler;
import org.foray.primitive.sequence.IntArrayBuilder;
import org.axsl.font.FontContext;
-import java.io.IOException;
-
/**
* An Alternate Substitution Format 1 GSUB Subtable.
*/
@@ -41,22 +40,37 @@
public class GsubLookup03x01 extends GsubLookupSubtable {
/**
- * Constructor.
+ * The handler of events from the parser.
*/
- public GsubLookup03x01() {
+ private final class ContentHandler implements GsubLookup03x01Handler {
+
+ /** The table instance being created. */
+ @SuppressWarnings("unused")
+ private GsubLookup03x01 table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final GsubLookup03x01 table) {
+ this.table = table;
+ }
}
+
+
+
+
+
+
/**
- * Parses a lookup.
- * @param raInput The input from which the subtable is being parsed.
- * @param offset The offset in {@code raInput} for the start of the subtable.
- * @return The parsed subtable instance.
- * @throws IOException For I/O errors during parsing.
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
*/
- public static GsubLookup03x01 parse(final RandomAccessInput raInput, final int offset) throws IOException {
- raInput.seek(offset);
- final GsubLookup03x01 subtable = new GsubLookup03x01();
- return subtable;
+ public static ParserKit<GsubLookup03x01, GsubLookup03x01Handler> createContentHandler() {
+ final GsubLookup03x01 table = new GsubLookup03x01();
+ final GsubLookup03x01Handler handler = table.new ContentHandler(table);
+ return new ParserKit<GsubLookup03x01, GsubLookup03x01Handler>(table, handler);
}
@Override
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup04x01.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup04x01.java 2025-04-29 16:49:17 UTC (rev 13540)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup04x01.java 2025-04-29 18:03:15 UTC (rev 13541)
@@ -31,6 +31,7 @@
import org.foray.common.RandomAccessInput;
import org.foray.font.ttf.OtfCoverage;
import org.foray.fontParse.ttf.TtfType;
+import org.foray.fontParse.ttfHandler.GsubLookup04x01Handler;
import org.foray.primitive.sequence.IntArrayBuilder;
import org.axsl.font.FontContext;
@@ -43,6 +44,30 @@
public class GsubLookup04x01 extends GsubLookupSubtable {
/**
+ * The handler of events from the parser.
+ */
+ private final class ContentHandler implements GsubLookup04x01Handler {
+
+ /** The table instance being created. */
+ @SuppressWarnings("unused")
+ private GsubLookup04x01 table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final GsubLookup04x01 table) {
+ this.table = table;
+ }
+ }
+
+
+
+
+
+
+
+ /**
* One ligature.
*/
public class Ligature {
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup05x01.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup05x01.java 2025-04-29 16:49:17 UTC (rev 13540)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup05x01.java 2025-04-29 18:03:15 UTC (rev 13541)
@@ -28,13 +28,12 @@
package org.foray.font.ttf.table;
-import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.ParserKit;
+import org.foray.fontParse.ttfHandler.GsubLookup05x01Handler;
import org.foray.primitive.sequence.IntArrayBuilder;
import org.axsl.font.FontContext;
-import java.io.IOException;
-
/**
* A Contextual Substitution Format 1 GSUB Subtable.
*/
@@ -41,22 +40,37 @@
public class GsubLookup05x01 extends GsubLookupSubtable {
/**
- * Constructor.
+ * The handler of events from the parser.
*/
- public GsubLookup05x01() {
+ private final class ContentHandler implements GsubLookup05x01Handler {
+
+ /** The table instance being created. */
+ @SuppressWarnings("unused")
+ private GsubLookup05x01 table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final GsubLookup05x01 table) {
+ this.table = table;
+ }
}
+
+
+
+
+
+
/**
- * Parses a lookup.
- * @param raInput The input from which the subtable is being parsed.
- * @param offset The offset in {@code raInput} for the start of the subtable.
- * @return The parsed subtable instance.
- * @throws IOException For I/O errors during parsing.
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
*/
- public static GsubLookup05x01 parse(final RandomAccessInput raInput, final int offset) throws IOException {
- raInput.seek(offset);
- final GsubLookup05x01 subtable = new GsubLookup05x01();
- return subtable;
+ public static ParserKit<GsubLookup05x01, GsubLookup05x01Handler> createContentHandler() {
+ final GsubLookup05x01 table = new GsubLookup05x01();
+ final GsubLookup05x01Handler handler = table.new ContentHandler(table);
+ return new ParserKit<GsubLookup05x01, GsubLookup05x01Handler>(table, handler);
}
@Override
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup05x02.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup05x02.java 2025-04-29 16:49:17 UTC (rev 13540)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup05x02.java 2025-04-29 18:03:15 UTC (rev 13541)
@@ -28,13 +28,12 @@
package org.foray.font.ttf.table;
-import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.ParserKit;
+import org.foray.fontParse.ttfHandler.GsubLookup05x02Handler;
import org.foray.primitive.sequence.IntArrayBuilder;
import org.axsl.font.FontContext;
-import java.io.IOException;
-
/**
* A Contextual Substitution Format 2 GSUB Subtable.
*/
@@ -41,22 +40,37 @@
public class GsubLookup05x02 extends GsubLookupSubtable {
/**
- * Constructor.
+ * The handler of events from the parser.
*/
- public GsubLookup05x02() {
+ private final class ContentHandler implements GsubLookup05x02Handler {
+
+ /** The table instance being created. */
+ @SuppressWarnings("unused")
+ private GsubLookup05x02 table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final GsubLookup05x02 table) {
+ this.table = table;
+ }
}
+
+
+
+
+
+
/**
- * Parses a lookup.
- * @param raInput The input from which the subtable is being parsed.
- * @param offset The offset in {@code raInput} for the start of the subtable.
- * @return The parsed subtable instance.
- * @throws IOException For I/O errors during parsing.
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
*/
- public static GsubLookup05x02 parse(final RandomAccessInput raInput, final int offset) throws IOException {
- raInput.seek(offset);
- final GsubLookup05x02 subtable = new GsubLookup05x02();
- return subtable;
+ public static ParserKit<GsubLookup05x02, GsubLookup05x02Handler> createContentHandler() {
+ final GsubLookup05x02 table = new GsubLookup05x02();
+ final GsubLookup05x02Handler handler = table.new ContentHandler(table);
+ return new ParserKit<GsubLookup05x02, GsubLookup05x02Handler>(table, handler);
}
@Override
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup05x03.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup05x03.java 2025-04-29 16:49:17 UTC (rev 13540)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup05x03.java 2025-04-29 18:03:15 UTC (rev 13541)
@@ -28,13 +28,12 @@
package org.foray.font.ttf.table;
-import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.ParserKit;
+import org.foray.fontParse.ttfHandler.GsubLookup05x03Handler;
import org.foray.primitive.sequence.IntArrayBuilder;
import org.axsl.font.FontContext;
-import java.io.IOException;
-
/**
* A Contextual Substitution Format 3 GSUB Subtable.
*/
@@ -41,22 +40,37 @@
public class GsubLookup05x03 extends GsubLookupSubtable {
/**
- * Constructor.
+ * The handler of events from the parser.
*/
- public GsubLookup05x03() {
+ private final class ContentHandler implements GsubLookup05x03Handler {
+
+ /** The table instance being created. */
+ @SuppressWarnings("unused")
+ private GsubLookup05x03 table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final GsubLookup05x03 table) {
+ this.table = table;
+ }
}
+
+
+
+
+
+
/**
- * Parses a lookup.
- * @param raInput The input from which the subtable is being parsed.
- * @param offset The offset in {@code raInput} for the start of the subtable.
- * @return The parsed subtable instance.
- * @throws IOException For I/O errors during parsing.
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
*/
- public static GsubLookup05x03 parse(final RandomAccessInput raInput, final int offset) throws IOException {
- raInput.seek(offset);
- final GsubLookup05x03 subtable = new GsubLookup05x03();
- return subtable;
+ public static ParserKit<GsubLookup05x03, GsubLookup05x03Handler> createContentHandler() {
+ final GsubLookup05x03 table = new GsubLookup05x03();
+ final GsubLookup05x03Handler handler = table.new ContentHandler(table);
+ return new ParserKit<GsubLookup05x03, GsubLookup05x03Handler>(table, handler);
}
@Override
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup06x01.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup06x01.java 2025-04-29 16:49:17 UTC (rev 13540)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup06x01.java 2025-04-29 18:03:15 UTC (rev 13541)
@@ -28,13 +28,12 @@
package org.foray.font.ttf.table;
-import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.ParserKit;
+import org.foray.fontParse.ttfHandler.GsubLookup06x01Handler;
import org.foray.primitive.sequence.IntArrayBuilder;
import org.axsl.font.FontContext;
-import java.io.IOException;
-
/**
* A Chaining Context Substitution Format 1 GSUB Subtable.
*/
@@ -41,22 +40,37 @@
public class GsubLookup06x01 extends GsubLookupSubtable {
/**
- * Constructor.
+ * The handler of events from the parser.
*/
- public GsubLookup06x01() {
+ private final class ContentHandler implements GsubLookup06x01Handler {
+
+ /** The table instance being created. */
+ @SuppressWarnings("unused")
+ private GsubLookup06x01 table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final GsubLookup06x01 table) {
+ this.table = table;
+ }
}
+
+
+
+
+
+
/**
- * Parses a lookup.
- * @param raInput The input from which the subtable is being parsed.
- * @param offset The offset in {@code raInput} for the start of the subtable.
- * @return The parsed subtable instance.
- * @throws IOException For I/O errors during parsing.
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
*/
- public static GsubLookup06x01 parse(final RandomAccessInput raInput, final int offset) throws IOException {
- raInput.seek(offset);
- final GsubLookup06x01 subtable = new GsubLookup06x01();
- return subtable;
+ public static ParserKit<GsubLookup06x01, GsubLookup06x01Handler> createContentHandler() {
+ final GsubLookup06x01 table = new GsubLookup06x01();
+ final GsubLookup06x01Handler handler = table.new ContentHandler(table);
+ return new ParserKit<GsubLookup06x01, GsubLookup06x01Handler>(table, handler);
}
@Override
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup06x02.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup06x02.java 2025-04-29 16:49:17 UTC (rev 13540)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup06x02.java 2025-04-29 18:03:15 UTC (rev 13541)
@@ -28,13 +28,12 @@
package org.foray.font.ttf.table;
-import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.ParserKit;
+import org.foray.fontParse.ttfHandler.GsubLookup06x02Handler;
import org.foray.primitive.sequence.IntArrayBuilder;
import org.axsl.font.FontContext;
-import java.io.IOException;
-
/**
* A Chaining Context Format 2 GSUB Subtable.
*/
@@ -41,22 +40,37 @@
public class GsubLookup06x02 extends GsubLookupSubtable {
/**
- * Constructor.
+ * The handler of events from the parser.
*/
- public GsubLookup06x02() {
+ private final class ContentHandler implements GsubLookup06x02Handler {
+
+ /** The table instance being created. */
+ @SuppressWarnings("unused")
+ private GsubLookup06x02 table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final GsubLookup06x02 table) {
+ this.table = table;
+ }
}
+
+
+
+
+
+
/**
- * Parses a lookup.
- * @param raInput The input from which the subtable is being parsed.
- * @param offset The offset in {@code raInput} for the start of the subtable.
- * @return The parsed subtable instance.
- * @throws IOException For I/O errors during parsing.
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
*/
- public static GsubLookup06x02 parse(final RandomAccessInput raInput, final int offset) throws IOException {
- raInput.seek(offset);
- final GsubLookup06x02 subtable = new GsubLookup06x02();
- return subtable;
+ public static ParserKit<GsubLookup06x02, GsubLookup06x02Handler> createContentHandler() {
+ final GsubLookup06x02 table = new GsubLookup06x02();
+ final GsubLookup06x02Handler handler = table.new ContentHandler(table);
+ return new ParserKit<GsubLookup06x02, GsubLookup06x02Handler>(table, handler);
}
@Override
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup06x03.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup06x03.java 2025-04-29 16:49:17 UTC (rev 13540)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup06x03.java 2025-04-29 18:03:15 UTC (rev 13541)
@@ -28,13 +28,12 @@
package org.foray.font.ttf.table;
-import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.ParserKit;
+import org.foray.fontParse.ttfHandler.GsubLookup06x03Handler;
import org.foray.primitive.sequence.IntArrayBuilder;
import org.axsl.font.FontContext;
-import java.io.IOException;
-
/**
* A Chaining Context Format 3 GSUB Subtable.
*/
@@ -41,22 +40,37 @@
public class GsubLookup06x03 extends GsubLookupSubtable {
/**
- * Constructor.
+ * The handler of events from the parser.
*/
- public GsubLookup06x03() {
+ private final class ContentHandler implements GsubLookup06x03Handler {
+
+ /** The table instance being created. */
+ @SuppressWarnings("unused")
+ private GsubLookup06x03 table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final GsubLookup06x03 table) {
+ this.table = table;
+ }
}
+
+
+
+
+
+
/**
- * Parses a lookup.
- * @param raInput The input from which the subtable is being parsed.
- * @param offset The offset in {@code raInput} for the start of the subtable.
- * @return The parsed subtable instance.
- * @throws IOException For I/O errors during parsing.
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
*/
- public static GsubLookup06x03 parse(final RandomAccessInput raInput, final int offset) throws IOException {
- raInput.seek(offset);
- final GsubLookup06x03 subtable = new GsubLookup06x03();
- return subtable;
+ public static ParserKit<GsubLookup06x03, GsubLookup06x03Handler> createContentHandler() {
+ final GsubLookup06x03 table = new GsubLookup06x03();
+ final GsubLookup06x03Handler handler = table.new ContentHandler(table);
+ return new ParserKit<GsubLookup06x03, GsubLookup06x03Handler>(table, handler);
}
@Override
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup07x01.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup07x01.java 2025-04-29 16:49:17 UTC (rev 13540)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup07x01.java 2025-04-29 18:03:15 UTC (rev 13541)
@@ -28,13 +28,12 @@
package org.foray.font.ttf.table;
-import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.ParserKit;
+import org.foray.fontParse.ttfHandler.GsubLookup07x01Handler;
import org.foray.primitive.sequence.IntArrayBuilder;
import org.axsl.font.FontContext;
-import java.io.IOException;
-
/**
* An Extension Substitution Format 1 GSUB Subtable.
*/
@@ -41,22 +40,36 @@
public class GsubLookup07x01 extends GsubLookupSubtable {
/**
- * Constructor.
+ * The handler of events from the parser.
*/
- public GsubLookup07x01() {
+ private final class ContentHandler implements GsubLookup07x01Handler {
+
+ /** The table instance being created. */
+ @SuppressWarnings("unused")
+ private GsubLookup07x01 table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final GsubLookup07x01 table) {
+ this.table = table;
+ }
}
+
+
+
+
+
/**
- * Parses a lookup.
- * @param raInput The input from which the subtable is being parsed.
- * @param offset The offset in {@code raInput} for the start of the subtable.
- * @return The parsed subtable instance.
- * @throws IOException For I/O errors during parsing.
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
*/
- public static GsubLookup07x01 parse(final RandomAccessInput raInput, final int offset) throws IOException {
- raInput.seek(offset);
- final GsubLookup07x01 subtable = new GsubLookup07x01();
- return subtable;
+ public static ParserKit<GsubLookup07x01, GsubLookup07x01Handler> createContentHandler() {
+ final GsubLookup07x01 table = new GsubLookup07x01();
+ final GsubLookup07x01Handler handler = table.new ContentHandler(table);
+ return new ParserKit<GsubLookup07x01, GsubLookup07x01Handler>(table, handler);
}
@Override
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup08x01.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup08x01.java 2025-04-29 16:49:17 UTC (rev 13540)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookup08x01.java 2025-04-29 18:03:15 UTC (rev 13541)
@@ -28,13 +28,12 @@
package org.foray.font.ttf.table;
-import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.ParserKit;
+import org.foray.fontParse.ttfHandler.GsubLookup08x01Handler;
import org.foray.primitive.sequence.IntArrayBuilder;
import org.axsl.font.FontContext;
-import java.io.IOException;
-
/**
* A Reverse Chaining Contextual Single Substitution Format 1 GSUB Subtable.
*/
@@ -41,22 +40,37 @@
public class GsubLookup08x01 extends GsubLookupSubtable {
/**
- * Constructor.
+ * The handler of events from the parser.
*/
- public GsubLookup08x01() {
+ private final class ContentHandler implements GsubLookup08x01Handler {
+
+ /** The table instance being created. */
+ @SuppressWarnings("unused")
+ private GsubLookup08x01 table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final GsubLookup08x01 table) {
+ this.table = table;
+ }
}
+
+
+
+
+
+
/**
- * Parses a lookup.
- * @param raInput The input from which the subtable is being parsed.
- * @param offset The offset in {@code raInput} for the start of the subtable.
- * @return The parsed subtable instance.
- * @throws IOException For I/O errors during parsing.
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
*/
- public static GsubLookup08x01 parse(final RandomAccessInput raInput, final int offset) throws IOException {
- raInput.seek(offset);
- final GsubLookup08x01 subtable = new GsubLookup08x01();
- return subtable;
+ public static ParserKit<GsubLookup08x01, GsubLookup08x01Handler> createContentHandler() {
+ final GsubLookup08x01 table = new GsubLookup08x01();
+ final GsubLookup08x01Handler handler = table.new ContentHandler(table);
+ return new ParserKit<GsubLookup08x01, GsubLookup08x01Handler>(table, handler);
}
@Override
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookupSubtable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookupSubtable.java 2025-04-29 16:49:17 UTC (rev 13540)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubLookupSubtable.java 2025-04-29 18:03:15 UTC (rev 13541)
@@ -28,6 +28,7 @@
package org.foray.font.ttf.table;
+import org.foray.font.ttf.RoTable;
import org.foray.primitive.sequence.IntArrayBuilder;
import org.axsl.font.FontContext;
@@ -35,7 +36,7 @@
/**
* Abstract superclass for all GSUB subtables.
*/
-public abstract class GsubLookupSubtable {
+public abstract class GsubLookupSubtable extends RoTable {
/**
* Process the substitution for this subtable.
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubTable.java 2025-04-29 16:49:17 UTC (rev 13540)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubTable.java 2025-04-29 18:03:15 UTC (rev 13541)
@@ -28,10 +28,10 @@
package org.foray.font.ttf.table;
-import org.foray.common.RandomAccessInput;
import org.foray.font.ttf.OtfFeature;
import org.foray.font.ttf.OtfScript;
import org.foray.font.ttf.TtfOffsetTableRecord;
+import org.foray.fontParse.ttf.TtfRandomAccessInput;
import org.foray.primitive.sequence.IntArrayBuilder;
import org.axsl.font.FontContext;
@@ -67,7 +67,7 @@
* @return The parsed instance.
* @throws IOException For I/O Error.
*/
- public static GsubTable parse(final TtfOffsetTableRecord offsetRecord, final RandomAccessInput raInput)
+ public static GsubTable parse(final TtfOffsetTableRecord offsetRecord, final TtfRandomAccessInput raInput)
throws IOException {
raInput.seek(offsetRecord.getOffset());
final int majorVersion = raInput.readUnsignedShort();
@@ -102,7 +102,7 @@
* @return The parsed lookup list.
* @throws IOException For I/O errors during parsing.
*/
- protected static List<GsubLookup> parseLookupList(final RandomAccessInput raInput, final int offset)
+ protected static List<GsubLookup> parseLookupList(final TtfRandomAccessInput raInput, final int offset)
throws IOException {
raInput.seek(offset);
final int lookupCount = raInput.readUnsignedShort();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-29 16:49:35
|
Revision: 13540
http://sourceforge.net/p/foray/code/13540
Author: victormote
Date: 2025-04-29 16:49:17 +0000 (Tue, 29 Apr 2025)
Log Message:
-----------
Rough-in handlers and parsers for the GSUB Lookups.
Modified Paths:
--------------
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/DeviceTableParser.java
Added Paths:
-----------
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup01x01Parser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup01x02Parser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup02x01Parser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup03x01Parser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup04x01Parser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup05x01Parser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup05x02Parser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup05x03Parser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup06x01Parser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup06x02Parser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup06x03Parser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup07x01Parser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup08x01Parser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup01x01Handler.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup01x02Handler.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup02x01Handler.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup03x01Handler.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup04x01Handler.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup05x01Handler.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup05x02Handler.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup05x03Handler.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup06x01Handler.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup06x02Handler.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup06x03Handler.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup07x01Handler.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup08x01Handler.java
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/DeviceTableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/DeviceTableParser.java 2025-04-29 14:37:09 UTC (rev 13539)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/DeviceTableParser.java 2025-04-29 16:49:17 UTC (rev 13540)
@@ -41,8 +41,10 @@
@Override
public void parse(final TtfRandomAccessInput input, final int offset, final DeviceTableHandler handler)
throws IOException {
- // TODO Auto-generated method stub
+ input.seek(offset);
+ /* TODO: Complete this. */
+
}
}
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup01x01Parser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup01x01Parser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup01x01Parser.java 2025-04-29 16:49:17 UTC (rev 13540)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.GsubLookup01x01Handler;
+
+import java.io.IOException;
+
+/**
+ * Parses a GSUB Lookup Type 1, Format 1.
+ */
+public class GsubLookup01x01Parser extends TableParser<GsubLookup01x01Handler> {
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final GsubLookup01x01Handler handler)
+ throws IOException {
+ input.seek(offset);
+
+ /* TODO: Complete this. */
+
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup01x01Parser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup01x02Parser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup01x02Parser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup01x02Parser.java 2025-04-29 16:49:17 UTC (rev 13540)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.GsubLookup01x02Handler;
+
+import java.io.IOException;
+
+/**
+ * Parses a GSUB Lookup Type 1, Format 2.
+ */
+public class GsubLookup01x02Parser extends TableParser<GsubLookup01x02Handler> {
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final GsubLookup01x02Handler handler)
+ throws IOException {
+ input.seek(offset);
+
+ /* TODO: Complete this. */
+
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup01x02Parser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup02x01Parser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup02x01Parser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup02x01Parser.java 2025-04-29 16:49:17 UTC (rev 13540)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.GsubLookup02x01Handler;
+
+import java.io.IOException;
+
+/**
+ * Parses a GSUB Lookup Type 2, Format 1.
+ */
+public class GsubLookup02x01Parser extends TableParser<GsubLookup02x01Handler> {
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final GsubLookup02x01Handler handler)
+ throws IOException {
+ input.seek(offset);
+
+ /* TODO: Complete this. */
+
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup02x01Parser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup03x01Parser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup03x01Parser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup03x01Parser.java 2025-04-29 16:49:17 UTC (rev 13540)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.GsubLookup03x01Handler;
+
+import java.io.IOException;
+
+/**
+ * Parses a GSUB Lookup Type 3, Format 1.
+ */
+public class GsubLookup03x01Parser extends TableParser<GsubLookup03x01Handler> {
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final GsubLookup03x01Handler handler)
+ throws IOException {
+ input.seek(offset);
+
+ /* TODO: Complete this. */
+
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup03x01Parser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup04x01Parser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup04x01Parser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup04x01Parser.java 2025-04-29 16:49:17 UTC (rev 13540)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.GsubLookup04x01Handler;
+
+import java.io.IOException;
+
+/**
+ * Parses a GSUB Lookup Type 4, Format 1.
+ */
+public class GsubLookup04x01Parser extends TableParser<GsubLookup04x01Handler> {
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final GsubLookup04x01Handler handler)
+ throws IOException {
+ input.seek(offset);
+
+ /* TODO: Complete this. */
+
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup04x01Parser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup05x01Parser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup05x01Parser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup05x01Parser.java 2025-04-29 16:49:17 UTC (rev 13540)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.GsubLookup05x01Handler;
+
+import java.io.IOException;
+
+/**
+ * Parses a GSUB Lookup Type 5, Format 1.
+ */
+public class GsubLookup05x01Parser extends TableParser<GsubLookup05x01Handler> {
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final GsubLookup05x01Handler handler)
+ throws IOException {
+ input.seek(offset);
+
+ /* TODO: Complete this. */
+
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup05x01Parser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup05x02Parser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup05x02Parser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup05x02Parser.java 2025-04-29 16:49:17 UTC (rev 13540)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.GsubLookup05x02Handler;
+
+import java.io.IOException;
+
+/**
+ * Parses a GSUB Lookup Type 5, Format 2.
+ */
+public class GsubLookup05x02Parser extends TableParser<GsubLookup05x02Handler> {
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final GsubLookup05x02Handler handler)
+ throws IOException {
+ input.seek(offset);
+
+ /* TODO: Complete this. */
+
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup05x02Parser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup05x03Parser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup05x03Parser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup05x03Parser.java 2025-04-29 16:49:17 UTC (rev 13540)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.GsubLookup05x03Handler;
+
+import java.io.IOException;
+
+/**
+ * Parses a GSUB Lookup Type 5, Format 3.
+ */
+public class GsubLookup05x03Parser extends TableParser<GsubLookup05x03Handler> {
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final GsubLookup05x03Handler handler)
+ throws IOException {
+ input.seek(offset);
+
+ /* TODO: Complete this. */
+
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup05x03Parser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup06x01Parser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup06x01Parser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup06x01Parser.java 2025-04-29 16:49:17 UTC (rev 13540)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.GsubLookup06x01Handler;
+
+import java.io.IOException;
+
+/**
+ * Parses a GSUB Lookup Type 6, Format 1.
+ */
+public class GsubLookup06x01Parser extends TableParser<GsubLookup06x01Handler> {
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final GsubLookup06x01Handler handler)
+ throws IOException {
+ input.seek(offset);
+
+ /* TODO: Complete this. */
+
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup06x01Parser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup06x02Parser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup06x02Parser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup06x02Parser.java 2025-04-29 16:49:17 UTC (rev 13540)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.GsubLookup06x02Handler;
+
+import java.io.IOException;
+
+/**
+ * Parses a GSUB Lookup Type 6, Format 2.
+ */
+public class GsubLookup06x02Parser extends TableParser<GsubLookup06x02Handler> {
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final GsubLookup06x02Handler handler)
+ throws IOException {
+ input.seek(offset);
+
+ /* TODO: Complete this. */
+
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup06x02Parser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup06x03Parser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup06x03Parser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup06x03Parser.java 2025-04-29 16:49:17 UTC (rev 13540)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.GsubLookup06x03Handler;
+
+import java.io.IOException;
+
+/**
+ * Parses a GSUB Lookup Type 6, Format 3.
+ */
+public class GsubLookup06x03Parser extends TableParser<GsubLookup06x03Handler> {
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final GsubLookup06x03Handler handler)
+ throws IOException {
+ input.seek(offset);
+
+ /* TODO: Complete this. */
+
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup06x03Parser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup07x01Parser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup07x01Parser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup07x01Parser.java 2025-04-29 16:49:17 UTC (rev 13540)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.GsubLookup07x01Handler;
+
+import java.io.IOException;
+
+/**
+ * Parses a GSUB Lookup Type 7, Format 1.
+ */
+public class GsubLookup07x01Parser extends TableParser<GsubLookup07x01Handler> {
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final GsubLookup07x01Handler handler)
+ throws IOException {
+ input.seek(offset);
+
+ /* TODO: Complete this. */
+
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup07x01Parser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup08x01Parser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup08x01Parser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup08x01Parser.java 2025-04-29 16:49:17 UTC (rev 13540)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.GsubLookup08x01Handler;
+
+import java.io.IOException;
+
+/**
+ * Parses a GSUB Lookup Type 8, Format 1.
+ */
+public class GsubLookup08x01Parser extends TableParser<GsubLookup08x01Handler> {
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final GsubLookup08x01Handler handler)
+ throws IOException {
+ input.seek(offset);
+
+ /* TODO: Complete this. */
+
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GsubLookup08x01Parser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup01x01Handler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup01x01Handler.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup01x01Handler.java 2025-04-29 16:49:17 UTC (rev 13540)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttfHandler;
+
+import org.foray.fontParse.FontContentHandler;
+
+/**
+ * Implementations catch and handle the output from {@link GsubLookup01x01Parser}.
+ */
+public interface GsubLookup01x01Handler extends FontContentHandler {
+
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup01x01Handler.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup01x02Handler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup01x02Handler.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup01x02Handler.java 2025-04-29 16:49:17 UTC (rev 13540)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttfHandler;
+
+import org.foray.fontParse.FontContentHandler;
+
+/**
+ * Implementations catch and handle the output from {@link GsubLookup01x02Parser}.
+ */
+public interface GsubLookup01x02Handler extends FontContentHandler {
+
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup01x02Handler.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup02x01Handler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup02x01Handler.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup02x01Handler.java 2025-04-29 16:49:17 UTC (rev 13540)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttfHandler;
+
+import org.foray.fontParse.FontContentHandler;
+
+/**
+ * Implementations catch and handle the output from {@link GsubLookup02x01Parser}.
+ */
+public interface GsubLookup02x01Handler extends FontContentHandler {
+
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup02x01Handler.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup03x01Handler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup03x01Handler.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup03x01Handler.java 2025-04-29 16:49:17 UTC (rev 13540)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttfHandler;
+
+import org.foray.fontParse.FontContentHandler;
+
+/**
+ * Implementations catch and handle the output from {@link GsubLookup03x01Parser}.
+ */
+public interface GsubLookup03x01Handler extends FontContentHandler {
+
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup03x01Handler.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup04x01Handler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup04x01Handler.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup04x01Handler.java 2025-04-29 16:49:17 UTC (rev 13540)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttfHandler;
+
+import org.foray.fontParse.FontContentHandler;
+
+/**
+ * Implementations catch and handle the output from {@link GsubLookup04x01Parser}.
+ */
+public interface GsubLookup04x01Handler extends FontContentHandler {
+
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup04x01Handler.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup05x01Handler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup05x01Handler.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup05x01Handler.java 2025-04-29 16:49:17 UTC (rev 13540)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttfHandler;
+
+import org.foray.fontParse.FontContentHandler;
+
+/**
+ * Implementations catch and handle the output from {@link GsubLookup05x01Parser}.
+ */
+public interface GsubLookup05x01Handler extends FontContentHandler {
+
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup05x01Handler.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup05x02Handler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup05x02Handler.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup05x02Handler.java 2025-04-29 16:49:17 UTC (rev 13540)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttfHandler;
+
+import org.foray.fontParse.FontContentHandler;
+
+/**
+ * Implementations catch and handle the output from {@link GsubLookup05x02Parser}.
+ */
+public interface GsubLookup05x02Handler extends FontContentHandler {
+
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup05x02Handler.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup05x03Handler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup05x03Handler.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup05x03Handler.java 2025-04-29 16:49:17 UTC (rev 13540)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttfHandler;
+
+import org.foray.fontParse.FontContentHandler;
+
+/**
+ * Implementations catch and handle the output from {@link GsubLookup05x03Parser}.
+ */
+public interface GsubLookup05x03Handler extends FontContentHandler {
+
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup05x03Handler.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup06x01Handler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup06x01Handler.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup06x01Handler.java 2025-04-29 16:49:17 UTC (rev 13540)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttfHandler;
+
+import org.foray.fontParse.FontContentHandler;
+
+/**
+ * Implementations catch and handle the output from {@link GsubLookup06x01Parser}.
+ */
+public interface GsubLookup06x01Handler extends FontContentHandler {
+
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup06x01Handler.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup06x02Handler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup06x02Handler.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup06x02Handler.java 2025-04-29 16:49:17 UTC (rev 13540)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttfHandler;
+
+import org.foray.fontParse.FontContentHandler;
+
+/**
+ * Implementations catch and handle the output from {@link GsubLookup06x02Parser}.
+ */
+public interface GsubLookup06x02Handler extends FontContentHandler {
+
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup06x02Handler.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup06x03Handler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup06x03Handler.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup06x03Handler.java 2025-04-29 16:49:17 UTC (rev 13540)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttfHandler;
+
+import org.foray.fontParse.FontContentHandler;
+
+/**
+ * Implementations catch and handle the output from {@link GsubLookup06x03Parser}.
+ */
+public interface GsubLookup06x03Handler extends FontContentHandler {
+
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup06x03Handler.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup07x01Handler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup07x01Handler.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup07x01Handler.java 2025-04-29 16:49:17 UTC (rev 13540)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttfHandler;
+
+import org.foray.fontParse.FontContentHandler;
+
+/**
+ * Implementations catch and handle the output from {@link GsubLookup07x01Parser}.
+ */
+public interface GsubLookup07x01Handler extends FontContentHandler {
+
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup07x01Handler.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup08x01Handler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup08x01Handler.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup08x01Handler.java 2025-04-29 16:49:17 UTC (rev 13540)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttfHandler;
+
+import org.foray.fontParse.FontContentHandler;
+
+/**
+ * Implementations catch and handle the output from {@link GsubLookup08x01Parser}.
+ */
+public interface GsubLookup08x01Handler extends FontContentHandler {
+
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GsubLookup08x01Handler.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-29 14:37:27
|
Revision: 13539
http://sourceforge.net/p/foray/code/13539
Author: victormote
Date: 2025-04-29 14:37:09 +0000 (Tue, 29 Apr 2025)
Log Message:
-----------
Convert kern to new parsing scheme.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/KernTable.java
trunk/foray/foray-font-parse/build.gradle
Added Paths:
-----------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Kern00Table.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Kern02Table.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/KernSubtable.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Kern00TableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Kern02TableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/KernTableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Kern00TableHandler.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Kern02TableHandler.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/KernTableHandler.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-04-29 11:34:30 UTC (rev 13538)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-04-29 14:37:09 UTC (rev 13539)
@@ -72,6 +72,7 @@
import org.foray.fontParse.ttf.HeadTableParser;
import org.foray.fontParse.ttf.HheaTableParser;
import org.foray.fontParse.ttf.JstfTableParser;
+import org.foray.fontParse.ttf.KernTableParser;
import org.foray.fontParse.ttf.MathTableParser;
import org.foray.fontParse.ttf.MaxpTableParser;
import org.foray.fontParse.ttf.NameTableParser;
@@ -93,6 +94,7 @@
import org.foray.fontParse.ttfHandler.HeadTableHandler;
import org.foray.fontParse.ttfHandler.HheaTableHandler;
import org.foray.fontParse.ttfHandler.JstfTableHandler;
+import org.foray.fontParse.ttfHandler.KernTableHandler;
import org.foray.fontParse.ttfHandler.MathTableHandler;
import org.foray.fontParse.ttfHandler.MaxpTableHandler;
import org.foray.fontParse.ttfHandler.NameTableHandler;
@@ -433,7 +435,10 @@
dirEntry = ttfTableDir.getTableDirectoryEntry("kern");
if (dirEntry != null) {
- font.kernTable = KernTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength(), font.cmapTable);
+ final ParserKit<KernTable, KernTableHandler> contentHandler = KernTable.createContentHandler();
+ final KernTableParser parser = new KernTableParser();
+ parser.parse(raInput, dirEntry.getOffset(), contentHandler.getHandler());
+ font.kernTable = contentHandler.getTable();
}
return font;
Added: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Kern00Table.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Kern00Table.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Kern00Table.java 2025-04-29 14:37:09 UTC (rev 13539)
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.font.ttf.table;
+
+import org.foray.font.format.Kerning;
+import org.foray.font.ttf.ParserKit;
+import org.foray.fontParse.ttfHandler.Kern00TableHandler;
+
+import org.checkerframework.checker.signedness.qual.Unsigned;
+
+/**
+ * Class representing a TTF "kern" (kerning) table, Type 0 subtable.
+ */
+public class Kern00Table extends KernSubtable {
+
+ /**
+ * The handler of events from the parser.
+ */
+ private final class ContentHandler implements Kern00TableHandler {
+
+ /** The table instance being created. */
+ @SuppressWarnings("unused")
+ private Kern00Table table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final Kern00Table table) {
+ this.table = table;
+ }
+ }
+
+
+
+
+
+
+
+ /** The parsed kerning data from this table. */
+ private Kerning kerning;
+
+ /** This table's coverage. */
+ private @Unsigned short coverage;
+
+ /**
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
+ */
+ public static ParserKit<Kern00Table, Kern00TableHandler> createContentHandler() {
+ final Kern00Table table = new Kern00Table();
+ final Kern00TableHandler handler = table.new ContentHandler(table);
+ return new ParserKit<Kern00Table, Kern00TableHandler>(table, handler);
+ }
+
+ /**
+ * Returns the parsed kerning information for this table.
+ * @return The parsed kerning information for this table.
+ */
+ public Kerning getKerning() {
+ return this.kerning;
+ }
+
+ @Override
+ public @Unsigned short getCoverage() {
+ return this.coverage;
+ }
+
+}
Property changes on: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Kern00Table.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Kern02Table.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Kern02Table.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Kern02Table.java 2025-04-29 14:37:09 UTC (rev 13539)
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.font.ttf.table;
+
+import org.foray.font.ttf.ParserKit;
+import org.foray.fontParse.ttfHandler.Kern02TableHandler;
+
+import org.checkerframework.checker.signedness.qual.Unsigned;
+
+/**
+ * Class representing a TTF "kern" (kerning) table, Type 2 subtable.
+ */
+public class Kern02Table extends KernSubtable {
+
+ /**
+ * The handler of events from the parser.
+ */
+ private final class ContentHandler implements Kern02TableHandler {
+
+ /** The table instance being created. */
+ @SuppressWarnings("unused")
+ private Kern02Table table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final Kern02Table table) {
+ this.table = table;
+ }
+ }
+
+ /** This table's coverage. */
+ private @Unsigned short coverage;
+
+
+
+
+
+
+ /**
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
+ */
+ public static ParserKit<Kern02Table, Kern02TableHandler> createContentHandler() {
+ final Kern02Table table = new Kern02Table();
+ final Kern02TableHandler handler = table.new ContentHandler(table);
+ return new ParserKit<Kern02Table, Kern02TableHandler>(table, handler);
+ }
+
+
+
+
+
+
+
+ @Override
+ public @Unsigned short getCoverage() {
+ return this.coverage;
+ }
+
+}
Property changes on: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Kern02Table.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/KernSubtable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/KernSubtable.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/KernSubtable.java 2025-04-29 14:37:09 UTC (rev 13539)
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.font.ttf.table;
+
+import org.foray.font.ttf.RoTable;
+import org.foray.primitive.BitUtils;
+
+import org.checkerframework.checker.signedness.qual.Unsigned;
+
+/**
+ * Abstract superclass for kerning subtables.
+ */
+public abstract class KernSubtable extends RoTable {
+
+ /** Constant indicating the 0-based bit number in the "coverage" value that
+ * containts the "horizontal" boolean, that is bit 0. */
+ private static final byte COVERAGE_BIT_HORIZONTAL = 0;
+
+ /** Constant indicating the 0-based bit number in the "coverage" value that
+ * containts the "minimum" boolean, that is bit 1. */
+ private static final byte COVERAGE_BIT_MINIMUM = 1;
+
+ /** Constant indicating the 0-based bit number in the "coverage" value that
+ * containts the "cross-stream" boolean, that is bit 2. */
+ private static final byte COVERAGE_BIT_CROSS_STREAM = 2;
+
+ /**
+ * Returns the coverage.
+ * @return The coverage.
+ */
+ public abstract @Unsigned short getCoverage();
+
+ /**
+ * Indicates whether a given kerning subtable is horizontal or vertical.
+ * @return True if the subtable contains horizontal data, false if it contains vertical data.
+ */
+ public boolean isHorizontal() {
+ final @Unsigned short coverage = getCoverage();
+ return BitUtils.getBit(coverage, COVERAGE_BIT_HORIZONTAL);
+ }
+
+ /**
+ * Indicates whether a given kerning subtable contains minimums or kerning data.
+ * @return True if the subtable contains minimum values, false if it contains kerning data.
+ */
+ public boolean hasMinimums() {
+ final @Unsigned short coverage = getCoverage();
+ return BitUtils.getBit(coverage, COVERAGE_BIT_MINIMUM);
+ }
+
+ /**
+ * Indicates whether the kerning data in a given subtable is perpendicular to the flow of the text.
+ * @return True if the subtable kerning data is perpendicular to the flow of text.
+ */
+ public boolean isCrossStream() {
+ final @Unsigned short coverage = getCoverage();
+ return BitUtils.getBit(coverage, COVERAGE_BIT_CROSS_STREAM);
+ }
+
+}
Property changes on: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/KernSubtable.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/KernTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/KernTable.java 2025-04-29 11:34:30 UTC (rev 13538)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/KernTable.java 2025-04-29 14:37:09 UTC (rev 13539)
@@ -28,176 +28,204 @@
package org.foray.font.ttf.table;
-import org.foray.common.RandomAccessInput;
import org.foray.font.format.Kerning;
+import org.foray.font.ttf.ParserKit;
import org.foray.font.ttf.RoTable;
-import org.foray.primitive.BitUtils;
+import org.foray.fontParse.ttfHandler.Kern00TableHandler;
+import org.foray.fontParse.ttfHandler.Kern02TableHandler;
+import org.foray.fontParse.ttfHandler.KernTableHandler;
-import org.axsl.constants.PrimitiveConstants;
+import java.util.ArrayList;
+import java.util.List;
-import java.io.IOException;
-
/**
* Class representing a TTF "kern" (kerning) table.
*/
public class KernTable extends RoTable {
- /** Constant indicating the 0-based bit number in the "coverage" value that
- * containts the "horizontal" boolean, that is bit 0. */
- private static final byte COVERAGE_BIT_HORIZONTAL = 0;
-
- /** Constant indicating the 0-based bit number in the "coverage" value that
- * containts the "minimum" boolean, that is bit 1. */
- private static final byte COVERAGE_BIT_MINIMUM = 1;
-
- /** Constant indicating the 0-based bit number in the "coverage" value that
- * containts the "cross-stream" boolean, that is bit 2. */
- private static final byte COVERAGE_BIT_CROSS_STREAM = 2;
-
- /** The parsed kerning data from this table. */
- private Kerning kerning;
-
/**
- * Parse the needed information from the table contents.
- * @param input The input which is being parsed.
- * @param offset The offset into {@code input} at which to start parsing.
- * @param length The number of bytes to parse from {@code input}.
- * @param cmap The related cmap table that knows how to encode/decode the glyph indices.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
+ * The handler of events from the parser.
*/
- public static KernTable parse(final RandomAccessInput input, final int offset, final int length,
- final CmapTable cmap) throws IOException {
- input.seek(offset);
- final KernTable kern = new KernTable();
- /* Skip the Table Version. */
- input.skipBytes(RoTable.USHORT_BYTES);
- final int qtySubtables = input.readUnsignedShort();
- for (int i = 0; i < qtySubtables; i++) {
- readNextSubtable(kern, input, cmap);
- }
- if (kern.kerning != null) {
- kern.kerning.lock();
- }
- return kern;
- }
+ private final class ContentHandler implements KernTableHandler {
- /**
- * Reads the next subtable in the table being parsed.
- * @param kern The table being parsed.
- * @param raInput The input which is being parsed.
- * @param cmap The related cmap table that knows how to encode/decode the glyph indices.
- * @throws IOException For I/O Error.
- */
- private static void readNextSubtable(final KernTable kern, final RandomAccessInput raInput,
- final CmapTable cmap) throws IOException {
- int headerSize = 0;
- /* Skip Kern subtable version number. */
- raInput.skipBytes(RoTable.USHORT_BYTES);
- headerSize += RoTable.USHORT_BYTES;
- /* Read the length of the subtable, in bytes (including this header). */
- final char length = (char) raInput.readUnsignedShort();
- headerSize += RoTable.USHORT_BYTES;
- /* Read what type of information is contained in this table. */
- final short coverage = (short) raInput.readUnsignedShort();
- headerSize += RoTable.USHORT_BYTES;
+ /** The table instance being created. */
+ @SuppressWarnings("unused")
+ private KernTable table;
- final int remainingSize = length - headerSize;
-
- /* For not, we only handle horizontal kerning. */
- if (! isHorizontal(coverage)) {
- raInput.skipBytes(remainingSize);
- return;
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final KernTable table) {
+ this.table = table;
}
- /* For now, skip the subtable if it contains minimums. */
- if (hasMinimums(coverage)) {
- raInput.skipBytes(remainingSize);
+ @Override
+ public void nTables(final short value) {
+ this.table.subtables = new ArrayList<KernSubtable>(value);
return;
}
- /* Skip this subtable if it is cross-stream. */
- if (isCrossStream(coverage)) {
- raInput.skipBytes(remainingSize);
- return;
+ @Override
+ public Kern00TableHandler startKern00Table() {
+ final ParserKit<Kern00Table, Kern00TableHandler> handler = Kern00Table.createContentHandler();
+ this.table.subtables.add(handler.getTable());
+ return handler.getHandler();
}
- /* For now, we only read Format 0 subtables. */
- if (subtableFormat(coverage) != 0) {
- raInput.skipBytes(remainingSize);
- return;
+ @Override
+ public Kern02TableHandler startKern02Table() {
+ final ParserKit<Kern02Table, Kern02TableHandler> handler = Kern02Table.createContentHandler();
+ this.table.subtables.add(handler.getTable());
+ return handler.getHandler();
}
-
- final int numPairs = raInput.readUnsignedShort();
- if (kern.kerning == null) {
- kern.kerning = new Kerning(numPairs);
- } else {
- kern.kerning.addCapacity(numPairs);
- }
- /* Skip Search range. */
- raInput.skipBytes(RoTable.USHORT_BYTES);
- /* Skip Entry selector. */
- raInput.skipBytes(RoTable.USHORT_BYTES);
- /* Skip Range shift. */
- raInput.skipBytes(RoTable.USHORT_BYTES);
- if (cmap == null) {
- return;
- }
- for (int i = 0; i < numPairs; i++) {
- final char glyph1 = (char) raInput.readUnsignedShort();
- final char glyph2 = (char) raInput.readUnsignedShort();
- final short kernAmount = raInput.readShort();
- kern.kerning.addKerningEntry(glyph1, glyph2, kernAmount);
- }
}
- /**
- * Indicates whether a given kerning subtable is horizontal or vertical.
- * @param coverage The coverage value parsed from the subtable.
- * @return True if the subtable contains horizontal data, false if it
- * contains vertical data.
- */
- private static boolean isHorizontal(final short coverage) {
- return BitUtils.getBit(coverage, KernTable.COVERAGE_BIT_HORIZONTAL);
- }
- /**
- * Indicates whether a given kerning subtable contains minimums or kerning
- * data.
- * @param coverage The coverage value parsed from the subtable.
- * @return True if the subtable contains minimum values, false if it
- * contains kerning data.
- */
- private static boolean hasMinimums(final short coverage) {
- return BitUtils.getBit(coverage, KernTable.COVERAGE_BIT_MINIMUM);
- }
- /**
- * Indicates whether the kerning data in a given subtable is perpendicular
- * to the flow of the text.
- * @param coverage The coverage value parsed from the subtable.
- * @return True if the subtable kerning data is perpendicular to the flow
- * of text.
- */
- private static boolean isCrossStream(final short coverage) {
- return BitUtils.getBit(coverage, KernTable.COVERAGE_BIT_CROSS_STREAM);
- }
+
+
+
+ /** The parsed kerning data from this table. */
+ private List<KernSubtable> subtables;
+
/**
- * Converts the parsed subtable coverage value to its usable value.
- * @param coverage The parsed coverage value.
- * @return The shifted value.
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
*/
- private static short subtableFormat(final short coverage) {
- return (short) (coverage >> PrimitiveConstants.SHIFT_1_BYTE);
+ public static ParserKit<KernTable, KernTableHandler> createContentHandler() {
+ final KernTable table = new KernTable();
+ final KernTableHandler handler = table.new ContentHandler(table);
+ return new ParserKit<KernTable, KernTableHandler>(table, handler);
}
+// /**
+// * Parse the needed information from the table contents.
+// * @param input The input which is being parsed.
+// * @param offset The offset into {@code input} at which to start parsing.
+// * @param length The number of bytes to parse from {@code input}.
+// * @param cmap The related cmap table that knows how to encode/decode the glyph indices.
+// * @return The parsed instance.
+// * @throws IOException For I/O Error.
+// */
+// public static KernTable parse(final RandomAccessInput input, final int offset, final int length,
+// final CmapTable cmap) throws IOException {
+// input.seek(offset);
+// final KernTable kern = new KernTable();
+// /* Skip the Table Version. */
+// input.skipBytes(RoTable.USHORT_BYTES);
+// final int qtySubtables = input.readUnsignedShort();
+// for (int i = 0; i < qtySubtables; i++) {
+// readNextSubtable(kern, input, cmap);
+// }
+// if (kern.kerning != null) {
+// kern.kerning.lock();
+// }
+// return kern;
+// }
+//
+// /**
+// * Reads the next subtable in the table being parsed.
+// * @param kern The table being parsed.
+// * @param raInput The input which is being parsed.
+// * @param cmap The related cmap table that knows how to encode/decode the glyph indices.
+// * @throws IOException For I/O Error.
+// */
+// private static void readNextSubtable(final KernTable kern, final RandomAccessInput raInput,
+// final CmapTable cmap) throws IOException {
+// int headerSize = 0;
+// /* Skip Kern subtable version number. */
+// raInput.skipBytes(RoTable.USHORT_BYTES);
+// headerSize += RoTable.USHORT_BYTES;
+// /* Read the length of the subtable, in bytes (including this header). */
+// final char length = (char) raInput.readUnsignedShort();
+// headerSize += RoTable.USHORT_BYTES;
+// /* Read what type of information is contained in this table. */
+// final short coverage = (short) raInput.readUnsignedShort();
+// headerSize += RoTable.USHORT_BYTES;
+//
+// final int remainingSize = length - headerSize;
+//
+// /* For not, we only handle horizontal kerning. */
+// if (! isHorizontal(coverage)) {
+// raInput.skipBytes(remainingSize);
+// return;
+// }
+//
+// /* For now, skip the subtable if it contains minimums. */
+// if (hasMinimums(coverage)) {
+// raInput.skipBytes(remainingSize);
+// return;
+// }
+//
+// /* Skip this subtable if it is cross-stream. */
+// if (isCrossStream(coverage)) {
+// raInput.skipBytes(remainingSize);
+// return;
+// }
+//
+// /* For now, we only read Format 0 subtables. */
+// if (subtableFormat(coverage) != 0) {
+// raInput.skipBytes(remainingSize);
+// return;
+// }
+//
+// final int numPairs = raInput.readUnsignedShort();
+// if (kern.kerning == null) {
+// kern.kerning = new Kerning(numPairs);
+// } else {
+// kern.kerning.addCapacity(numPairs);
+// }
+// /* Skip Search range. */
+// raInput.skipBytes(RoTable.USHORT_BYTES);
+// /* Skip Entry selector. */
+// raInput.skipBytes(RoTable.USHORT_BYTES);
+// /* Skip Range shift. */
+// raInput.skipBytes(RoTable.USHORT_BYTES);
+// if (cmap == null) {
+// return;
+// }
+// for (int i = 0; i < numPairs; i++) {
+// final char glyph1 = (char) raInput.readUnsignedShort();
+// final char glyph2 = (char) raInput.readUnsignedShort();
+// final short kernAmount = raInput.readShort();
+// kern.kerning.addKerningEntry(glyph1, glyph2, kernAmount);
+// }
+// }
+
/**
* Returns the parsed kerning information for this table.
* @return The parsed kerning information for this table.
*/
public Kerning getKerning() {
- return this.kerning;
+ for (int index = 0; index < this.subtables.size(); index ++) {
+ final KernSubtable subtable = this.subtables.get(index);
+
+ /* For now, we only handle horizontal kerning. */
+ if (! subtable.isHorizontal()) {
+ continue;
+ }
+
+ /* For now, skip the subtable if it contains minimums. */
+ if (subtable.hasMinimums()) {
+ continue;
+ }
+
+ /* For now, skip this subtable if it is cross-stream. */
+ if (subtable.isCrossStream()) {
+ continue;
+ }
+
+ if (subtable instanceof Kern00Table) {
+ final Kern00Table kern00Table = (Kern00Table) subtable;
+ return kern00Table.getKerning();
+ } else {
+ /* TODO: Add processing for type 2 kerning tables. */
+ continue;
+ }
+ }
+ return null;
}
}
Modified: trunk/foray/foray-font-parse/build.gradle
===================================================================
--- trunk/foray/foray-font-parse/build.gradle 2025-04-29 11:34:30 UTC (rev 13538)
+++ trunk/foray/foray-font-parse/build.gradle 2025-04-29 14:37:09 UTC (rev 13539)
@@ -8,6 +8,7 @@
dependencies {
+ api (group: 'org.axsl', name: 'axsl-constants', version: versions.axsl)
api (group: 'org.axsl', name: 'axsl-primitive', version: versions.axsl)
api (project(':foray-common'))
}
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Kern00TableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Kern00TableParser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Kern00TableParser.java 2025-04-29 14:37:09 UTC (rev 13539)
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.Kern00TableHandler;
+
+import java.io.IOException;
+
+/**
+ * Parses a TTF "kern" table, Type 0 subtatle.
+ */
+public class Kern00TableParser extends TableParser<Kern00TableHandler> {
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final Kern00TableHandler handler)
+ throws IOException {
+ input.seek(offset);
+
+ /* Subtable header. */
+ handler.version(input.read_uint16()); // 2 bytes, total 2
+ final short length = input.read_uint16(); // 2 bytes, total 4
+ handler.length(length);
+ handler.coverage(input.read_uint16()); // 2 bytes, total 6
+
+ final short nPairs = input.read_uint16(); // 2 bytes, total 8
+ handler.nPairs(nPairs);
+ handler.searchRange(input.read_uint16()); // 2 bytes, total 10
+ handler.entrySelector(input.read_uint16()); // 2 bytes, total 12
+ handler.rangeShift(input.read_uint16()); // 2 bytes, total 14
+
+ for (int index = 0; index < nPairs; index ++) {
+ handler.left(input.read_uint16());
+ handler.right(input.read_uint16());
+ handler.value(input.read_FWORD());
+ }
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Kern00TableParser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Kern02TableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Kern02TableParser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Kern02TableParser.java 2025-04-29 14:37:09 UTC (rev 13539)
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.Kern02TableHandler;
+
+import java.io.IOException;
+
+/**
+ * Parses a TTF "kern" table, Type 2 subtatle.
+ */
+public class Kern02TableParser extends TableParser<Kern02TableHandler> {
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final Kern02TableHandler handler)
+ throws IOException {
+ input.seek(offset);
+
+ /* Subtable header. */
+ handler.version(input.read_uint16()); // 2 bytes, total 2
+ final short length = input.read_uint16(); // 2 bytes, total 4
+ handler.length(length);
+ handler.coverage(input.read_uint16()); // 2 bytes, total 6
+
+
+ /* TODO: Complete this. */
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Kern02TableParser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/KernTableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/KernTableParser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/KernTableParser.java 2025-04-29 14:37:09 UTC (rev 13539)
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.Kern00TableHandler;
+import org.foray.fontParse.ttfHandler.Kern02TableHandler;
+import org.foray.fontParse.ttfHandler.KernTableHandler;
+
+import org.axsl.constants.PrimitiveConstants;
+
+import java.io.IOException;
+
+/**
+ * Parses a TTF "kern" table.
+ */
+public class KernTableParser extends TableParser<KernTableHandler> {
+
+ /** The number of bytes in the table header. */
+ private static final byte TABLE_HEADER_SIZE = 4;
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final KernTableHandler handler)
+ throws IOException {
+ input.seek(offset);
+
+ /* Table header. */
+ handler.version(input.read_uint16()); // 2 bytes, total 2
+ final short nTables = input.read_uint16(); // 2 bytes, total 4
+ handler.nTables(nTables);
+
+
+ /* Parse each subtable. */
+ int subtableOffset = offset + TABLE_HEADER_SIZE;
+ for (int index = 0; index < nTables; index ++) {
+
+ /* Subtable header. Need to read down to the coverage to figure out which format it is. */
+ /* Skip the subtable version. */
+ input.skipBytes(TtfType.uint16.getQtyBytes());
+ final short length = input.read_uint16();
+ final short coverage = input.read_uint16();
+
+ final short subtableFormat = subtableFormat(coverage);
+ switch (subtableFormat) {
+ case 0: {
+ final Kern00TableHandler kern00Handler = handler.startKern00Table();
+ if (kern00Handler != null) {
+ final Kern00TableParser kern00Parser = new Kern00TableParser();
+ kern00Parser.parse(input, subtableOffset, kern00Handler);
+ }
+ break;
+ }
+ case 2: {
+ final Kern02TableHandler kern02Handler = handler.startKern02Table();
+ if (kern02Handler != null) {
+ final Kern02TableParser kern02Parser = new Kern02TableParser();
+ kern02Parser.parse(input, subtableOffset, kern02Handler);
+ }
+ break;
+ }
+ default: throw new UnsupportedOperationException("Unable to parse kern subtable type: " + subtableFormat);
+ }
+
+ subtableOffset += length;
+ }
+
+ }
+
+ /**
+ * Converts the parsed subtable coverage value to its usable value.
+ * @param coverage The parsed coverage value.
+ * @return The shifted value.
+ */
+ public static short subtableFormat(final short coverage) {
+ return (short) (coverage >> PrimitiveConstants.SHIFT_1_BYTE);
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/KernTableParser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Kern00TableHandler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Kern00TableHandler.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Kern00TableHandler.java 2025-04-29 14:37:09 UTC (rev 13539)
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttfHandler;
+
+import org.foray.fontParse.FontContentHandler;
+import org.foray.fontParse.ttf.Kern00TableParser;
+
+/**
+ * Implementations catch and handle the output from {@link Kern00TableParser}.
+ */
+public interface Kern00TableHandler extends FontContentHandler {
+
+ default void version(short value) { return; }
+ default void length(short value) { return; }
+ default void coverage(short value) { return; }
+
+ default void nPairs(short value) { return; }
+ default void searchRange(short value) { return; }
+ default void entrySelector(short value) { return; }
+ default void rangeShift(short value) { return; }
+
+ default void left(short value) { return; }
+ default void right(short value) { return; }
+ default void value(short value) { return; }
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Kern00TableHandler.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Kern02TableHandler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Kern02TableHandler.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Kern02TableHandler.java 2025-04-29 14:37:09 UTC (rev 13539)
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttfHandler;
+
+import org.foray.fontParse.FontContentHandler;
+import org.foray.fontParse.ttf.Kern02TableParser;
+
+/**
+ * Implementations catch and handle the output from {@link Kern02TableParser}.
+ */
+public interface Kern02TableHandler extends FontContentHandler {
+
+ default void version(short value) { return; }
+ default void length(short value) { return; }
+ default void coverage(short value) { return; }
+
+ /* TODO: Complete this. */
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Kern02TableHandler.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/KernTableHandler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/KernTableHandler.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/KernTableHandler.java 2025-04-29 14:37:09 UTC (rev 13539)
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttfHandler;
+
+import org.foray.fontParse.FontContentHandler;
+import org.foray.fontParse.ttf.KernTableParser;
+
+/**
+ * Implementations catch and handle the output from {@link KernTableParser}.
+ */
+public interface KernTableHandler extends FontContentHandler {
+
+ default void version(short value) { return; }
+ default void nTables(short value) { return; }
+
+ default Kern00TableHandler startKern00Table() { return null; }
+ default Kern02TableHandler startKern02Table() { return null; }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/KernTableHandler.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-29 11:34:48
|
Revision: 13538
http://sourceforge.net/p/foray/code/13538
Author: victormote
Date: 2025-04-29 11:34:30 +0000 (Tue, 29 Apr 2025)
Log Message:
-----------
Rough-in new parsing scheme for tables that are not currently parsed.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cff2Table.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CffTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CvtTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/FpgmTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GaspTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GdefTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GposTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/JstfTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/MathTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PrepTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/VorgTable.java
Added Paths:
-----------
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cff2TableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CffTableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CvtTableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/FpgmTableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GaspTableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GdefTableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GposTableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/JstfTableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/MathTableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/PrepTableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/VorgTableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Cff2TableHandler.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/CffTableHandler.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/CvtTableHandler.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/FpgmTableHandler.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GaspTableHandler.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GdefTableHandler.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/GposTableHandler.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/JstfTableHandler.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/MathTableHandler.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/PrepTableHandler.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/VorgTableHandler.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-04-28 22:23:57 UTC (rev 13537)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-04-29 11:34:30 UTC (rev 13538)
@@ -61,24 +61,46 @@
import org.foray.fontParse.FontFormat;
import org.foray.fontParse.TableParser;
import org.foray.fontParse.ttf.BaseTableParser;
+import org.foray.fontParse.ttf.Cff2TableParser;
+import org.foray.fontParse.ttf.CffTableParser;
import org.foray.fontParse.ttf.CmapTableParser;
+import org.foray.fontParse.ttf.CvtTableParser;
+import org.foray.fontParse.ttf.FpgmTableParser;
+import org.foray.fontParse.ttf.GaspTableParser;
+import org.foray.fontParse.ttf.GdefTableParser;
+import org.foray.fontParse.ttf.GposTableParser;
import org.foray.fontParse.ttf.HeadTableParser;
import org.foray.fontParse.ttf.HheaTableParser;
+import org.foray.fontParse.ttf.JstfTableParser;
+import org.foray.fontParse.ttf.MathTableParser;
import org.foray.fontParse.ttf.MaxpTableParser;
import org.foray.fontParse.ttf.NameTableParser;
import org.foray.fontParse.ttf.Os2TableParser;
import org.foray.fontParse.ttf.PcltTableParser;
import org.foray.fontParse.ttf.PostTableParser;
+import org.foray.fontParse.ttf.PrepTableParser;
import org.foray.fontParse.ttf.TtfRandomAccessInput;
+import org.foray.fontParse.ttf.VorgTableParser;
import org.foray.fontParse.ttfHandler.BaseTableHandler;
+import org.foray.fontParse.ttfHandler.Cff2TableHandler;
+import org.foray.fontParse.ttfHandler.CffTableHandler;
import org.foray.fontParse.ttfHandler.CmapTableHandler;
+import org.foray.fontParse.ttfHandler.CvtTableHandler;
+import org.foray.fontParse.ttfHandler.FpgmTableHandler;
+import org.foray.fontParse.ttfHandler.GaspTableHandler;
+import org.foray.fontParse.ttfHandler.GdefTableHandler;
+import org.foray.fontParse.ttfHandler.GposTableHandler;
import org.foray.fontParse.ttfHandler.HeadTableHandler;
import org.foray.fontParse.ttfHandler.HheaTableHandler;
+import org.foray.fontParse.ttfHandler.JstfTableHandler;
+import org.foray.fontParse.ttfHandler.MathTableHandler;
import org.foray.fontParse.ttfHandler.MaxpTableHandler;
import org.foray.fontParse.ttfHandler.NameTableHandler;
import org.foray.fontParse.ttfHandler.Os2TableHandler;
import org.foray.fontParse.ttfHandler.PcltTableHandler;
import org.foray.fontParse.ttfHandler.PostTableHandler;
+import org.foray.fontParse.ttfHandler.PrepTableHandler;
+import org.foray.fontParse.ttfHandler.VorgTableHandler;
import org.foray.primitive.BitUtils;
import org.foray.primitive.sequence.ShortArrayBuilder;
@@ -283,12 +305,18 @@
dirEntry = ttfTableDir.getTableDirectoryEntry("cvt");
if (dirEntry != null) {
- font.cvtTable = CvtTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength());
+ final ParserKit<CvtTable, CvtTableHandler> contentHandler = CvtTable.createContentHandler();
+ final CvtTableParser parser = new CvtTableParser();
+ parser.parse(raInput, dirEntry.getOffset(), contentHandler.getHandler());
+ font.cvtTable = contentHandler.getTable();
}
dirEntry = ttfTableDir.getTableDirectoryEntry("fpgm");
if (dirEntry != null) {
- font.fpgmTable = FpgmTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength());
+ final ParserKit<FpgmTable, FpgmTableHandler> contentHandler = FpgmTable.createContentHandler();
+ final FpgmTableParser parser = new FpgmTableParser();
+ parser.parse(raInput, dirEntry.getOffset(), contentHandler.getHandler());
+ font.fpgmTable = contentHandler.getTable();
}
dirEntry = ttfTableDir.getTableDirectoryEntry("loca");
@@ -306,12 +334,18 @@
dirEntry = ttfTableDir.getTableDirectoryEntry("prep");
if (dirEntry != null) {
- font.prepTable = PrepTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength());
+ final ParserKit<PrepTable, PrepTableHandler> contentHandler = PrepTable.createContentHandler();
+ final PrepTableParser parser = new PrepTableParser();
+ parser.parse(raInput, dirEntry.getOffset(), contentHandler.getHandler());
+ font.prepTable = contentHandler.getTable();
}
dirEntry = ttfTableDir.getTableDirectoryEntry("gasp");
if (dirEntry != null) {
- font.gaspTable = GaspTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength());
+ final ParserKit<GaspTable, GaspTableHandler> contentHandler = GaspTable.createContentHandler();
+ final GaspTableParser parser = new GaspTableParser();
+ parser.parse(raInput, dirEntry.getOffset(), contentHandler.getHandler());
+ font.gaspTable = contentHandler.getTable();
}
/* BEGIN POSTSCRIPT-OUTLINE TABLES ************************************************************************** */
@@ -318,17 +352,26 @@
dirEntry = ttfTableDir.getTableDirectoryEntry("CFF");
if (dirEntry != null) {
- font.cffTable = CffTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength());
+ final ParserKit<CffTable, CffTableHandler> contentHandler = CffTable.createContentHandler();
+ final CffTableParser parser = new CffTableParser();
+ parser.parse(raInput, dirEntry.getOffset(), contentHandler.getHandler());
+ font.cffTable = contentHandler.getTable();
}
dirEntry = ttfTableDir.getTableDirectoryEntry("CFF2");
if (dirEntry != null) {
- font.cff2Table = Cff2Table.parse(raInput, dirEntry.getOffset(), dirEntry.getLength());
+ final ParserKit<Cff2Table, Cff2TableHandler> contentHandler = Cff2Table.createContentHandler();
+ final Cff2TableParser parser = new Cff2TableParser();
+ parser.parse(raInput, dirEntry.getOffset(), contentHandler.getHandler());
+ font.cff2Table = contentHandler.getTable();
}
dirEntry = ttfTableDir.getTableDirectoryEntry("VORG");
if (dirEntry != null) {
- font.vorgTable = VorgTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength());
+ final ParserKit<VorgTable, VorgTableHandler> contentHandler = VorgTable.createContentHandler();
+ final VorgTableParser parser = new VorgTableParser();
+ parser.parse(raInput, dirEntry.getOffset(), contentHandler.getHandler());
+ font.vorgTable = contentHandler.getTable();
}
/* BEGIN OPENTYPE ADVANCED TYPOGRAPHIC TABLES *************************************************************** */
@@ -343,12 +386,18 @@
dirEntry = ttfTableDir.getTableDirectoryEntry("GDEF");
if (dirEntry != null) {
- font.gdefTable = GdefTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength());
+ final ParserKit<GdefTable, GdefTableHandler> contentHandler = GdefTable.createContentHandler();
+ final GdefTableParser parser = new GdefTableParser();
+ parser.parse(raInput, dirEntry.getOffset(), contentHandler.getHandler());
+ font.gdefTable = contentHandler.getTable();
}
dirEntry = ttfTableDir.getTableDirectoryEntry("GPOS");
if (dirEntry != null) {
- font.gposTable = GposTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength());
+ final ParserKit<GposTable, GposTableHandler> contentHandler = GposTable.createContentHandler();
+ final GposTableParser parser = new GposTableParser();
+ parser.parse(raInput, dirEntry.getOffset(), contentHandler.getHandler());
+ font.gposTable = contentHandler.getTable();
}
dirEntry = ttfTableDir.getTableDirectoryEntry("GSUB");
@@ -358,12 +407,18 @@
dirEntry = ttfTableDir.getTableDirectoryEntry("JSTF");
if (dirEntry != null) {
- font.jstfTable = JstfTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength());
+ final ParserKit<JstfTable, JstfTableHandler> contentHandler = JstfTable.createContentHandler();
+ final JstfTableParser parser = new JstfTableParser();
+ parser.parse(raInput, dirEntry.getOffset(), contentHandler.getHandler());
+ font.jstfTable = contentHandler.getTable();
}
dirEntry = ttfTableDir.getTableDirectoryEntry("MATH");
if (dirEntry != null) {
- font.mathTable = MathTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength());
+ final ParserKit<MathTable, MathTableHandler> contentHandler = MathTable.createContentHandler();
+ final MathTableParser parser = new MathTableParser();
+ parser.parse(raInput, dirEntry.getOffset(), contentHandler.getHandler());
+ font.mathTable = contentHandler.getTable();
}
/* BEGIN OPTIONAL TABLES ************************************************************************************ */
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cff2Table.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cff2Table.java 2025-04-28 22:23:57 UTC (rev 13537)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cff2Table.java 2025-04-29 11:34:30 UTC (rev 13538)
@@ -28,11 +28,10 @@
package org.foray.font.ttf.table;
-import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.ParserKit;
import org.foray.font.ttf.RoTable;
+import org.foray.fontParse.ttfHandler.Cff2TableHandler;
-import java.io.IOException;
-
/**
* An OpenType "CFF2" (Compact File Format 2.0 PostScript Outlines) table.
* This table is used only in OpenType fonts that contain PostScript outlines.
@@ -40,18 +39,35 @@
public class Cff2Table extends RoTable {
/**
- * Parse the table from the table content.
- * @param input The input which is being parsed.
- * @param offset The offset into {@code input} at which to start parsing.
- * @param length The number of bytes to parse from {@code input}.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
+ * The handler of events from the parser.
*/
- public static Cff2Table parse(final RandomAccessInput input, final int offset, final int length)
- throws IOException {
- input.seek(offset);
+ private final class ContentHandler implements Cff2TableHandler {
+
+ /** The table instance being created. */
+ @SuppressWarnings("unused")
+ private Cff2Table table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final Cff2Table table) {
+ this.table = table;
+ }
+ }
+
+
+
+
+
+ /**
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
+ */
+ public static ParserKit<Cff2Table, Cff2TableHandler> createContentHandler() {
final Cff2Table table = new Cff2Table();
- return table;
+ final Cff2TableHandler handler = table.new ContentHandler(table);
+ return new ParserKit<Cff2Table, Cff2TableHandler>(table, handler);
}
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CffTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CffTable.java 2025-04-28 22:23:57 UTC (rev 13537)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CffTable.java 2025-04-29 11:34:30 UTC (rev 13538)
@@ -28,11 +28,10 @@
package org.foray.font.ttf.table;
-import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.ParserKit;
import org.foray.font.ttf.RoTable;
+import org.foray.fontParse.ttfHandler.CffTableHandler;
-import java.io.IOException;
-
/**
* An OpenType "CFF" (Compact File Format 1.0 PostScript Outlines) table.
* This table is used only in OpenType fonts that contain PostScript outlines.
@@ -40,18 +39,35 @@
public class CffTable extends RoTable {
/**
- * Parse the table from the table content.
- * @param input The input which is being parsed.
- * @param offset The offset into {@code input} at which to start parsing.
- * @param length The number of bytes to parse from {@code input}.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
+ * The handler of events from the parser.
*/
- public static CffTable parse(final RandomAccessInput input, final int offset, final int length)
- throws IOException {
- input.seek(offset);
+ private final class ContentHandler implements CffTableHandler {
+
+ /** The table instance being created. */
+ @SuppressWarnings("unused")
+ private CffTable table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final CffTable table) {
+ this.table = table;
+ }
+ }
+
+
+
+
+
+ /**
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
+ */
+ public static ParserKit<CffTable, CffTableHandler> createContentHandler() {
final CffTable table = new CffTable();
- return table;
+ final CffTableHandler handler = table.new ContentHandler(table);
+ return new ParserKit<CffTable, CffTableHandler>(table, handler);
}
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CvtTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CvtTable.java 2025-04-28 22:23:57 UTC (rev 13537)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CvtTable.java 2025-04-29 11:34:30 UTC (rev 13538)
@@ -28,11 +28,10 @@
package org.foray.font.ttf.table;
-import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.ParserKit;
import org.foray.font.ttf.RoTable;
+import org.foray.fontParse.ttfHandler.CvtTableHandler;
-import java.io.IOException;
-
/**
* A TrueType/OpenType "cvt" (Control Value Table) table.
* This table is used only in fonts that contain TrueType outlines.
@@ -40,18 +39,40 @@
public class CvtTable extends RoTable {
/**
- * Parse the table from the table content.
- * @param input The input which is being parsed.
- * @param offset The offset into {@code input} at which to start parsing.
- * @param length The number of bytes to parse from {@code input}.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
+ * The handler of events from the parser.
*/
- public static CvtTable parse(final RandomAccessInput input, final int offset, final int length)
- throws IOException {
- input.seek(offset);
+ private final class ContentHandler implements CvtTableHandler {
+
+ /** The table instance being created. */
+ @SuppressWarnings("unused")
+ private CvtTable table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final CvtTable table) {
+ this.table = table;
+ }
+ }
+
+
+
+
+
+
+
+
+
+
+ /**
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
+ */
+ public static ParserKit<CvtTable, CvtTableHandler> createContentHandler() {
final CvtTable table = new CvtTable();
- return table;
+ final CvtTableHandler handler = table.new ContentHandler(table);
+ return new ParserKit<CvtTable, CvtTableHandler>(table, handler);
}
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/FpgmTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/FpgmTable.java 2025-04-28 22:23:57 UTC (rev 13537)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/FpgmTable.java 2025-04-29 11:34:30 UTC (rev 13538)
@@ -28,11 +28,10 @@
package org.foray.font.ttf.table;
-import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.ParserKit;
import org.foray.font.ttf.RoTable;
+import org.foray.fontParse.ttfHandler.FpgmTableHandler;
-import java.io.IOException;
-
/**
* A TrueType/OpenType "fpgm" (Font Program) table.
* This table is used only in fonts that contain TrueType outlines.
@@ -40,18 +39,35 @@
public class FpgmTable extends RoTable {
/**
- * Parse the table from the table content.
- * @param input The input which is being parsed.
- * @param offset The offset into {@code input} at which to start parsing.
- * @param length The number of bytes to parse from {@code input}.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
+ * The handler of events from the parser.
*/
- public static FpgmTable parse(final RandomAccessInput input, final int offset, final int length)
- throws IOException {
- input.seek(offset);
+ private final class ContentHandler implements FpgmTableHandler {
+
+ /** The table instance being created. */
+ @SuppressWarnings("unused")
+ private FpgmTable table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final FpgmTable table) {
+ this.table = table;
+ }
+ }
+
+
+
+
+
+ /**
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
+ */
+ public static ParserKit<FpgmTable, FpgmTableHandler> createContentHandler() {
final FpgmTable table = new FpgmTable();
- return table;
+ final FpgmTableHandler handler = table.new ContentHandler(table);
+ return new ParserKit<FpgmTable, FpgmTableHandler>(table, handler);
}
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GaspTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GaspTable.java 2025-04-28 22:23:57 UTC (rev 13537)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GaspTable.java 2025-04-29 11:34:30 UTC (rev 13538)
@@ -28,11 +28,10 @@
package org.foray.font.ttf.table;
-import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.ParserKit;
import org.foray.font.ttf.RoTable;
+import org.foray.fontParse.ttfHandler.GaspTableHandler;
-import java.io.IOException;
-
/**
* A TrueType/OpenType "gasp" (Grid-fitting/Scan-conversion) table.
* This table is used only in fonts that contain TrueType outlines, and is optional in those.
@@ -40,18 +39,35 @@
public class GaspTable extends RoTable {
/**
- * Parse the table from the table content.
- * @param input The input which is being parsed.
- * @param offset The offset into {@code input} at which to start parsing.
- * @param length The number of bytes to parse from {@code input}.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
+ * The handler of events from the parser.
*/
- public static GaspTable parse(final RandomAccessInput input, final int offset, final int length)
- throws IOException {
- input.seek(offset);
+ private final class ContentHandler implements GaspTableHandler {
+
+ /** The table instance being created. */
+ @SuppressWarnings("unused")
+ private GaspTable table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final GaspTable table) {
+ this.table = table;
+ }
+ }
+
+
+
+
+
+ /**
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
+ */
+ public static ParserKit<GaspTable, GaspTableHandler> createContentHandler() {
final GaspTable table = new GaspTable();
- return table;
+ final GaspTableHandler handler = table.new ContentHandler(table);
+ return new ParserKit<GaspTable, GaspTableHandler>(table, handler);
}
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GdefTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GdefTable.java 2025-04-28 22:23:57 UTC (rev 13537)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GdefTable.java 2025-04-29 11:34:30 UTC (rev 13538)
@@ -28,11 +28,10 @@
package org.foray.font.ttf.table;
-import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.ParserKit;
import org.foray.font.ttf.RoTable;
+import org.foray.fontParse.ttfHandler.GdefTableHandler;
-import java.io.IOException;
-
/**
* An OpenType "GDEF" (Glyph Definition Data) table.
* This table is an Advanced Typographic Table.
@@ -40,18 +39,35 @@
public class GdefTable extends RoTable {
/**
- * Parse the table from the table content.
- * @param input The input which is being parsed.
- * @param offset The offset into {@code input} at which to start parsing.
- * @param length The number of bytes to parse from {@code input}.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
+ * The handler of events from the parser.
*/
- public static GdefTable parse(final RandomAccessInput input, final int offset, final int length)
- throws IOException {
- input.seek(offset);
+ private final class ContentHandler implements GdefTableHandler {
+
+ /** The table instance being created. */
+ @SuppressWarnings("unused")
+ private GdefTable table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final GdefTable table) {
+ this.table = table;
+ }
+ }
+
+
+
+
+
+ /**
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
+ */
+ public static ParserKit<GdefTable, GdefTableHandler> createContentHandler() {
final GdefTable table = new GdefTable();
- return table;
+ final GdefTableHandler handler = table.new ContentHandler(table);
+ return new ParserKit<GdefTable, GdefTableHandler>(table, handler);
}
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GposTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GposTable.java 2025-04-28 22:23:57 UTC (rev 13537)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GposTable.java 2025-04-29 11:34:30 UTC (rev 13538)
@@ -28,11 +28,10 @@
package org.foray.font.ttf.table;
-import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.ParserKit;
import org.foray.font.ttf.RoTable;
+import org.foray.fontParse.ttfHandler.GposTableHandler;
-import java.io.IOException;
-
/**
* An OpenType "GPOS" (Glyph Positioning Data) table.
* This table is an Advanced Typographic Table.
@@ -40,18 +39,40 @@
public class GposTable extends RoTable {
/**
- * Parse the table from the table content.
- * @param input The input which is being parsed.
- * @param offset The offset into {@code input} at which to start parsing.
- * @param length The number of bytes to parse from {@code input}.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
+ * The handler of events from the parser.
*/
- public static GposTable parse(final RandomAccessInput input, final int offset, final int length)
- throws IOException {
- input.seek(offset);
+ private final class ContentHandler implements GposTableHandler {
+
+ /** The table instance being created. */
+ @SuppressWarnings("unused")
+ private GposTable table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final GposTable table) {
+ this.table = table;
+ }
+ }
+
+
+
+
+
+
+
+
+
+
+ /**
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
+ */
+ public static ParserKit<GposTable, GposTableHandler> createContentHandler() {
final GposTable table = new GposTable();
- return table;
+ final GposTableHandler handler = table.new ContentHandler(table);
+ return new ParserKit<GposTable, GposTableHandler>(table, handler);
}
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/JstfTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/JstfTable.java 2025-04-28 22:23:57 UTC (rev 13537)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/JstfTable.java 2025-04-29 11:34:30 UTC (rev 13538)
@@ -28,11 +28,10 @@
package org.foray.font.ttf.table;
-import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.ParserKit;
import org.foray.font.ttf.RoTable;
+import org.foray.fontParse.ttfHandler.JstfTableHandler;
-import java.io.IOException;
-
/**
* An OpenType "JSTF" (Justification Data) table.
* This table is an Advanced Typographic Table.
@@ -40,18 +39,38 @@
public class JstfTable extends RoTable {
/**
- * Parse the table from the table content.
- * @param input The input which is being parsed.
- * @param offset The offset into {@code input} at which to start parsing.
- * @param length The number of bytes to parse from {@code input}.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
+ * The handler of events from the parser.
*/
- public static JstfTable parse(final RandomAccessInput input, final int offset, final int length)
- throws IOException {
- input.seek(offset);
+ private final class ContentHandler implements JstfTableHandler {
+
+ /** The table instance being created. */
+ @SuppressWarnings("unused")
+ private JstfTable table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final JstfTable table) {
+ this.table = table;
+ }
+ }
+
+
+
+
+
+
+
+ /**
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
+ */
+ public static ParserKit<JstfTable, JstfTableHandler> createContentHandler() {
final JstfTable table = new JstfTable();
- return table;
+ final JstfTableHandler handler = table.new ContentHandler(table);
+ return new ParserKit<JstfTable, JstfTableHandler>(table, handler);
}
+
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/MathTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/MathTable.java 2025-04-28 22:23:57 UTC (rev 13537)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/MathTable.java 2025-04-29 11:34:30 UTC (rev 13538)
@@ -28,11 +28,10 @@
package org.foray.font.ttf.table;
-import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.ParserKit;
import org.foray.font.ttf.RoTable;
+import org.foray.fontParse.ttfHandler.MathTableHandler;
-import java.io.IOException;
-
/**
* An OpenType "MATH" (Math Layout Data) table.
* This table is an Advanced Typographic Table.
@@ -40,18 +39,35 @@
public class MathTable extends RoTable {
/**
- * Parse the table from the table content.
- * @param input The input which is being parsed.
- * @param offset The offset into {@code input} at which to start parsing.
- * @param length The number of bytes to parse from {@code input}.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
+ * The handler of events from the parser.
*/
- public static MathTable parse(final RandomAccessInput input, final int offset, final int length)
- throws IOException {
- input.seek(offset);
+ private final class ContentHandler implements MathTableHandler {
+
+ /** The table instance being created. */
+ @SuppressWarnings("unused")
+ private MathTable table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final MathTable table) {
+ this.table = table;
+ }
+ }
+
+
+
+
+
+ /**
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
+ */
+ public static ParserKit<MathTable, MathTableHandler> createContentHandler() {
final MathTable table = new MathTable();
- return table;
+ final MathTableHandler handler = table.new ContentHandler(table);
+ return new ParserKit<MathTable, MathTableHandler>(table, handler);
}
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PrepTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PrepTable.java 2025-04-28 22:23:57 UTC (rev 13537)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PrepTable.java 2025-04-29 11:34:30 UTC (rev 13538)
@@ -28,11 +28,10 @@
package org.foray.font.ttf.table;
-import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.ParserKit;
import org.foray.font.ttf.RoTable;
+import org.foray.fontParse.ttfHandler.PrepTableHandler;
-import java.io.IOException;
-
/**
* A TrueType/OpenType "prep" (CVT Program) table.
* This table is used only in fonts that contain TrueType outlines.
@@ -40,18 +39,35 @@
public class PrepTable extends RoTable {
/**
- * Parse the table from the table content.
- * @param input The input which is being parsed.
- * @param offset The offset into {@code input} at which to start parsing.
- * @param length The number of bytes to parse from {@code input}.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
+ * The handler of events from the parser.
*/
- public static PrepTable parse(final RandomAccessInput input, final int offset, final int length)
- throws IOException {
- input.seek(offset);
+ private final class ContentHandler implements PrepTableHandler {
+
+ /** The table instance being created. */
+ @SuppressWarnings("unused")
+ private PrepTable table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final PrepTable table) {
+ this.table = table;
+ }
+ }
+
+
+
+
+
+ /**
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
+ */
+ public static ParserKit<PrepTable, PrepTableHandler> createContentHandler() {
final PrepTable table = new PrepTable();
- return table;
+ final PrepTableHandler handler = table.new ContentHandler(table);
+ return new ParserKit<PrepTable, PrepTableHandler>(table, handler);
}
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/VorgTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/VorgTable.java 2025-04-28 22:23:57 UTC (rev 13537)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/VorgTable.java 2025-04-29 11:34:30 UTC (rev 13538)
@@ -28,11 +28,10 @@
package org.foray.font.ttf.table;
-import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.ParserKit;
import org.foray.font.ttf.RoTable;
+import org.foray.fontParse.ttfHandler.VorgTableHandler;
-import java.io.IOException;
-
/**
* An OpenType "VORG" (Vertical Origin) table.
* This table is used only in OpenType fonts that contain PostScript outlines, and is optional in those.
@@ -40,18 +39,35 @@
public class VorgTable extends RoTable {
/**
- * Parse the table from the table content.
- * @param input The input which is being parsed.
- * @param offset The offset into {@code input} at which to start parsing.
- * @param length The number of bytes to parse from {@code input}.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
+ * The handler of events from the parser.
*/
- public static VorgTable parse(final RandomAccessInput input, final int offset, final int length)
- throws IOException {
- input.seek(offset);
+ private final class ContentHandler implements VorgTableHandler {
+
+ /** The table instance being created. */
+ @SuppressWarnings("unused")
+ private VorgTable table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final VorgTable table) {
+ this.table = table;
+ }
+ }
+
+
+
+
+
+ /**
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
+ */
+ public static ParserKit<VorgTable, VorgTableHandler> createContentHandler() {
final VorgTable table = new VorgTable();
- return table;
+ final VorgTableHandler handler = table.new ContentHandler(table);
+ return new ParserKit<VorgTable, VorgTableHandler>(table, handler);
}
}
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cff2TableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cff2TableParser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cff2TableParser.java 2025-04-29 11:34:30 UTC (rev 13538)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.Cff2TableHandler;
+
+import java.io.IOException;
+
+/**
+ * Parses a TTF "CFF2" table.
+ */
+public class Cff2TableParser extends TableParser<Cff2TableHandler> {
+
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final Cff2TableHandler handler)
+ throws IOException {
+ input.seek(offset);
+
+ /* TODO: Complete this. */
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cff2TableParser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CffTableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CffTableParser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CffTableParser.java 2025-04-29 11:34:30 UTC (rev 13538)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.CffTableHandler;
+
+import java.io.IOException;
+
+/**
+ * Parses a TTF "CFF" table.
+ */
+public class CffTableParser extends TableParser<CffTableHandler> {
+
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final CffTableHandler handler)
+ throws IOException {
+ input.seek(offset);
+
+ /* TODO: Complete this. */
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CffTableParser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CvtTableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CvtTableParser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CvtTableParser.java 2025-04-29 11:34:30 UTC (rev 13538)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.CvtTableHandler;
+
+import java.io.IOException;
+
+/**
+ * Parses a TTF "cvt" table.
+ */
+public class CvtTableParser extends TableParser<CvtTableHandler> {
+
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final CvtTableHandler handler)
+ throws IOException {
+ input.seek(offset);
+
+ /* TODO: Complete this. */
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CvtTableParser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/FpgmTableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/FpgmTableParser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/FpgmTableParser.java 2025-04-29 11:34:30 UTC (rev 13538)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.FpgmTableHandler;
+
+import java.io.IOException;
+
+/**
+ * Parses a TTF "fpgm" table.
+ */
+public class FpgmTableParser extends TableParser<FpgmTableHandler> {
+
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final FpgmTableHandler handler)
+ throws IOException {
+ input.seek(offset);
+
+ /* TODO: Complete this. */
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/FpgmTableParser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GaspTableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GaspTableParser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GaspTableParser.java 2025-04-29 11:34:30 UTC (rev 13538)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.GaspTableHandler;
+
+import java.io.IOException;
+
+/**
+ * Parses a TTF "gasp" table.
+ */
+public class GaspTableParser extends TableParser<GaspTableHandler> {
+
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final GaspTableHandler handler)
+ throws IOException {
+ input.seek(offset);
+
+ /* TODO: Complete this. */
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GaspTableParser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GdefTableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GdefTableParser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GdefTableParser.java 2025-04-29 11:34:30 UTC (rev 13538)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.GdefTableHandler;
+
+import java.io.IOException;
+
+/**
+ * Parses a TTF "GDEF" table.
+ */
+public class GdefTableParser extends TableParser<GdefTableHandler> {
+
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final GdefTableHandler handler)
+ throws IOException {
+ input.seek(offset);
+
+ /* TODO: Complete this. */
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GdefTableParser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GposTableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GposTableParser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GposTableParser.java 2025-04-29 11:34:30 UTC (rev 13538)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.GposTableHandler;
+
+import java.io.IOException;
+
+/**
+ * Parses a TTF "GPOS" table.
+ */
+public class GposTableParser extends TableParser<GposTableHandler> {
+
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final GposTableHandler handler)
+ throws IOException {
+ input.seek(offset);
+
+ /* TODO: Complete this. */
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/GposTableParser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/JstfTableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/JstfTableParser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/JstfTableParser.java 2025-04-29 11:34:30 UTC (rev 13538)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.JstfTableHandler;
+
+import java.io.IOException;
+
+/**
+ * Parses a TTF "JSTF" table.
+ */
+public class JstfTableParser extends TableParser<JstfTableHandler> {
+
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final JstfTableHandler handler)
+ throws IOException {
+ input.seek(offset);
+
+ /* TODO: Complete this. */
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/JstfTableParser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/MathTableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/MathTableParser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/MathTableParser.java 2025-04-29 11:34:30 UTC (rev 13538)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.MathTableHandler;
+
+import java.io.IOException;
+
+/**
+ * Parses a TTF "MATH" table.
+ */
+public class MathTableParser extends TableParser<MathTableHandler> {
+
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final MathTableHandler handler)
+ throws IOException {
+ input.seek(offset);
+
+ /* TODO: Complete this. */
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/MathTableParser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/PrepTableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/PrepTableParser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/PrepTableParser.java 2025-04-29 11:34:30 UTC (rev 13538)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.PrepTableHandler;
+
+import java.io.IOException;
+
+/**
+ * Parses a TTF "prep" table.
+ */
+public class PrepTableParser extends TableParser<PrepTableHandler> {
+
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final PrepTableHandler handler)
+ throws IOException {
+ input.seek(offset);
+
+ /* TODO: Complete this. */
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/PrepTableParser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/VorgTableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/VorgTableParser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/VorgTableParser.java 2025-04-29 11:34:30 UTC (rev 13538)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.VorgTableHandler;
+
+import java.io.IOException;
+
+/**
+ * Parses a TTF "VORG" table.
+ */
+public class VorgTableParser extends TableParser<VorgTableHandler> {
+
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final VorgTableHandler handler)
+ throws IOException {
+ input.seek(offse...
[truncated message content] |
|
From: <vic...@us...> - 2025-04-28 22:24:20
|
Revision: 13537
http://sourceforge.net/p/foray/code/13537
Author: victormote
Date: 2025-04-28 22:23:57 +0000 (Mon, 28 Apr 2025)
Log Message:
-----------
Add support for parsing Type 6 Cmap tables.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CmapTableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/CmapTableHandler.java
Added Paths:
-----------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap06Table.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cmap06TableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Cmap06TableHandler.java
Added: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap06Table.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap06Table.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap06Table.java 2025-04-28 22:23:57 UTC (rev 13537)
@@ -0,0 +1,159 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.font.ttf.table;
+
+import org.foray.font.ttf.ParserKit;
+import org.foray.font.ttf.RoTable;
+import org.foray.fontParse.ttfHandler.Cmap06TableHandler;
+
+import org.axsl.ps.Encoding;
+
+import org.checkerframework.checker.signedness.qual.Unsigned;
+
+/**
+ * Class containing an array of 16-bit glyph indexes that map to a contiguous set of Unicode code points.
+ */
+public class Cmap06Table extends RoTable implements Encoding {
+
+ /**
+ * The handler of events from the parser.
+ */
+ private final class ContentHandler implements Cmap06TableHandler {
+
+ /** The table instance being created. */
+ private Cmap06Table table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final Cmap06Table table) {
+ this.table = table;
+ }
+
+ @Override
+ public void firstCode(final @Unsigned short value) {
+ this.table.firstCode = value;
+ }
+
+ @Override
+ public void glyphIdArray(final @Unsigned short[] value) {
+ this.table.glyphIndexArray = value;
+ }
+
+ }
+
+
+
+
+
+
+
+ /** Constant needed for serialization. */
+ public static final long serialVersionUID = -606154911100219394L;
+
+ /** The first Unicode code point in this entry. */
+ private @Unsigned short firstCode;
+
+ /** The array of glyph indexes for this entry. */
+ private @Unsigned short[] glyphIndexArray;
+
+ /**
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
+ */
+ public static ParserKit<Cmap06Table, Cmap06TableHandler> createContentHandler() {
+ final Cmap06Table table = new Cmap06Table();
+ final Cmap06TableHandler handler = table.new ContentHandler(table);
+ return new ParserKit<Cmap06Table, Cmap06TableHandler>(table, handler);
+ }
+
+
+ @Override
+ public String getName() {
+ return "internal";
+ }
+
+ @Override
+ public int encode(final int codePoint) {
+ if (codePoint >= this.firstCode
+ && codePoint < (this.firstCode + this.glyphIndexArray.length)) {
+ final int index = codePoint + this.firstCode;
+ return this.glyphIndexArray[index];
+ } else {
+ return -1;
+ }
+ }
+
+ @Override
+ public int decode(final int glyphIndex) {
+ for (int index = 0; index < this.glyphIndexArray.length; index ++) {
+ final short mappedIndex = this.glyphIndexArray[index];
+ if (mappedIndex == glyphIndex) {
+ return index + this.firstCode;
+ }
+ }
+ return -1;
+ }
+
+ @Override
+ public String asPostScript(final org.axsl.ps.Encoding baseEncoding) {
+ return null;
+ }
+
+ @Override
+ public int getFirstIndex() {
+ return -1;
+ }
+
+ @Override
+ public int getLastIndex() {
+ return -1;
+ }
+
+ @Override
+ public boolean isBuiltInPs() {
+ /* TODO Make this class abstract and make a subclass that handled custom instances, so that we can keep the
+ * prebuilt instances separate, and return different values here. */
+ return false;
+ }
+
+ @Override
+ public boolean isBuiltInPdf() {
+ /* TODO Make this class abstract and make a subclass that handled custom instances, so that we can keep the
+ * prebuilt instances separate, and return different values here. */
+ return false;
+ }
+
+ @Override
+ public boolean canEncode(final int codePoint) {
+ return this.encode(codePoint) > -1;
+ }
+
+}
Property changes on: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap06Table.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java 2025-04-28 20:43:01 UTC (rev 13536)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java 2025-04-28 22:23:57 UTC (rev 13537)
@@ -31,6 +31,7 @@
import org.foray.font.ttf.ParserKit;
import org.foray.font.ttf.RoTable;
import org.foray.fontParse.ttfHandler.Cmap04TableHandler;
+import org.foray.fontParse.ttfHandler.Cmap06TableHandler;
import org.foray.fontParse.ttfHandler.Cmap12TableHandler;
import org.foray.fontParse.ttfHandler.CmapTableHandler;
@@ -38,6 +39,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.logging.Logger;
/**
* Class representing a TTF "cmap" (character-to-glyph index mapping) table.
@@ -73,11 +75,23 @@
}
@Override
+ public Cmap06TableHandler startCmap06Table() {
+ final ParserKit<Cmap06Table, Cmap06TableHandler> handler = Cmap06Table.createContentHandler();
+ this.table.unicodeCMap.add(handler.getTable());
+ return handler.getHandler();
+ }
+
+ @Override
public Cmap12TableHandler startCmap12Table() {
final ParserKit<Cmap12Table, Cmap12TableHandler> handler = Cmap12Table.createContentHandler();
this.table.unicodeCMap.add(handler.getTable());
return handler.getHandler();
}
+
+ @Override
+ public void unsupportedSubtableFormat(final short value) {
+ Logger.getLogger("Cmap parsing").warning("Unsupported Cmap Subtable format: " + value);
+ }
}
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cmap06TableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cmap06TableParser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cmap06TableParser.java 2025-04-28 22:23:57 UTC (rev 13537)
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.Cmap06TableHandler;
+
+import org.checkerframework.checker.signedness.qual.Unsigned;
+
+import java.io.IOException;
+
+/**
+ * Parses a TTF Cmap Type 06 subtable.
+ */
+public class Cmap06TableParser extends TableParser<Cmap06TableHandler> {
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final Cmap06TableHandler handler)
+ throws IOException {
+ input.seek(offset);
+
+ handler.format(input.read_Offset16()); // 2 bytes, total 2
+ handler.length(input.read_uint16()); // 2 bytes, total 4
+ handler.language(input.read_uint16()); // 2 bytes, total 6
+ handler.firstCode(input.read_uint16()); // 2 bytes, total 8
+
+ final @Unsigned short entryCount = input.read_uint16(); // 2 bytes, total 10
+ handler.entryCount(entryCount);
+
+ /* Parse each glyph Id. */ // *** Restart Count ***
+ final @Unsigned short[] glyphIdArray = new @Unsigned short[entryCount];
+ for (int index = 0; index < entryCount; index ++) {
+ final @Unsigned short glyphIndex = input.read_uint16(); // 4 bytes, total 2
+ handler.glyphId(entryCount);
+ glyphIdArray[index] = glyphIndex;
+ }
+ handler.glyphIdArray(glyphIdArray);
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cmap06TableParser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CmapTableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CmapTableParser.java 2025-04-28 20:43:01 UTC (rev 13536)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CmapTableParser.java 2025-04-28 22:23:57 UTC (rev 13537)
@@ -30,6 +30,7 @@
import org.foray.fontParse.TableParser;
import org.foray.fontParse.ttfHandler.Cmap04TableHandler;
+import org.foray.fontParse.ttfHandler.Cmap06TableHandler;
import org.foray.fontParse.ttfHandler.Cmap12TableHandler;
import org.foray.fontParse.ttfHandler.CmapTableHandler;
@@ -36,7 +37,6 @@
import org.checkerframework.checker.signedness.qual.Unsigned;
import java.io.IOException;
-import java.util.logging.Logger;
/**
* Parses a TTF Cmap table.
@@ -94,6 +94,12 @@
cmap04Parser.parse(input, absoluteSubtableOffset, cmap04Handler);
break;
}
+ case CMAP_FORMAT_6: {
+ final Cmap06TableHandler cmap06Handler = handler.startCmap06Table();
+ final Cmap06TableParser cmap06Parser = new Cmap06TableParser();
+ cmap06Parser.parse(input, absoluteSubtableOffset, cmap06Handler);
+ break;
+ }
case CMAP_FORMAT_12: {
final Cmap12TableHandler cmap12Handler = handler.startCmap12Table();
final Cmap12TableParser cmap12Parser = new Cmap12TableParser();
@@ -100,8 +106,7 @@
cmap12Parser.parse(input, absoluteSubtableOffset, cmap12Handler);
break;
}
- default: Logger.getLogger(this.getClass().getName()).warning(
- "Cmap subtable format not supported: " + format);
+ default: handler.unsupportedSubtableFormat(format);
}
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Cmap06TableHandler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Cmap06TableHandler.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Cmap06TableHandler.java 2025-04-28 22:23:57 UTC (rev 13537)
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttfHandler;
+
+import org.foray.fontParse.FontContentHandler;
+
+import org.checkerframework.checker.signedness.qual.Unsigned;
+
+/**
+ * Implementations catch and handle the output from {@link org.foray.fontParse.ttf.Cmap06TableParser}.
+ */
+public interface Cmap06TableHandler extends FontContentHandler {
+
+ default void format(@Unsigned short value) { return; }
+ default void length(@Unsigned short value) { return; }
+ default void language(@Unsigned short value) { return; }
+ default void firstCode(@Unsigned short value) { return; }
+ default void entryCount(@Unsigned short value) { return; }
+
+ /* Being the same data, implementations likely need only of of 1. glyphId or 2. glyphIdArray. */
+ default void glyphId(@Unsigned short value) { return; }
+ default void glyphIdArray(@Unsigned short[] value) { return; }
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Cmap06TableHandler.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/CmapTableHandler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/CmapTableHandler.java 2025-04-28 20:43:01 UTC (rev 13536)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/CmapTableHandler.java 2025-04-28 22:23:57 UTC (rev 13537)
@@ -50,5 +50,14 @@
default void subtableFormat(@Unsigned short value) { return; }
default Cmap04TableHandler startCmap04Table() { return null; }
+ default Cmap06TableHandler startCmap06Table() { return null; }
default Cmap12TableHandler startCmap12Table() { return null; }
+
+ /**
+ * Report that an unsupported subtable format was found while parsing a Cmap, so that client code can log a message,
+ * throw an exception, etc.
+ * @param value The numeric subtable format.
+ */
+ default void unsupportedSubtableFormat(@Unsigned short value) { return; }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-28 20:43:19
|
Revision: 13536
http://sourceforge.net/p/foray/code/13536
Author: victormote
Date: 2025-04-28 20:43:01 +0000 (Mon, 28 Apr 2025)
Log Message:
-----------
Convert Cmap to new parsing scheme.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CmapTableParser.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-04-28 17:11:09 UTC (rev 13535)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-04-28 20:43:01 UTC (rev 13536)
@@ -61,6 +61,7 @@
import org.foray.fontParse.FontFormat;
import org.foray.fontParse.TableParser;
import org.foray.fontParse.ttf.BaseTableParser;
+import org.foray.fontParse.ttf.CmapTableParser;
import org.foray.fontParse.ttf.HeadTableParser;
import org.foray.fontParse.ttf.HheaTableParser;
import org.foray.fontParse.ttf.MaxpTableParser;
@@ -70,6 +71,7 @@
import org.foray.fontParse.ttf.PostTableParser;
import org.foray.fontParse.ttf.TtfRandomAccessInput;
import org.foray.fontParse.ttfHandler.BaseTableHandler;
+import org.foray.fontParse.ttfHandler.CmapTableHandler;
import org.foray.fontParse.ttfHandler.HeadTableHandler;
import org.foray.fontParse.ttfHandler.HheaTableHandler;
import org.foray.fontParse.ttfHandler.MaxpTableHandler;
@@ -235,8 +237,12 @@
/* Then the CMAP, so that glyph indexes can be computed. */
dirEntry = ttfTableDir.getTableDirectoryEntry("cmap");
- font.cmapTable = CmapTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength(),
- font.nameTable.getPostscriptName());
+ {
+ final ParserKit<CmapTable, CmapTableHandler> parseKit = CmapTable.createContentHandler();
+ final CmapTableParser parser = new CmapTableParser();
+ parser.parse(raInput, dirEntry.getOffset(), parseKit.getHandler());
+ font.cmapTable = parseKit.getTable();
+ }
/* Read the Horizontal Header before the Horizontal Metrics. */
dirEntry = ttfTableDir.getTableDirectoryEntry("hhea");
@@ -852,7 +858,8 @@
* @return The "To Unicode" Cmap4a for this font, or null if there is none.
*/
public Encoding getUnicodeCMap() {
- return this.cmapTable.getUnicodeCMap();
+ /* TODO: Not sure this is right. Might need to consider the platform ID and encoding ID. */
+ return this.cmapTable.getEncoding(0);
}
/**
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java 2025-04-28 17:11:09 UTC (rev 13535)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java 2025-04-28 20:43:01 UTC (rev 13536)
@@ -30,16 +30,14 @@
import org.foray.font.ttf.ParserKit;
import org.foray.font.ttf.RoTable;
-import org.foray.fontParse.ttf.Cmap04TableParser;
-import org.foray.fontParse.ttf.Cmap12TableParser;
-import org.foray.fontParse.ttf.CmapTableParser;
-import org.foray.fontParse.ttf.TtfRandomAccessInput;
import org.foray.fontParse.ttfHandler.Cmap04TableHandler;
import org.foray.fontParse.ttfHandler.Cmap12TableHandler;
+import org.foray.fontParse.ttfHandler.CmapTableHandler;
import org.axsl.ps.Encoding;
-import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
/**
* Class representing a TTF "cmap" (character-to-glyph index mapping) table.
@@ -46,6 +44,51 @@
*/
public class CmapTable extends RoTable {
+ /**
+ * The handler of events from the parser.
+ */
+ private final class ContentHandler implements CmapTableHandler {
+
+ /** The table instance being created. */
+ private CmapTable table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final CmapTable table) {
+ this.table = table;
+ }
+
+ @Override
+ public void numTables(final short value) {
+ this.table.unicodeCMap = new ArrayList<Encoding>(value);
+ }
+
+ @Override
+ public Cmap04TableHandler startCmap04Table() {
+ final ParserKit<Cmap04Table, Cmap04TableHandler> handler = Cmap04Table.createContentHandler();
+ this.table.unicodeCMap.add(handler.getTable());
+ return handler.getHandler();
+ }
+
+ @Override
+ public Cmap12TableHandler startCmap12Table() {
+ final ParserKit<Cmap12Table, Cmap12TableHandler> handler = Cmap12Table.createContentHandler();
+ this.table.unicodeCMap.add(handler.getTable());
+ return handler.getHandler();
+ }
+ }
+
+
+
+
+
+
+
+
+
+
/** Constant indicating that the platform is Microsoft. */
protected static final int PLATFORM_MICROSOFT = 3;
@@ -56,135 +99,65 @@
protected static final int ENCODING_UCS_4 = 10;
/** The Cmap4a instance that was parsed from this table. */
- private Encoding unicodeCMap;
+ private List<Encoding> unicodeCMap;
/**
- * Parse the cmap table.
- * Currently only unicode cmaps are supported.
- * @param input The input which is being parsed.
- * @param offset The offset into {@code input} at which to start parsing.
- * @param length The number of bytes to parse from {@code input}.
- * @param fontPostScriptName The PostScript name of this font.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
+ * Returns the quantity of subtables in this table.
+ * @return The quantity of subtables in this table.
*/
- public static CmapTable parse(final TtfRandomAccessInput input, final int offset, final int length,
- final String fontPostScriptName) throws IOException {
- input.seek(offset);
- final CmapTable cmap = new CmapTable();
- /* Skip table version. */
- input.skipBytes(RoTable.USHORT_BYTES);
- final int numSubtables = input.readUnsignedShort();
-
- long offsetToCMap04 = -1;
- long offsetToCMap12 = -1;
-
- /* Parse the header entry for each encoding table and find the best
- * Unicode entry to parse and store. */
- for (int i = 0; i < numSubtables; i++) {
- final int platformID = input.readUnsignedShort();
- final int encodingID = input.readUnsignedShort();
- final long subtableOffset = input.readUnsignedInt();
- if (platformID == CmapTable.PLATFORM_MICROSOFT
- && encodingID == CmapTable.ENCODING_UNICODE) {
- /* Platform is Microsoft, encoding is Unicode. */
- offsetToCMap04 = subtableOffset;
- }
- if (platformID == CmapTable.PLATFORM_MICROSOFT
- && encodingID == CmapTable.ENCODING_UCS_4) {
- /* Platform is Microsoft, encoding is UCS-4 (32-bit Unicode). */
- offsetToCMap12 = subtableOffset;
- }
- }
-
- /* The offset to the subtable that we wish to parse. Use the format 12
- * subtable if there is one. Otherwise use the format 4 subtable.
- * According to the Microsoft cmap spec at
- * http://www.microsoft.com/typography/otspec/cmap.htm,
- * "The contents of the Format 12 subtable need to be a superset of the
- * contents of the Format 4 subtable."
- * Therefore we only need to parse one of them. */
- long offsetToParse = offsetToCMap04;
- if (offsetToCMap12 > -1) {
- offsetToParse = offsetToCMap12;
- }
-
-// if (offsetToParse < 0) {
-// getLogger().warn("No Unicode cmap table: " + this.ttfFont().getFontName());
-// return;
-// }
- cmap.unicodeCMap = parseCMap(input, offset, offsetToParse, fontPostScriptName);
- return cmap;
+ public int getQtySubtables() {
+ return this.unicodeCMap.size();
}
/**
- * Parse one cmap table.
- * @param input The input which is being parsed.
- * @param tableOffset The offset into {@code input} at which to start parsing.
- * @param offsetToParse The offset of the table to be parsed.
- * @param fontPostScriptName The PostScript name of this font.
- * @return The parsed Cmap4a instance.
- * @throws IOException For I/O Error.
+ * Returns the subtable at a specific index.
+ * @param index The index into the subtables.
+ * @return The subtable at index {@code index}.
*/
- private static Encoding parseCMap(final TtfRandomAccessInput input, final int tableOffset,
- final long offsetToParse, final String fontPostScriptName) throws IOException {
- input.seek(tableOffset + offsetToParse);
- final int formatHigh = input.readUnsignedShort();
-// int formatLow = 0;
-// long length = 0;
- if (formatHigh > CmapTableParser.CMAP_FORMAT_6) {
- /*formatLow = */input.readUnsignedShort();
- /*length = */input.readUnsignedInt();
- } else {
- /*length = */input.readUnsignedShort();
- }
- switch (formatHigh) {
- case CmapTableParser.CMAP_FORMAT_4: {
- final ParserKit<Cmap04Table, Cmap04TableHandler> contentHandler = Cmap04Table.createContentHandler();
- final Cmap04TableParser parser = new Cmap04TableParser();
- parser.parse(input, (int) (tableOffset + offsetToParse), contentHandler.getHandler());
- return contentHandler.getTable();
- }
- case CmapTableParser.CMAP_FORMAT_12: {
- final ParserKit<Cmap12Table, Cmap12TableHandler> contentHandler = Cmap12Table.createContentHandler();
- final Cmap12TableParser parser = new Cmap12TableParser();
- parser.parse(input, (int) (tableOffset + offsetToParse), contentHandler.getHandler());
- return contentHandler.getTable();
- }
- }
- return null;
+ public Encoding getEncoding(final int index) {
+ return this.unicodeCMap.get(index);
}
/**
- * Returns the Unicode Cmap4a instance parsed from this table.
- * @return The Unicode Cmap4a instance parsed from this table.
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
*/
- public Encoding getUnicodeCMap() {
- return this.unicodeCMap;
+ public static ParserKit<CmapTable, CmapTableHandler> createContentHandler() {
+ final CmapTable table = new CmapTable();
+ final CmapTableHandler handler = table.new ContentHandler(table);
+ return new ParserKit<CmapTable, CmapTableHandler>(table, handler);
}
/**
* Encode a specific character using the Unicode Cmap4a from this table.
* @param codePoint The code point to be encoded.
- * @return The glyph index corresponding to {@code codePoint}.
+ * @return The glyph index corresponding to {@code codePoint}, or -1 if not found.
*/
public int encodeCharacter(final int codePoint) {
- if (this.unicodeCMap == null) {
- return -1;
+ for (int index = 0; index < this.unicodeCMap.size(); index ++) {
+ final Encoding cmap = this.unicodeCMap.get(index);
+ final int encoded = cmap.encode(codePoint);
+ if (encoded > -1) {
+ return encoded;
+ }
}
- return this.unicodeCMap.encode(codePoint);
+ return -1;
}
/**
* Decodes a glyph index using the Unicode Cmap4a from this table.
* @param glyphIndex The glyph index to be decoded.
- * @return The Unicode code point corresponding to {@code glyphIndex}.
+ * @return The Unicode code point corresponding to {@code glyphIndex}, or -1 if not found.
*/
public int decodeCharacter(final int glyphIndex) {
- if (this.unicodeCMap == null) {
- return -1;
+ for (int index = 0; index < this.unicodeCMap.size(); index ++) {
+ final Encoding cmap = this.unicodeCMap.get(index);
+ final int decoded = cmap.decode(glyphIndex);
+ if (decoded > -1) {
+ return decoded;
+ }
}
- return this.unicodeCMap.decode(glyphIndex);
+ return -1;
}
}
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CmapTableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CmapTableParser.java 2025-04-28 17:11:09 UTC (rev 13535)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CmapTableParser.java 2025-04-28 20:43:01 UTC (rev 13536)
@@ -36,6 +36,7 @@
import org.checkerframework.checker.signedness.qual.Unsigned;
import java.io.IOException;
+import java.util.logging.Logger;
/**
* Parses a TTF Cmap table.
@@ -99,7 +100,8 @@
cmap12Parser.parse(input, absoluteSubtableOffset, cmap12Handler);
break;
}
- default: throw new UnsupportedOperationException("Cmap subtable format not supported: " + format);
+ default: Logger.getLogger(this.getClass().getName()).warning(
+ "Cmap subtable format not supported: " + format);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-28 17:11:28
|
Revision: 13535
http://sourceforge.net/p/foray/code/13535
Author: victormote
Date: 2025-04-28 17:11:09 +0000 (Mon, 28 Apr 2025)
Log Message:
-----------
Complete conversion of Cmap04 to new parsing scheme.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java
trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/Cmap04TableTests.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cmap04TableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Cmap04TableHandler.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java 2025-04-28 13:03:24 UTC (rev 13534)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java 2025-04-28 17:11:09 UTC (rev 13535)
@@ -60,29 +60,23 @@
@Override
public void endCodeArray(final @Unsigned short[] value) {
- this.table.unicodeEnd = value;
+ this.table.endCode = value;
}
@Override
public void startCodeArray(final @Unsigned short[] value) {
- this.table.unicodeStart = value;
+ this.table.startCode = value;
}
@Override
- public void idDeltaArray(final @Unsigned short[] value) {
- this.table.glyphStartIndex = value;
+ public void idDeltaArray(final short[] value) {
+ this.table.idDelta = value;
}
@Override
- public void idRangeOffsetArray(final @Unsigned short[] value) {
- this.table.idRangeOffset = value;
- return;
+ public void computedGlyphIdArray(final @Unsigned short[][] value) {
+ this.table.noncontiguousIndexes = value;
}
-
- @Override
- public void glyphIdArray(final @Unsigned short[] value) {
- this.table.glyphIndexes = value;
- }
}
@@ -99,23 +93,18 @@
private String name;
/** The first Unicode code point in this entry. */
- private @Unsigned short[] unicodeStart;
+ private @Unsigned short[] startCode;
/** The last Unicode code point in this entry.*/
- private @Unsigned short[] unicodeEnd;
+ private @Unsigned short[] endCode;
/** The starting glyph index for this entry. This index points to the glyph
- * representing {@link #unicodeStart}. */
- private @Unsigned short[] glyphStartIndex;
+ * representing {@link #startCode}. */
+ private short[] idDelta;
- /** For contiguous ranges, 0; for non-contiguous ranges, the offsets into {@link #glyphIndexes}. */
- private @Unsigned short[] idRangeOffset;
+ /** For non-contiguous ranges, the glyph indexes for that range. For contiguous ranges, this will be null. */
+ private short[][] noncontiguousIndexes;
- /** The list of non-contiguous entries, if any, for this entry.
- * For contiguous entries, this will be null.
- * For non-contiguous entries, this array contains the glyph Indexes for the range of Unicode characters. */
- private short[] glyphIndexes;
-
/**
* No-args Constructor, used by the parsing process.
*/
@@ -124,14 +113,12 @@
/**
* Constructor used mainly for testing.
* @param qtyEntries The number of entries in this encoding.
- * @param glyphIdArray The array containing indexes for non-contiguous code points.
*/
- public Cmap04Table(final int qtyEntries, final short[] glyphIdArray) {
- this.unicodeStart = new short[qtyEntries];
- this.unicodeEnd = new short[qtyEntries];
- this.glyphStartIndex = new short[qtyEntries];
- this.idRangeOffset = new short[qtyEntries];
- this.glyphIndexes = glyphIdArray;
+ public Cmap04Table(final int qtyEntries) {
+ this.startCode = new short[qtyEntries];
+ this.endCode = new short[qtyEntries];
+ this.idDelta = new short[qtyEntries];
+ this.noncontiguousIndexes = new short[qtyEntries][];
}
/**
@@ -156,26 +143,37 @@
* @param unicodeStart The starting Unicode code point for this map.
* @param unicodeEnd The ending Unicode code point for this map.
* @param glyphStartIndex The starting glyph index for this map.
- * @param idRangeOffset The offset into the glyphIdArray, or 0.
+ * @param glyphIndexes The glyph indexes for this segment, if it is a non-contiguous segment, or null if contiguous.
* This index is the encoded value for {@code unicodeStart}.
*/
public void addEntry(final @Unsigned int index, final @Unsigned int unicodeStart, final @Unsigned int unicodeEnd,
- final @Unsigned int glyphStartIndex, final @Unsigned int idRangeOffset) {
- this.unicodeStart[index] = (short) unicodeStart;
- this.unicodeEnd[index] = (short) unicodeEnd;
- this.glyphStartIndex[index] = (short) glyphStartIndex;
- this.idRangeOffset[index] = (short) idRangeOffset;
+ final @Unsigned int glyphStartIndex, final @Unsigned short[] glyphIndexes) {
+ this.startCode[index] = (short) unicodeStart;
+ this.endCode[index] = (short) unicodeEnd;
+ this.idDelta[index] = (short) glyphStartIndex;
+ this.noncontiguousIndexes[index] = glyphIndexes;
}
@Override
- public int encode(final int c) {
- for (int i = 0; i < this.unicodeStart.length; i++) {
- if ((c >= this.unicodeStart[i])
- && (c <= this.unicodeEnd[i])) {
- if (this.idRangeOffset[i] == 0) {
- return (c - this.unicodeStart[i] + this.glyphStartIndex[i]);
+ public int encode(final int codePoint) {
+ for (int segmentIndex = 0; segmentIndex < this.endCode.length; segmentIndex++) {
+ if (Short.toUnsignedInt(this.endCode[segmentIndex]) >= codePoint) {
+ if (this.startCode[segmentIndex] <= codePoint) {
+ if (this.noncontiguousIndexes[segmentIndex] == null) {
+ /* Contiguous range. */
+ final int provisionalIndex =
+ codePoint +
+ this.idDelta[segmentIndex];
+ return provisionalIndex % Character.MAX_VALUE;
+ } else {
+ /* Non-contiguous range. */
+ final short[] glyphIndexes = this.noncontiguousIndexes[segmentIndex];
+ return glyphIndexes[codePoint - Short.toUnsignedInt(this.startCode[segmentIndex])];
+ }
+ } else {
+ /* Since the segments are sorted by ending index, none of the remaining segments qualify. */
+ return -1;
}
- return this.glyphIndexes[c - this.unicodeStart[i]];
}
}
return -1;
@@ -183,20 +181,20 @@
@Override
public int decode(final int glyphIndex) {
- for (int i = 0; i < this.unicodeStart.length; i++) {
- if (this.idRangeOffset[i] == 0) {
- final int provisionalCodePoint = glyphIndex - this.glyphStartIndex[i] + this.unicodeStart[i];
- if (provisionalCodePoint >= this.unicodeStart[i]
- && provisionalCodePoint <= this.unicodeEnd[i]) {
+ for (int i = 0; i < this.startCode.length; i++) {
+ final short[] glyphIndexes = this.noncontiguousIndexes[i];
+ if (glyphIndexes == null) {
+ final int provisionalCodePoint = glyphIndex - this.idDelta[i] + this.startCode[i];
+ if (provisionalCodePoint >= this.startCode[i]
+ && provisionalCodePoint <= this.endCode[i]) {
return provisionalCodePoint;
}
} else {
- for (int j = 0; j < this.glyphIndexes.length; j++) {
- if (this.glyphIndexes[j] == glyphIndex) {
- return this.unicodeStart[i] + j;
+ for (int j = 0; j < glyphIndexes.length; j++) {
+ if (glyphIndexes[j] == glyphIndex) {
+ return this.startCode[i] + j;
}
}
-
}
}
return -1;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java 2025-04-28 13:03:24 UTC (rev 13534)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java 2025-04-28 17:11:09 UTC (rev 13535)
@@ -155,81 +155,6 @@
return null;
}
-// /**
-// * Parse a Cmap4a format 4 table.
-// * @param raInput The input which is being parsed.
-// * @param fontPostScriptName The PostScript name of this font.
-// * @return The parsed Cmap4a format 4 table.
-// * @throws IOException For I/O Error.
-// */
-// private static Cmap04Table parseCMap04(final TtfRandomAccessInput raInput, final String fontPostScriptName)
-// throws IOException {
-// /* Format and Length have already been read. */
-// /* Skip version */
-// raInput.skipBytes(RoTable.USHORT_BYTES);
-// final int segCountX2 = raInput.readUnsignedShort();
-// /* Skip searchRange. */
-// raInput.skipBytes(RoTable.USHORT_BYTES);
-// /* Skip entrySelector. */
-// raInput.skipBytes(RoTable.USHORT_BYTES);
-// /* Skip rangeShift. */
-// raInput.skipBytes(RoTable.USHORT_BYTES);
-//
-// final @Unsigned short[] endCount = new @Unsigned short[segCountX2 / 2];
-// final int[] startCount = new int[segCountX2 / 2];
-// final int deltas[] = new int[segCountX2 / 2];
-// final int rangeOffset[] = new int[segCountX2 / 2];
-//
-// for (int i = 0; i < (segCountX2 / 2); i++) {
-// endCount[i] = raInput.read_uint16();
-// }
-//
-// /* Skip reservedPad. */
-// raInput.skipBytes(RoTable.USHORT_BYTES);
-//
-// for (int i = 0; i < (segCountX2 / 2); i++) {
-// startCount[i] = (char) raInput.readUnsignedShort();
-// }
-//
-// for (int i = 0; i < (segCountX2 / 2); i++) {
-// deltas[i] = raInput.readShort();
-// }
-//
-// for (int i = 0; i < (segCountX2 / 2); i++) {
-// rangeOffset[i] = raInput.readUnsignedShort();
-// }
-//
-// final int glyphIdArrayOffset = (int) raInput.getOffset();
-//
-// // Parse the table entries and build a CMap4 from them.
-// final Cmap04Table cmap04 = new Cmap04Table(segCountX2 / 2);
-// for (int i = 0; i < startCount.length; i++) {
-// if (rangeOffset[i] == 0) {
-// cmap04.addEntry(startCount[i],
-// endCount[i],
-// (short) (startCount[i] + deltas[i]));
-// } else {
-// final short[] computedIndexes = new short[endCount[i]
-// - startCount[i] + 1];
-// for (int j = startCount[i]; j <= endCount[i]; j++) {
-// final short glyphOffset
-// = (short) (glyphIdArrayOffset
-// + ((rangeOffset[i] / 2)
-// + (j - startCount[i])
-// + i - segCountX2 / 2)
-// * 2);
-// raInput.seek(glyphOffset);
-// final short glyphIndex =
-// (short) ((raInput.readUnsignedShort()
-// + deltas[i]) & Character.MAX_VALUE);
-// computedIndexes[j - startCount[i]] = glyphIndex;
-// }
-// cmap04.addEntry(startCount[i], endCount[i], new ShortArray(computedIndexes));
-// }
-// }
-// return cmap04;
-// }
-
/**
* Returns the Unicode Cmap4a instance parsed from this table.
* @return The Unicode Cmap4a instance parsed from this table.
Modified: trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/Cmap04TableTests.java
===================================================================
--- trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/Cmap04TableTests.java 2025-04-28 13:03:24 UTC (rev 13534)
+++ trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/Cmap04TableTests.java 2025-04-28 17:11:09 UTC (rev 13535)
@@ -30,7 +30,6 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
@@ -44,24 +43,22 @@
* All we care about is whether we can accurately encode & decode.
*/
@Test
- @Disabled
public void test01() {
- final short[] glyphIdArray = {16537, 17001, 19000, 2000, 3000, 4000};
- final Cmap04Table out = new Cmap04Table(5, glyphIdArray);
+ final Cmap04Table out = new Cmap04Table(5);
/* Add some contiguous segments. */
- out.addEntry(0, 20, 30, 100, 0);
- out.addEntry(1, 120, 130, 200, 0);
+ out.addEntry(0, 20, 30, 100, null);
+ out.addEntry(1, 120, 130, 200, null);
/* Add some non-contiguous segments. */
- out.addEntry(2, 220, 222, 0, 0);
- out.addEntry(3, 320, 322, 0, 3);
- out.addEntry(4, Character.MAX_VALUE, Character.MAX_VALUE, 0, 0);
+ out.addEntry(2, 220, 222, 0, new short[]{16537, 17001, 19000});
+ out.addEntry(3, 320, 322, 0, new short[]{2000, 3000, 4000});
+ out.addEntry(4, Character.MAX_VALUE, Character.MAX_VALUE, 0, null);
assertFalse(out.canEncode(1));
assertTrue(out.canEncode(221));
- assertEquals(105, out.encode(25));
+ assertEquals(125, out.encode(25));
assertEquals(-1, out.encode(40));
assertEquals(3000, out.encode(321));
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cmap04TableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cmap04TableParser.java 2025-04-28 13:03:24 UTC (rev 13534)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cmap04TableParser.java 2025-04-28 17:11:09 UTC (rev 13535)
@@ -81,9 +81,9 @@
}
handler.startCodeArray(startCodeArray);
- final @Unsigned short[] idDeltaArray = new @Unsigned short[segCount];
+ final short[] idDeltaArray = new short[segCount];
for (int segmentIndex = 0; segmentIndex < segCount; segmentIndex ++) {
- final @Unsigned short idDelta = input.read_uint16(); // 2 bytes @
+ final short idDelta = input.read_int16(); // 2 bytes @
handler.idDelta(idDelta);
idDeltaArray[segmentIndex] = idDelta;
}
@@ -97,7 +97,7 @@
}
handler.idRangeOffsetArray(idRangeOffsetArray);
-
+ final int glyphIdArrayOffset = (int) input.getOffset();
final int glyphIdArraySize = length - HEADER_BYTES - (BYTES_PER_SEGMENT * segCount) - 2;
final short[] glyphIdArray = new short [glyphIdArraySize];
for (int index = 0; index < glyphIdArraySize; index ++) {
@@ -104,6 +104,34 @@
glyphIdArray[index] = input.read_uint16();
}
handler.glyphIdArray(glyphIdArray);
+
+
+ final short[][] computedIndexesArray = new short[segCount][];
+ for (int segmentIndex = 0; segmentIndex < segCount; segmentIndex ++) {
+ @Unsigned short[] computedIndexes = null;
+ if (idRangeOffsetArray[segmentIndex] == 0) {
+ computedIndexes = null;
+ } else {
+ final int startCodeAsInt = Short.toUnsignedInt(startCodeArray[segmentIndex]);
+ final int endCodeAsInt = Short.toUnsignedInt(endCodeArray[segmentIndex]);
+ final int idRangeOffsetAsInt = Short.toUnsignedInt(idRangeOffsetArray[segmentIndex]);
+ computedIndexes = new @Unsigned short[endCodeAsInt - startCodeAsInt + 1];
+ for (int codePoint = startCodeAsInt; codePoint <= endCodeAsInt; codePoint++) {
+ final int glyphOffset =
+ glyphIdArrayOffset +
+ ((idRangeOffsetAsInt / 2) +
+ (codePoint - startCodeAsInt) +
+ idRangeOffsetAsInt);
+ input.seek(glyphOffset);
+ final short glyphId = input.read_uint16();
+ final short glyphIndex = (short) ((glyphId + idDeltaArray[segmentIndex]) % Character.MAX_VALUE);
+ computedIndexes[codePoint - startCodeAsInt] = glyphIndex;
+ }
+ }
+ computedIndexesArray[segmentIndex] = computedIndexes;
+ }
+ handler.computedGlyphIdArray(computedIndexesArray);
+
}
}
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Cmap04TableHandler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Cmap04TableHandler.java 2025-04-28 13:03:24 UTC (rev 13534)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Cmap04TableHandler.java 2025-04-28 17:11:09 UTC (rev 13535)
@@ -45,17 +45,39 @@
default void entrySelector(@Unsigned short value) { return; }
default void rangeShift(@Unsigned short value) { return; }
+ /* Being the same data, implementations will typically need only one of either 1. endCode or 2. endCodeArray. */
default void endCode(@Unsigned short value) { return; }
default void endCodeArray(@Unsigned short[] value) { return; }
+ /* Being the same data, implementations will typically need only one of either 1. startCode or 2. startCodeArray. */
default void startCode(@Unsigned short value) { return; }
default void startCodeArray(@Unsigned short[] value) { return; }
- default void idDelta(@Unsigned short value) { return; }
- default void idDeltaArray(@Unsigned short[] value) { return; }
+ /* Being the same data, implementations will typically need only one of either 1. idDelta or 2. idDeltaArray. */
+ default void idDelta(short value) { return; }
+ default void idDeltaArray(short[] value) { return; }
+ /* Being the same data, implementations will typically need only one of either 1. idRangeOffset or
+ * 2. idRangeOffsetArray. */
default void idRangeOffset(@Unsigned short value) { return; }
default void idRangeOffsetArray(@Unsigned short[] value) { return; }
+ /**
+ * Handles the raw glyph Id array for the entire subtable (not just a single segment).
+ * See {@link #computedGlyphIdArray(short[])} for a method that handles the computed glyph ID array for a single
+ * segment.
+ * Being the same data, implementations will typically need only one or the other.
+ * @param value The raw glyph Id array.
+ */
default void glyphIdArray(@Unsigned short[] value) { return; }
+
+ /**
+ * Handles the computed glyph Id array for a single segment of non-contiguous elements.
+ * See {@link #glyphIdArray(short[])} for a method that handles the glyph ID array for the entire subtable.
+ * Being the same data, implementations will typically need only one or the other.
+ * @param value The computed glyph Ids for each element in a non-contiguous segment.
+ * This will be null for a segment of contiguous elements.
+ */
+ default void computedGlyphIdArray(@Unsigned short[][] value) { return; }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-28 13:03:42
|
Revision: 13534
http://sourceforge.net/p/foray/code/13534
Author: victormote
Date: 2025-04-28 13:03:24 +0000 (Mon, 28 Apr 2025)
Log Message:
-----------
Convert Cmap04 to new parsing scheme. (Test failing temporarily).
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Table.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java
trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/Cmap04TableTests.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cmap04TableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Cmap04TableHandler.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java 2025-04-28 11:00:22 UTC (rev 13533)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java 2025-04-28 13:03:24 UTC (rev 13534)
@@ -28,7 +28,10 @@
package org.foray.font.ttf.table;
-import org.axsl.primitive.sequence.ShortSequence;
+import org.foray.font.ttf.ParserKit;
+import org.foray.font.ttf.RoTable;
+import org.foray.fontParse.ttfHandler.Cmap04TableHandler;
+
import org.axsl.ps.Encoding;
import org.checkerframework.checker.signedness.qual.Unsigned;
@@ -37,8 +40,58 @@
* Class containing a set of 16-bit Unicode ranges that sequentially map to the same-sized range of glyph indexes.
* The contents are analogous to a Format 4 TrueType Font cmap table (from which this class derives its name).
*/
-public class Cmap04Table implements Encoding {
+public class Cmap04Table extends RoTable implements Encoding {
+ /**
+ * The handler of events from the parser.
+ */
+ private final class ContentHandler implements Cmap04TableHandler {
+
+ /** The table instance being created. */
+ private Cmap04Table table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final Cmap04Table table) {
+ this.table = table;
+ }
+
+ @Override
+ public void endCodeArray(final @Unsigned short[] value) {
+ this.table.unicodeEnd = value;
+ }
+
+ @Override
+ public void startCodeArray(final @Unsigned short[] value) {
+ this.table.unicodeStart = value;
+ }
+
+ @Override
+ public void idDeltaArray(final @Unsigned short[] value) {
+ this.table.glyphStartIndex = value;
+ }
+
+ @Override
+ public void idRangeOffsetArray(final @Unsigned short[] value) {
+ this.table.idRangeOffset = value;
+ return;
+ }
+
+ @Override
+ public void glyphIdArray(final @Unsigned short[] value) {
+ this.table.glyphIndexes = value;
+ }
+ }
+
+
+
+
+
+
+
+
/** Constant needed for serialization. */
public static final long serialVersionUID = 985957847129472354L;
@@ -45,37 +98,52 @@
/** The name of this encoding. */
private String name;
- /** Index to the last entry added. */
- private int lastEntryAdded = -1;
-
/** The first Unicode code point in this entry. */
- private @Unsigned short unicodeStart[];
+ private @Unsigned short[] unicodeStart;
/** The last Unicode code point in this entry.*/
- private @Unsigned short unicodeEnd[];
+ private @Unsigned short[] unicodeEnd;
/** The starting glyph index for this entry. This index points to the glyph
* representing {@link #unicodeStart}. */
- private @Unsigned short glyphStartIndex[];
+ private @Unsigned short[] glyphStartIndex;
+ /** For contiguous ranges, 0; for non-contiguous ranges, the offsets into {@link #glyphIndexes}. */
+ private @Unsigned short[] idRangeOffset;
+
/** The list of non-contiguous entries, if any, for this entry.
* For contiguous entries, this will be null.
* For non-contiguous entries, this array contains the glyph Indexes for the range of Unicode characters. */
- private ShortSequence glyphIndexes[];
+ private short[] glyphIndexes;
/**
- * Constructor.
- * @param expectedEntries The number of expected entries in this encoding.
- * Setting this to the correct value will result in more efficient
- * processing.
+ * No-args Constructor, used by the parsing process.
*/
- public Cmap04Table(final int expectedEntries) {
- this.unicodeStart = new short[expectedEntries];
- this.unicodeEnd = new short[expectedEntries];
- this.glyphStartIndex = new short[expectedEntries];
- this.glyphIndexes = new ShortSequence[expectedEntries];
+ public Cmap04Table() { }
+
+ /**
+ * Constructor used mainly for testing.
+ * @param qtyEntries The number of entries in this encoding.
+ * @param glyphIdArray The array containing indexes for non-contiguous code points.
+ */
+ public Cmap04Table(final int qtyEntries, final short[] glyphIdArray) {
+ this.unicodeStart = new short[qtyEntries];
+ this.unicodeEnd = new short[qtyEntries];
+ this.glyphStartIndex = new short[qtyEntries];
+ this.idRangeOffset = new short[qtyEntries];
+ this.glyphIndexes = glyphIdArray;
}
+ /**
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
+ */
+ public static ParserKit<Cmap04Table, Cmap04TableHandler> createContentHandler() {
+ final Cmap04Table table = new Cmap04Table();
+ final Cmap04TableHandler handler = table.new ContentHandler(table);
+ return new ParserKit<Cmap04Table, Cmap04TableHandler>(table, handler);
+ }
+
@Override
public String getName() {
return this.name;
@@ -82,43 +150,32 @@
}
/**
- * Add a new entry to this map for contiguous values.
+ * Add a new entry to this map.
+ * This is used mostly for testing.
+ * @param index The index into which each of the other parameters should be placed.
* @param unicodeStart The starting Unicode code point for this map.
* @param unicodeEnd The ending Unicode code point for this map.
* @param glyphStartIndex The starting glyph index for this map.
+ * @param idRangeOffset The offset into the glyphIdArray, or 0.
* This index is the encoded value for {@code unicodeStart}.
*/
- public void addEntry(final @Unsigned int unicodeStart, final @Unsigned int unicodeEnd,
- final @Unsigned int glyphStartIndex) {
- this.lastEntryAdded ++;
- this.unicodeStart[this.lastEntryAdded] = (short) unicodeStart;
- this.unicodeEnd[this.lastEntryAdded] = (short) unicodeEnd;
- this.glyphStartIndex[this.lastEntryAdded] = (short) glyphStartIndex;
+ public void addEntry(final @Unsigned int index, final @Unsigned int unicodeStart, final @Unsigned int unicodeEnd,
+ final @Unsigned int glyphStartIndex, final @Unsigned int idRangeOffset) {
+ this.unicodeStart[index] = (short) unicodeStart;
+ this.unicodeEnd[index] = (short) unicodeEnd;
+ this.glyphStartIndex[index] = (short) glyphStartIndex;
+ this.idRangeOffset[index] = (short) idRangeOffset;
}
- /**
- * Add a new entry to this map for non-contiguous values.
- * @param unicodeStart The starting Unicode code point for this map.
- * @param unicodeEnd The ending Unicode code point for this map.
- * @param glyphIndexes The array of glyph indexes corresponding to the range {@code unicodeStart} through
- * {@code unicodeEnd}.
- */
- public void addEntry(final int unicodeStart, final @Unsigned int unicodeEnd, final ShortSequence glyphIndexes) {
- this.lastEntryAdded ++;
- this.unicodeStart[this.lastEntryAdded] = (short) unicodeStart;
- this.unicodeEnd[this.lastEntryAdded] = (short) unicodeEnd;
- this.glyphIndexes[this.lastEntryAdded] = glyphIndexes;
- }
-
@Override
public int encode(final int c) {
for (int i = 0; i < this.unicodeStart.length; i++) {
if ((c >= this.unicodeStart[i])
&& (c <= this.unicodeEnd[i])) {
- if (this.glyphIndexes[i] == null) {
+ if (this.idRangeOffset[i] == 0) {
return (c - this.unicodeStart[i] + this.glyphStartIndex[i]);
}
- return this.glyphIndexes[i].shortAt(c - this.unicodeStart[i]);
+ return this.glyphIndexes[c - this.unicodeStart[i]];
}
}
return -1;
@@ -127,7 +184,7 @@
@Override
public int decode(final int glyphIndex) {
for (int i = 0; i < this.unicodeStart.length; i++) {
- if (this.glyphIndexes[i] == null) {
+ if (this.idRangeOffset[i] == 0) {
final int provisionalCodePoint = glyphIndex - this.glyphStartIndex[i] + this.unicodeStart[i];
if (provisionalCodePoint >= this.unicodeStart[i]
&& provisionalCodePoint <= this.unicodeEnd[i]) {
@@ -134,8 +191,8 @@
return provisionalCodePoint;
}
} else {
- for (int j = 0; j < this.glyphIndexes[i].length(); j++) {
- if (this.glyphIndexes[i].shortAt(j) == glyphIndex) {
+ for (int j = 0; j < this.glyphIndexes.length; j++) {
+ if (this.glyphIndexes[j] == glyphIndex) {
return this.unicodeStart[i] + j;
}
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Table.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Table.java 2025-04-28 11:00:22 UTC (rev 13533)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Table.java 2025-04-28 13:03:24 UTC (rev 13534)
@@ -112,13 +112,12 @@
/**
* Constructor used mainly for testing.
- * @param expectedEntries The number of expected entries in this encoding.
- * Setting this to the correct value will result in more efficient processing.
+ * @param qtyEntries The number of entries in this encoding.
*/
- public Cmap12Table(final int expectedEntries) {
- this.startCharCode = new @Unsigned int[expectedEntries];
- this.endCharCode = new @Unsigned int[expectedEntries];
- this.startGlyphID = new @Unsigned int[expectedEntries];
+ public Cmap12Table(final int qtyEntries) {
+ this.startCharCode = new @Unsigned int[qtyEntries];
+ this.endCharCode = new @Unsigned int[qtyEntries];
+ this.startGlyphID = new @Unsigned int[qtyEntries];
}
/**
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java 2025-04-28 11:00:22 UTC (rev 13533)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java 2025-04-28 13:03:24 UTC (rev 13534)
@@ -30,16 +30,15 @@
import org.foray.font.ttf.ParserKit;
import org.foray.font.ttf.RoTable;
+import org.foray.fontParse.ttf.Cmap04TableParser;
import org.foray.fontParse.ttf.Cmap12TableParser;
import org.foray.fontParse.ttf.CmapTableParser;
import org.foray.fontParse.ttf.TtfRandomAccessInput;
+import org.foray.fontParse.ttfHandler.Cmap04TableHandler;
import org.foray.fontParse.ttfHandler.Cmap12TableHandler;
-import org.foray.primitive.sequence.ShortArray;
import org.axsl.ps.Encoding;
-import org.checkerframework.checker.signedness.qual.Unsigned;
-
import java.io.IOException;
/**
@@ -141,7 +140,10 @@
}
switch (formatHigh) {
case CmapTableParser.CMAP_FORMAT_4: {
- return parseCMap04(input, fontPostScriptName);
+ final ParserKit<Cmap04Table, Cmap04TableHandler> contentHandler = Cmap04Table.createContentHandler();
+ final Cmap04TableParser parser = new Cmap04TableParser();
+ parser.parse(input, (int) (tableOffset + offsetToParse), contentHandler.getHandler());
+ return contentHandler.getTable();
}
case CmapTableParser.CMAP_FORMAT_12: {
final ParserKit<Cmap12Table, Cmap12TableHandler> contentHandler = Cmap12Table.createContentHandler();
@@ -153,81 +155,81 @@
return null;
}
- /**
- * Parse a Cmap4a format 4 table.
- * @param raInput The input which is being parsed.
- * @param fontPostScriptName The PostScript name of this font.
- * @return The parsed Cmap4a format 4 table.
- * @throws IOException For I/O Error.
- */
- private static Cmap04Table parseCMap04(final TtfRandomAccessInput raInput, final String fontPostScriptName)
- throws IOException {
- /* Format and Length have already been read. */
- /* Skip version */
- raInput.skipBytes(RoTable.USHORT_BYTES);
- final int segCountX2 = raInput.readUnsignedShort();
- /* Skip searchRange. */
- raInput.skipBytes(RoTable.USHORT_BYTES);
- /* Skip entrySelector. */
- raInput.skipBytes(RoTable.USHORT_BYTES);
- /* Skip rangeShift. */
- raInput.skipBytes(RoTable.USHORT_BYTES);
+// /**
+// * Parse a Cmap4a format 4 table.
+// * @param raInput The input which is being parsed.
+// * @param fontPostScriptName The PostScript name of this font.
+// * @return The parsed Cmap4a format 4 table.
+// * @throws IOException For I/O Error.
+// */
+// private static Cmap04Table parseCMap04(final TtfRandomAccessInput raInput, final String fontPostScriptName)
+// throws IOException {
+// /* Format and Length have already been read. */
+// /* Skip version */
+// raInput.skipBytes(RoTable.USHORT_BYTES);
+// final int segCountX2 = raInput.readUnsignedShort();
+// /* Skip searchRange. */
+// raInput.skipBytes(RoTable.USHORT_BYTES);
+// /* Skip entrySelector. */
+// raInput.skipBytes(RoTable.USHORT_BYTES);
+// /* Skip rangeShift. */
+// raInput.skipBytes(RoTable.USHORT_BYTES);
+//
+// final @Unsigned short[] endCount = new @Unsigned short[segCountX2 / 2];
+// final int[] startCount = new int[segCountX2 / 2];
+// final int deltas[] = new int[segCountX2 / 2];
+// final int rangeOffset[] = new int[segCountX2 / 2];
+//
+// for (int i = 0; i < (segCountX2 / 2); i++) {
+// endCount[i] = raInput.read_uint16();
+// }
+//
+// /* Skip reservedPad. */
+// raInput.skipBytes(RoTable.USHORT_BYTES);
+//
+// for (int i = 0; i < (segCountX2 / 2); i++) {
+// startCount[i] = (char) raInput.readUnsignedShort();
+// }
+//
+// for (int i = 0; i < (segCountX2 / 2); i++) {
+// deltas[i] = raInput.readShort();
+// }
+//
+// for (int i = 0; i < (segCountX2 / 2); i++) {
+// rangeOffset[i] = raInput.readUnsignedShort();
+// }
+//
+// final int glyphIdArrayOffset = (int) raInput.getOffset();
+//
+// // Parse the table entries and build a CMap4 from them.
+// final Cmap04Table cmap04 = new Cmap04Table(segCountX2 / 2);
+// for (int i = 0; i < startCount.length; i++) {
+// if (rangeOffset[i] == 0) {
+// cmap04.addEntry(startCount[i],
+// endCount[i],
+// (short) (startCount[i] + deltas[i]));
+// } else {
+// final short[] computedIndexes = new short[endCount[i]
+// - startCount[i] + 1];
+// for (int j = startCount[i]; j <= endCount[i]; j++) {
+// final short glyphOffset
+// = (short) (glyphIdArrayOffset
+// + ((rangeOffset[i] / 2)
+// + (j - startCount[i])
+// + i - segCountX2 / 2)
+// * 2);
+// raInput.seek(glyphOffset);
+// final short glyphIndex =
+// (short) ((raInput.readUnsignedShort()
+// + deltas[i]) & Character.MAX_VALUE);
+// computedIndexes[j - startCount[i]] = glyphIndex;
+// }
+// cmap04.addEntry(startCount[i], endCount[i], new ShortArray(computedIndexes));
+// }
+// }
+// return cmap04;
+// }
- final @Unsigned short[] endCount = new @Unsigned short[segCountX2 / 2];
- final int[] startCount = new int[segCountX2 / 2];
- final int deltas[] = new int[segCountX2 / 2];
- final int rangeOffset[] = new int[segCountX2 / 2];
-
- for (int i = 0; i < (segCountX2 / 2); i++) {
- endCount[i] = raInput.read_uint16();
- }
-
- /* Skip reservedPad. */
- raInput.skipBytes(RoTable.USHORT_BYTES);
-
- for (int i = 0; i < (segCountX2 / 2); i++) {
- startCount[i] = (char) raInput.readUnsignedShort();
- }
-
- for (int i = 0; i < (segCountX2 / 2); i++) {
- deltas[i] = raInput.readShort();
- }
-
- for (int i = 0; i < (segCountX2 / 2); i++) {
- rangeOffset[i] = raInput.readUnsignedShort();
- }
-
- final int glyphIdArrayOffset = (int) raInput.getOffset();
-
- // Parse the table entries and build a CMap4 from them.
- final Cmap04Table cmap04 = new Cmap04Table(segCountX2 / 2);
- for (int i = 0; i < startCount.length; i++) {
- if (rangeOffset[i] == 0) {
- cmap04.addEntry(startCount[i],
- endCount[i],
- (short) (startCount[i] + deltas[i]));
- } else {
- final short[] computedIndexes = new short[endCount[i]
- - startCount[i] + 1];
- for (int j = startCount[i]; j <= endCount[i]; j++) {
- final short glyphOffset
- = (short) (glyphIdArrayOffset
- + ((rangeOffset[i] / 2)
- + (j - startCount[i])
- + i - segCountX2 / 2)
- * 2);
- raInput.seek(glyphOffset);
- final short glyphIndex =
- (short) ((raInput.readUnsignedShort()
- + deltas[i]) & Character.MAX_VALUE);
- computedIndexes[j - startCount[i]] = glyphIndex;
- }
- cmap04.addEntry(startCount[i], endCount[i], new ShortArray(computedIndexes));
- }
- }
- return cmap04;
- }
-
/**
* Returns the Unicode Cmap4a instance parsed from this table.
* @return The Unicode Cmap4a instance parsed from this table.
Modified: trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/Cmap04TableTests.java
===================================================================
--- trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/Cmap04TableTests.java 2025-04-28 11:00:22 UTC (rev 13533)
+++ trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/Cmap04TableTests.java 2025-04-28 13:03:24 UTC (rev 13534)
@@ -27,11 +27,10 @@
*/
package org.foray.font.ttf.table;
-import org.foray.primitive.sequence.ShortArray;
-
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
@@ -45,16 +44,19 @@
* All we care about is whether we can accurately encode & decode.
*/
@Test
+ @Disabled
public void test01() {
- final Cmap04Table out = new Cmap04Table(5);
+ final short[] glyphIdArray = {16537, 17001, 19000, 2000, 3000, 4000};
+ final Cmap04Table out = new Cmap04Table(5, glyphIdArray);
+
/* Add some contiguous segments. */
- out.addEntry(20, 30, 100);
- out.addEntry(120, 130, 200);
+ out.addEntry(0, 20, 30, 100, 0);
+ out.addEntry(1, 120, 130, 200, 0);
/* Add some non-contiguous segments. */
- out.addEntry(220, 222, new ShortArray((short) 16537, (short) 17001, (short) 19000));
- out.addEntry(320, 322, new ShortArray((short) 2000, (short) 3000, (short) 4000));
- out.addEntry(Character.MAX_VALUE, Character.MAX_VALUE, (short) 0);
+ out.addEntry(2, 220, 222, 0, 0);
+ out.addEntry(3, 320, 322, 0, 3);
+ out.addEntry(4, Character.MAX_VALUE, Character.MAX_VALUE, 0, 0);
assertFalse(out.canEncode(1));
assertTrue(out.canEncode(221));
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cmap04TableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cmap04TableParser.java 2025-04-28 11:00:22 UTC (rev 13533)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cmap04TableParser.java 2025-04-28 13:03:24 UTC (rev 13534)
@@ -62,24 +62,40 @@
handler.entrySelector(input.read_uint16()); // 2 bytes, total 12
handler.rangeShift(input.read_uint16()); // 2 bytes, total 14
+ final @Unsigned short[] endCodeArray = new @Unsigned short[segCount];
for (int segmentIndex = 0; segmentIndex < segCount; segmentIndex ++) {
- handler.endCode(input.read_uint16()); // 2 bytes @
+ final @Unsigned short endCode = input.read_uint16(); // 2 bytes @
+ handler.endCode(endCode);
+ endCodeArray[segmentIndex] = endCode;
}
+ handler.endCodeArray(endCodeArray);
/* Skip reservedPad. */
input.skipBytes(2); // 2 bytes
+ final @Unsigned short[] startCodeArray = new @Unsigned short[segCount];
for (int segmentIndex = 0; segmentIndex < segCount; segmentIndex ++) {
- handler.startCode(input.read_uint16()); // 2 bytes @
+ final @Unsigned short startCode = input.read_uint16(); // 2 bytes @
+ handler.startCode(startCode);
+ startCodeArray[segmentIndex] = startCode;
}
+ handler.startCodeArray(startCodeArray);
+ final @Unsigned short[] idDeltaArray = new @Unsigned short[segCount];
for (int segmentIndex = 0; segmentIndex < segCount; segmentIndex ++) {
- handler.idDelta(input.read_int16()); // 2 bytes @
+ final @Unsigned short idDelta = input.read_uint16(); // 2 bytes @
+ handler.idDelta(idDelta);
+ idDeltaArray[segmentIndex] = idDelta;
}
+ handler.idDeltaArray(idDeltaArray);
+ final @Unsigned short[] idRangeOffsetArray = new @Unsigned short[segCount];
for (int segmentIndex = 0; segmentIndex < segCount; segmentIndex ++) {
- handler.idRangeOffset(input.read_int16()); // 2 bytes @
+ final @Unsigned short idRangeOffset = input.read_int16(); // 2 bytes @
+ handler.idRangeOffset(idRangeOffset);
+ idRangeOffsetArray[segmentIndex] = idRangeOffset;
}
+ handler.idRangeOffsetArray(idRangeOffsetArray);
final int glyphIdArraySize = length - HEADER_BYTES - (BYTES_PER_SEGMENT * segCount) - 2;
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Cmap04TableHandler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Cmap04TableHandler.java 2025-04-28 11:00:22 UTC (rev 13533)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Cmap04TableHandler.java 2025-04-28 13:03:24 UTC (rev 13534)
@@ -44,10 +44,18 @@
default void searchRange(@Unsigned short value) { return; }
default void entrySelector(@Unsigned short value) { return; }
default void rangeShift(@Unsigned short value) { return; }
+
default void endCode(@Unsigned short value) { return; }
+ default void endCodeArray(@Unsigned short[] value) { return; }
default void startCode(@Unsigned short value) { return; }
+ default void startCodeArray(@Unsigned short[] value) { return; }
+
default void idDelta(@Unsigned short value) { return; }
+ default void idDeltaArray(@Unsigned short[] value) { return; }
+
default void idRangeOffset(@Unsigned short value) { return; }
+ default void idRangeOffsetArray(@Unsigned short[] value) { return; }
+
default void glyphIdArray(@Unsigned short[] value) { return; }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-28 11:00:42
|
Revision: 13533
http://sourceforge.net/p/foray/code/13533
Author: victormote
Date: 2025-04-28 11:00:22 +0000 (Mon, 28 Apr 2025)
Log Message:
-----------
Convert Cmap12 to new parsing scheme.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Table.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java
trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/Cmap12TableTests.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Table.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Table.java 2025-04-27 17:42:57 UTC (rev 13532)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Table.java 2025-04-28 11:00:22 UTC (rev 13533)
@@ -28,6 +28,10 @@
package org.foray.font.ttf.table;
+import org.foray.font.ttf.ParserKit;
+import org.foray.font.ttf.RoTable;
+import org.foray.fontParse.ttfHandler.Cmap12TableHandler;
+
import org.axsl.ps.Encoding;
import org.checkerframework.checker.signedness.qual.Unsigned;
@@ -36,14 +40,61 @@
* Class containing a set of 32-bit Unicode ranges that sequentially map to the same-sized range of glyph indexes.
* The contents are analogous to a Format 12 TrueType Font cmap table (from which this class derives its name).
*/
-public class Cmap12Table implements Encoding {
+public class Cmap12Table extends RoTable implements Encoding {
+ /**
+ * The handler of events from the parser.
+ */
+ private final class ContentHandler implements Cmap12TableHandler {
+
+ /** The table instance being created. */
+ private Cmap12Table table;
+
+ /** Index to the last entry added. */
+ private int lastEntryAdded = -1;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final Cmap12Table table) {
+ this.table = table;
+ }
+
+ @Override
+ public void numGroups(final @Unsigned int value) {
+ this.table.startCharCode = new @Unsigned int[value];
+ this.table.endCharCode = new @Unsigned int[value];
+ this.table.startGlyphID = new @Unsigned int[value];
+ return;
+ }
+
+ @Override
+ public void startCharCode(final @Unsigned int value) {
+ this.lastEntryAdded ++;
+ this.table.startCharCode[lastEntryAdded] = value;
+ }
+
+ @Override
+ public void endCharCode(final @Unsigned int value) {
+ this.table.endCharCode[lastEntryAdded] = value;
+ }
+
+ @Override
+ public void startGlyphID(final @Unsigned int value) {
+ this.table.startGlyphID[lastEntryAdded] = value;
+ }
+ }
+
+
+
+
+
+
+
/** Constant needed for serialization. */
public static final long serialVersionUID = -606154911100219394L;
- /** The name of this encoding. */
- private String name;
-
/** The first Unicode code point in this entry. */
private @Unsigned int[] startCharCode;
@@ -54,43 +105,53 @@
* representing {@link #startCharCode}. */
private @Unsigned int[] startGlyphID;
- /** Index to the last entry added. */
- private int lastEntryAdded = -1;
+ /**
+ * No-args Constructor, used by the parsing process.
+ */
+ public Cmap12Table() { }
/**
- * Constructor.
- * @param name The name of this encoding.
+ * Constructor used mainly for testing.
* @param expectedEntries The number of expected entries in this encoding.
- * Setting this to the correct value will result in more efficient
- * processing.
+ * Setting this to the correct value will result in more efficient processing.
*/
- public Cmap12Table(final String name, final int expectedEntries) {
- this.name = name;
+ public Cmap12Table(final int expectedEntries) {
this.startCharCode = new @Unsigned int[expectedEntries];
this.endCharCode = new @Unsigned int[expectedEntries];
this.startGlyphID = new @Unsigned int[expectedEntries];
}
- @Override
- public String getName() {
- return this.name;
+ /**
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
+ */
+ public static ParserKit<Cmap12Table, Cmap12TableHandler> createContentHandler() {
+ final Cmap12Table table = new Cmap12Table();
+ final Cmap12TableHandler handler = table.new ContentHandler(table);
+ return new ParserKit<Cmap12Table, Cmap12TableHandler>(table, handler);
}
- /**
+ /**
* Add a new entry to this map.
+ * This is used mostly for testing.
+ * @param index The index into which each of the other parameters should be placed.
* @param unicodeStart The starting Unicode code point for this map.
* @param unicodeEnd The ending Unicode code point for this map.
* @param glyphStartIndex The starting glyph index for this map.
* This index is the encoded value for {@code unicodeStart}.
*/
- public void addEntry(final int unicodeStart, final int unicodeEnd, final int glyphStartIndex) {
- this.lastEntryAdded ++;
- this.startCharCode[this.lastEntryAdded] = unicodeStart;
- this.endCharCode[this.lastEntryAdded] = unicodeEnd;
- this.startGlyphID[this.lastEntryAdded] = glyphStartIndex;
+ public void addEntry(final int index, final int unicodeStart, final int unicodeEnd, final int glyphStartIndex) {
+ this.startCharCode[index] = unicodeStart;
+ this.endCharCode[index] = unicodeEnd;
+ this.startGlyphID[index] = glyphStartIndex;
}
@Override
+ public String getName() {
+ return "internal";
+ }
+
+ @Override
public int encode(final int codePoint) {
for (int index = 0; index < this.startCharCode.length; index ++) {
if (codePoint >= this.startCharCode[index]
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java 2025-04-27 17:42:57 UTC (rev 13532)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java 2025-04-28 11:00:22 UTC (rev 13533)
@@ -28,10 +28,12 @@
package org.foray.font.ttf.table;
-import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.ParserKit;
import org.foray.font.ttf.RoTable;
+import org.foray.fontParse.ttf.Cmap12TableParser;
import org.foray.fontParse.ttf.CmapTableParser;
import org.foray.fontParse.ttf.TtfRandomAccessInput;
+import org.foray.fontParse.ttfHandler.Cmap12TableHandler;
import org.foray.primitive.sequence.ShortArray;
import org.axsl.ps.Encoding;
@@ -142,7 +144,10 @@
return parseCMap04(input, fontPostScriptName);
}
case CmapTableParser.CMAP_FORMAT_12: {
- return parseCMap12(input, fontPostScriptName);
+ final ParserKit<Cmap12Table, Cmap12TableHandler> contentHandler = Cmap12Table.createContentHandler();
+ final Cmap12TableParser parser = new Cmap12TableParser();
+ parser.parse(input, (int) (tableOffset + offsetToParse), contentHandler.getHandler());
+ return contentHandler.getTable();
}
}
return null;
@@ -224,33 +229,6 @@
}
/**
- * Creates a Cmap4a12 instance by parsing the subtable contents.
- * @param raInput The input which is being parsed.
- * @param fontPostScriptName The PostScript name of this font.
- * @return A Cmap4a12 instance.
- * @throws IOException If error reading file.
- * @see <a href="http://developer.apple.com/fonts/TTRefMan/RM06/Chap6cmap.html">The Apple doc for the cmap table</a>
- */
- private static Cmap12Table parseCMap12(final RandomAccessInput raInput, final String fontPostScriptName)
- throws IOException {
- /* Format and Length have already been read. */
- /* Skip language. */
- raInput.skipBytes(RoTable.ULONG_BYTES);
- final int nGroups = (int) raInput.readUnsignedInt();
-
- final String encodingName = "internal-" + fontPostScriptName;
- final Cmap12Table cmap12 = new Cmap12Table(encodingName, nGroups);
-
- for (int i = 0; i < nGroups; i++) {
- final int startCharCode = (int) raInput.readUnsignedInt();
- final int endCharCode = (int) raInput.readUnsignedInt();
- final int startGlyphCode = (int) raInput.readUnsignedInt();
- cmap12.addEntry(startCharCode, endCharCode, startGlyphCode);
- }
- return cmap12;
- }
-
- /**
* Returns the Unicode Cmap4a instance parsed from this table.
* @return The Unicode Cmap4a instance parsed from this table.
*/
Modified: trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/Cmap12TableTests.java
===================================================================
--- trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/Cmap12TableTests.java 2025-04-27 17:42:57 UTC (rev 13532)
+++ trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/Cmap12TableTests.java 2025-04-28 11:00:22 UTC (rev 13533)
@@ -42,12 +42,12 @@
*/
@Test
public void test01() {
- final Cmap12Table out = new Cmap12Table("test", 5);
- out.addEntry(20, 30, 100);
- out.addEntry(120, 130, 200);
- out.addEntry(220, 230, 300);
- out.addEntry(320, 330, 400);
- out.addEntry(420, 430, 500);
+ final Cmap12Table out = new Cmap12Table(5);
+ out.addEntry(0, 20, 30, 100);
+ out.addEntry(1, 120, 130, 200);
+ out.addEntry(2, 220, 230, 300);
+ out.addEntry(3, 320, 330, 400);
+ out.addEntry(4, 420, 430, 500);
assertFalse(out.canEncode(1));
assertTrue(out.canEncode(225));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-27 17:43:15
|
Revision: 13532
http://sourceforge.net/p/foray/code/13532
Author: victormote
Date: 2025-04-27 17:42:57 +0000 (Sun, 27 Apr 2025)
Log Message:
-----------
Rough-in parsers and handler for the Cmap tables.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java
Added Paths:
-----------
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cmap04TableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cmap12TableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CmapTableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Cmap04TableHandler.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Cmap12TableHandler.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/CmapTableHandler.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java 2025-04-27 14:22:12 UTC (rev 13531)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java 2025-04-27 17:42:57 UTC (rev 13532)
@@ -30,6 +30,7 @@
import org.foray.common.RandomAccessInput;
import org.foray.font.ttf.RoTable;
+import org.foray.fontParse.ttf.CmapTableParser;
import org.foray.fontParse.ttf.TtfRandomAccessInput;
import org.foray.primitive.sequence.ShortArray;
@@ -44,24 +45,6 @@
*/
public class CmapTable extends RoTable {
- /** Constant indicating that this Cmap4a table is in an unknown format. */
- public static final byte CMAP_FORMAT_UNKNOWN = -1;
-
- /** Constant indicating that this Cmap4a table is format 0. */
- public static final byte CMAP_FORMAT_0 = 0;
-
- /** Constant indicating that this Cmap4a table is format 2. */
- public static final byte CMAP_FORMAT_2 = 2;
-
- /** Constant indicating that this Cmap4a table is format 4. */
- public static final byte CMAP_FORMAT_4 = 4;
-
- /** Constant indicating that this Cmap4a table is format 6. */
- public static final byte CMAP_FORMAT_6 = 6;
-
- /** Constant indicating that this Cmap4a table is format 12. */
- public static final byte CMAP_FORMAT_12 = 12;
-
/** Constant indicating that the platform is Microsoft. */
protected static final int PLATFORM_MICROSOFT = 3;
@@ -148,7 +131,7 @@
final int formatHigh = input.readUnsignedShort();
// int formatLow = 0;
// long length = 0;
- if (formatHigh > CmapTable.CMAP_FORMAT_6) {
+ if (formatHigh > CmapTableParser.CMAP_FORMAT_6) {
/*formatLow = */input.readUnsignedShort();
/*length = */input.readUnsignedInt();
} else {
@@ -155,10 +138,10 @@
/*length = */input.readUnsignedShort();
}
switch (formatHigh) {
- case CmapTable.CMAP_FORMAT_4: {
+ case CmapTableParser.CMAP_FORMAT_4: {
return parseCMap04(input, fontPostScriptName);
}
- case CmapTable.CMAP_FORMAT_12: {
+ case CmapTableParser.CMAP_FORMAT_12: {
return parseCMap12(input, fontPostScriptName);
}
}
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cmap04TableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cmap04TableParser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cmap04TableParser.java 2025-04-27 17:42:57 UTC (rev 13532)
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.Cmap04TableHandler;
+
+import org.checkerframework.checker.signedness.qual.Unsigned;
+
+import java.io.IOException;
+
+/**
+ * Parses a TTF Cmap Type 4 subtable.
+ */
+public class Cmap04TableParser extends TableParser<Cmap04TableHandler> {
+
+ /** The number of bytes in the header portion of the table. */
+ private static final byte HEADER_BYTES = 14;
+
+ /** The number of bytes in each of the segment portions of the table. */
+ private static final int BYTES_PER_SEGMENT = 8;
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final Cmap04TableHandler handler)
+ throws IOException {
+ input.seek(offset);
+
+ handler.format(input.read_uint16()); // 2 bytes, total 2
+ final @Unsigned short length = input.read_uint16(); // 2 bytes, total 4
+ handler.length(length);
+ handler.language(input.read_uint16()); // 2 bytes, total 6
+ final @Unsigned short segCountX2 = input.read_uint16(); // 2 bytes, total 8
+ handler.segCountX2(segCountX2);
+ final @Unsigned short segCount = (short) (segCountX2 / 2);
+ handler.searchRange(input.read_uint16()); // 2 bytes, total 10
+ handler.entrySelector(input.read_uint16()); // 2 bytes, total 12
+ handler.rangeShift(input.read_uint16()); // 2 bytes, total 14
+
+ for (int segmentIndex = 0; segmentIndex < segCount; segmentIndex ++) {
+ handler.endCode(input.read_uint16()); // 2 bytes @
+ }
+
+ /* Skip reservedPad. */
+ input.skipBytes(2); // 2 bytes
+
+ for (int segmentIndex = 0; segmentIndex < segCount; segmentIndex ++) {
+ handler.startCode(input.read_uint16()); // 2 bytes @
+ }
+
+ for (int segmentIndex = 0; segmentIndex < segCount; segmentIndex ++) {
+ handler.idDelta(input.read_int16()); // 2 bytes @
+ }
+
+ for (int segmentIndex = 0; segmentIndex < segCount; segmentIndex ++) {
+ handler.idRangeOffset(input.read_int16()); // 2 bytes @
+ }
+
+
+ final int glyphIdArraySize = length - HEADER_BYTES - (BYTES_PER_SEGMENT * segCount) - 2;
+ final short[] glyphIdArray = new short [glyphIdArraySize];
+ for (int index = 0; index < glyphIdArraySize; index ++) {
+ glyphIdArray[index] = input.read_uint16();
+ }
+ handler.glyphIdArray(glyphIdArray);
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cmap04TableParser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cmap12TableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cmap12TableParser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cmap12TableParser.java 2025-04-27 17:42:57 UTC (rev 13532)
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.Cmap12TableHandler;
+
+import java.io.IOException;
+
+/**
+ * Parses a TTF Cmap Type 12 subtable.
+ */
+public class Cmap12TableParser extends TableParser<Cmap12TableHandler> {
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final Cmap12TableHandler handler)
+ throws IOException {
+ input.seek(offset);
+
+ handler.format(input.read_Offset16()); // 2 bytes, total 2
+ /* Skip reserved area. */
+ input.skipBytes(2); // 2 bytes, total 4
+ handler.length(input.read_uint32()); // 4 bytes, total 8
+ handler.language(input.read_uint32()); // 4 bytes, total 12
+ final int numGroups = input.read_uint32(); // 4 bytes, total 16
+ handler.numGroups(numGroups);
+
+ /* Parse each group. */ // *** Restart Count ***
+ for (int index = 0; index < numGroups; index ++) {
+ handler.startCharCode(input.read_uint32()); // 4 bytes, total 4
+ handler.endCharCode(input.read_uint32()); // 4 bytes, total 8
+ handler.startGlyphID(input.read_uint32()); // 4 bytes, total 12
+ }
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Cmap12TableParser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CmapTableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CmapTableParser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CmapTableParser.java 2025-04-27 17:42:57 UTC (rev 13532)
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.Cmap04TableHandler;
+import org.foray.fontParse.ttfHandler.Cmap12TableHandler;
+import org.foray.fontParse.ttfHandler.CmapTableHandler;
+
+import org.checkerframework.checker.signedness.qual.Unsigned;
+
+import java.io.IOException;
+
+/**
+ * Parses a TTF Cmap table.
+ */
+public class CmapTableParser extends TableParser<CmapTableHandler> {
+
+ /** Constant indicating that this Cmap4a table is in an unknown format. */
+ public static final byte CMAP_FORMAT_UNKNOWN = -1;
+
+ /** Constant indicating that this Cmap4a table is format 0. */
+ public static final byte CMAP_FORMAT_0 = 0;
+
+ /** Constant indicating that this Cmap4a table is format 2. */
+ public static final byte CMAP_FORMAT_2 = 2;
+
+ /** Constant indicating that this Cmap4a table is format 4. */
+ public static final byte CMAP_FORMAT_4 = 4;
+
+ /** Constant indicating that this Cmap4a table is format 6. */
+ public static final byte CMAP_FORMAT_6 = 6;
+
+ /** Constant indicating that this Cmap4a table is format 12. */
+ public static final byte CMAP_FORMAT_12 = 12;
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final CmapTableHandler handler)
+ throws IOException {
+ input.seek(offset);
+
+ /* Read the header. */
+ handler.version(input.read_uint16()); // 2 bytes, total 2
+ final @Unsigned short numTables = input.read_uint16(); // 2 bytes, total 4
+ handler.numTables(numTables);
+
+ /* Read each EncodingRecord, parsing the related subtable as we go. */
+ for (int index = 0; index < numTables; index ++) { // *** Restart count ***
+ handler.platformID(input.read_uint16()); // 2 bytes, total 2
+ handler.encodingID(input.read_uint16()); // 2 bytes, total 4
+ final @Unsigned int subtableOffset = input.read_Offset32(); // 4 bytes, total 8
+ handler.subtableOffset(subtableOffset);
+
+ /* Read the format from the subtable. */ // *** Restart count ***
+ final long bookmark = input.getOffset();
+ final int absoluteSubtableOffset = offset + subtableOffset;
+
+ input.seek(absoluteSubtableOffset);
+ final @Unsigned short format = input.read_uint16(); // 2 bytes, total 2
+ handler.subtableFormat(format);
+
+ /* Read the subtable. */
+ switch (format) {
+ case CMAP_FORMAT_4: {
+ final Cmap04TableHandler cmap04Handler = handler.startCmap04Table();
+ final Cmap04TableParser cmap04Parser = new Cmap04TableParser();
+ cmap04Parser.parse(input, absoluteSubtableOffset, cmap04Handler);
+ break;
+ }
+ case CMAP_FORMAT_12: {
+ final Cmap12TableHandler cmap12Handler = handler.startCmap12Table();
+ final Cmap12TableParser cmap12Parser = new Cmap12TableParser();
+ cmap12Parser.parse(input, absoluteSubtableOffset, cmap12Handler);
+ break;
+ }
+ default: throw new UnsupportedOperationException("Cmap subtable format not supported: " + format);
+ }
+
+
+ /* Subtable has been read. Return to the bookmark so that the next */
+ input.seek(bookmark);
+ }
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/CmapTableParser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Cmap04TableHandler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Cmap04TableHandler.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Cmap04TableHandler.java 2025-04-27 17:42:57 UTC (rev 13532)
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttfHandler;
+
+import org.foray.fontParse.FontContentHandler;
+
+import org.checkerframework.checker.signedness.qual.Unsigned;
+
+/**
+ * Implementations catch and handle the output from {@link org.foray.fontParse.ttf.Cmap04TableParser}.
+ */
+public interface Cmap04TableHandler extends FontContentHandler {
+
+ default void format(@Unsigned short value) { return; }
+ default void length(@Unsigned short value) { return; }
+ default void language(@Unsigned short value) { return; }
+ default void segCountX2(@Unsigned short value) { return; }
+ default void searchRange(@Unsigned short value) { return; }
+ default void entrySelector(@Unsigned short value) { return; }
+ default void rangeShift(@Unsigned short value) { return; }
+ default void endCode(@Unsigned short value) { return; }
+
+ default void startCode(@Unsigned short value) { return; }
+ default void idDelta(@Unsigned short value) { return; }
+ default void idRangeOffset(@Unsigned short value) { return; }
+ default void glyphIdArray(@Unsigned short[] value) { return; }
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Cmap04TableHandler.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Cmap12TableHandler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Cmap12TableHandler.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Cmap12TableHandler.java 2025-04-27 17:42:57 UTC (rev 13532)
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttfHandler;
+
+import org.foray.fontParse.FontContentHandler;
+
+import org.checkerframework.checker.signedness.qual.Unsigned;
+
+/**
+ * Implementations catch and handle the output from {@link org.foray.fontParse.ttf.Cmap12TableParser}.
+ */
+public interface Cmap12TableHandler extends FontContentHandler {
+
+ default void format(@Unsigned short value) { return; }
+ default void length(@Unsigned int value) { return; }
+ default void language(@Unsigned int value) { return; }
+ default void numGroups(@Unsigned int value) { return; }
+
+ default void startCharCode(@Unsigned int value) { return; }
+ default void endCharCode(@Unsigned int value) { return; }
+ default void startGlyphID(@Unsigned int value) { return; }
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Cmap12TableHandler.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/CmapTableHandler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/CmapTableHandler.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/CmapTableHandler.java 2025-04-27 17:42:57 UTC (rev 13532)
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttfHandler;
+
+import org.foray.fontParse.FontContentHandler;
+
+import org.checkerframework.checker.signedness.qual.Unsigned;
+
+/**
+ * Implementations catch and handle the output from {@link org.foray.fontParse.ttf.CmapTableParser}.
+ */
+public interface CmapTableHandler extends FontContentHandler {
+
+ default void version(@Unsigned short value) { return; }
+ default void numTables(@Unsigned short value) { return; }
+
+ /* Encoding record. */
+ default void platformID(@Unsigned short value) { return; }
+ default void encodingID(@Unsigned short value) { return; }
+ default void subtableOffset(@Unsigned int value) { return; }
+
+ /* Read and return the subtable format. This is actually part of the subtable, but most clients will want to know
+ * which subtable format they are parsing before they start parsing it. */
+ default void subtableFormat(@Unsigned short value) { return; }
+
+ default Cmap04TableHandler startCmap04Table() { return null; }
+ default Cmap12TableHandler startCmap12Table() { return null; }
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/CmapTableHandler.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-27 14:22:30
|
Revision: 13531
http://sourceforge.net/p/foray/code/13531
Author: victormote
Date: 2025-04-27 14:22:12 +0000 (Sun, 27 Apr 2025)
Log Message:
-----------
Add tests and cleanup logic for Cmap4 decode.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java
trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/Cmap04TableTests.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java 2025-04-27 13:55:29 UTC (rev 13530)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java 2025-04-27 14:22:12 UTC (rev 13531)
@@ -128,17 +128,18 @@
public int decode(final int glyphIndex) {
for (int i = 0; i < this.unicodeStart.length; i++) {
if (this.glyphIndexes[i] == null) {
- final int codePoint = glyphIndex - this.glyphStartIndex[i] + this.unicodeStart[i];
- if (glyphIndex >= this.glyphStartIndex[i]
- && codePoint <= this.unicodeStart[i]) {
- return codePoint;
+ final int provisionalCodePoint = glyphIndex - this.glyphStartIndex[i] + this.unicodeStart[i];
+ if (provisionalCodePoint >= this.unicodeStart[i]
+ && provisionalCodePoint <= this.unicodeEnd[i]) {
+ return provisionalCodePoint;
}
- return -1;
- }
- for (int j = 0; j < this.glyphIndexes[i].length(); j++) {
- if (this.glyphIndexes[i].shortAt(j) == glyphIndex) {
- return this.unicodeStart[i] + j;
+ } else {
+ for (int j = 0; j < this.glyphIndexes[i].length(); j++) {
+ if (this.glyphIndexes[i].shortAt(j) == glyphIndex) {
+ return this.unicodeStart[i] + j;
+ }
}
+
}
}
return -1;
Modified: trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/Cmap04TableTests.java
===================================================================
--- trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/Cmap04TableTests.java 2025-04-27 13:55:29 UTC (rev 13530)
+++ trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/Cmap04TableTests.java 2025-04-27 14:22:12 UTC (rev 13531)
@@ -63,7 +63,9 @@
assertEquals(-1, out.encode(40));
assertEquals(3000, out.encode(321));
- /* TODO: Add test for decode(), which is low priority, probably never used. */
+ assertEquals(25, out.decode(105));
+ assertEquals(-1, out.decode(1500));
+ assertEquals(321, out.decode(3000));
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-27 13:55:47
|
Revision: 13530
http://sourceforge.net/p/foray/code/13530
Author: victormote
Date: 2025-04-27 13:55:29 +0000 (Sun, 27 Apr 2025)
Log Message:
-----------
Flatten inner class into parallel arrays.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java 2025-04-27 13:16:35 UTC (rev 13529)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java 2025-04-27 13:55:29 UTC (rev 13530)
@@ -39,122 +39,6 @@
*/
public class Cmap04Table implements Encoding {
- /**
- * Contains one entry from a TrueType Cmap4a subtable, format 4, which handles
- * 16-bit Unicode code point ranges.
- */
- public class Entry {
-
- /** The first Unicode code point in this entry. */
- private @Unsigned short unicodeStart;
-
- /** The last Unicode code point in this entry.*/
- private @Unsigned short unicodeEnd;
-
- /** The starting glyph index for this entry. This index points to the glyph
- * representing {@link #unicodeStart}. */
- private @Unsigned short glyphStartIndex;
-
- /** The list of non-contiguous entries, if any, for this entry.
- * For contiguous entries, this will be null.
- * For non-contiguous entries, this array contains the glyph Indexes for the range of Unicode characters. */
- private ShortSequence glyphIndexes;
-
- /**
- * Constructor for contiguous entries.
- * @param unicodeStart The starting Unicode code point covered by this
- * mapping.
- * @param unicodeEnd The ending Unicode code point covered by this mapping.
- * @param glyphStartIndex The starting glyph index mapped by this mapping.
- * This is the encoded value for {@code unicodeStart}.
- */
- public Entry(final @Unsigned short unicodeStart, final @Unsigned short unicodeEnd,
- final @Unsigned short glyphStartIndex) {
- this.unicodeStart = unicodeStart;
- this.unicodeEnd = unicodeEnd;
- this.glyphStartIndex = glyphStartIndex;
- }
-
- /**
- * Constructor for non-contiguous entries.
- * @param unicodeStart The starting Unicode code point covered by this
- * mapping.
- * @param unicodeEnd The ending Unicode code point covered by this mapping.
- * @param glyphIndexes The array of encoded glyph indexes corresponding to
- * the range {@code unicodeStart} through {@code unicodeEnd}.
- */
- public Entry(final @Unsigned short unicodeStart, final @Unsigned short unicodeEnd,
- final ShortSequence glyphIndexes) {
- this.unicodeStart = unicodeStart;
- this.unicodeEnd = unicodeEnd;
- this.glyphIndexes = glyphIndexes;
- }
-
- /**
- * Compute the glyphEndIndex that is implied from the raw data.
- * @return The last glyphIndex that is addressed by this entry, i.e. the
- * glyph index that corresponds to unicodeEnd.
- */
- public char getGlyphEndIndex() {
- return (char) (this.glyphStartIndex + this.unicodeEnd
- - this.unicodeStart);
- }
-
- /**
- * Indicates whether this entry can encode a given character.
- * @param c The character to be tested.
- * @return True if and only if this entry has encoding information for {@code c}.
- */
- public boolean containsChar(final int c) {
- return (c >= this.unicodeStart) && (c <= this.unicodeEnd);
- }
-
- /**
- * Encodes a given character.
- * @param c The character to be encoded.
- * @return The glyph index corresponding to {@code c}, or -1 if this entry does not know how to encode it.
- */
- public int encodeCharacter(final int c) {
- if (! containsChar(c)) {
- return -1;
- }
- if (this.glyphIndexes == null) {
- return (char) (c - this.unicodeStart + this.glyphStartIndex);
- }
- return this.glyphIndexes.shortAt(c - this.unicodeStart);
- }
-
- /**
- * Decodes a given glyphIndex.
- * @param glyphIndex The glyph index to be decoded.
- * @return The Unicode code point corresponding to {@code glyphIndex}, or -1 if this entry does not know how to
- * decode it.
- */
- public int decodeCharacter(final int glyphIndex) {
- if (this.glyphIndexes == null) {
- final char codePoint = (char) (glyphIndex - this.glyphStartIndex + this.unicodeStart);
- if (glyphIndex >= this.glyphStartIndex
- && codePoint <= this.unicodeStart) {
- return codePoint;
- }
- return -1;
- }
- for (int i = 0; i < this.glyphIndexes.length(); i++) {
- if (this.glyphIndexes.shortAt(i) == glyphIndex) {
- return this.unicodeStart + i;
- }
- }
- return -1;
- }
-
- }
-
-
-
-
-
-
-
/** Constant needed for serialization. */
public static final long serialVersionUID = 985957847129472354L;
@@ -161,12 +45,24 @@
/** The name of this encoding. */
private String name;
- /** The array of entries. */
- private Entry[] entries;
-
/** Index to the last entry added. */
private int lastEntryAdded = -1;
+ /** The first Unicode code point in this entry. */
+ private @Unsigned short unicodeStart[];
+
+ /** The last Unicode code point in this entry.*/
+ private @Unsigned short unicodeEnd[];
+
+ /** The starting glyph index for this entry. This index points to the glyph
+ * representing {@link #unicodeStart}. */
+ private @Unsigned short glyphStartIndex[];
+
+ /** The list of non-contiguous entries, if any, for this entry.
+ * For contiguous entries, this will be null.
+ * For non-contiguous entries, this array contains the glyph Indexes for the range of Unicode characters. */
+ private ShortSequence glyphIndexes[];
+
/**
* Constructor.
* @param expectedEntries The number of expected entries in this encoding.
@@ -174,7 +70,10 @@
* processing.
*/
public Cmap04Table(final int expectedEntries) {
- this.entries = new Entry[expectedEntries];
+ this.unicodeStart = new short[expectedEntries];
+ this.unicodeEnd = new short[expectedEntries];
+ this.glyphStartIndex = new short[expectedEntries];
+ this.glyphIndexes = new ShortSequence[expectedEntries];
}
@Override
@@ -183,19 +82,6 @@
}
/**
- * Add a new entry to this map.
- * @param entry The entry to be added.
- */
- public void addEntry(final Entry entry) {
- this.lastEntryAdded++;
- if (this.lastEntryAdded >= this.entries.length) {
- // Fails silently.
- return;
- }
- this.entries[this.lastEntryAdded] = entry;
- }
-
- /**
* Add a new entry to this map for contiguous values.
* @param unicodeStart The starting Unicode code point for this map.
* @param unicodeEnd The ending Unicode code point for this map.
@@ -204,9 +90,10 @@
*/
public void addEntry(final @Unsigned int unicodeStart, final @Unsigned int unicodeEnd,
final @Unsigned int glyphStartIndex) {
- final Entry newEntry = new Entry((@Unsigned short) unicodeStart, (@Unsigned short) unicodeEnd,
- (@Unsigned short) glyphStartIndex);
- addEntry(newEntry);
+ this.lastEntryAdded ++;
+ this.unicodeStart[this.lastEntryAdded] = (short) unicodeStart;
+ this.unicodeEnd[this.lastEntryAdded] = (short) unicodeEnd;
+ this.glyphStartIndex[this.lastEntryAdded] = (short) glyphStartIndex;
}
/**
@@ -217,40 +104,42 @@
* {@code unicodeEnd}.
*/
public void addEntry(final int unicodeStart, final @Unsigned int unicodeEnd, final ShortSequence glyphIndexes) {
- final Entry newEntry = new Entry((@Unsigned short) unicodeStart, (@Unsigned short) unicodeEnd, glyphIndexes);
- addEntry(newEntry);
+ this.lastEntryAdded ++;
+ this.unicodeStart[this.lastEntryAdded] = (short) unicodeStart;
+ this.unicodeEnd[this.lastEntryAdded] = (short) unicodeEnd;
+ this.glyphIndexes[this.lastEntryAdded] = glyphIndexes;
}
@Override
public int encode(final int c) {
- final Entry entry = entryForChar((char) c);
- if (entry == null) {
- return -1;
- }
- return entry.encodeCharacter((char) c);
- }
-
- /**
- * Find the entry for a given character.
- * @param c The character for which an entry is sought.
- * @return The entry, or null if none is defined for {@code c}.
- */
- private Entry entryForChar(final char c) {
- for (int i = 0; i < this.entries.length; i++) {
- if (this.entries[i].containsChar(c)) {
- return this.entries[i];
+ for (int i = 0; i < this.unicodeStart.length; i++) {
+ if ((c >= this.unicodeStart[i])
+ && (c <= this.unicodeEnd[i])) {
+ if (this.glyphIndexes[i] == null) {
+ return (c - this.unicodeStart[i] + this.glyphStartIndex[i]);
+ }
+ return this.glyphIndexes[i].shortAt(c - this.unicodeStart[i]);
}
}
- return null;
+ return -1;
}
@Override
- public int decode(final int glyphIndexInput) {
- for (int i = 0; i < this.entries.length; i++) {
- final int codePoint = this.entries[i].decodeCharacter(glyphIndexInput);
- if (codePoint > -1) {
- return codePoint;
+ public int decode(final int glyphIndex) {
+ for (int i = 0; i < this.unicodeStart.length; i++) {
+ if (this.glyphIndexes[i] == null) {
+ final int codePoint = glyphIndex - this.glyphStartIndex[i] + this.unicodeStart[i];
+ if (glyphIndex >= this.glyphStartIndex[i]
+ && codePoint <= this.unicodeStart[i]) {
+ return codePoint;
+ }
+ return -1;
}
+ for (int j = 0; j < this.glyphIndexes[i].length(); j++) {
+ if (this.glyphIndexes[i].shortAt(j) == glyphIndex) {
+ return this.unicodeStart[i] + j;
+ }
+ }
}
return -1;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-27 13:16:51
|
Revision: 13529
http://sourceforge.net/p/foray/code/13529
Author: victormote
Date: 2025-04-27 13:16:35 +0000 (Sun, 27 Apr 2025)
Log Message:
-----------
Improvements to Cmap04.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java
trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/Cmap04TableTests.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java 2025-04-27 12:35:03 UTC (rev 13528)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java 2025-04-27 13:16:35 UTC (rev 13529)
@@ -28,6 +28,7 @@
package org.foray.font.ttf.table;
+import org.axsl.primitive.sequence.ShortSequence;
import org.axsl.ps.Encoding;
import org.checkerframework.checker.signedness.qual.Unsigned;
@@ -57,7 +58,7 @@
/** The list of non-contiguous entries, if any, for this entry.
* For contiguous entries, this will be null.
* For non-contiguous entries, this array contains the glyph Indexes for the range of Unicode characters. */
- private CharSequence glyphIndexes;
+ private ShortSequence glyphIndexes;
/**
* Constructor for contiguous entries.
@@ -83,7 +84,7 @@
* the range {@code unicodeStart} through {@code unicodeEnd}.
*/
public Entry(final @Unsigned short unicodeStart, final @Unsigned short unicodeEnd,
- final CharSequence glyphIndexes) {
+ final ShortSequence glyphIndexes) {
this.unicodeStart = unicodeStart;
this.unicodeEnd = unicodeEnd;
this.glyphIndexes = glyphIndexes;
@@ -120,7 +121,7 @@
if (this.glyphIndexes == null) {
return (char) (c - this.unicodeStart + this.glyphStartIndex);
}
- return this.glyphIndexes.charAt(c - this.unicodeStart);
+ return this.glyphIndexes.shortAt(c - this.unicodeStart);
}
/**
@@ -139,7 +140,7 @@
return -1;
}
for (int i = 0; i < this.glyphIndexes.length(); i++) {
- if (this.glyphIndexes.charAt(i) == glyphIndex) {
+ if (this.glyphIndexes.shortAt(i) == glyphIndex) {
return this.unicodeStart + i;
}
}
@@ -215,7 +216,7 @@
* @param glyphIndexes The array of glyph indexes corresponding to the range {@code unicodeStart} through
* {@code unicodeEnd}.
*/
- public void addEntry(final int unicodeStart, final @Unsigned int unicodeEnd, final CharSequence glyphIndexes) {
+ public void addEntry(final int unicodeStart, final @Unsigned int unicodeEnd, final ShortSequence glyphIndexes) {
final Entry newEntry = new Entry((@Unsigned short) unicodeStart, (@Unsigned short) unicodeEnd, glyphIndexes);
addEntry(newEntry);
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java 2025-04-27 12:35:03 UTC (rev 13528)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java 2025-04-27 13:16:35 UTC (rev 13529)
@@ -31,6 +31,7 @@
import org.foray.common.RandomAccessInput;
import org.foray.font.ttf.RoTable;
import org.foray.fontParse.ttf.TtfRandomAccessInput;
+import org.foray.primitive.sequence.ShortArray;
import org.axsl.ps.Encoding;
@@ -218,22 +219,22 @@
endCount[i],
(short) (startCount[i] + deltas[i]));
} else {
- final char[] computedIndexes = new char[endCount[i]
+ final short[] computedIndexes = new short[endCount[i]
- startCount[i] + 1];
for (int j = startCount[i]; j <= endCount[i]; j++) {
- final int glyphOffset
- = glyphIdArrayOffset
+ final short glyphOffset
+ = (short) (glyphIdArrayOffset
+ ((rangeOffset[i] / 2)
+ (j - startCount[i])
+ i - segCountX2 / 2)
- * 2;
+ * 2);
raInput.seek(glyphOffset);
- final char glyphIndex =
- (char) ((raInput.readUnsignedShort()
+ final short glyphIndex =
+ (short) ((raInput.readUnsignedShort()
+ deltas[i]) & Character.MAX_VALUE);
computedIndexes[j - startCount[i]] = glyphIndex;
}
- cmap04.addEntry(startCount[i], endCount[i], new String(computedIndexes));
+ cmap04.addEntry(startCount[i], endCount[i], new ShortArray(computedIndexes));
}
}
return cmap04;
Modified: trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/Cmap04TableTests.java
===================================================================
--- trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/Cmap04TableTests.java 2025-04-27 12:35:03 UTC (rev 13528)
+++ trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/Cmap04TableTests.java 2025-04-27 13:16:35 UTC (rev 13529)
@@ -27,10 +27,11 @@
*/
package org.foray.font.ttf.table;
+import org.foray.primitive.sequence.ShortArray;
+
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
@@ -44,23 +45,25 @@
* All we care about is whether we can accurately encode & decode.
*/
@Test
- @Disabled
public void test01() {
final Cmap04Table out = new Cmap04Table(5);
/* Add some contiguous segments. */
- out.addEntry(20, 30, (short) 100);
- out.addEntry(120, 130, (short) 200);
+ out.addEntry(20, 30, 100);
+ out.addEntry(120, 130, 200);
/* Add some non-contiguous segments. */
- out.addEntry(220, 230, "abc");
- out.addEntry(320, 330, "xyz");
+ out.addEntry(220, 222, new ShortArray((short) 16537, (short) 17001, (short) 19000));
+ out.addEntry(320, 322, new ShortArray((short) 2000, (short) 3000, (short) 4000));
out.addEntry(Character.MAX_VALUE, Character.MAX_VALUE, (short) 0);
assertFalse(out.canEncode(1));
- assertTrue(out.canEncode(225));
+ assertTrue(out.canEncode(221));
- assertEquals(401, out.encode(321));
- assertEquals(321, out.decode(401));
+ assertEquals(105, out.encode(25));
+ assertEquals(-1, out.encode(40));
+ assertEquals(3000, out.encode(321));
+
+ /* TODO: Add test for decode(), which is low priority, probably never used. */
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|