foray-commit Mailing List for FOray (Page 17)
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-04-22 12:59:17
|
Revision: 13477
http://sourceforge.net/p/foray/code/13477
Author: victormote
Date: 2025-04-22 12:58:59 +0000 (Tue, 22 Apr 2025)
Log Message:
-----------
Add more table and parser classes in support of the BASE table.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseAxisTableParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseAxisTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseScriptTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseTable.java
Added Paths:
-----------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseScriptTableParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/AdjustmentTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseCoordTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseValuesTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/DeviceTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/VariationIndexTable.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseAxisTableParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseAxisTableParser.java 2025-04-22 11:00:14 UTC (rev 13476)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseAxisTableParser.java 2025-04-22 12:58:59 UTC (rev 13477)
@@ -66,6 +66,7 @@
input.seek(offset + baseScriptListOffset);
final short baseScriptCount = input.read_uint16();
handler.primitiveField("baseScriptCount", ferry.setShort(baseScriptCount));
+ final short[] baseScriptOffsets = new short[baseScriptCount];
for (int index = 0; index < baseScriptCount; index ++) {
handler.objectField("baseScriptTag", input.read_Tag());
final short baseScriptOffset = input.read_Offset16();
@@ -73,6 +74,13 @@
}
// ********** Base Script Subtable **********
+ for (int index = 0; index < baseScriptOffsets.length; index ++) {
+ final FontContentHandler newHandler = handler.startTable("script");
+ final BaseScriptTableParser parser = new BaseScriptTableParser();
+ final int scriptTableOffset = baseScriptListOffset + baseScriptOffsets[index];
+ parser.parse(input, scriptTableOffset, size, newHandler);
+ }
+
}
}
Added: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseScriptTableParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseScriptTableParser.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseScriptTableParser.java 2025-04-22 12:58:59 UTC (rev 13477)
@@ -0,0 +1,59 @@
+/*
+ * 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.parse;
+
+import org.foray.common.primitive.PrimitiveFerry;
+import org.foray.font.FontContentHandler;
+import org.foray.font.FontParser;
+import org.foray.font.ttf.TtfRandomAccessInput;
+
+import java.io.IOException;
+
+/**
+ * Parses a TTF BASE table.
+ * @see org.foray.font.ttf.table.BaseTable
+ */
+public class BaseScriptTableParser extends FontParser {
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final int size,
+ final FontContentHandler startingHandler) throws IOException {
+ final FontContentHandler handler = initialize(startingHandler);
+ final PrimitiveFerry ferry = new PrimitiveFerry();
+ input.seek(offset);
+
+ final short baseValuesOffset = input.read_Offset16(); // 2 bytes, total 2
+ handler.primitiveField("baseValuesOffset", ferry.setShort(baseValuesOffset));
+ final short defaultMinMaxOffset = input.read_Offset16(); // 2 bytes, total 4
+ handler.primitiveField("defaultMinMaxOffset", ferry.setShort(defaultMinMaxOffset));
+ final short baseLangSysCount = input.read_uint16(); // 2 bytes, total 6
+ handler.primitiveField("baseLangSysCount", ferry.setShort(baseLangSysCount));
+ }
+
+}
Property changes on: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseScriptTableParser.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/AdjustmentTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/AdjustmentTable.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/AdjustmentTable.java 2025-04-22 12:58:59 UTC (rev 13477)
@@ -0,0 +1,36 @@
+/*
+ * 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;
+
+/**
+ * Interface for tables that make adjustments to values in other tables.
+ */
+public interface AdjustmentTable {
+
+}
Property changes on: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/AdjustmentTable.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/BaseAxisTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseAxisTable.java 2025-04-22 11:00:14 UTC (rev 13476)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseAxisTable.java 2025-04-22 12:58:59 UTC (rev 13477)
@@ -55,7 +55,14 @@
@Override
public FontContentHandler startTable(final String tableName) {
- return null;
+ switch (tableName) {
+ case "script": {
+ final TtfContentHandler<BaseScriptTable> handler = BaseScriptTable.createContentHandler();
+ getTable().scriptTables.add(handler.getTable());
+ return handler;
+ }
+ default: return null;
+ }
}
@Override
Added: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseCoordTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseCoordTable.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseCoordTable.java 2025-04-22 12:58:59 UTC (rev 13477)
@@ -0,0 +1,135 @@
+/*
+ * 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.common.primitive.PrimitiveFerry;
+import org.foray.font.ttf.RoTable;
+import org.foray.font.ttf.TtfContentHandler;
+
+/**
+ * A BASE table, BaseCoord subtable.
+ * There are 3 different table formats for BaseCoord records.
+ * This class is the union of those 3 formats.
+ */
+public class BaseCoordTable extends RoTable {
+ /* TODO: Consider splitting this class into 3 or 4 classes, to save memory. */
+
+ /** The handler of events from the parser. */
+ private final class ContentHandler extends TtfContentHandler<BaseCoordTable> {
+
+ /**
+ * Constructor.
+ * @param table The client being built from the parser results.
+ */
+ private ContentHandler(final BaseCoordTable table) {
+ super(table);
+ }
+
+ @Override
+ public TtfContentHandler<?> startTable(final String tableName) {
+ return null;
+ }
+
+ @Override
+ public void objectField(final String fieldName, final Object value) {
+ }
+
+ @Override
+ public void primitiveField(final String fieldName, final PrimitiveFerry value) {
+ }
+
+ }
+
+ /** (All formats) The format identifier. Should be 1, 2, or 3. */
+ private byte format;
+
+ /** (All formats) Either an x or a y coordinate (depending on axis), in design units. */
+ private short coordinate;
+
+ /** (Format 2 only) The glyph ID of the control glyph. */
+ private short referenceGlyph;
+
+ /** (Format 2 only) The index of the contour point on the reference glyph. */
+ private short baseCoordPoint;
+
+ /** (Format 3 only) Either a {@link DeviceTable} (for non-variable fonts) or {@link VariationIndexTable} (for
+ * variable fonts). */
+ private AdjustmentTable adjustmentTable;
+
+ /**
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
+ */
+ public static TtfContentHandler<BaseCoordTable> createContentHandler() {
+ final BaseCoordTable table = new BaseCoordTable();
+ return table.new ContentHandler(table);
+ }
+
+ /**
+ * Returns (All formats) The format identifier. Should be 1, 2, or 3.
+ * @return The format.
+ */
+ public byte getFormat() {
+ return format;
+ }
+
+ /**
+ * Returns (All formats) Either an x or a y coordinate (depending on axis), in design units.
+ * @return The coordinate.
+ */
+ public short getCoordinate() {
+ return coordinate;
+ }
+
+ /**
+ * Returns (Format 2 only) The glyph ID of the control glyph.
+ * @return The referenceGlyph.
+ */
+ public short getReferenceGlyph() {
+ return referenceGlyph;
+ }
+
+ /**
+ * Returns (Format 2 only) The index of the contour point on the reference glyph.
+ * @return The baseCoordPoint.
+ */
+ public short getBaseCoordPoint() {
+ return baseCoordPoint;
+ }
+
+ /**
+ * (Format 3 only) Either a {@link DeviceTable} (for non-variable fonts) or {@link VariationIndexTable} (for
+ * variable fonts).
+ * @return The adjustmentTable.
+ */
+ public AdjustmentTable getAdjustmentTable() {
+ return adjustmentTable;
+ }
+
+}
Property changes on: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseCoordTable.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/BaseScriptTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseScriptTable.java 2025-04-22 11:00:14 UTC (rev 13476)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseScriptTable.java 2025-04-22 12:58:59 UTC (rev 13477)
@@ -63,6 +63,9 @@
}
+ /** The values for this script. */
+ private BaseValuesTable values;
+
/**
* Creates a table instance and a content handler for that instance.
* @return A new content handler.
@@ -72,4 +75,12 @@
return table.new ContentHandler(table);
}
+ /**
+ * Returns the values for this script.
+ * @return The values for this script.
+ */
+ public BaseValuesTable getValues() {
+ return this.values;
+ }
+
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseTable.java 2025-04-22 11:00:14 UTC (rev 13476)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseTable.java 2025-04-22 12:58:59 UTC (rev 13477)
@@ -63,7 +63,6 @@
return handler;
}
default: return null;
-
}
}
Added: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseValuesTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseValuesTable.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseValuesTable.java 2025-04-22 12:58:59 UTC (rev 13477)
@@ -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.common.primitive.PrimitiveFerry;
+import org.foray.font.ttf.RoTable;
+import org.foray.font.ttf.TtfContentHandler;
+
+/**
+ * A BASE table, BaseValues subtable.
+ */
+public class BaseValuesTable extends RoTable {
+
+ /** The handler of events from the parser. */
+ private final class ContentHandler extends TtfContentHandler<BaseValuesTable> {
+
+ /**
+ * Constructor.
+ * @param table The client being built from the parser results.
+ */
+ private ContentHandler(final BaseValuesTable table) {
+ super(table);
+ }
+
+ @Override
+ public TtfContentHandler<?> startTable(final String tableName) {
+ return null;
+ }
+
+ @Override
+ public void objectField(final String fieldName, final Object value) {
+ }
+
+ @Override
+ public void primitiveField(final String fieldName, final PrimitiveFerry value) {
+ }
+
+ }
+
+ /** Index into the tags array for the default baseline for this script. */
+ private short defaultBaselineIndex;
+
+ /**
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
+ */
+ public static TtfContentHandler<BaseValuesTable> createContentHandler() {
+ final BaseValuesTable table = new BaseValuesTable();
+ return table.new ContentHandler(table);
+ }
+
+ /**
+ * Returns the index into the tags array for the default baseline for this script.
+ * @return the index into the tags array for the default baseline for this script.
+ */
+ public short getDefaultBaselineIndex() {
+ return this.defaultBaselineIndex;
+ }
+
+}
Property changes on: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseValuesTable.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/DeviceTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/DeviceTable.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/DeviceTable.java 2025-04-22 12:58:59 UTC (rev 13477)
@@ -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.font.ttf.table;
+
+import org.foray.common.primitive.PrimitiveFerry;
+import org.foray.font.ttf.RoTable;
+import org.foray.font.ttf.TtfContentHandler;
+
+/**
+ * An OpenType Device table, listed as an "OpenType(tm) Layout Common Table Format".
+ * Used for adjustments within non-variable (regular) fonts.
+ * See {@link VariationIndexTable} for a similar table used for variable fonts.
+ */
+public class DeviceTable extends RoTable implements AdjustmentTable {
+
+ /** The handler of events from the parser. */
+ private final class ContentHandler extends TtfContentHandler<DeviceTable> {
+
+ /**
+ * Constructor.
+ * @param table The client being built from the parser results.
+ */
+ private ContentHandler(final DeviceTable table) {
+ super(table);
+ }
+
+ @Override
+ public TtfContentHandler<?> startTable(final String tableName) {
+ return null;
+ }
+
+ @Override
+ public void objectField(final String fieldName, final Object value) {
+ }
+
+ @Override
+ public void primitiveField(final String fieldName, final PrimitiveFerry value) {
+ }
+
+ }
+
+ /**
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
+ */
+ public static TtfContentHandler<DeviceTable> createContentHandler() {
+ final DeviceTable table = new DeviceTable();
+ return table.new ContentHandler(table);
+ }
+
+}
Property changes on: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/DeviceTable.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/VariationIndexTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/VariationIndexTable.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/VariationIndexTable.java 2025-04-22 12:58:59 UTC (rev 13477)
@@ -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.font.ttf.table;
+
+import org.foray.common.primitive.PrimitiveFerry;
+import org.foray.font.ttf.RoTable;
+import org.foray.font.ttf.TtfContentHandler;
+
+/**
+ * An OpenType Device table, listed as an "OpenType(tm) Layout Common Table Format".
+ * Used for adjustments within variable (Multiple Master and OpenType Font Variations, for example) fonts.
+ * See {@link DeviceTable} for a similar table used for non-variable fonts.
+ */
+public class VariationIndexTable extends RoTable implements AdjustmentTable {
+
+ /** The handler of events from the parser. */
+ private final class ContentHandler extends TtfContentHandler<VariationIndexTable> {
+
+ /**
+ * Constructor.
+ * @param table The client being built from the parser results.
+ */
+ private ContentHandler(final VariationIndexTable table) {
+ super(table);
+ }
+
+ @Override
+ public TtfContentHandler<?> startTable(final String tableName) {
+ return null;
+ }
+
+ @Override
+ public void objectField(final String fieldName, final Object value) {
+ }
+
+ @Override
+ public void primitiveField(final String fieldName, final PrimitiveFerry value) {
+ }
+
+ }
+
+ /**
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
+ */
+ public static TtfContentHandler<VariationIndexTable> createContentHandler() {
+ final VariationIndexTable table = new VariationIndexTable();
+ return table.new ContentHandler(table);
+ }
+
+}
Property changes on: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/VariationIndexTable.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-22 11:00:32
|
Revision: 13476
http://sourceforge.net/p/foray/code/13476
Author: victormote
Date: 2025-04-22 11:00:14 +0000 (Tue, 22 Apr 2025)
Log Message:
-----------
Add more TTF Base table parsing.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseAxisTableParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseTableParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseAxisTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseScriptTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseTable.java
trunk/foray/foray-font/src/test/java/org/foray/font/ttf/TrueTypeFontParserTests.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseAxisTableParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseAxisTableParser.java 2025-04-22 08:31:07 UTC (rev 13475)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseAxisTableParser.java 2025-04-22 11:00:14 UTC (rev 13476)
@@ -52,6 +52,27 @@
handler.primitiveField("baseTagListOffset", ferry.setShort(baseTagListOffset));
final short baseScriptListOffset = input.read_Offset16(); // 2 bytes, total 4
handler.primitiveField("baseScriptListOffset", ferry.setShort(baseScriptListOffset));
+
+
+ // ********** Base Tag List Subtable **********
+ input.seek(offset + baseTagListOffset);
+ final short baseTagCount = input.read_uint16();
+ handler.primitiveField("baseTagCount", ferry.setShort(baseTagCount));
+ for (int index = 0; index < baseTagCount; index ++) {
+ handler.objectField("baselineTag", input.read_Tag());
+ }
+
+ // ********** Base Script List Subtable **********
+ input.seek(offset + baseScriptListOffset);
+ final short baseScriptCount = input.read_uint16();
+ handler.primitiveField("baseScriptCount", ferry.setShort(baseScriptCount));
+ for (int index = 0; index < baseScriptCount; index ++) {
+ handler.objectField("baseScriptTag", input.read_Tag());
+ final short baseScriptOffset = input.read_Offset16();
+ handler.primitiveField("baseScriptOffset", ferry.setShort(baseScriptOffset));
+ }
+
+ // ********** Base Script Subtable **********
}
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseTableParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseTableParser.java 2025-04-22 08:31:07 UTC (rev 13475)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseTableParser.java 2025-04-22 11:00:14 UTC (rev 13476)
@@ -73,13 +73,15 @@
if (horizAxisOffset > 0) {
final FontContentHandler newHandler = handler.startTable("horizAxis");
final BaseAxisTableParser parser = new BaseAxisTableParser();
- parser.parse(input, offset, size, newHandler);
+ final int axisOffset = offset + horizAxisOffset;
+ parser.parse(input, axisOffset, size, newHandler);
}
if (vertAxisOffset > 0) {
- final FontContentHandler newHandler = handler.startTable("horizAxis");
+ final FontContentHandler newHandler = handler.startTable("vertAxis");
final BaseAxisTableParser parser = new BaseAxisTableParser();
- parser.parse(input, offset, size, newHandler);
+ final int axisOffset = offset + vertAxisOffset;
+ parser.parse(input, axisOffset, size, newHandler);
}
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseAxisTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseAxisTable.java 2025-04-22 08:31:07 UTC (rev 13475)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseAxisTable.java 2025-04-22 11:00:14 UTC (rev 13476)
@@ -33,6 +33,7 @@
import org.foray.font.ttf.RoTable;
import org.foray.font.ttf.TtfContentHandler;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -59,10 +60,22 @@
@Override
public void objectField(final String fieldName, final Object value) {
+ switch (fieldName) {
+ case "baselineTag": getTable().tags.add((String) value); break;
+ case "baseScriptTag": getTable().scriptTags.add((String) value); break;
+ }
}
@Override
public void primitiveField(final String fieldName, final PrimitiveFerry value) {
+ switch (fieldName) {
+ case "baseTagCount": getTable().tags = new ArrayList<String>(value.getShort()); break;
+ case "baseScriptCount": {
+ getTable().scriptTags = new ArrayList<String>(value.getShort());
+ getTable().scriptTables = new ArrayList<BaseScriptTable>(value.getShort());
+ break;
+ }
+ }
}
}
@@ -70,9 +83,12 @@
/** The list of tags for this Axis. */
private List<String> tags;
- /** The list og scripts for this Axis. */
- private List<BaseScriptTable> scripts;
+ /** The list of script tags for this Axis. This should have the same size as {@link #scriptTables}. */
+ private List<String> scriptTags;
+ /** The list of script tables for this Axis. This should have the same size as {@link #scripts}. */
+ private List<BaseScriptTable> scriptTables;
+
/**
* Creates a table instance and a content handler for that instance.
* @return A new content handler.
@@ -104,16 +120,25 @@
* @return The quantity of scripts in this table.
*/
public int getQtyScripts() {
- return this.scripts.size();
+ return this.scriptTags.size();
}
/**
+ * Returns one script tag in this table.
+ * @param index The index of the script tag to be returned.
+ * @return The script tag at {@code index}.
+ */
+ public String getScriptTag(final int index) {
+ return this.scriptTags.get(index);
+ }
+
+ /**
* Returns one script in this table.
* @param index The index of the script to be returned.
* @return The script at {@code index}.
*/
public BaseScriptTable getScript(final int index) {
- return this.scripts.get(index);
+ return this.scriptTables.get(index);
}
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseScriptTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseScriptTable.java 2025-04-22 08:31:07 UTC (rev 13475)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseScriptTable.java 2025-04-22 11:00:14 UTC (rev 13476)
@@ -28,9 +28,48 @@
package org.foray.font.ttf.table;
+import org.foray.common.primitive.PrimitiveFerry;
+import org.foray.font.ttf.RoTable;
+import org.foray.font.ttf.TtfContentHandler;
+
/**
* A BASE table, ScriptList subtable.
*/
-public class BaseScriptTable {
+public class BaseScriptTable extends RoTable {
+ /** The handler of events from the parser. */
+ private final class ContentHandler extends TtfContentHandler<BaseScriptTable> {
+
+ /**
+ * Constructor.
+ * @param table The client being built from the parser results.
+ */
+ private ContentHandler(final BaseScriptTable table) {
+ super(table);
+ }
+
+ @Override
+ public TtfContentHandler<?> startTable(final String tableName) {
+ return null;
+ }
+
+ @Override
+ public void objectField(final String fieldName, final Object value) {
+ }
+
+ @Override
+ public void primitiveField(final String fieldName, final PrimitiveFerry value) {
+ }
+
+ }
+
+ /**
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
+ */
+ public static TtfContentHandler<BaseScriptTable> createContentHandler() {
+ final BaseScriptTable table = new BaseScriptTable();
+ return table.new ContentHandler(table);
+ }
+
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseTable.java 2025-04-22 08:31:07 UTC (rev 13475)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseTable.java 2025-04-22 11:00:14 UTC (rev 13476)
@@ -41,9 +41,6 @@
/** The handler of events from the parser. */
private final class ContentHandler extends TtfContentHandler<BaseTable> {
-// private short horizAxisOffset;
-// private short vertAxisOffset;
-
/**
* Constructor.
* @param table The client being built from the parser results.
@@ -78,8 +75,6 @@
public void primitiveField(final String fieldName, final PrimitiveFerry value) {
switch (fieldName) {
case "majorVersion": getTable().majorVersion = (byte) value.getInt(); break;
-// case "horizAxisOffset": this.horizAxisOffset = value.getShort(); break;
-// case "vertAxisOffset": this.vertAxisOffset = value.getShort(); break;
}
}
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-22 08:31:07 UTC (rev 13475)
+++ trunk/foray/foray-font/src/test/java/org/foray/font/ttf/TrueTypeFontParserTests.java 2025-04-22 11:00:14 UTC (rev 13476)
@@ -33,6 +33,8 @@
import org.foray.font.format.FontContent;
import org.foray.font.format.FontParser;
import org.foray.font.format.Panose4a;
+import org.foray.font.ttf.table.BaseAxisTable;
+import org.foray.font.ttf.table.BaseTable;
import org.axsl.font.FontException;
import org.axsl.font.Panose;
@@ -42,6 +44,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
@@ -211,7 +214,21 @@
final TrueTypeFont ttfFont = ttfSingle.getTTFFont(null);
assertNotNull(ttfFont);
- assertNotNull(ttfFont.getBaseTable());
+ final BaseTable baseTable = ttfFont.getBaseTable();
+ assertNotNull(baseTable);
+ final BaseAxisTable horizontal = baseTable.getHorizontal();
+
+ /* Not sure how to verify any of the following assertions. */
+ assertNotNull(horizontal);
+ assertNull(baseTable.getVertical());
+
+ assertEquals(2, horizontal.getQtyTags());
+ assertEquals("ideo", horizontal.getTag(0));
+ assertEquals("romn", horizontal.getTag(1));
+
+ assertEquals(2, horizontal.getQtyScripts());
+ assertEquals("hani", horizontal.getScriptTag(0));
+ assertEquals("latn", horizontal.getScriptTag(1));
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-22 00:05:16
|
Revision: 13474
http://sourceforge.net/p/foray/code/13474
Author: victormote
Date: 2025-04-22 00:04:58 +0000 (Tue, 22 Apr 2025)
Log Message:
-----------
Remove unneeded parameter on the parse method.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/FontParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseAxisTableParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseTableParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/HeadTableParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/Os2TableParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/PcltTableParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HeadTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Os2Table.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PcltTable.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FontParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FontParser.java 2025-04-21 23:59:03 UTC (rev 13473)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FontParser.java 2025-04-22 00:04:58 UTC (rev 13474)
@@ -46,7 +46,6 @@
/**
* Parses the input.
- * @param tableName The name of the table or subtable being parsed.
* @param input The input to be parsed.
* @param offset The offset, in bytes, into {@code input} at which parsing should begin.
* @param size The size, in bytes, of {@code input} that should be parsed.
@@ -53,7 +52,7 @@
* @param consumer The consumer of the parsing.
* @throws IOException For errors reading the input.
*/
- public abstract void parse(String tableName, TtfRandomAccessInput input, int offset, int size,
+ public abstract void parse(TtfRandomAccessInput input, int offset, int size,
FontContentHandler consumer) throws IOException;
/**
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-21 23:59:03 UTC (rev 13473)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-04-22 00:04:58 UTC (rev 13474)
@@ -279,7 +279,7 @@
if (dirEntry != null) {
final TtfContentHandler<BaseTable> contentHandler = BaseTable.createContentHandler();
final BaseTableParser parser = new BaseTableParser();
- parser.parse("BASE", raInput, dirEntry.getOffset(), dirEntry.getLength(), contentHandler);
+ parser.parse(raInput, dirEntry.getOffset(), dirEntry.getLength(), contentHandler);
font.baseTable = contentHandler.getTable();
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseAxisTableParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseAxisTableParser.java 2025-04-21 23:59:03 UTC (rev 13473)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseAxisTableParser.java 2025-04-22 00:04:58 UTC (rev 13474)
@@ -42,7 +42,7 @@
public class BaseAxisTableParser extends FontParser {
@Override
- public void parse(final String tableName, final TtfRandomAccessInput input, final int offset, final int size,
+ public void parse(final TtfRandomAccessInput input, final int offset, final int size,
final FontContentHandler startingHandler) throws IOException {
final FontContentHandler handler = initialize(startingHandler);
final PrimitiveFerry ferry = new PrimitiveFerry();
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseTableParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseTableParser.java 2025-04-21 23:59:03 UTC (rev 13473)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseTableParser.java 2025-04-22 00:04:58 UTC (rev 13474)
@@ -42,7 +42,7 @@
public class BaseTableParser extends FontParser {
@Override
- public void parse(final String tableName, final TtfRandomAccessInput input, final int offset, final int size,
+ public void parse(final TtfRandomAccessInput input, final int offset, final int size,
final FontContentHandler startingHandler) throws IOException {
final FontContentHandler handler = initialize(startingHandler);
final PrimitiveFerry ferry = new PrimitiveFerry();
@@ -73,13 +73,13 @@
if (horizAxisOffset > 0) {
final FontContentHandler newHandler = handler.startTable("horizAxis");
final BaseAxisTableParser parser = new BaseAxisTableParser();
- parser.parse("", input, offset, size, newHandler);
+ parser.parse(input, offset, size, newHandler);
}
if (vertAxisOffset > 0) {
final FontContentHandler newHandler = handler.startTable("horizAxis");
final BaseAxisTableParser parser = new BaseAxisTableParser();
- parser.parse("", input, offset, size, newHandler);
+ parser.parse(input, offset, size, newHandler);
}
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/HeadTableParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/HeadTableParser.java 2025-04-21 23:59:03 UTC (rev 13473)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/HeadTableParser.java 2025-04-22 00:04:58 UTC (rev 13474)
@@ -42,7 +42,7 @@
public class HeadTableParser extends FontParser {
@Override
- public void parse(final String tableName, final TtfRandomAccessInput input, final int offset, final int size,
+ public void parse(final TtfRandomAccessInput input, final int offset, final int size,
final FontContentHandler consumer) throws IOException {
final PrimitiveFerry ferry = new PrimitiveFerry();
input.seek(offset);
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/Os2TableParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/Os2TableParser.java 2025-04-21 23:59:03 UTC (rev 13473)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/Os2TableParser.java 2025-04-22 00:04:58 UTC (rev 13474)
@@ -46,7 +46,7 @@
public class Os2TableParser extends FontParser {
@Override
- public void parse(final String tableName, final TtfRandomAccessInput input, final int offset, final int size,
+ public void parse(final TtfRandomAccessInput input, final int offset, final int size,
final FontContentHandler consumer) throws IOException {
final PrimitiveFerry ferry = new PrimitiveFerry();
input.seek(offset);
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/PcltTableParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/PcltTableParser.java 2025-04-21 23:59:03 UTC (rev 13473)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/PcltTableParser.java 2025-04-22 00:04:58 UTC (rev 13474)
@@ -43,7 +43,7 @@
public class PcltTableParser extends FontParser {
@Override
- public void parse(final String tableName, final TtfRandomAccessInput input, final int offset, final int size,
+ public void parse(final TtfRandomAccessInput input, final int offset, final int size,
final FontContentHandler consumer) throws IOException {
final PrimitiveFerry ferry = new PrimitiveFerry();
input.seek(offset);
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HeadTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HeadTable.java 2025-04-21 23:59:03 UTC (rev 13473)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HeadTable.java 2025-04-22 00:04:58 UTC (rev 13474)
@@ -116,7 +116,7 @@
throws IOException {
final HeadTable head = new HeadTable();
final HeadTableParser parser = new HeadTableParser();
- parser.parse("head", input, offset, length, head.new ContentHandler(head));
+ parser.parse(input, offset, length, head.new ContentHandler(head));
return head;
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Os2Table.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Os2Table.java 2025-04-21 23:59:03 UTC (rev 13473)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Os2Table.java 2025-04-22 00:04:58 UTC (rev 13474)
@@ -124,7 +124,7 @@
throws IOException {
final Os2Table os2 = new Os2Table();
final Os2TableParser parser = new Os2TableParser();
- parser.parse("OS/2", input, offset, length, os2.new ContentHandler(os2));
+ parser.parse(input, offset, length, os2.new ContentHandler(os2));
return os2;
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PcltTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PcltTable.java 2025-04-21 23:59:03 UTC (rev 13473)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PcltTable.java 2025-04-22 00:04:58 UTC (rev 13474)
@@ -111,7 +111,7 @@
throws IOException {
final PcltTable pclt = new PcltTable();
final PcltTableParser parser = new PcltTableParser();
- parser.parse("PCLT", input, offset, length, pclt.new ContentHandler(pclt));
+ parser.parse(input, offset, length, pclt.new ContentHandler(pclt));
return pclt;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-21 23:59:21
|
Revision: 13473
http://sourceforge.net/p/foray/code/13473
Author: victormote
Date: 2025-04-21 23:59:03 +0000 (Mon, 21 Apr 2025)
Log Message:
-----------
Improved parsing scheme for tables with hierarchy of subtables.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/FontContentHandler.java
trunk/foray/foray-font/src/main/java/org/foray/font/FontParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseTableParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HeadTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Os2Table.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PcltTable.java
Added Paths:
-----------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfContentHandler.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseAxisTableParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseAxisTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseScriptTable.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FontContentHandler.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FontContentHandler.java 2025-04-21 16:29:47 UTC (rev 13472)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FontContentHandler.java 2025-04-21 23:59:03 UTC (rev 13473)
@@ -39,16 +39,11 @@
/**
* Parsing of table is beginning.
* @param tableName The context-sensitive name of the table about to be parsed.
+ * @return The content handler to be used for parsing the table being started.
*/
- void startTable(String tableName);
+ FontContentHandler startTable(String tableName);
/**
- * Parsing of a table is ending.
- * @param tableName The context-sensitive name of the table just parsed.
- */
- void endTable(String tableName);
-
- /**
* An Object field has been parsed.
* @param fieldName The name of the field parsed.
* @param value The parsed value.
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FontParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FontParser.java 2025-04-21 16:29:47 UTC (rev 13472)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FontParser.java 2025-04-21 23:59:03 UTC (rev 13473)
@@ -31,6 +31,7 @@
import org.foray.font.ttf.TtfRandomAccessInput;
import java.io.IOException;
+import java.util.Stack;
/**
* Parses font files and produces events to be consumed by a {@link FontContentHandler}.
@@ -40,6 +41,9 @@
*/
public abstract class FontParser {
+ /** The stack of font handlers. */
+ private Stack<FontContentHandler> contentHandlerStack = new Stack<FontContentHandler>();
+
/**
* Parses the input.
* @param tableName The name of the table or subtable being parsed.
@@ -52,4 +56,44 @@
public abstract void parse(String tableName, TtfRandomAccessInput input, int offset, int size,
FontContentHandler consumer) throws IOException;
+ /**
+ * Starts parsing a table by passing an initial content handler.
+ * Used primarily by the outermost table to start the parsing.
+ * @param initialHandler The initial content handler.
+ * @return The handler passed in, for chaining.
+ */
+ public FontContentHandler initialize(final FontContentHandler initialHandler) {
+ if (! contentHandlerStack.isEmpty()) {
+ throw new IllegalStateException("Content handler stack should be empty at parser initialization.");
+ }
+ this.contentHandlerStack.push(initialHandler);
+ return initialHandler;
+ }
+
+ /**
+ * General tasks handled at the beginning of a new table.
+ * @param tableName The name of the table that whose parsing is about to begin.
+ * This will be used to fire a startTable event for the handler at the top of the stack.
+ * That event returns the new handler to be used for the new table, which will be pushed onto the stack of handlers.
+ * @return The new handler obtained from the old handler.
+ */
+ protected FontContentHandler startTable(final String tableName) {
+ /* We deliberately don't do any state checking on the stack. The subclass must do that. */
+ final FontContentHandler newHandler = this.contentHandlerStack.peek().startTable(tableName);
+ if (newHandler == null) {
+ this.contentHandlerStack.push(this.contentHandlerStack.peek());
+ } else {
+ this.contentHandlerStack.push(newHandler);
+ }
+ return newHandler;
+ }
+
+ /**
+ * General tasks handled at the end a new table.
+ * Pops the handler that was presented during {@link #startTable(FontContentHandler)}.
+ */
+ protected void endTable() {
+ this.contentHandlerStack.pop();
+ }
+
}
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-21 16:29:47 UTC (rev 13472)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-04-21 23:59:03 UTC (rev 13473)
@@ -32,6 +32,7 @@
import org.foray.font.format.Kerning;
import org.foray.font.format.Panose4a;
import org.foray.font.output.FontPdfUtilities;
+import org.foray.font.ttf.parse.BaseTableParser;
import org.foray.font.ttf.table.BaseTable;
import org.foray.font.ttf.table.Cff2Table;
import org.foray.font.ttf.table.CffTable;
@@ -276,7 +277,10 @@
dirEntry = ttfTableDir.getTableDirectoryEntry("BASE");
if (dirEntry != null) {
- font.baseTable = BaseTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength());
+ final TtfContentHandler<BaseTable> contentHandler = BaseTable.createContentHandler();
+ final BaseTableParser parser = new BaseTableParser();
+ parser.parse("BASE", raInput, dirEntry.getOffset(), dirEntry.getLength(), contentHandler);
+ font.baseTable = contentHandler.getTable();
}
dirEntry = ttfTableDir.getTableDirectoryEntry("GDEF");
Added: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfContentHandler.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfContentHandler.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfContentHandler.java 2025-04-21 23:59:03 UTC (rev 13473)
@@ -0,0 +1,61 @@
+/*
+ * 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;
+
+import org.foray.font.FontContentHandler;
+
+/**
+ * Abstract superclass for TTF content handlers of parsing output.
+ * @param <T> The Table class which this content handler class serves.
+ */
+public abstract class TtfContentHandler<T extends RoTable> implements FontContentHandler {
+
+ /** The client table being built from the parser results. */
+ private T table;
+
+ /**
+ * Constructor.
+ * @param table The client being built from the parser results.
+ */
+ public TtfContentHandler(final T table) {
+ this.table = table;
+ }
+
+ /**
+ * Returns the table being parsed.
+ * @return The table being parsed.
+ */
+ public T getTable() {
+ return table;
+ }
+
+// @Override
+// public abstract TtfContentHandler<?> startTable(String tableName);
+
+}
Property changes on: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfContentHandler.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/parse/BaseAxisTableParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseAxisTableParser.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseAxisTableParser.java 2025-04-21 23:59:03 UTC (rev 13473)
@@ -0,0 +1,57 @@
+/*
+ * 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.parse;
+
+import org.foray.common.primitive.PrimitiveFerry;
+import org.foray.font.FontContentHandler;
+import org.foray.font.FontParser;
+import org.foray.font.ttf.TtfRandomAccessInput;
+
+import java.io.IOException;
+
+/**
+ * Parses a TTF BASE table.
+ * @see org.foray.font.ttf.table.BaseTable
+ */
+public class BaseAxisTableParser extends FontParser {
+
+ @Override
+ public void parse(final String tableName, final TtfRandomAccessInput input, final int offset, final int size,
+ final FontContentHandler startingHandler) throws IOException {
+ final FontContentHandler handler = initialize(startingHandler);
+ final PrimitiveFerry ferry = new PrimitiveFerry();
+ input.seek(offset);
+
+ final short baseTagListOffset = input.read_Offset16(); // 2 bytes, total 2
+ handler.primitiveField("baseTagListOffset", ferry.setShort(baseTagListOffset));
+ final short baseScriptListOffset = input.read_Offset16(); // 2 bytes, total 4
+ handler.primitiveField("baseScriptListOffset", ferry.setShort(baseScriptListOffset));
+ }
+
+}
Property changes on: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseAxisTableParser.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/parse/BaseTableParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseTableParser.java 2025-04-21 16:29:47 UTC (rev 13472)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseTableParser.java 2025-04-21 23:59:03 UTC (rev 13473)
@@ -43,27 +43,44 @@
@Override
public void parse(final String tableName, final TtfRandomAccessInput input, final int offset, final int size,
- final FontContentHandler consumer) throws IOException {
+ final FontContentHandler startingHandler) throws IOException {
+ final FontContentHandler handler = initialize(startingHandler);
final PrimitiveFerry ferry = new PrimitiveFerry();
input.seek(offset);
final int majorVersion = input.read_uint16(); // 2 bytes, total 2
- consumer.primitiveField("majorVersion", ferry.setInt(majorVersion));
+ handler.primitiveField("majorVersion", ferry.setInt(majorVersion));
final int minorVersion = input.read_uint16(); // 2 bytes, total 4
- consumer.primitiveField("minorVersion", ferry.setInt(minorVersion));
+ handler.primitiveField("minorVersion", ferry.setInt(minorVersion));
/* BASE Table Header, Version 1.0. */
- final int horizAxisOffset = input.read_Offset16(); // 2 bytes, total 6
- consumer.primitiveField("horizAxisOffset", ferry.setInt(horizAxisOffset));
- final int vertAxisOffset = input.read_Offset16(); // 2 bytes, total 8
- consumer.primitiveField("vertAxisOffset", ferry.setInt(vertAxisOffset));
+ final short horizAxisOffset = input.read_Offset16(); // 2 bytes, total 6
+ handler.primitiveField("horizAxisOffset", ferry.setShort(horizAxisOffset));
+ final short vertAxisOffset = input.read_Offset16(); // 2 bytes, total 8
+ handler.primitiveField("vertAxisOffset", ferry.setShort(vertAxisOffset));
/* BASE Table Header, Version 1.1. */
if (minorVersion > 0) {
final long itemVarStoreOffset = input.read_Offset32(); // 4 bytes, total 12
- consumer.primitiveField("itemVarStoreOffset", ferry.setLong(itemVarStoreOffset));
+ handler.primitiveField("itemVarStoreOffset", ferry.setLong(itemVarStoreOffset));
}
+
+
+
+ // ********** Subtables **********
+
+ if (horizAxisOffset > 0) {
+ final FontContentHandler newHandler = handler.startTable("horizAxis");
+ final BaseAxisTableParser parser = new BaseAxisTableParser();
+ parser.parse("", input, offset, size, newHandler);
+ }
+
+ if (vertAxisOffset > 0) {
+ final FontContentHandler newHandler = handler.startTable("horizAxis");
+ final BaseAxisTableParser parser = new BaseAxisTableParser();
+ parser.parse("", input, offset, size, newHandler);
+ }
}
}
Added: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseAxisTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseAxisTable.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseAxisTable.java 2025-04-21 23:59:03 UTC (rev 13473)
@@ -0,0 +1,119 @@
+/*
+ * 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.primitive.PrimitiveFerry;
+import org.foray.font.FontContentHandler;
+import org.foray.font.ttf.RoTable;
+import org.foray.font.ttf.TtfContentHandler;
+
+import java.util.List;
+
+/**
+ * An OpenType "BASE" (Baseline Data) table.
+ * This table is an Advanced Typographic Table.
+ */
+public class BaseAxisTable extends RoTable {
+
+ /** The handler of events from the parser. */
+ private final class ContentHandler extends TtfContentHandler<BaseAxisTable> {
+
+ /**
+ * Constructor.
+ * @param table The table instance being parsed.
+ */
+ private ContentHandler(final BaseAxisTable table) {
+ super(table);
+ }
+
+ @Override
+ public FontContentHandler startTable(final String tableName) {
+ return null;
+ }
+
+ @Override
+ public void objectField(final String fieldName, final Object value) {
+ }
+
+ @Override
+ public void primitiveField(final String fieldName, final PrimitiveFerry value) {
+ }
+
+ }
+
+ /** The list of tags for this Axis. */
+ private List<String> tags;
+
+ /** The list og scripts for this Axis. */
+ private List<BaseScriptTable> scripts;
+
+ /**
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
+ */
+ public static TtfContentHandler<BaseAxisTable> createContentHandler() {
+ final BaseAxisTable table = new BaseAxisTable();
+ return table.new ContentHandler(table);
+ }
+
+ /**
+ * Returns the quantity of tags in this table.
+ * @return The quantity of tags in this table.
+ */
+ public int getQtyTags() {
+ return this.tags.size();
+ }
+
+ /**
+ * Returns one tag in this table.
+ * @param index The index of the tag to be returned.
+ * @return The tag at {@code index}.
+ */
+ public String getTag(final int index) {
+ return this.tags.get(index);
+ }
+
+ /**
+ * Returns the quantity of scripts in this table.
+ * @return The quantity of scripts in this table.
+ */
+ public int getQtyScripts() {
+ return this.scripts.size();
+ }
+
+ /**
+ * Returns one script in this table.
+ * @param index The index of the script to be returned.
+ * @return The script at {@code index}.
+ */
+ public BaseScriptTable getScript(final int index) {
+ return this.scripts.get(index);
+ }
+
+}
Property changes on: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseAxisTable.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/BaseScriptTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseScriptTable.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseScriptTable.java 2025-04-21 23:59:03 UTC (rev 13473)
@@ -0,0 +1,36 @@
+/*
+ * 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;
+
+/**
+ * A BASE table, ScriptList subtable.
+ */
+public class BaseScriptTable {
+
+}
Property changes on: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseScriptTable.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/BaseTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseTable.java 2025-04-21 16:29:47 UTC (rev 13472)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseTable.java 2025-04-21 23:59:03 UTC (rev 13473)
@@ -29,13 +29,9 @@
package org.foray.font.ttf.table;
import org.foray.common.primitive.PrimitiveFerry;
-import org.foray.font.FontContentHandler;
import org.foray.font.ttf.RoTable;
-import org.foray.font.ttf.TtfRandomAccessInput;
-import org.foray.font.ttf.parse.BaseTableParser;
+import org.foray.font.ttf.TtfContentHandler;
-import java.io.IOException;
-
/**
* An OpenType "BASE" (Baseline Data) table.
* This table is an Advanced Typographic Table.
@@ -42,28 +38,36 @@
*/
public class BaseTable extends RoTable {
- /**
- * The handler of events from the parser.
- */
- private final class ParserConsumer implements FontContentHandler {
+ /** The handler of events from the parser. */
+ private final class ContentHandler extends TtfContentHandler<BaseTable> {
- /** The client being built from the parser results. */
- private BaseTable client;
+// private short horizAxisOffset;
+// private short vertAxisOffset;
/**
* Constructor.
- * @param client The client being built from the parser results.
+ * @param table The client being built from the parser results.
*/
- private ParserConsumer(final BaseTable client) {
- this.client = client;
+ private ContentHandler(final BaseTable table) {
+ super(table);
}
@Override
- public void startTable(final String tableName) {
- }
+ public TtfContentHandler<?> startTable(final String tableName) {
+ switch (tableName) {
+ case "horizAxis": {
+ final TtfContentHandler<BaseAxisTable> handler = BaseAxisTable.createContentHandler();
+ getTable().horizontal = handler.getTable();
+ return handler;
+ }
+ case "vertAxis": {
+ final TtfContentHandler<BaseAxisTable> handler = BaseAxisTable.createContentHandler();
+ getTable().vertical = handler.getTable();
+ return handler;
+ }
+ default: return null;
- @Override
- public void endTable(final String tableName) {
+ }
}
@Override
@@ -73,7 +77,9 @@
@Override
public void primitiveField(final String fieldName, final PrimitiveFerry value) {
switch (fieldName) {
- case "majorVersion": client.majorVersion = (byte) value.getInt(); break;
+ case "majorVersion": getTable().majorVersion = (byte) value.getInt(); break;
+// case "horizAxisOffset": this.horizAxisOffset = value.getShort(); break;
+// case "vertAxisOffset": this.vertAxisOffset = value.getShort(); break;
}
}
@@ -82,20 +88,19 @@
/** The major verions of this table. */
private byte majorVersion;
+ /** The horizontal axis subtable. */
+ private BaseAxisTable horizontal;
+
+ /** The horizontal axis subtable. */
+ private BaseAxisTable vertical;
+
/**
- * 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.
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
*/
- public static BaseTable parse(final TtfRandomAccessInput input, final int offset, final int length)
- throws IOException {
+ public static TtfContentHandler<BaseTable> createContentHandler() {
final BaseTable table = new BaseTable();
- final BaseTableParser parser = new BaseTableParser();
- parser.parse("BASE", input, offset, length, table.new ParserConsumer(table));
- return table;
+ return table.new ContentHandler(table);
}
/**
@@ -106,4 +111,20 @@
return this.majorVersion;
}
+ /**
+ * Returns the horizontal axis subtable.
+ * @return The horizontal axis subtable.
+ */
+ public BaseAxisTable getHorizontal() {
+ return this.horizontal;
+ }
+
+ /**
+ * Returns the vertical axis subtable.
+ * @return The vertical axis subtable.
+ */
+ public BaseAxisTable getVertical() {
+ return this.vertical;
+ }
+
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HeadTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HeadTable.java 2025-04-21 16:29:47 UTC (rev 13472)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HeadTable.java 2025-04-21 23:59:03 UTC (rev 13473)
@@ -31,8 +31,8 @@
import org.foray.common.data.BoundingBoxShort;
import org.foray.common.data.BoundingBoxUtils;
import org.foray.common.primitive.PrimitiveFerry;
-import org.foray.font.FontContentHandler;
import org.foray.font.ttf.RoTable;
+import org.foray.font.ttf.TtfContentHandler;
import org.foray.font.ttf.TtfRandomAccessInput;
import org.foray.font.ttf.parse.HeadTableParser;
@@ -48,33 +48,27 @@
/**
* The handler of events from the parser.
*/
- private final class ParserConsumer implements FontContentHandler {
+ private final class ContentHandler extends TtfContentHandler<HeadTable> {
- /** The client being built from the parser results. */
- private HeadTable client;
-
/**
* Constructor.
- * @param client The client being built from the parser results.
+ * @param table The client being built from the parser results.
*/
- private ParserConsumer(final HeadTable client) {
- this.client = client;
+ private ContentHandler(final HeadTable table) {
+ super(table);
}
@Override
- public void startTable(final String tableName) {
+ public TtfContentHandler<?> startTable(final String tableName) {
+ return null;
}
@Override
- public void endTable(final String tableName) {
- }
-
- @Override
public void objectField(final String fieldName, final Object value) {
switch (fieldName) {
case "boundingBox": {
final short[] boundingBoxArray = (short[]) value;
- client.boundingBox = new BoundingBoxShort(boundingBoxArray);
+ getTable().boundingBox = new BoundingBoxShort(boundingBoxArray);
break;
}
}
@@ -83,8 +77,8 @@
@Override
public void primitiveField(final String fieldName, final PrimitiveFerry value) {
switch (fieldName) {
- case "unitsPerEm": client.unitsPerEm = value.getInt(); break;
- case "indexToLocFormat": client.indexToLocFormat = value.getShort(); break;
+ case "unitsPerEm": getTable().unitsPerEm = value.getInt(); break;
+ case "indexToLocFormat": getTable().indexToLocFormat = value.getShort(); break;
}
}
@@ -122,7 +116,7 @@
throws IOException {
final HeadTable head = new HeadTable();
final HeadTableParser parser = new HeadTableParser();
- parser.parse("head", input, offset, length, head.new ParserConsumer(head));
+ parser.parse("head", input, offset, length, head.new ContentHandler(head));
return head;
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Os2Table.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Os2Table.java 2025-04-21 16:29:47 UTC (rev 13472)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Os2Table.java 2025-04-21 23:59:03 UTC (rev 13473)
@@ -29,9 +29,9 @@
package org.foray.font.ttf.table;
import org.foray.common.primitive.PrimitiveFerry;
-import org.foray.font.FontContentHandler;
import org.foray.font.format.Panose4a;
import org.foray.font.ttf.RoTable;
+import org.foray.font.ttf.TtfContentHandler;
import org.foray.font.ttf.TtfRandomAccessInput;
import org.foray.font.ttf.parse.Os2TableParser;
@@ -47,31 +47,25 @@
/**
* The handler of events from the parser.
*/
- private final class ParserConsumer implements FontContentHandler {
+ private final class ContentHandler extends TtfContentHandler<Os2Table> {
- /** The client being built from the parser results. */
- private Os2Table client;
-
/**
* Constructor.
- * @param client The client being built from the parser results.
+ * @param table The client being built from the parser results.
*/
- private ParserConsumer(final Os2Table client) {
- this.client = client;
+ private ContentHandler(final Os2Table table) {
+ super(table);
}
@Override
- public void startTable(final String tableName) {
+ public TtfContentHandler<?> startTable(final String tableName) {
+ return null;
}
@Override
- public void endTable(final String tableName) {
- }
-
- @Override
public void objectField(final String fieldName, final Object value) {
switch (fieldName) {
- case "panose": client.panose = Panose4a.forceInstance((@Unsigned byte[]) value);
+ case "panose": getTable().panose = Panose4a.forceInstance((@Unsigned byte[]) value);
}
}
@@ -78,14 +72,14 @@
@Override
public void primitiveField(final String fieldName, final PrimitiveFerry value) {
switch (fieldName) {
- case "version": client.version = (byte) value.getShort(); break;
- case "fstype": client.fsType = value.getInt(); break;
- case "yStrikeoutSize": client.yStrikeoutSize = value.getShort(); break;
- case "yStrikeoutPosition": client.yStrikeoutPosition = value.getShort(); break;
- case "sTypoAscender": client.sTypoAscender = value.getShort(); break;
- case "sTypoDescender": client.sTypoDescender = value.getShort(); break;
- case "sxHeight": client.sxHeight = value.getShort(); break;
- case "sCapHeight": client.sCapHeight = value.getShort(); break;
+ case "version": getTable().version = (byte) value.getShort(); break;
+ case "fstype": getTable().fsType = value.getInt(); break;
+ case "yStrikeoutSize": getTable().yStrikeoutSize = value.getShort(); break;
+ case "yStrikeoutPosition": getTable().yStrikeoutPosition = value.getShort(); break;
+ case "sTypoAscender": getTable().sTypoAscender = value.getShort(); break;
+ case "sTypoDescender": getTable().sTypoDescender = value.getShort(); break;
+ case "sxHeight": getTable().sxHeight = value.getShort(); break;
+ case "sCapHeight": getTable().sCapHeight = value.getShort(); break;
}
}
@@ -130,7 +124,7 @@
throws IOException {
final Os2Table os2 = new Os2Table();
final Os2TableParser parser = new Os2TableParser();
- parser.parse("OS/2", input, offset, length, os2.new ParserConsumer(os2));
+ parser.parse("OS/2", input, offset, length, os2.new ContentHandler(os2));
return os2;
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PcltTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PcltTable.java 2025-04-21 16:29:47 UTC (rev 13472)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PcltTable.java 2025-04-21 23:59:03 UTC (rev 13473)
@@ -29,8 +29,8 @@
package org.foray.font.ttf.table;
import org.foray.common.primitive.PrimitiveFerry;
-import org.foray.font.FontContentHandler;
import org.foray.font.ttf.RoTable;
+import org.foray.font.ttf.TtfContentHandler;
import org.foray.font.ttf.TtfRandomAccessInput;
import org.foray.font.ttf.parse.PcltTableParser;
@@ -44,28 +44,22 @@
/**
* The handler of events from the parser.
*/
- private final class ParserConsumer implements FontContentHandler {
+ private final class ContentHandler extends TtfContentHandler<PcltTable> {
- /** The client being built from the parser results. */
- private PcltTable client;
-
/**
* Constructor.
- * @param client The client being built from the parser results.
+ * @param table The client being built from the parser results.
*/
- private ParserConsumer(final PcltTable client) {
- this.client = client;
+ private ContentHandler(final PcltTable table) {
+ super(table);
}
@Override
- public void startTable(final String tableName) {
+ public TtfContentHandler<?> startTable(final String tableName) {
+ return null;
}
@Override
- public void endTable(final String tableName) {
- }
-
- @Override
public void objectField(final String fieldName, final Object value) {
}
@@ -72,9 +66,9 @@
@Override
public void primitiveField(final String fieldName, final PrimitiveFerry value) {
switch (fieldName) {
- case "xHeight": client.xHeight = value.getInt(); break;
- case "capHeight": client.capHeight = value.getInt(); break;
- case "serifStyle": client.serifStyle = value.getShort(); break;
+ case "xHeight": getTable().xHeight = value.getInt(); break;
+ case "capHeight": getTable().capHeight = value.getInt(); break;
+ case "serifStyle": getTable().serifStyle = value.getShort(); break;
}
}
@@ -117,7 +111,7 @@
throws IOException {
final PcltTable pclt = new PcltTable();
final PcltTableParser parser = new PcltTableParser();
- parser.parse("PCLT", input, offset, length, pclt.new ParserConsumer(pclt));
+ parser.parse("PCLT", input, offset, length, pclt.new ContentHandler(pclt));
return pclt;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-21 16:30:04
|
Revision: 13472
http://sourceforge.net/p/foray/code/13472
Author: victormote
Date: 2025-04-21 16:29:47 +0000 (Mon, 21 Apr 2025)
Log Message:
-----------
Complete convertion to read-only table.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeCollection.java
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/NameTable.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeCollection.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeCollection.java 2025-04-21 16:25:46 UTC (rev 13471)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeCollection.java 2025-04-21 16:29:47 UTC (rev 13472)
@@ -106,7 +106,7 @@
// Get the "name" table
final TtfOffsetTableRecord tableDirEntry
= tableDir.getTableDirectoryEntry("name");
- final NameTable nameTable = NameTable.parse(tableDirEntry, this.raInput, tableDirEntry.getOffset(),
+ final NameTable nameTable = NameTable.parse(this.raInput, tableDirEntry.getOffset(),
tableDirEntry.getLength());
fontNames[i] = nameTable.getFullName();
}
@@ -124,7 +124,7 @@
final TtfOffsetTableRecord tableDirEntry
= tableDir.getTableDirectoryEntry("name");
this.getReader().getRandomInput().seek(tableDirEntry.getOffset());
- final NameTable nameTable = NameTable.parse(tableDirEntry, this.raInput, tableDirEntry.getOffset(),
+ final NameTable nameTable = NameTable.parse(this.raInput, tableDirEntry.getOffset(),
tableDirEntry.getLength());
if (nameTable.getFullName().equals(fontName)) {
tableDir.parseFont();
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-21 16:25:46 UTC (rev 13471)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-04-21 16:29:47 UTC (rev 13472)
@@ -195,7 +195,7 @@
/* The NAME table needs to be read before the CMAP. */
dirEntry = ttfTableDir.getTableDirectoryEntry("name");
- font.nameTable = NameTable.parse(dirEntry, raInput, dirEntry.getOffset(), dirEntry.getLength());
+ font.nameTable = NameTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength());
/* Then the CMAP, so that glyph indexes can be computed. */
dirEntry = ttfTableDir.getTableDirectoryEntry("cmap");
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/NameTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/NameTable.java 2025-04-21 16:25:46 UTC (rev 13471)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/NameTable.java 2025-04-21 16:29:47 UTC (rev 13472)
@@ -30,8 +30,6 @@
import org.foray.common.RandomAccessInput;
import org.foray.font.ttf.RoTable;
-import org.foray.font.ttf.RwTable;
-import org.foray.font.ttf.TtfOffsetTableRecord;
import org.foray.primitive.StringUtils;
import java.io.IOException;
@@ -41,7 +39,7 @@
/**
* Class representing a TTF "name" (naming) table.
*/
-public class NameTable extends RwTable {
+public class NameTable extends RoTable {
/** Constant documented in the TTF "name" table doc as indicating the
* Macintosh platform. */
@@ -180,16 +178,7 @@
private int[] nameArray;
/**
- * Constructor.
- * @param dirEntry The table directory entry for this table.
- */
- public NameTable(final TtfOffsetTableRecord dirEntry) {
- super(dirEntry);
- }
-
- /**
* Reads the "name" table.
- * @param dirEntry The table directory entry for this table.
* @param raInput 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}.
@@ -196,10 +185,10 @@
* @return The parsed instance.
* @throws IOException For I/O error.
*/
- public static NameTable parse(final TtfOffsetTableRecord dirEntry, final RandomAccessInput raInput,
- final int offset, final int length) throws IOException {
- raInput.seek(dirEntry.getOffset());
- final NameTable name = new NameTable(dirEntry);
+ public static NameTable parse(final RandomAccessInput raInput, final int offset, final int length)
+ throws IOException {
+ raInput.seek(offset);
+ final NameTable name = new NameTable();
/* Skip the format selector. */
raInput.skipBytes(2);
name.numNameRecords = raInput.readUnsignedShort();
@@ -212,7 +201,7 @@
name.nameArray = new int[name.numNameRecords];
/* Populate the key arrays. */
for (int i = 1; i <= name.numNameRecords; i++) {
- seekNameRecord(raInput, name.getTableDirEntry().getOffset(), i);
+ seekNameRecord(raInput, offset, i);
parseNameRecordKey(name, raInput, i);
}
/*
@@ -425,7 +414,7 @@
private static String readString(final NameTable name, final RandomAccessInput raInput, final int tableOffset,
final int nameRecordNum) throws IOException {
final int arrayIndex = nameRecordNum - 1;
- seekNameRecord(raInput, name.getTableDirEntry().getOffset(), nameRecordNum);
+ seekNameRecord(raInput, tableOffset, nameRecordNum);
/* Skip the Platform ID. */
raInput.skipBytes(RoTable.USHORT_BYTES);
/* Skip the Platform-specific encoding ID. */
@@ -442,9 +431,9 @@
name.platformArray[arrayIndex], name.encodingArray[arrayIndex],
name.languageArray[arrayIndex]);
final long stringOffsetInFile
- = name.getTableDirEntry().getOffset()// start of table
- + name.offsetToStrings // start of string area
- + stringOffset; // start of this string
+ = tableOffset // start of table
+ + name.offsetToStrings // start of string area
+ + stringOffset; // start of this string
raInput.seek(stringOffsetInFile);
final String txt = raInput.readString(stringLength, charset);
return txt;
@@ -520,11 +509,6 @@
return true;
}
- @Override
- public String getTableTag() {
- return "name";
- }
-
/**
* Returns the postscript name of this font.
* @return The postscript name.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-21 16:26:04
|
Revision: 13471
http://sourceforge.net/p/foray/code/13471
Author: victormote
Date: 2025-04-21 16:25:46 +0000 (Mon, 21 Apr 2025)
Log Message:
-----------
Reduce dependency on retention of TableDir instance.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeCollection.java
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/NameTable.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeCollection.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeCollection.java 2025-04-21 16:10:27 UTC (rev 13470)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeCollection.java 2025-04-21 16:25:46 UTC (rev 13471)
@@ -106,7 +106,8 @@
// Get the "name" table
final TtfOffsetTableRecord tableDirEntry
= tableDir.getTableDirectoryEntry("name");
- final NameTable nameTable = NameTable.parse(tableDirEntry, this.raInput);
+ final NameTable nameTable = NameTable.parse(tableDirEntry, this.raInput, tableDirEntry.getOffset(),
+ tableDirEntry.getLength());
fontNames[i] = nameTable.getFullName();
}
return fontNames;
@@ -123,7 +124,8 @@
final TtfOffsetTableRecord tableDirEntry
= tableDir.getTableDirectoryEntry("name");
this.getReader().getRandomInput().seek(tableDirEntry.getOffset());
- final NameTable nameTable = NameTable.parse(tableDirEntry, this.raInput);
+ final NameTable nameTable = NameTable.parse(tableDirEntry, this.raInput, tableDirEntry.getOffset(),
+ tableDirEntry.getLength());
if (nameTable.getFullName().equals(fontName)) {
tableDir.parseFont();
return tableDir.getTTFFont();
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-21 16:10:27 UTC (rev 13470)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-04-21 16:25:46 UTC (rev 13471)
@@ -195,7 +195,7 @@
/* The NAME table needs to be read before the CMAP. */
dirEntry = ttfTableDir.getTableDirectoryEntry("name");
- font.nameTable = NameTable.parse(dirEntry, raInput);
+ font.nameTable = NameTable.parse(dirEntry, raInput, dirEntry.getOffset(), dirEntry.getLength());
/* Then the CMAP, so that glyph indexes can be computed. */
dirEntry = ttfTableDir.getTableDirectoryEntry("cmap");
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/NameTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/NameTable.java 2025-04-21 16:10:27 UTC (rev 13470)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/NameTable.java 2025-04-21 16:25:46 UTC (rev 13471)
@@ -191,11 +191,13 @@
* Reads the "name" table.
* @param dirEntry The table directory entry for this table.
* @param raInput 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.
*/
- public static NameTable parse(final TtfOffsetTableRecord dirEntry, final RandomAccessInput raInput)
- throws IOException {
+ public static NameTable parse(final TtfOffsetTableRecord dirEntry, final RandomAccessInput raInput,
+ final int offset, final int length) throws IOException {
raInput.seek(dirEntry.getOffset());
final NameTable name = new NameTable(dirEntry);
/* Skip the format selector. */
@@ -220,18 +222,21 @@
* We'll try the Microsoft keys first, since we think we know what
* encoding they use.
*/
- findForKeySet(name, raInput, NameTable.PLATFORM_MICROSOFT,
+ findForKeySet(name, raInput, offset,
+ NameTable.PLATFORM_MICROSOFT,
NameTable.ENCODING_MICROSOFT_UGL,
NameTable.LANGUAGE_MICROSOFT_ENGLISH_AMERICAN);
- findForKeySet(name, raInput, NameTable.PLATFORM_MICROSOFT,
+ findForKeySet(name, raInput, offset,
+ NameTable.PLATFORM_MICROSOFT,
NameTable.ENCODING_MICROSOFT_UNDEFINED,
NameTable.LANGUAGE_MICROSOFT_ENGLISH_AMERICAN);
/* Now try Macintosh. */
- findForKeySet(name, raInput, NameTable.PLATFORM_MACINTOSH,
+ findForKeySet(name, raInput, offset,
+ NameTable.PLATFORM_MACINTOSH,
NameTable.ENCODING_MACINTOSH_ROMAN,
NameTable.LANGUAGE_MACINTOSH_ENGLISH);
/* If we haven't found it yet, take anything you can get. */
- findAny(name, raInput);
+ findAny(name, raInput, offset);
return name;
}
@@ -241,13 +246,14 @@
* which any value should be accepted.
* @param name The table being parsed.
* @param raInput The input which is being parsed.
+ * @param tableOffset The offset to the beginning of the table.
* @param platformID The platform ID portion of the key.
* @param encodingID The encoding ID portion of the key.
* @param languageID The language ID portion of the key.
* @throws IOException For I/O error.
*/
- private static void findForKeySet(final NameTable name, final RandomAccessInput raInput, final int platformID,
- final int encodingID, final int languageID) throws IOException {
+ private static void findForKeySet(final NameTable name, final RandomAccessInput raInput, final int tableOffset,
+ final int platformID, final int encodingID, final int languageID) throws IOException {
for (int i = 0; i < NameTable.NAMES_TO_TEST.length; i++) {
if (nameRecorded(name, NameTable.NAMES_TO_TEST[i])) {
continue;
@@ -254,7 +260,7 @@
}
final int nameRecordNumber = name.findNameRecord(platformID, encodingID,
languageID, NameTable.NAMES_TO_TEST[i]);
- parseNameRecord(name, raInput, nameRecordNumber);
+ parseNameRecord(name, raInput, tableOffset, nameRecordNumber);
}
}
@@ -263,11 +269,13 @@
* variables.
* @param name The table being parsed.
* @param raInput The input which is being parsed.
+ * @param tableOffset The offset to the beginning of the table.
* @throws IOException For I/O error.
*/
- private static void findAny(final NameTable name, final RandomAccessInput raInput) throws IOException {
+ private static void findAny(final NameTable name, final RandomAccessInput raInput, final int tableOffset)
+ throws IOException {
for (int i = 1; i <= name.numNameRecords && ! name.allStringsFound(); i++) {
- parseNameRecord(name, raInput, i);
+ parseNameRecord(name, raInput, tableOffset, i);
}
}
@@ -275,16 +283,17 @@
* Parses one name record.
* @param name The table being parsed.
* @param raInput The input which is being parsed.
+ * @param tableOffset The offset to the beginning of the table.
* @param nameRecordNum The name record number.
* @throws IOException For I/O error.
*/
- private static void parseNameRecord(final NameTable name, final RandomAccessInput raInput,
+ private static void parseNameRecord(final NameTable name, final RandomAccessInput raInput, final int tableOffset,
final int nameRecordNum) throws IOException {
if (nameRecordNum < 1 || nameRecordNum > name.platformArray.length) {
return;
}
final int arrayIndex = nameRecordNum - 1;
- final String txt = readString(name, raInput, nameRecordNum);
+ final String txt = readString(name, raInput, tableOffset, nameRecordNum);
if (name.platformArray[arrayIndex] != NameTable.PLATFORM_MACINTOSH
&& name.platformArray[arrayIndex]
!= NameTable.PLATFORM_MICROSOFT) {
@@ -408,12 +417,13 @@
* Reads a specific name record.
* @param name The table being parsed.
* @param raInput The input which is being parsed.
+ * @param tableOffset The offset to the beginning of the table.
* @param nameRecordNum The record number to be read.
* @return The parsed name.
* @throws IOException For I/O Error.
*/
- private static String readString(final NameTable name, final RandomAccessInput raInput, final int nameRecordNum)
- throws IOException {
+ private static String readString(final NameTable name, final RandomAccessInput raInput, final int tableOffset,
+ final int nameRecordNum) throws IOException {
final int arrayIndex = nameRecordNum - 1;
seekNameRecord(raInput, name.getTableDirEntry().getOffset(), nameRecordNum);
/* Skip the Platform ID. */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-21 16:10:43
|
Revision: 13470
http://sourceforge.net/p/foray/code/13470
Author: victormote
Date: 2025-04-21 16:10:27 +0000 (Mon, 21 Apr 2025)
Log Message:
-----------
Begin unwinding dependency on retention of TableDir instance.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/NameTable.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/NameTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/NameTable.java 2025-04-21 15:42:24 UTC (rev 13469)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/NameTable.java 2025-04-21 16:10:27 UTC (rev 13470)
@@ -210,7 +210,7 @@
name.nameArray = new int[name.numNameRecords];
/* Populate the key arrays. */
for (int i = 1; i <= name.numNameRecords; i++) {
- seekNameRecord(name, raInput, i);
+ seekNameRecord(raInput, name.getTableDirEntry().getOffset(), i);
parseNameRecordKey(name, raInput, i);
}
/*
@@ -382,15 +382,15 @@
/**
* Seeks to the beginning of a specific name record.
- * @param name The table being parsed.
* @param raInput The input which is being parsed.
+ * @param tableOffset The offset to the beginning of the table.
* @param nameRecordNum The record number to be sought.
* @throws IOException For I/O Error.
*/
- private static void seekNameRecord(final NameTable name, final RandomAccessInput raInput,
- final int nameRecordNum) throws IOException {
+ private static void seekNameRecord(final RandomAccessInput raInput, final int tableOffset, final int nameRecordNum)
+ throws IOException {
/* Start at the beginning of the table. */
- long offsetOfThisNameRecord = name.getTableDirEntry().getOffset();
+ long offsetOfThisNameRecord = tableOffset;
/* Skip the bytes before name records. */
/* Skip the Format selector. */
offsetOfThisNameRecord += RoTable.USHORT_BYTES;
@@ -415,7 +415,7 @@
private static String readString(final NameTable name, final RandomAccessInput raInput, final int nameRecordNum)
throws IOException {
final int arrayIndex = nameRecordNum - 1;
- seekNameRecord(name, raInput, nameRecordNum);
+ seekNameRecord(raInput, name.getTableDirEntry().getOffset(), nameRecordNum);
/* Skip the Platform ID. */
raInput.skipBytes(RoTable.USHORT_BYTES);
/* Skip the Platform-specific encoding ID. */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-21 15:42:43
|
Revision: 13469
http://sourceforge.net/p/foray/code/13469
Author: victormote
Date: 2025-04-21 15:42:24 +0000 (Mon, 21 Apr 2025)
Log Message:
-----------
Move most existing Font Table classes from RwTable to RoTable.
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/AbstractOtfLayoutTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseTable.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/CmapTable.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/GlyfTable.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/GsubTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HeadTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HheaTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HtmxTable.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/KernTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/LocaTable.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/MaxpTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Os2Table.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PcltTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PostTable.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
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-21 14:42:24 UTC (rev 13468)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-04-21 15:42:24 UTC (rev 13469)
@@ -187,11 +187,11 @@
/* Read the Font Header first. */
TtfOffsetTableRecord dirEntry = ttfTableDir.getTableDirectoryEntry("head");
- font.headTable = HeadTable.parse(dirEntry, raInput);
+ font.headTable = HeadTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength());
/* Then the Maximum Profile, so general sizes are known. */
dirEntry = ttfTableDir.getTableDirectoryEntry("maxp");
- font.maxpTable = MaxpTable.parse(dirEntry, raInput);
+ font.maxpTable = MaxpTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength());
/* The NAME table needs to be read before the CMAP. */
dirEntry = ttfTableDir.getTableDirectoryEntry("name");
@@ -199,11 +199,12 @@
/* Then the CMAP, so that glyph indexes can be computed. */
dirEntry = ttfTableDir.getTableDirectoryEntry("cmap");
- font.cmapTable = CmapTable.parse(dirEntry, raInput, font.nameTable.getPostscriptName());
+ font.cmapTable = CmapTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength(),
+ font.nameTable.getPostscriptName());
/* Read the Horizontal Header before the Horizontal Metrics. */
dirEntry = ttfTableDir.getTableDirectoryEntry("hhea");
- font.hheaTable = HheaTable.parse(dirEntry, raInput);
+ font.hheaTable = HheaTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength());
/* After this point, the order may not matter. */
@@ -210,45 +211,48 @@
dirEntry = ttfTableDir.getTableDirectoryEntry("hmtx");
final int numberOfGlyphs = font.maxpTable.getNumberOfGlyphs();
final int numberOfHMetrics = font.hheaTable.getNumberOfHMetrics();
- font.hmtxTable = HtmxTable.parse(dirEntry, raInput, numberOfGlyphs, numberOfHMetrics);
+ font.hmtxTable = HtmxTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength(), numberOfGlyphs,
+ numberOfHMetrics);
dirEntry = ttfTableDir.getTableDirectoryEntry("post");
- font.postTable = PostTable.parse(dirEntry, raInput);
+ font.postTable = PostTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength());
dirEntry = ttfTableDir.getTableDirectoryEntry("OS/2");
- font.os2Table = Os2Table.parse(dirEntry, raInput);
+ font.os2Table = Os2Table.parse(raInput, dirEntry.getOffset(), dirEntry.getLength());
/* BEGIN TRUETYPE-OUTLINE TABLES **************************************************************************** */
dirEntry = ttfTableDir.getTableDirectoryEntry("cvt");
if (dirEntry != null) {
- font.cvtTable = CvtTable.parse(dirEntry, raInput);
+ font.cvtTable = CvtTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength());
}
dirEntry = ttfTableDir.getTableDirectoryEntry("fpgm");
if (dirEntry != null) {
- font.fpgmTable = FpgmTable.parse(dirEntry, raInput);
+ font.fpgmTable = FpgmTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength());
}
dirEntry = ttfTableDir.getTableDirectoryEntry("loca");
if (dirEntry != null) {
final boolean isLongFormat = font.headTable.longLocaFormat();
- font.locaTable = LocaTable.parse(dirEntry, raInput, isLongFormat, numberOfGlyphs, font.hmtxTable);
+ font.locaTable = LocaTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength(), isLongFormat,
+ numberOfGlyphs, font.hmtxTable);
}
dirEntry = ttfTableDir.getTableDirectoryEntry("glyf");
if (dirEntry != null) {
- font.glyfTable = GlyfTable.parse(dirEntry, raInput, numberOfGlyphs, font.hmtxTable);
+ font.glyfTable = GlyfTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength(), numberOfGlyphs,
+ font.hmtxTable);
}
dirEntry = ttfTableDir.getTableDirectoryEntry("prep");
if (dirEntry != null) {
- font.prepTable = PrepTable.parse(dirEntry, raInput);
+ font.prepTable = PrepTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength());
}
dirEntry = ttfTableDir.getTableDirectoryEntry("gasp");
if (dirEntry != null) {
- font.gaspTable = GaspTable.parse(dirEntry, raInput);
+ font.gaspTable = GaspTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength());
}
/* BEGIN POSTSCRIPT-OUTLINE TABLES ************************************************************************** */
@@ -255,17 +259,17 @@
dirEntry = ttfTableDir.getTableDirectoryEntry("CFF");
if (dirEntry != null) {
- font.cffTable = CffTable.parse(dirEntry, raInput);
+ font.cffTable = CffTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength());
}
dirEntry = ttfTableDir.getTableDirectoryEntry("CFF2");
if (dirEntry != null) {
- font.cff2Table = Cff2Table.parse(dirEntry, raInput);
+ font.cff2Table = Cff2Table.parse(raInput, dirEntry.getOffset(), dirEntry.getLength());
}
dirEntry = ttfTableDir.getTableDirectoryEntry("VORG");
if (dirEntry != null) {
- font.vorgTable = VorgTable.parse(dirEntry, raInput);
+ font.vorgTable = VorgTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength());
}
/* BEGIN OPENTYPE ADVANCED TYPOGRAPHIC TABLES *************************************************************** */
@@ -272,17 +276,17 @@
dirEntry = ttfTableDir.getTableDirectoryEntry("BASE");
if (dirEntry != null) {
- font.baseTable = BaseTable.parse(dirEntry, raInput);
+ font.baseTable = BaseTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength());
}
dirEntry = ttfTableDir.getTableDirectoryEntry("GDEF");
if (dirEntry != null) {
- font.gdefTable = GdefTable.parse(dirEntry, raInput);
+ font.gdefTable = GdefTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength());
}
dirEntry = ttfTableDir.getTableDirectoryEntry("GPOS");
if (dirEntry != null) {
- font.gposTable = GposTable.parse(dirEntry, raInput);
+ font.gposTable = GposTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength());
}
dirEntry = ttfTableDir.getTableDirectoryEntry("GSUB");
@@ -292,12 +296,12 @@
dirEntry = ttfTableDir.getTableDirectoryEntry("JSTF");
if (dirEntry != null) {
- font.jstfTable = JstfTable.parse(dirEntry, raInput);
+ font.jstfTable = JstfTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength());
}
dirEntry = ttfTableDir.getTableDirectoryEntry("MATH");
if (dirEntry != null) {
- font.mathTable = MathTable.parse(dirEntry, raInput);
+ font.mathTable = MathTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength());
}
/* BEGIN OPTIONAL TABLES ************************************************************************************ */
@@ -304,12 +308,12 @@
dirEntry = ttfTableDir.getTableDirectoryEntry("PCLT");
if (dirEntry != null) {
- font.pcltTable = PcltTable.parse(dirEntry, raInput);
+ font.pcltTable = PcltTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength());
}
dirEntry = ttfTableDir.getTableDirectoryEntry("kern");
if (dirEntry != null) {
- font.kernTable = KernTable.parse(dirEntry, raInput, font.cmapTable);
+ font.kernTable = KernTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength(), font.cmapTable);
}
return font;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/AbstractOtfLayoutTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/AbstractOtfLayoutTable.java 2025-04-21 14:42:24 UTC (rev 13468)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/AbstractOtfLayoutTable.java 2025-04-21 15:42:24 UTC (rev 13469)
@@ -31,8 +31,7 @@
import org.foray.common.RandomAccessInput;
import org.foray.font.ttf.OtfFeature;
import org.foray.font.ttf.OtfScript;
-import org.foray.font.ttf.RwTable;
-import org.foray.font.ttf.TtfOffsetTableRecord;
+import org.foray.font.ttf.RoTable;
import java.io.IOException;
import java.util.HashMap;
@@ -41,7 +40,7 @@
/**
* Abstract superclass for the OpenType layout tables.
*/
-public abstract class AbstractOtfLayoutTable extends RwTable {
+public abstract class AbstractOtfLayoutTable extends RoTable {
/** Map of OpenType scripts for this table. The key is the script tag, and the value is the OtfScript instance for
* that tag. */
@@ -53,13 +52,10 @@
/**
* Constructor.
- * @param offsetTableRecord The offset table record that defines this table.
* @param scriptMap The script map for this table.
* @param featureMap The feature map for this table.
*/
- AbstractOtfLayoutTable(final TtfOffsetTableRecord offsetTableRecord, final Map<String, OtfScript> scriptMap,
- final Map<String, OtfFeature> featureMap) {
- super(offsetTableRecord);
+ AbstractOtfLayoutTable(final Map<String, OtfScript> scriptMap, final Map<String, OtfFeature> featureMap) {
this.scriptMap = scriptMap;
this.featureMap = featureMap;
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseTable.java 2025-04-21 14:42:24 UTC (rev 13468)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseTable.java 2025-04-21 15:42:24 UTC (rev 13469)
@@ -30,8 +30,7 @@
import org.foray.common.primitive.PrimitiveFerry;
import org.foray.font.FontContentHandler;
-import org.foray.font.ttf.RwTable;
-import org.foray.font.ttf.TtfOffsetTableRecord;
+import org.foray.font.ttf.RoTable;
import org.foray.font.ttf.TtfRandomAccessInput;
import org.foray.font.ttf.parse.BaseTableParser;
@@ -41,7 +40,7 @@
* An OpenType "BASE" (Baseline Data) table.
* This table is an Advanced Typographic Table.
*/
-public class BaseTable extends RwTable {
+public class BaseTable extends RoTable {
/**
* The handler of events from the parser.
@@ -84,33 +83,21 @@
private byte majorVersion;
/**
- * Constructor.
- * @param offsetRecord The parent table directory entry.
- */
- public BaseTable(final TtfOffsetTableRecord offsetRecord) {
- super(offsetRecord);
- }
-
- /**
* Parse the table from the table content.
- * @param dirEntry The parent table directory entry.
* @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.
*/
- public static BaseTable parse(final TtfOffsetTableRecord dirEntry, final TtfRandomAccessInput input)
+ public static BaseTable parse(final TtfRandomAccessInput input, final int offset, final int length)
throws IOException {
- final BaseTable table = new BaseTable(dirEntry);
+ final BaseTable table = new BaseTable();
final BaseTableParser parser = new BaseTableParser();
- parser.parse("BASE", input, dirEntry.getOffset(), dirEntry.getLength(), table.new ParserConsumer(table));
+ parser.parse("BASE", input, offset, length, table.new ParserConsumer(table));
return table;
}
- @Override
- public String getTableTag() {
- return "BASE";
- }
-
/**
* Returns the major version of this table.
* @return The major version of this table.
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-21 14:42:24 UTC (rev 13468)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cff2Table.java 2025-04-21 15:42:24 UTC (rev 13469)
@@ -29,8 +29,7 @@
package org.foray.font.ttf.table;
import org.foray.common.RandomAccessInput;
-import org.foray.font.ttf.RwTable;
-import org.foray.font.ttf.TtfOffsetTableRecord;
+import org.foray.font.ttf.RoTable;
import java.io.IOException;
@@ -38,33 +37,21 @@
* An OpenType "CFF2" (Compact File Format 2.0 PostScript Outlines) table.
* This table is used only in OpenType fonts that contain PostScript outlines.
*/
-public class Cff2Table extends RwTable {
+public class Cff2Table extends RoTable {
/**
- * Constructor.
- * @param offsetRecord The parent offset table record.
- */
- public Cff2Table(final TtfOffsetTableRecord offsetRecord) {
- super(offsetRecord);
- }
-
- /**
* Parse the table from the table content.
- * @param offsetRecord The parent offset table record.
- * @param raInput The input which is being parsed.
+ * @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.
*/
- public static Cff2Table parse(final TtfOffsetTableRecord offsetRecord, final RandomAccessInput raInput)
+ public static Cff2Table parse(final RandomAccessInput input, final int offset, final int length)
throws IOException {
- raInput.seek(offsetRecord.getOffset());
- final Cff2Table table = new Cff2Table(offsetRecord);
+ input.seek(offset);
+ final Cff2Table table = new Cff2Table();
return table;
}
- @Override
- public String getTableTag() {
- return "CFF2";
- }
-
}
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-21 14:42:24 UTC (rev 13468)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CffTable.java 2025-04-21 15:42:24 UTC (rev 13469)
@@ -29,8 +29,7 @@
package org.foray.font.ttf.table;
import org.foray.common.RandomAccessInput;
-import org.foray.font.ttf.RwTable;
-import org.foray.font.ttf.TtfOffsetTableRecord;
+import org.foray.font.ttf.RoTable;
import java.io.IOException;
@@ -38,33 +37,21 @@
* An OpenType "CFF" (Compact File Format 1.0 PostScript Outlines) table.
* This table is used only in OpenType fonts that contain PostScript outlines.
*/
-public class CffTable extends RwTable {
+public class CffTable extends RoTable {
/**
- * Constructor.
- * @param offsetRecord The parent table directory entry.
- */
- public CffTable(final TtfOffsetTableRecord offsetRecord) {
- super(offsetRecord);
- }
-
- /**
* Parse the table from the table content.
- * @param offsetRecord The parent offset table record.
- * @param raInput The input which is being parsed.
+ * @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.
*/
- public static CffTable parse(final TtfOffsetTableRecord offsetRecord, final RandomAccessInput raInput)
+ public static CffTable parse(final RandomAccessInput input, final int offset, final int length)
throws IOException {
- raInput.seek(offsetRecord.getOffset());
- final CffTable table = new CffTable(offsetRecord);
+ input.seek(offset);
+ final CffTable table = new CffTable();
return table;
}
- @Override
- public String getTableTag() {
- return "CFF";
- }
-
}
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-21 14:42:24 UTC (rev 13468)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java 2025-04-21 15:42:24 UTC (rev 13469)
@@ -30,8 +30,6 @@
import org.foray.common.RandomAccessInput;
import org.foray.font.ttf.RoTable;
-import org.foray.font.ttf.RwTable;
-import org.foray.font.ttf.TtfOffsetTableRecord;
import org.foray.ps.encode.Cmap04Ttf4a;
import org.foray.ps.encode.Cmap12Ttf4a;
@@ -44,7 +42,7 @@
/**
* Class representing a TTF "cmap" (character-to-glyph index mapping) table.
*/
-public class CmapTable extends RwTable {
+public class CmapTable extends RoTable {
/** Constant indicating that this Cmap4a table is in an unknown format. */
public static final byte CMAP_FORMAT_UNKNOWN = -1;
@@ -77,29 +75,22 @@
private Cmap unicodeCMap;
/**
- * Constructor.
- * @param dirEntry The parent table directory entry.
- */
- public CmapTable(final TtfOffsetTableRecord dirEntry) {
- super(dirEntry);
- }
-
- /**
* Parse the cmap table.
* Currently only unicode cmaps are supported.
- * @param dirEntry The parent table directory entry.
- * @param raInput The input which is being parsed.
+ * @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.
*/
- public static CmapTable parse(final TtfOffsetTableRecord dirEntry, final RandomAccessInput raInput,
+ public static CmapTable parse(final RandomAccessInput input, final int offset, final int length,
final String fontPostScriptName) throws IOException {
- raInput.seek(dirEntry.getOffset());
- final CmapTable cmap = new CmapTable(dirEntry);
+ input.seek(offset);
+ final CmapTable cmap = new CmapTable();
/* Skip table version. */
- raInput.skipBytes(RoTable.USHORT_BYTES);
- final int numSubtables = raInput.readUnsignedShort();
+ input.skipBytes(RoTable.USHORT_BYTES);
+ final int numSubtables = input.readUnsignedShort();
long offsetToCMap04 = -1;
long offsetToCMap12 = -1;
@@ -107,9 +98,9 @@
/* 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 = raInput.readUnsignedShort();
- final int encodingID = raInput.readUnsignedShort();
- final long subtableOffset = raInput.readUnsignedInt();
+ 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. */
@@ -138,39 +129,37 @@
// getLogger().warn("No Unicode cmap table: " + this.ttfFont().getFontName());
// return;
// }
- cmap.unicodeCMap = parseCMap(dirEntry, raInput, offsetToParse, fontPostScriptName);
+ cmap.unicodeCMap = parseCMap(input, offset, offsetToParse, fontPostScriptName);
return cmap;
}
/**
* Parse one cmap table.
- * @param dirEntry The parent table directory entry.
- * @param raInput The input which is being parsed.
+ * @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.
*/
- private static Cmap parseCMap(final TtfOffsetTableRecord dirEntry, final RandomAccessInput raInput,
+ private static Cmap parseCMap(final RandomAccessInput input, final int tableOffset,
final long offsetToParse, final String fontPostScriptName) throws IOException {
- int tableOffset = dirEntry.getOffset();
- tableOffset += offsetToParse;
- raInput.seek(tableOffset);
- final int formatHigh = raInput.readUnsignedShort();
+ input.seek(tableOffset + offsetToParse);
+ final int formatHigh = input.readUnsignedShort();
// int formatLow = 0;
// long length = 0;
if (formatHigh > CmapTable.CMAP_FORMAT_6) {
- /*formatLow = */raInput.readUnsignedShort();
- /*length = */raInput.readUnsignedInt();
+ /*formatLow = */input.readUnsignedShort();
+ /*length = */input.readUnsignedInt();
} else {
- /*length = */raInput.readUnsignedShort();
+ /*length = */input.readUnsignedShort();
}
switch (formatHigh) {
case CmapTable.CMAP_FORMAT_4: {
- return parseCMap04(raInput, fontPostScriptName);
+ return parseCMap04(input, fontPostScriptName);
}
case CmapTable.CMAP_FORMAT_12: {
- return parseCMap12(raInput, fontPostScriptName);
+ return parseCMap12(input, fontPostScriptName);
}
}
return null;
@@ -279,11 +268,6 @@
return cmap12;
}
- @Override
- public String getTableTag() {
- return "cmap";
- }
-
/**
* Returns the Unicode Cmap4a instance parsed from this table.
* @return The Unicode Cmap4a instance parsed from this table.
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-21 14:42:24 UTC (rev 13468)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CvtTable.java 2025-04-21 15:42:24 UTC (rev 13469)
@@ -29,8 +29,7 @@
package org.foray.font.ttf.table;
import org.foray.common.RandomAccessInput;
-import org.foray.font.ttf.RwTable;
-import org.foray.font.ttf.TtfOffsetTableRecord;
+import org.foray.font.ttf.RoTable;
import java.io.IOException;
@@ -38,33 +37,21 @@
* A TrueType/OpenType "cvt" (Control Value Table) table.
* This table is used only in fonts that contain TrueType outlines.
*/
-public class CvtTable extends RwTable {
+public class CvtTable extends RoTable {
/**
- * Constructor.
- * @param offsetRecord The parent table directory entry.
- */
- public CvtTable(final TtfOffsetTableRecord offsetRecord) {
- super(offsetRecord);
- }
-
- /**
* Parse the table from the table content.
- * @param offsetRecord The parent offset table record.
- * @param raInput The input which is being parsed.
+ * @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.
*/
- public static CvtTable parse(final TtfOffsetTableRecord offsetRecord, final RandomAccessInput raInput)
+ public static CvtTable parse(final RandomAccessInput input, final int offset, final int length)
throws IOException {
- raInput.seek(offsetRecord.getOffset());
- final CvtTable table = new CvtTable(offsetRecord);
+ input.seek(offset);
+ final CvtTable table = new CvtTable();
return table;
}
- @Override
- public String getTableTag() {
- return "cvt";
- }
-
}
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-21 14:42:24 UTC (rev 13468)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/FpgmTable.java 2025-04-21 15:42:24 UTC (rev 13469)
@@ -29,8 +29,7 @@
package org.foray.font.ttf.table;
import org.foray.common.RandomAccessInput;
-import org.foray.font.ttf.RwTable;
-import org.foray.font.ttf.TtfOffsetTableRecord;
+import org.foray.font.ttf.RoTable;
import java.io.IOException;
@@ -38,33 +37,21 @@
* A TrueType/OpenType "fpgm" (Font Program) table.
* This table is used only in fonts that contain TrueType outlines.
*/
-public class FpgmTable extends RwTable {
+public class FpgmTable extends RoTable {
/**
- * Constructor.
- * @param offsetRecord The parent table directory entry.
- */
- public FpgmTable(final TtfOffsetTableRecord offsetRecord) {
- super(offsetRecord);
- }
-
- /**
* Parse the table from the table content.
- * @param offsetRecord The parent offset table record.
- * @param raInput The input which is being parsed.
+ * @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.
*/
- public static FpgmTable parse(final TtfOffsetTableRecord offsetRecord, final RandomAccessInput raInput)
+ public static FpgmTable parse(final RandomAccessInput input, final int offset, final int length)
throws IOException {
- raInput.seek(offsetRecord.getOffset());
- final FpgmTable table = new FpgmTable(offsetRecord);
+ input.seek(offset);
+ final FpgmTable table = new FpgmTable();
return table;
}
- @Override
- public String getTableTag() {
- return "fpgm";
- }
-
}
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-21 14:42:24 UTC (rev 13468)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GaspTable.java 2025-04-21 15:42:24 UTC (rev 13469)
@@ -29,8 +29,7 @@
package org.foray.font.ttf.table;
import org.foray.common.RandomAccessInput;
-import org.foray.font.ttf.RwTable;
-import org.foray.font.ttf.TtfOffsetTableRecord;
+import org.foray.font.ttf.RoTable;
import java.io.IOException;
@@ -38,33 +37,21 @@
* 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.
*/
-public class GaspTable extends RwTable {
+public class GaspTable extends RoTable {
/**
- * Constructor.
- * @param offsetRecord The parent table directory entry.
- */
- public GaspTable(final TtfOffsetTableRecord offsetRecord) {
- super(offsetRecord);
- }
-
- /**
* Parse the table from the table content.
- * @param offsetRecord The parent offset table record.
- * @param raInput The input which is being parsed.
+ * @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.
*/
- public static GaspTable parse(final TtfOffsetTableRecord offsetRecord, final RandomAccessInput raInput)
+ public static GaspTable parse(final RandomAccessInput input, final int offset, final int length)
throws IOException {
- raInput.seek(offsetRecord.getOffset());
- final GaspTable table = new GaspTable(offsetRecord);
+ input.seek(offset);
+ final GaspTable table = new GaspTable();
return table;
}
- @Override
- public String getTableTag() {
- return "cvt";
- }
-
}
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-21 14:42:24 UTC (rev 13468)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GdefTable.java 2025-04-21 15:42:24 UTC (rev 13469)
@@ -29,8 +29,7 @@
package org.foray.font.ttf.table;
import org.foray.common.RandomAccessInput;
-import org.foray.font.ttf.RwTable;
-import org.foray.font.ttf.TtfOffsetTableRecord;
+import org.foray.font.ttf.RoTable;
import java.io.IOException;
@@ -38,33 +37,21 @@
* An OpenType "GDEF" (Glyph Definition Data) table.
* This table is an Advanced Typographic Table.
*/
-public class GdefTable extends RwTable {
+public class GdefTable extends RoTable {
/**
- * Constructor.
- * @param offsetRecord The parent table directory entry.
- */
- public GdefTable(final TtfOffsetTableRecord offsetRecord) {
- super(offsetRecord);
- }
-
- /**
* Parse the table from the table content.
- * @param offsetRecord The parent offset table record.
- * @param raInput The input which is being parsed.
+ * @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.
*/
- public static GdefTable parse(final TtfOffsetTableRecord offsetRecord, final RandomAccessInput raInput)
+ public static GdefTable parse(final RandomAccessInput input, final int offset, final int length)
throws IOException {
- raInput.seek(offsetRecord.getOffset());
- final GdefTable table = new GdefTable(offsetRecord);
+ input.seek(offset);
+ final GdefTable table = new GdefTable();
return table;
}
- @Override
- public String getTableTag() {
- return "GDEF";
- }
-
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GlyfTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GlyfTable.java 2025-04-21 14:42:24 UTC (rev 13468)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GlyfTable.java 2025-04-21 15:42:24 UTC (rev 13469)
@@ -31,8 +31,6 @@
import org.foray.common.RandomAccessInput;
import org.foray.common.data.BoundingBoxShort;
import org.foray.font.ttf.RoTable;
-import org.foray.font.ttf.RwTable;
-import org.foray.font.ttf.TtfOffsetTableRecord;
import org.foray.primitive.BitUtils;
import org.axsl.ps.BoundingBox;
@@ -43,7 +41,7 @@
* A TrueType/OpenType "glyf" (Glyph Data) table.
* This table is used only in fonts that contain TrueType outlines.
*/
-public class GlyfTable extends RwTable {
+public class GlyfTable extends RoTable {
/** The size, in bytes, of the header portion of this table. */
public static final byte HEADER_SIZE = RoTable.SHORT_BYTES + RoTable.FWORD_BYTES
@@ -77,17 +75,10 @@
public static final byte CF_BIT_USE_MY_METRICS = 9;
/**
- * Constructor.
- * @param dirEntry The parent table directory entry.
- */
- public GlyfTable(final TtfOffsetTableRecord dirEntry) {
- super(dirEntry);
- }
-
- /**
* Reads the "glyf" table to find the bounding boxes.
- * @param dirEntry The parent table directory entry.
- * @param raInput The input which is being parsed.
+ * @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 numberOfGlyphs The number of glyphs to be parsed.
* This data is derived from the "maxp" table.
* @param hmtx The related horizontal metrics (hmtx) table.
@@ -94,20 +85,20 @@
* @return The parsed instance.
* @throws IOException For I/O Error.
*/
- public static GlyfTable parse(final TtfOffsetTableRecord dirEntry, final RandomAccessInput raInput,
+ public static GlyfTable parse(final RandomAccessInput input, final int offset, final int length,
final int numberOfGlyphs, final HtmxTable hmtx) throws IOException {
- raInput.seek(dirEntry.getOffset());
- final GlyfTable glyf = new GlyfTable(dirEntry);
+ input.seek(offset);
+ final GlyfTable glyf = new GlyfTable();
final MtxEntry firstMetric = hmtx.getMtxEntry(0);
for (int i = 0; i < (numberOfGlyphs - 1); i++) {
final MtxEntry thisMetric = hmtx.getMtxEntry(i);
final MtxEntry nextMetric = hmtx.getMtxEntry(i + 1);
if (thisMetric.getOffset() != nextMetric.getOffset()) {
- raInput.seek(dirEntry.getOffset() + thisMetric.getOffset());
- raInput.skipBytes(2);
+ input.seek(offset + thisMetric.getOffset());
+ input.skipBytes(2);
final short[] bboxEntries = new short[BoundingBox.QTY_ENTRIES];
for (int j = 0; j < BoundingBox.QTY_ENTRIES; j++) {
- bboxEntries[j] = raInput.readShort();
+ bboxEntries[j] = input.readShort();
}
thisMetric.setBoundingBox(new BoundingBoxShort(bboxEntries));
} else {
@@ -115,17 +106,17 @@
}
}
- final int n = dirEntry.getOffset();
+ final int n = offset;
for (int i = 0; i < numberOfGlyphs; i++) {
final MtxEntry thisMetric = hmtx.getMtxEntry(i);
final MtxEntry nextMetric = hmtx.getMtxEntry(i + 1);
if ((i + 1) >= hmtx.numMtxEntries()
|| thisMetric.getOffset() != nextMetric.getOffset()) {
- raInput.seek(n + thisMetric.getOffset());
- raInput.skipBytes(2);
+ input.seek(n + thisMetric.getOffset());
+ input.skipBytes(2);
final short[] bboxEntries = new short[BoundingBox.QTY_ENTRIES];
for (int j = 0; j < BoundingBox.QTY_ENTRIES; j++) {
- bboxEntries[j] = raInput.readShort();
+ bboxEntries[j] = input.readShort();
}
thisMetric.setBoundingBox(new BoundingBoxShort(bboxEntries));
} else {
@@ -135,11 +126,6 @@
return glyf;
}
- @Override
- public String getTableTag() {
- return "glyf";
- }
-
/**
* Computes the size, in bytes, of a composite entry, based on the flags for that entry.
* @param compositeFlags The flags for the entry.
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-21 14:42:24 UTC (rev 13468)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GposTable.java 2025-04-21 15:42:24 UTC (rev 13469)
@@ -29,8 +29,7 @@
package org.foray.font.ttf.table;
import org.foray.common.RandomAccessInput;
-import org.foray.font.ttf.RwTable;
-import org.foray.font.ttf.TtfOffsetTableRecord;
+import org.foray.font.ttf.RoTable;
import java.io.IOException;
@@ -38,33 +37,21 @@
* An OpenType "GPOS" (Glyph Positioning Data) table.
* This table is an Advanced Typographic Table.
*/
-public class GposTable extends RwTable {
+public class GposTable extends RoTable {
/**
- * Constructor.
- * @param offsetRecord The parent table directory entry.
- */
- public GposTable(final TtfOffsetTableRecord offsetRecord) {
- super(offsetRecord);
- }
-
- /**
* Parse the table from the table content.
- * @param offsetRecord The parent offset table record.
- * @param raInput The input which is being parsed.
+ * @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.
*/
- public static GposTable parse(final TtfOffsetTableRecord offsetRecord, final RandomAccessInput raInput)
+ public static GposTable parse(final RandomAccessInput input, final int offset, final int length)
throws IOException {
- raInput.seek(offsetRecord.getOffset());
- final GposTable table = new GposTable(offsetRecord);
+ input.seek(offset);
+ final GposTable table = new GposTable();
return table;
}
- @Override
- public String getTableTag() {
- return "GPOS";
- }
-
}
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-21 14:42:24 UTC (rev 13468)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GsubTable.java 2025-04-21 15:42:24 UTC (rev 13469)
@@ -53,13 +53,11 @@
/**
* Constructor.
- * @param offsetRecord The parent table directory entry.
* @param scriptMap The scripts for this table.
* @param featureMap The features for this table.
*/
- public GsubTable(final TtfOffsetTableRecord offsetRecord, final Map<String, OtfScript> scriptMap,
- final Map<String, OtfFeature> featureMap) {
- super(offsetRecord, scriptMap, featureMap);
+ public GsubTable(final Map<String, OtfScript> scriptMap, final Map<String, OtfFeature> featureMap) {
+ super(scriptMap, featureMap);
}
/**
@@ -89,7 +87,7 @@
final Map<String, OtfFeature> featureMap =
parseFeatureList(raInput, offsetRecord.getOffset() + featureListOffset);
- final GsubTable table = new GsubTable(offsetRecord, scriptMap, featureMap);
+ final GsubTable table = new GsubTable(scriptMap, featureMap);
table.lookupList = parseLookupList(raInput, offsetRecord.getOffset() + lookupListOffset);
parseFeatureVariations(raInput, offsetRecord.getOffset() + featureVariationsOffset);
@@ -121,11 +119,6 @@
return lookupList;
}
- @Override
- public String getTableTag() {
- return "GSUB";
- }
-
/**
* Returns the lookup list.
* @return The lookup list.
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HeadTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HeadTable.java 2025-04-21 14:42:24 UTC (rev 13468)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HeadTable.java 2025-04-21 15:42:24 UTC (rev 13469)
@@ -32,8 +32,7 @@
import org.foray.common.data.BoundingBoxUtils;
import org.foray.common.primitive.PrimitiveFerry;
import org.foray.font.FontContentHandler;
-import org.foray.font.ttf.RwTable;
-import org.foray.font.ttf.TtfOffsetTableRecord;
+import org.foray.font.ttf.RoTable;
import org.foray.font.ttf.TtfRandomAccessInput;
import org.foray.font.ttf.parse.HeadTableParser;
@@ -44,7 +43,7 @@
/**
* Class representing a TTF "head" table.
*/
-public class HeadTable extends RwTable {
+public class HeadTable extends RoTable {
/**
* The handler of events from the parser.
@@ -112,33 +111,21 @@
private short indexToLocFormat;
/**
- * Constructor.
- * @param dirEntry The parent table directory entry.
- */
- public HeadTable(final TtfOffsetTableRecord dirEntry) {
- super(dirEntry);
- }
-
- /**
* Read the "head" table.
- * @param dirEntry The parent table directory entry.
* @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.
*/
- public static HeadTable parse(final TtfOffsetTableRecord dirEntry, final TtfRandomAccessInput input)
+ public static HeadTable parse(final TtfRandomAccessInput input, final int offset, final int length)
throws IOException {
- final HeadTable head = new HeadTable(dirEntry);
+ final HeadTable head = new HeadTable();
final HeadTableParser parser = new HeadTableParser();
- parser.parse("head", input, dirEntry.getOffset(), dirEntry.getLength(), head.new ParserConsumer(head));
+ parser.parse("head", input, offset, length, head.new ParserConsumer(head));
return head;
}
- @Override
- public String getTableTag() {
- return "head";
- }
-
/**
* Indicates whether the "long" or "short" version of the "loca" table is used.
* @return True if and only if the "long" version of the "loca" table is used.
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HheaTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HheaTable.java 2025-04-21 14:42:24 UTC (rev 13468)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HheaTable.java 2025-04-21 15:42:24 UTC (rev 13469)
@@ -30,8 +30,6 @@
import org.foray.common.RandomAccessInput;
import org.foray.font.ttf.RoTable;
-import org.foray.font.ttf.RwTable;
-import org.foray.font.ttf.TtfOffsetTableRecord;
import java.io.IOException;
@@ -38,7 +36,7 @@
/**
* Class representing a TTF "hhea" (horizontal header) table.
*/
-public class HheaTable extends RwTable {
+public class HheaTable extends RoTable {
/** Typographic ascent. */
private int ascender = 0;
@@ -53,63 +51,51 @@
private int numberOfHMetrics;
/**
- * Constructor.
- * @param dirEntry The parent table directory entry.
- */
- public HheaTable(final TtfOffsetTableRecord dirEntry) {
- super(dirEntry);
- }
-
- /**
* Parse the table.
- * @param dirEntry The parent table directory entry.
- * @param raInput The input which is being parsed.
+ * @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.
*/
- public static HheaTable parse(final TtfOffsetTableRecord dirEntry, final RandomAccessInput raInput)
+ public static HheaTable parse(final RandomAccessInput input, final int offset, final int length)
throws IOException {
- raInput.seek(dirEntry.getOffset());
- final HheaTable hhea = new HheaTable(dirEntry);
+ input.seek(offset);
+ final HheaTable hhea = new HheaTable();
/* Skip the table version number. */
- raInput.skipBytes(RoTable.FIXED_BYTES);
- hhea.ascender = raInput.readShort();
- hhea.descender = raInput.readShort();
+ input.skipBytes(RoTable.FIXED_BYTES);
+ hhea.ascender = input.readShort();
+ hhea.descender = input.readShort();
/* Skip the lineGap. */
- raInput.skipBytes(RoTable.FWORD_BYTES);
+ input.skipBytes(RoTable.FWORD_BYTES);
/* Skip the advanceWidthMax*/
- raInput.skipBytes(RoTable.UFWORD_BYTES);
+ input.skipBytes(RoTable.UFWORD_BYTES);
/* Skip the minLeftSideBearing*/
- raInput.skipBytes(RoTable.FWORD_BYTES);
+ input.skipBytes(RoTable.FWORD_BYTES);
/* Skip the minRightSideBearing*/
- raInput.skipBytes(RoTable.FWORD_BYTES);
+ input.skipBytes(RoTable.FWORD_BYTES);
/* Skip the xMaxExtent*/
- raInput.skipBytes(RoTable.FWORD_BYTES);
+ input.skipBytes(RoTable.FWORD_BYTES);
/* Skip the caretSlopeRise*/
- raInput.skipBytes(RoTable.SHORT_BYTES);
+ input.skipBytes(RoTable.SHORT_BYTES);
/* Skip the caretSlopeRun*/
- raInput.skipBytes(RoTable.SHORT_BYTES);
+ input.skipBytes(RoTable.SHORT_BYTES);
/* Skip this reserved area. */
- raInput.skipBytes(RoTable.SHORT_BYTES);
+ input.skipBytes(RoTable.SHORT_BYTES);
/* Skip this reserved area. */
- raInput.skipBytes(RoTable.SHORT_BYTES);
+ input.skipBytes(RoTable.SHORT_BYTES);
/* Skip this reserved area. */
- raInput.skipBytes(RoTable.SHORT_BYTES);
+ input.skipBytes(RoTable.SHORT_BYTES);
/* Skip this reserved area. */
- raInput.skipBytes(RoTable.SHORT_BYTES);
+ input.skipBytes(RoTable.SHORT_BYTES);
/* Skip this reserved area. */
- raInput.skipBytes(RoTable.SHORT_BYTES);
+ input.skipBytes(RoTable.SHORT_BYTES);
/* Skip the metricDataFormat. */
- raInput.skipBytes(RoTable.SHORT_BYTES);
- hhea.numberOfHMetrics = raInput.readUnsignedShort();
+ input.skipBytes(RoTable.SHORT_BYTES);
+ hhea.numberOfHMetrics = input.readUnsignedShort();
return hhea;
}
- @Override
- public String getTableTag() {
- return "hhea";
- }
-
/**
* Returns the ascender.
* @return The ascender.
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HtmxTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HtmxTable.java 2025-04-21 14:42:24 UTC (rev 13468)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HtmxTable.java 2025-04-21 15:42:24 UTC (rev 13469)
@@ -29,8 +29,7 @@
package org.foray.font.ttf.table;
import org.foray.common.RandomAccessInput;
-import org.foray.font.ttf.RwTable;
-import org.foray.font.ttf.TtfOffsetTableRecord;
+import org.foray.font.ttf.RoTable;
import java.io.IOException;
@@ -37,25 +36,18 @@
/**
* Class representing a TTF "hmtx" (horizontal metrics) table.
*/
-public class HtmxTable extends RwTable {
+public class HtmxTable extends RoTable {
/** The metrics entries for this table. */
private MtxEntry[] metrics;
/**
- * Constructor.
- * @param dirEntry The parent table directory entry.
- */
- public HtmxTable(final TtfOffsetTableRecord dirEntry) {
- super(dirEntry);
- }
-
- /**
* Read "hmtx" table and put the horizontal metrics in the metrics array.
* If the number of metrics is less than the number of glyphs (eg fixed size fonts), extend the metrics array and
* fill in the missing widths.
- * @param dirEntry The parent table directory entry.
- * @param raInput The input which is being parsed.
+ * @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 numberOfGlyphs The number of glyphs in the font.
* This information is derived from the "maxp" table.
* @param numberOfHMetrics The number of horizontal metrics in the font.
@@ -63,11 +55,10 @@
* @return The parsed instance.
* @throws IOException For I/O Error.
*/
- public static HtmxTable parse(final TtfOffsetTableRecord dirEntry, final RandomAccessInput raInput,
- final int numberOfGlyphs, final int numberOfHMetrics)
- throws IOException {
- raInput.seek(dirEntry.getOffset());
- final HtmxTable hmtx = new HtmxTable(dirEntry);
+ public static HtmxTable parse(final RandomAccessInput input, final int offset, final int length,
+ final int numberOfGlyphs, final int numberOfHMetrics) throws IOException {
+ input.seek(offset);
+ final HtmxTable hmtx = new HtmxTable();
final int metricsSize = Math.max(numberOfGlyphs, numberOfHMetrics);
hmtx.metrics = new MtxEntry[metricsSize];
@@ -75,8 +66,8 @@
hmtx.metrics[i] = new MtxEntry();
}
for (int i = 0; i < numberOfHMetrics; i++) {
- hmtx.metrics[i].setWidth(raInput.readUnsignedShort());
- hmtx.metrics[i].setLeftSideBearing(raInput.readShort());
+ hmtx.metrics[i].setWidth(input.readUnsignedShort());
+ hmtx.metrics[i].setLeftSideBearing(input.readShort());
}
if (numberOfHMetrics < metricsSize) {
@@ -84,17 +75,12 @@
final int lastWidth = hmtx.metrics[numberOfHMetrics - 1].getWidth();
for (int i = numberOfHMetrics; i < metricsSize; i++) {
hmtx.metrics[i].setWidth(lastWidth);
- hmtx.metrics[i].setLeftSideBearing(raInput.readShort());
+ hmtx.metrics[i].setLeftSideBearing(input.readShort());
}
}
return hmtx;
}
- @Override
- public String getTableTag() {
- return "hmtx";
- }
-
/**
* Return a specific metric record.
* @param index The index to the desired metric record.
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-21 14:42:24 UTC (rev 13468)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/JstfTable.java 2025-04-21 15:42:24 UTC (rev 13469)
@@ -29,8 +29,7 @@
package org.foray.font.ttf.table;
import org.foray.common.RandomAccessInput;
-import org.foray.font.ttf.RwTable;
-import org.foray.font.ttf.TtfOffsetTableRecord;
+import org.foray.font.ttf.RoTable;
import java.io.IOException;
@@ -38,33 +37,21 @@
* An OpenType "JSTF" (Justification Data) table.
* This table is an Advanced Typographic Table.
*/
-public class JstfTable extends RwTable {
+public class JstfTable extends RoTable {
/**
- * Constructor.
- * @param offsetRecord The parent table directory entry.
- */
- public JstfTable(final TtfOffsetTableRecord offsetRecord) {
- super(offsetRecord);
- }
-
- /**
* Parse the table from the table content.
- * @param offsetRecord The parent offset table record.
- * @param raInput The input which is being parsed.
+ * @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.
*/
- public static JstfTable parse(final TtfOffsetTableRecord offsetRecord, final RandomAccessInput raInput)
+ public static JstfTable parse(final RandomAccessInput input, final int offset, final int length)
throws IOException {
- raInput.seek(offsetRecord.getOffset());
- final JstfTable table = new JstfTable(offsetRecord);
+ input.seek(offset);
+ final JstfTable table = new JstfTable();
return table;
}
- @Override
- public String getTableTag() {
- return "JSTF";
- }
-
}
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-21 14:42:24 UTC (rev 13468)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/KernTable.java 2025-04-21 15:42:24 UTC (rev 13469)
@@ -31,8 +31,6 @@
import org.foray.common.RandomAccessInput;
import org.foray.font.format.Kerning;
import org.foray.font.ttf.RoTable;
-import org.foray.font.ttf.RwTable;
-import org.foray.font.ttf.TtfOffsetTableRecord;
import org.foray.primitive.BitUtils;
import org.axsl.constants.PrimitiveConstants;
@@ -42,7 +40,7 @@
/**
* Class representing a TTF "kern" (kerning) table.
*/
-public class KernTable extends RwTable {
+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. */
@@ -60,30 +58,23 @@
private Kerning kerning;
/**
- * Constructor.
- * @param dirEntry The parent table directory entry.
- */
- public KernTable(final TtfOffsetTableRecord dirEntry) {
- super(dirEntry);
- }
-
- /**
* Parse the needed information from the table contents.
- * @param dirEntry The parent table directory entry.
- * @param raInput The input which is being parsed.
+ * @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 TtfOffsetTableRecord dirEntry, final RandomAccessInput raInput,
+ public static KernTable parse(final RandomAccessInput input, final int offset, final int length,
final CmapTable cmap) throws IOException {
- raInput.seek(dirEntry.getOffset());
- final KernTable kern = new KernTable(dirEntry);
+ input.seek(offset);
+ final KernTable kern = new KernTable();
/* Skip the Table Version. */
- raInput.skipBytes(RoTable.USHORT_BYTES);
- final int qtySubtables = raInput.readUnsignedShort();
+ input.skipBytes(RoTable.USHORT_BYTES);
+ final int qtySubtables = input.readUnsignedShort();
for (int i = 0; i < qtySubtables; i++) {
- readNextSubtable(kern, raInput, cmap);
+ readNextSubtable(kern, input, cmap);
}
if (kern.kerning != null) {
kern.kerning.lock();
@@ -201,11 +192,6 @@
return (short) (coverage >> PrimitiveConstants.SHIFT_1_BYTE);
}
- @Override
- public String getTableTag() {
- return "kern";
- }
-
/**
* Returns the parsed kerning information for this table.
* @return The parsed kerning information for this table.
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/LocaTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/LocaTable.java 2025-04-21 14:42:24 UTC (rev 13468)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/LocaTable.java 2025-04-21 15:42:24 UTC (rev 13469)
@@ -29,8 +29,7 @@
package org.foray.font.ttf.table;
import org.foray.common.RandomAccessInput;
-import org.foray.font.ttf.RwTable;
-import org.foray.font.ttf.TtfOffsetTableRecord;
+import org.foray.font.ttf.RoTable;
import java.io.IOException;
@@ -38,7 +37,7 @@
* A TrueType/OpenType "loca" (Index to location) table.
* This table is used only in fonts that contain TrueType outlines.
*/
-public class LocaTable extends RwTable {
+public class LocaTable extends RoTable {
/** The last offset value in the table, which points to no glyph, but
* exists to be able to compute the size of the previous entry. */
@@ -45,17 +44,10 @@
private long lastOffset = 0;
/**
- * Constructor.
- * @param dirEntry The parent table directory entry.
- */
- public LocaTable(final TtfOffsetTableRecord dirEntry) {
- super(dirEntry);
- }
-
- /**
* Reads the "loca" table.
- * @param dirEntry The parent table directory entry.
- * @param raInput The input which is being parsed.
+ * @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 isLongFormat Indicates whether the long format (true) or the short format (false) should be used.
* This information is derived from the "head" table.
* @param numberOfGlyphs The number of glyph entries to be parsed.
@@ -64,28 +56,23 @@
* @return The parsed instance.
* @throws IOException For I/O Error.
*/
- public static LocaTable parse(final TtfOffsetTableRecord dirEntry, final RandomAccessInput raInput,
+ public static LocaTable parse(final RandomAccessInput input, final int offset, final int length,
final boolean isLongFormat, final int numberOfGlyphs, final HtmxTable hmtx) throws IOException {
- raInput.seek(dirEntry.getOffset());
- final LocaTable loca = new LocaTable(dirEntry);
+ input.seek(offset);
+ final LocaTable loca = new LocaTable();
for (int i = 0; i < numberOfGlyphs; i++) {
final long entry;
if (isLongFormat) {
- entry = raInput.readUnsignedInt();
+ entry = input.readUnsignedInt();
} else {
- entry = raInput.readUnsignedShort() << 1;
+ entry = input.readUnsignedShort() << 1;
}
hmtx.getMtxEntry(i).setOffset(entry);
}
- lo...
[truncated message content] |
|
From: <vic...@us...> - 2025-04-21 14:42:42
|
Revision: 13468
http://sourceforge.net/p/foray/code/13468
Author: victormote
Date: 2025-04-21 14:42:24 +0000 (Mon, 21 Apr 2025)
Log Message:
-----------
Split TtfTable into RoTable (read-only) and RwTable (read-write) in first step toward simplifying read-only font access.
Modified Paths:
--------------
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
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLanguageSystem.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtcTableHeader.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfOffsetTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfOffsetTableRecord.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfSubSetFile.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/Os2TableParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/AbstractOtfLayoutTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseTable.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/CmapTable.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/GlyfTable.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/HeadTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HheaTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HtmxTable.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/KernTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/LocaTable.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/MaxpTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/NameTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Os2Table.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PcltTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PostTable.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/src/main/java/org/foray/font/ttf/RoTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/RwTable.java
Removed Paths:
-------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTable.java
Modified: 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-21 12:02:44 UTC (rev 13467)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfCoveragex01.java 2025-04-21 14:42:24 UTC (rev 13468)
@@ -53,7 +53,7 @@
final OtfCoveragex01 coverage = new OtfCoveragex01();
/* Skip reading the CoverageFormat. We already read it when deciding to come here. */
- raInput.skipBytes(TtfTable.USHORT_BYTES);
+ raInput.skipBytes(RoTable.USHORT_BYTES);
final int glyphCount = raInput.readUnsignedShort();
coverage.glyphArray = new char[glyphCount];
for (int index = 0; index < coverage.glyphArray.length; index ++) {
Modified: 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-21 12:02:44 UTC (rev 13467)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfCoveragex02.java 2025-04-21 14:42:24 UTC (rev 13468)
@@ -92,7 +92,7 @@
final OtfCoveragex02 coverage = new OtfCoveragex02();
/* Skip reading the CoverageFormat. We already read it when deciding to come here. */
- raInput.skipBytes(TtfTable.USHORT_BYTES);
+ raInput.skipBytes(RoTable.USHORT_BYTES);
final int rangeCount = raInput.readUnsignedShort();
coverage.ranges = new RangeRecord[rangeCount];
for (int index = 0; index < coverage.ranges.length; index ++) {
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLanguageSystem.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLanguageSystem.java 2025-04-21 12:02:44 UTC (rev 13467)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLanguageSystem.java 2025-04-21 14:42:24 UTC (rev 13468)
@@ -64,7 +64,7 @@
raInput.seek(offset);
final OtfLanguageSystem langSys = new OtfLanguageSystem();
/* Skip the LookupOrder. */
- raInput.skipBytes(TtfTable.OFFSET_BYTES);
+ raInput.skipBytes(RoTable.OFFSET_BYTES);
langSys.reqFeatureIndex = raInput.readChar();
final int featureCount = raInput.readUnsignedShort();
langSys.featureIndexes = new char[featureCount];
Added: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/RoTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/RoTable.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/RoTable.java 2025-04-21 14:42:24 UTC (rev 13468)
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2004 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;
+
+/**
+ * Superclass for all Read-Only TTF Table classes.
+ */
+public abstract class RoTable {
+
+ /**
+ * Enumeration of valid <em>table</em> major versions, not to be confused with TrueType or OpenType version numbers.
+ */
+ public enum MajorVersion {
+
+ /** Major version 0. */
+ v0(0),
+
+ /** Major version 0. */
+ v1(1),
+
+ /** Major version 0. */
+ v2(2),
+
+ /** Major version 0. */
+ v3(3),
+
+ /** Major version 0. */
+ v4(4),
+
+ /** Major version 0. */
+ v5(5);
+
+ /** The numeric value. */
+ private byte value;
+
+ /**
+ * Constructor.
+ * @param value The numeric value.
+ */
+ MajorVersion(final int value) {
+ this.value = (byte) value;
+ }
+
+ /**
+ * Returns the numeric value.
+ * @return The numeric value.
+ */
+ public byte getValue() {
+ return this.value;
+ }
+ }
+
+ /** The size, in bytes of the data type "BYTE", that is, 1. */
+ public static final byte BYTE_BYTES = 1;
+
+ /** The size, in bytes of the data type "CHAR", that is, 1. */
+ public static final byte CHAR_BYTES = 1;
+
+ /** The size, in bytes of the data type "USHORT", that is, 2. */
+ public static final byte USHORT_BYTES = 2;
+
+ /** The size, in bytes of the data type "SHORT", that is, 2. */
+ public static final byte SHORT_BYTES = 2;
+
+ /** The size, in bytes of the data type "ULONG", that is, 4. */
+ public static final byte ULONG_BYTES = 4;
+
+ /** The size, in bytes of the data type "LONG", that is, 4. */
+ public static final byte LONG_BYTES = 4;
+
+ /** The size, in bytes of the data type "FIXED", that is, 4. */
+ public static final byte FIXED_BYTES = 4;
+
+ /** The size, in bytes of the data type "FWORD", that is, 2. */
+ public static final byte FWORD_BYTES = RoTable.SHORT_BYTES;
+
+ /** The size, in bytes of the data type "UFWORD", that is, 2. */
+ public static final byte UFWORD_BYTES = RoTable.USHORT_BYTES;
+
+ /** The size, in bytes of the data type "F2DOT14", that is, 2. */
+ public static final byte F2DOT14_BYTES = 2;
+
+ /** The size, in bytes of the data type "International Date", that is, 8. */
+ public static final byte LONG_DATE_TIME_BYTES = 8;
+
+ /** The size, in bytes of the data type "Offset", that is, 2. */
+ public static final byte OFFSET_BYTES = USHORT_BYTES;
+
+}
Property changes on: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/RoTable.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/RwTable.java (from rev 13455, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTable.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/RwTable.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/RwTable.java 2025-04-21 14:42:24 UTC (rev 13468)
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2004 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;
+
+/**
+ * Superclass for all Read-Write TTF Table classes.
+ */
+public abstract class RwTable extends RoTable {
+
+
+ /** The Table Directory Entry corresponding to this table. */
+ private TtfOffsetTableRecord tableDirEntry;
+
+ /**
+ * Constructor.
+ * @param tableDirEntry The TTFTableDirEntry that defines this table.
+ */
+ public RwTable(final TtfOffsetTableRecord tableDirEntry) {
+ this.tableDirEntry = tableDirEntry;
+ tableDirEntry.setTable(this);
+ }
+
+ /**
+ * Return the 4-character name of this table, for example, "post" or "glyf".
+ * @return The name of this table.
+ */
+ public abstract String getTableTag();
+
+ /**
+ * Returns the TTFTableDirEntry that goes with this table.
+ * @return The TTFTableDirEntry related to this table.
+ */
+ public TtfOffsetTableRecord getTableDirEntry() {
+ return this.tableDirEntry;
+ }
+
+}
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-21 12:02:44 UTC (rev 13467)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-04-21 14:42:24 UTC (rev 13468)
@@ -612,7 +612,7 @@
*/
public int getCapHeight() {
if ((this.os2Table != null)
- && (this.os2Table.getVersion() >= TtfTable.MajorVersion.v2.getValue())) {
+ && (this.os2Table.getVersion() >= RoTable.MajorVersion.v2.getValue())) {
return this.os2Table.getCapHeight();
}
if (this.pcltTable != null) {
@@ -635,7 +635,7 @@
*/
public int getXHeight() {
if ((this.os2Table != null)
- && (this.os2Table.getVersion() >= TtfTable.MajorVersion.v2.getValue())) {
+ && (this.os2Table.getVersion() >= RoTable.MajorVersion.v2.getValue())) {
return this.os2Table.getXHeight();
}
if (this.pcltTable != null) {
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtcTableHeader.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtcTableHeader.java 2025-04-21 12:02:44 UTC (rev 13467)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtcTableHeader.java 2025-04-21 14:42:24 UTC (rev 13468)
@@ -64,9 +64,9 @@
/* Start at beginning of file. */
raInput.seek(0);
/* Skip TTCTag. */
- raInput.skipBytes(TtfTable.FIXED_BYTES);
+ raInput.skipBytes(RoTable.FIXED_BYTES);
/* Skip Version. */
- raInput.skipBytes(TtfTable.FIXED_BYTES);
+ raInput.skipBytes(RoTable.FIXED_BYTES);
/* Read DirectoryCount. */
final int numDirectories = (int) raInput.readUnsignedInt();
/* Read array of table directories. */
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfOffsetTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfOffsetTable.java 2025-04-21 12:02:44 UTC (rev 13467)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfOffsetTable.java 2025-04-21 14:42:24 UTC (rev 13468)
@@ -88,15 +88,15 @@
final TtfOffsetTable directory = new TtfOffsetTable(container);
raInput.seek(fileOffset);
/* Skip sfnt version (format version). */
- raInput.skipBytes(TtfTable.FIXED_BYTES);
+ raInput.skipBytes(RoTable.FIXED_BYTES);
/* Read the number of tables. */
final int numberOfTables = raInput.readUnsignedShort();
/* Skip the searchRange. */
- raInput.skipBytes(TtfTable.USHORT_BYTES);
+ raInput.skipBytes(RoTable.USHORT_BYTES);
/* Skip the entrySelector. */
- raInput.skipBytes(TtfTable.USHORT_BYTES);
+ raInput.skipBytes(RoTable.USHORT_BYTES);
/* Skip the rangeShift. */
- raInput.skipBytes(TtfTable.USHORT_BYTES);
+ raInput.skipBytes(RoTable.USHORT_BYTES);
for (int i = 0; i < numberOfTables; i++) {
final TtfOffsetTableRecord entry = TtfOffsetTableRecord.parse(directory, raInput);
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfOffsetTableRecord.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfOffsetTableRecord.java 2025-04-21 12:02:44 UTC (rev 13467)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfOffsetTableRecord.java 2025-04-21 14:42:24 UTC (rev 13468)
@@ -47,7 +47,7 @@
/** The related TtfTable. This is null until the table has been parsed.
* There is a nominal one-to-one relationship between a TTFTableDirEntry and a TtfTable. */
- private TtfTable ttfTable = null;
+ private RwTable ttfTable = null;
/** The tag for the table. */
private String tag;
@@ -80,9 +80,9 @@
throws IOException {
final TtfOffsetTableRecord entry = new TtfOffsetTableRecord(directory);
/* Read the 4-byte table identifier. */
- entry.tag = raInput.readString(TtfTable.ULONG_BYTES, StandardCharsets.ISO_8859_1);
+ entry.tag = raInput.readString(RoTable.ULONG_BYTES, StandardCharsets.ISO_8859_1);
/* Skip the checkSum. */
- raInput.skipBytes(TtfTable.ULONG_BYTES);
+ raInput.skipBytes(RoTable.ULONG_BYTES);
/* Read the offset to the table. */
entry.offset = (int) raInput.readUnsignedInt();
/* Read the length of the table. */
@@ -130,7 +130,7 @@
* read and parsed later.
* @param table The table that corresponds to this entry.
*/
- protected void setTable(final TtfTable table) {
+ protected void setTable(final RwTable table) {
this.ttfTable = table;
}
@@ -139,7 +139,7 @@
* @return The TtfTable that this entry points to, if it has been parsed,
* or null otherwise.
*/
- public TtfTable getTable() {
+ public RwTable getTable() {
return this.ttfTable;
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfSubSetFile.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfSubSetFile.java 2025-04-21 12:02:44 UTC (rev 13467)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfSubSetFile.java 2025-04-21 14:42:24 UTC (rev 13468)
@@ -274,11 +274,11 @@
writeString(byteArray, arrayIndex, tableName);
/* Although we write a String, the String is fixed at the size of
* a ULONG. */
- arrayIndex += TtfTable.ULONG_BYTES;
+ arrayIndex += RoTable.ULONG_BYTES;
writeULong(byteArray, arrayIndex, tableChecksum);
- arrayIndex += TtfTable.ULONG_BYTES;
+ arrayIndex += RoTable.ULONG_BYTES;
writeULong(byteArray, arrayIndex, tableOffset);
- arrayIndex += TtfTable.ULONG_BYTES;
+ arrayIndex += RoTable.ULONG_BYTES;
writeULong(byteArray, arrayIndex, tableArray.length);
}
return byteArray;
@@ -342,13 +342,13 @@
*/
private byte[] createLoca() throws IOException {
final int arraySize = (this.subset.numGlyphsUsed() + 1)
- * TtfTable.ULONG_BYTES;
+ * RoTable.ULONG_BYTES;
final byte[] byteArray = createTableByteArray(arraySize);
int endOffset = 0; // Store this as the last loca
for (int i = 0; i < this.subset.numGlyphsUsed(); i++) {
final int origGlyphIndex = this.subset.decodeSubsetIndex(i);
final int glyphLength = computeGlyphLength(origGlyphIndex);
- writeULong(byteArray, i * TtfTable.ULONG_BYTES, endOffset);
+ writeULong(byteArray, i * RoTable.ULONG_BYTES, endOffset);
if ((endOffset + glyphLength) > endOffset) {
endOffset = endOffset + glyphLength;
}
@@ -355,7 +355,7 @@
}
// Write the "extra" entry
writeULong(byteArray, this.subset.numGlyphsUsed()
- * TtfTable.ULONG_BYTES, endOffset);
+ * RoTable.ULONG_BYTES, endOffset);
return byteArray;
}
@@ -376,7 +376,7 @@
final byte[] byteArray = copyTableToByteArray(entry.getLength());
int arrayIndex = 0;
/* Skip the table name (already written). */
- arrayIndex += TtfTable.ULONG_BYTES;
+ arrayIndex += RoTable.ULONG_BYTES;
/* Set numGlyphs to its proper value. */
writeUShort(byteArray, arrayIndex, this.subset.numGlyphsUsed());
return byteArray;
@@ -532,8 +532,8 @@
if (entry == null) {
return null;
}
- final int widthSize = TtfTable.UFWORD_BYTES;
- final int lsbSize = TtfTable.FWORD_BYTES;
+ final int widthSize = RoTable.UFWORD_BYTES;
+ final int lsbSize = RoTable.FWORD_BYTES;
final int entrySize = widthSize + lsbSize;
final int arraySize = this.subset.numGlyphsUsed() * entrySize;
final byte[] byteArray = createTableByteArray(arraySize);
@@ -606,7 +606,7 @@
boolean moreComposites = true;
while (moreComposites) {
final int flags = readTTFUShort(byteArray, offset);
- final int indexOffset = offset + TtfTable.USHORT_BYTES;
+ final int indexOffset = offset + RoTable.USHORT_BYTES;
final char compositeIdx = (char) readTTFUShort(byteArray,
indexOffset);
final int newIndex = this.subset.encodeSubsetIndex(compositeIdx);
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTable.java 2025-04-21 12:02:44 UTC (rev 13467)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTable.java 2025-04-21 14:42:24 UTC (rev 13468)
@@ -1,141 +0,0 @@
-/*
- * Copyright 2004 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;
-
-/**
- * Superclass for all TTF Table classes.
- */
-public abstract class TtfTable {
-
- /**
- * Enumeration of valid <em>table</em> major versions, not to be confused with TrueType or OpenType version numbers.
- */
- public enum MajorVersion {
-
- /** Major version 0. */
- v0(0),
-
- /** Major version 0. */
- v1(1),
-
- /** Major version 0. */
- v2(2),
-
- /** Major version 0. */
- v3(3),
-
- /** Major version 0. */
- v4(4),
-
- /** Major version 0. */
- v5(5);
-
- /** The numeric value. */
- private byte value;
-
- /**
- * Constructor.
- * @param value The numeric value.
- */
- MajorVersion(final int value) {
- this.value = (byte) value;
- }
-
- /**
- * Returns the numeric value.
- * @return The numeric value.
- */
- public byte getValue() {
- return this.value;
- }
- }
-
- /** The size, in bytes of the data type "BYTE", that is, 1. */
- protected static final byte BYTE_BYTES = 1;
-
- /** The size, in bytes of the data type "CHAR", that is, 1. */
- protected static final byte CHAR_BYTES = 1;
-
- /** The size, in bytes of the data type "USHORT", that is, 2. */
- protected static final byte USHORT_BYTES = 2;
-
- /** The size, in bytes of the data type "SHORT", that is, 2. */
- protected static final byte SHORT_BYTES = 2;
-
- /** The size, in bytes of the data type "ULONG", that is, 4. */
- protected static final byte ULONG_BYTES = 4;
-
- /** The size, in bytes of the data type "LONG", that is, 4. */
- protected static final byte LONG_BYTES = 4;
-
- /** The size, in bytes of the data type "FIXED", that is, 4. */
- protected static final byte FIXED_BYTES = 4;
-
- /** The size, in bytes of the data type "FWORD", that is, 2. */
- protected static final byte FWORD_BYTES = TtfTable.SHORT_BYTES;
-
- /** The size, in bytes of the data type "UFWORD", that is, 2. */
- protected static final byte UFWORD_BYTES = TtfTable.USHORT_BYTES;
-
- /** The size, in bytes of the data type "F2DOT14", that is, 2. */
- protected static final byte F2DOT14_BYTES = 2;
-
- /** The size, in bytes of the data type "International Date", that is, 8. */
- protected static final byte LONG_DATE_TIME_BYTES = 8;
-
- /** The size, in bytes of the data type "Offset", that is, 2. */
- protected static final byte OFFSET_BYTES = USHORT_BYTES;
-
- /** The Table Directory Entry corresponding to this table. */
- private TtfOffsetTableRecord tableDirEntry;
-
- /**
- * Constructor.
- * @param tableDirEntry The TTFTableDirEntry that defines this table.
- */
- public TtfTable(final TtfOffsetTableRecord tableDirEntry) {
- this.tableDirEntry = tableDirEntry;
- tableDirEntry.setTable(this);
- }
-
- /**
- * Return the 4-character name of this table, for example, "post" or "glyf".
- * @return The name of this table.
- */
- public abstract String getTableTag();
-
- /**
- * Returns the TTFTableDirEntry that goes with this table.
- * @return The TTFTableDirEntry related to this table.
- */
- public TtfOffsetTableRecord getTableDirEntry() {
- return this.tableDirEntry;
- }
-
-}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/Os2TableParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/Os2TableParser.java 2025-04-21 12:02:44 UTC (rev 13467)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/Os2TableParser.java 2025-04-21 14:42:24 UTC (rev 13468)
@@ -32,8 +32,8 @@
import org.foray.font.FontContentHandler;
import org.foray.font.FontParser;
import org.foray.font.format.Panose4a;
+import org.foray.font.ttf.RwTable;
import org.foray.font.ttf.TtfRandomAccessInput;
-import org.foray.font.ttf.TtfTable;
import org.checkerframework.checker.signedness.qual.Unsigned;
@@ -92,7 +92,7 @@
consumer.primitiveField("usWinAscent", ferry.setInt(input.read_UFWORD())); // 2 bytes, total 76
consumer.primitiveField("usWinDescent", ferry.setInt(input.read_UFWORD())); // 2 bytes, total 78
- if (version < TtfTable.MajorVersion.v1.getValue()) {
+ if (version < RwTable.MajorVersion.v1.getValue()) {
return;
}
@@ -100,7 +100,7 @@
consumer.primitiveField("ulCodePageRange1", ferry.setLong(input.read_uint32())); // 4 bytes, total 82
consumer.primitiveField("ulCodePageRange2", ferry.setLong(input.read_uint32())); // 4 bytes, total 86
- if (version < TtfTable.MajorVersion.v2.getValue()) {
+ if (version < RwTable.MajorVersion.v2.getValue()) {
return;
}
@@ -111,7 +111,7 @@
consumer.primitiveField("usBreakChar", ferry.setInt(input.read_uint16())); // 2 bytes, total 94
consumer.primitiveField("usMaxContext", ferry.setInt(input.read_uint16())); // 2 bytes, total 96
- if (version < TtfTable.MajorVersion.v5.getValue()) {
+ if (version < RwTable.MajorVersion.v5.getValue()) {
return;
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/AbstractOtfLayoutTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/AbstractOtfLayoutTable.java 2025-04-21 12:02:44 UTC (rev 13467)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/AbstractOtfLayoutTable.java 2025-04-21 14:42:24 UTC (rev 13468)
@@ -31,8 +31,8 @@
import org.foray.common.RandomAccessInput;
import org.foray.font.ttf.OtfFeature;
import org.foray.font.ttf.OtfScript;
+import org.foray.font.ttf.RwTable;
import org.foray.font.ttf.TtfOffsetTableRecord;
-import org.foray.font.ttf.TtfTable;
import java.io.IOException;
import java.util.HashMap;
@@ -41,7 +41,7 @@
/**
* Abstract superclass for the OpenType layout tables.
*/
-public abstract class AbstractOtfLayoutTable extends TtfTable {
+public abstract class AbstractOtfLayoutTable extends RwTable {
/** Map of OpenType scripts for this table. The key is the script tag, and the value is the OtfScript instance for
* that tag. */
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseTable.java 2025-04-21 12:02:44 UTC (rev 13467)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseTable.java 2025-04-21 14:42:24 UTC (rev 13468)
@@ -30,9 +30,9 @@
import org.foray.common.primitive.PrimitiveFerry;
import org.foray.font.FontContentHandler;
+import org.foray.font.ttf.RwTable;
import org.foray.font.ttf.TtfOffsetTableRecord;
import org.foray.font.ttf.TtfRandomAccessInput;
-import org.foray.font.ttf.TtfTable;
import org.foray.font.ttf.parse.BaseTableParser;
import java.io.IOException;
@@ -41,7 +41,7 @@
* An OpenType "BASE" (Baseline Data) table.
* This table is an Advanced Typographic Table.
*/
-public class BaseTable extends TtfTable {
+public class BaseTable extends RwTable {
/**
* The handler of events from the parser.
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-21 12:02:44 UTC (rev 13467)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cff2Table.java 2025-04-21 14:42:24 UTC (rev 13468)
@@ -29,8 +29,8 @@
package org.foray.font.ttf.table;
import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.RwTable;
import org.foray.font.ttf.TtfOffsetTableRecord;
-import org.foray.font.ttf.TtfTable;
import java.io.IOException;
@@ -38,7 +38,7 @@
* An OpenType "CFF2" (Compact File Format 2.0 PostScript Outlines) table.
* This table is used only in OpenType fonts that contain PostScript outlines.
*/
-public class Cff2Table extends TtfTable {
+public class Cff2Table extends RwTable {
/**
* Constructor.
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-21 12:02:44 UTC (rev 13467)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CffTable.java 2025-04-21 14:42:24 UTC (rev 13468)
@@ -29,8 +29,8 @@
package org.foray.font.ttf.table;
import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.RwTable;
import org.foray.font.ttf.TtfOffsetTableRecord;
-import org.foray.font.ttf.TtfTable;
import java.io.IOException;
@@ -38,7 +38,7 @@
* An OpenType "CFF" (Compact File Format 1.0 PostScript Outlines) table.
* This table is used only in OpenType fonts that contain PostScript outlines.
*/
-public class CffTable extends TtfTable {
+public class CffTable extends RwTable {
/**
* Constructor.
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-21 12:02:44 UTC (rev 13467)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java 2025-04-21 14:42:24 UTC (rev 13468)
@@ -29,8 +29,9 @@
package org.foray.font.ttf.table;
import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.RoTable;
+import org.foray.font.ttf.RwTable;
import org.foray.font.ttf.TtfOffsetTableRecord;
-import org.foray.font.ttf.TtfTable;
import org.foray.ps.encode.Cmap04Ttf4a;
import org.foray.ps.encode.Cmap12Ttf4a;
@@ -43,7 +44,7 @@
/**
* Class representing a TTF "cmap" (character-to-glyph index mapping) table.
*/
-public class CmapTable extends TtfTable {
+public class CmapTable extends RwTable {
/** Constant indicating that this Cmap4a table is in an unknown format. */
public static final byte CMAP_FORMAT_UNKNOWN = -1;
@@ -97,7 +98,7 @@
raInput.seek(dirEntry.getOffset());
final CmapTable cmap = new CmapTable(dirEntry);
/* Skip table version. */
- raInput.skipBytes(USHORT_BYTES);
+ raInput.skipBytes(RoTable.USHORT_BYTES);
final int numSubtables = raInput.readUnsignedShort();
long offsetToCMap04 = -1;
@@ -186,14 +187,14 @@
throws IOException {
/* Format and Length have already been read. */
/* Skip version */
- raInput.skipBytes(USHORT_BYTES);
+ raInput.skipBytes(RoTable.USHORT_BYTES);
final int segCountX2 = raInput.readUnsignedShort();
/* Skip searchRange. */
- raInput.skipBytes(USHORT_BYTES);
+ raInput.skipBytes(RoTable.USHORT_BYTES);
/* Skip entrySelector. */
- raInput.skipBytes(USHORT_BYTES);
+ raInput.skipBytes(RoTable.USHORT_BYTES);
/* Skip rangeShift. */
- raInput.skipBytes(USHORT_BYTES);
+ raInput.skipBytes(RoTable.USHORT_BYTES);
final int[] endCount = new int[segCountX2 / 2];
final int[] startCount = new int[segCountX2 / 2];
@@ -205,7 +206,7 @@
}
/* Skip reservedPad. */
- raInput.skipBytes(USHORT_BYTES);
+ raInput.skipBytes(RoTable.USHORT_BYTES);
for (int i = 0; i < (segCountX2 / 2); i++) {
startCount[i] = (char) raInput.readUnsignedShort();
@@ -263,7 +264,7 @@
throws IOException {
/* Format and Length have already been read. */
/* Skip language. */
- raInput.skipBytes(ULONG_BYTES);
+ raInput.skipBytes(RoTable.ULONG_BYTES);
final int nGroups = (int) raInput.readUnsignedInt();
final String encodingName = "internal-" + fontPostScriptName;
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-21 12:02:44 UTC (rev 13467)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CvtTable.java 2025-04-21 14:42:24 UTC (rev 13468)
@@ -29,8 +29,8 @@
package org.foray.font.ttf.table;
import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.RwTable;
import org.foray.font.ttf.TtfOffsetTableRecord;
-import org.foray.font.ttf.TtfTable;
import java.io.IOException;
@@ -38,7 +38,7 @@
* A TrueType/OpenType "cvt" (Control Value Table) table.
* This table is used only in fonts that contain TrueType outlines.
*/
-public class CvtTable extends TtfTable {
+public class CvtTable extends RwTable {
/**
* Constructor.
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-21 12:02:44 UTC (rev 13467)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/FpgmTable.java 2025-04-21 14:42:24 UTC (rev 13468)
@@ -29,8 +29,8 @@
package org.foray.font.ttf.table;
import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.RwTable;
import org.foray.font.ttf.TtfOffsetTableRecord;
-import org.foray.font.ttf.TtfTable;
import java.io.IOException;
@@ -38,7 +38,7 @@
* A TrueType/OpenType "fpgm" (Font Program) table.
* This table is used only in fonts that contain TrueType outlines.
*/
-public class FpgmTable extends TtfTable {
+public class FpgmTable extends RwTable {
/**
* Constructor.
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-21 12:02:44 UTC (rev 13467)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GaspTable.java 2025-04-21 14:42:24 UTC (rev 13468)
@@ -29,8 +29,8 @@
package org.foray.font.ttf.table;
import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.RwTable;
import org.foray.font.ttf.TtfOffsetTableRecord;
-import org.foray.font.ttf.TtfTable;
import java.io.IOException;
@@ -38,7 +38,7 @@
* 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.
*/
-public class GaspTable extends TtfTable {
+public class GaspTable extends RwTable {
/**
* Constructor.
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-21 12:02:44 UTC (rev 13467)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GdefTable.java 2025-04-21 14:42:24 UTC (rev 13468)
@@ -29,8 +29,8 @@
package org.foray.font.ttf.table;
import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.RwTable;
import org.foray.font.ttf.TtfOffsetTableRecord;
-import org.foray.font.ttf.TtfTable;
import java.io.IOException;
@@ -38,7 +38,7 @@
* An OpenType "GDEF" (Glyph Definition Data) table.
* This table is an Advanced Typographic Table.
*/
-public class GdefTable extends TtfTable {
+public class GdefTable extends RwTable {
/**
* Constructor.
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GlyfTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GlyfTable.java 2025-04-21 12:02:44 UTC (rev 13467)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GlyfTable.java 2025-04-21 14:42:24 UTC (rev 13468)
@@ -30,8 +30,9 @@
import org.foray.common.RandomAccessInput;
import org.foray.common.data.BoundingBoxShort;
+import org.foray.font.ttf.RoTable;
+import org.foray.font.ttf.RwTable;
import org.foray.font.ttf.TtfOffsetTableRecord;
-import org.foray.font.ttf.TtfTable;
import org.foray.primitive.BitUtils;
import org.axsl.ps.BoundingBox;
@@ -42,11 +43,11 @@
* A TrueType/OpenType "glyf" (Glyph Data) table.
* This table is used only in fonts that contain TrueType outlines.
*/
-public class GlyfTable extends TtfTable {
+public class GlyfTable extends RwTable {
/** The size, in bytes, of the header portion of this table. */
- public static final byte HEADER_SIZE = SHORT_BYTES + FWORD_BYTES
- + FWORD_BYTES + FWORD_BYTES + FWORD_BYTES;
+ public static final byte HEADER_SIZE = RoTable.SHORT_BYTES + RoTable.FWORD_BYTES
+ + RoTable.FWORD_BYTES + RoTable.FWORD_BYTES + RoTable.FWORD_BYTES;
/** The bit in the composite flag indicating ARG_1_AND_2_ARE_WORDS. */
public static final byte CF_BIT_ARG_1_AND_2_ARE_WORDS = 0;
@@ -147,28 +148,28 @@
public static int computeCompositeEntrySize(final int compositeFlags) {
int size = 0;
/* The size of the flag itself. */
- size += TtfTable.USHORT_BYTES;
+ size += RoTable.USHORT_BYTES;
/* The size of the glyph index. */
- size += TtfTable.USHORT_BYTES;
+ size += RoTable.USHORT_BYTES;
/* The remainder of this logic is from the standard itself. */
if (BitUtils.getBit(compositeFlags, GlyfTable.CF_BIT_ARG_1_AND_2_ARE_WORDS)) {
- size += TtfTable.SHORT_BYTES;
- size += TtfTable.SHORT_BYTES;
+ size += RoTable.SHORT_BYTES;
+ size += RoTable.SHORT_BYTES;
} else {
- size += TtfTable.USHORT_BYTES;
+ size += RoTable.USHORT_BYTES;
}
if (BitUtils.getBit(compositeFlags, GlyfTable.CF_BIT_WE_HAVE_A_SCALE)) {
- size += TtfTable.F2DOT14_BYTES;
+ size += RoTable.F2DOT14_BYTES;
} else if (BitUtils.getBit(compositeFlags, GlyfTable.CF_BIT_WE_HAVE_AN_X_AND_Y_SCALE)) {
- size += TtfTable.F2DOT14_BYTES;
- size += TtfTable.F2DOT14_BYTES;
+ size += RoTable.F2DOT14_BYTES;
+ size += RoTable.F2DOT14_BYTES;
} else if (BitUtils.getBit(compositeFlags, GlyfTable.CF_BIT_WE_HAVE_A_TWO_BY_TWO)) {
- size += TtfTable.F2DOT14_BYTES;
- size += TtfTable.F2DOT14_BYTES;
- size += TtfTable.F2DOT14_BYTES;
- size += TtfTable.F2DOT14_BYTES;
+ size += RoTable.F2DOT14_BYTES;
+ size += RoTable.F2DOT14_BYTES;
+ size += RoTable.F2DOT14_BYTES;
+ size += RoTable.F2DOT14_BYTES;
}
return size;
}
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-21 12:02:44 UTC (rev 13467)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GposTable.java 2025-04-21 14:42:24 UTC (rev 13468)
@@ -29,8 +29,8 @@
package org.foray.font.ttf.table;
import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.RwTable;
import org.foray.font.ttf.TtfOffsetTableRecord;
-import org.foray.font.ttf.TtfTable;
import java.io.IOException;
@@ -38,7 +38,7 @@
* An OpenType "GPOS" (Glyph Positioning Data) table.
* This table is an Advanced Typographic Table.
*/
-public class GposTable extends TtfTable {
+public class GposTable extends RwTable {
/**
* Constructor.
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HeadTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HeadTable.java 2025-04-21 12:02:44 UTC (rev 13467)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HeadTable.java 2025-04-21 14:42:24 UTC (rev 13468)
@@ -32,9 +32,9 @@
import org.foray.common.data.BoundingBoxUtils;
import org.foray.common.primitive.PrimitiveFerry;
import org.foray.font.FontContentHandler;
+import org.foray.font.ttf.RwTable;
import org.foray.font.ttf.TtfOffsetTableRecord;
import org.foray.font.ttf.TtfRandomAccessInput;
-import org.foray.font.ttf.TtfTable;
import org.foray.font.ttf.parse.HeadTableParser;
import org.axsl.ps.BoundingBox;
@@ -44,7 +44,7 @@
/**
* Class representing a TTF "head" table.
*/
-public class HeadTable extends TtfTable {
+public class HeadTable extends RwTable {
/**
* The handler of events from the parser.
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HheaTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HheaTable.java 2025-04-21 12:02:44 UTC (rev 13467)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HheaTable.java 2025-04-21 14:42:24 UTC (rev 13468)
@@ -29,8 +29,9 @@
package org.foray.font.ttf.table;
import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.RoTable;
+import org.foray.font.ttf.RwTable;
import org.foray.font.ttf.TtfOffsetTableRecord;
-import org.foray.font.ttf.TtfTable;
import java.io.IOException;
@@ -37,7 +38,7 @@
/**
* Class representing a TTF "hhea" (horizontal header) table.
*/
-public class HheaTable extends TtfTable {
+public class HheaTable extends RwTable {
/** Typographic ascent. */
private int ascender = 0;
@@ -71,35 +72,35 @@
raInput.seek(dirEntry.getOffset());
final HheaTable hhea = new HheaTable(dirEntry);
/* Skip the table version number. */
- raInput.skipBytes(FIXED_BYTES);
+ raInput.skipBytes(RoTable.FIXED_BYTES);
hhea.ascender = raInput.readShort();
hhea.descender = raInput.readShort();
/* Skip the lineGap. */
- raInput.skipBytes(FWORD_BYTES);
+ raInput.skipBytes(RoTable.FWORD_BYTES);
/* Skip the advanceWidthMax*/
- raInput.skipBytes(UFWORD_BYTES);
+ raInput.skipBytes(RoTable.UFWORD_BYTES);
/* Skip the minLeftSideBearing*/
- raInput.skipBytes(FWORD_BYTES);
+ raInput.skipBytes(RoTable.FWORD_BYTES);
/* Skip the minRightSideBearing*/
- raInput.skipBytes(FWORD_BYTES);
+ raInput.skipBytes(RoTable.FWORD_BYTES);
/* Skip the xMaxExtent*/
- raInput.skipBytes(FWORD_BYTES);
+ raInput.skipBytes(RoTable.FWORD_BYTES);
/* Skip the caretSlopeRise*/
- raInput.skipBytes(SHORT_BYTES);
+ raInput.skipBytes(RoTable.SHORT_BYTES);
/* Skip the caretSlopeRun*/
- raInput.skipBytes(SHORT_BYTES);
+ raInput.skipBytes(RoTable.SHORT_BYTES);
/* Skip this reserved area. */
- raInput.skipBytes(SHORT_BYTES);
+ raInput.skipBytes(RoTable.SHORT_BYTES);
/* Skip this reserved area. */
- raInput.skipBytes(SHORT_BYTES);
+ raInput.skipBytes(RoTable.SHORT_BYTES);
/* Skip this reserved area. */
- raInput.skipBytes(SHORT_BYTES);
+ raInput.skipBytes(RoTable.SHORT_BYTES);
/* Skip this reserved area. */
- raInput.skipBytes(SHORT_BYTES);
+ raInput.skipBytes(RoTable.SHORT_BYTES);
/* Skip this reserved area. */
- raInput.skipBytes(SHORT_BYTES);
+ raInput.skipBytes(RoTable.SHORT_BYTES);
/* Skip the metricDataFormat. */
- raInput.skipBytes(SHORT_BYTES);
+ raInput.skipBytes(RoTable.SHORT_BYTES);
hhea.numberOfHMetrics = raInput.readUnsignedShort();
return hhea;
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HtmxTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HtmxTable.java 2025-04-21 12:02:44 UTC (rev 13467)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HtmxTable.java 2025-04-21 14:42:24 UTC (rev 13468)
@@ -29,8 +29,8 @@
package org.foray.font.ttf.table;
import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.RwTable;
import org.foray.font.ttf.TtfOffsetTableRecord;
-import org.foray.font.ttf.TtfTable;
import java.io.IOException;
@@ -37,7 +37,7 @@
/**
* Class representing a TTF "hmtx" (horizontal metrics) table.
*/
-public class HtmxTable extends TtfTable {
+public class HtmxTable extends RwTable {
/** The metrics entries for this table. */
private MtxEntry[] metrics;
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-21 12:02:44 UTC (rev 13467)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/JstfTable.java 2025-04-21 14:42:24 UTC (rev 13468)
@@ -29,8 +29,8 @@
package org.foray.font.ttf.table;
import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.RwTable;
import org.foray.font.ttf.TtfOffsetTableRecord;
-import org.foray.font.ttf.TtfTable;
import java.io.IOException;
@@ -38,7 +38,7 @@
* An OpenType "JSTF" (Justification Data) table.
* This table is an Advanced Typographic Table.
*/
-public class JstfTable extends TtfTable {
+public class JstfTable extends RwTable {
/**
* Constructor.
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-21 12:02:44 UTC (rev 13467)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/KernTable.java 2025-04-21 14:42:24 UTC (rev 13468)
@@ -30,8 +30,9 @@
import org.foray.common.RandomAccessInput;
import org.foray.font.format.Kerning;
+import org.foray.font.ttf.RoTable;
+import org.foray.font.ttf.RwTable;
import org.foray.font.ttf.TtfOffsetTableRecord;
-import org.foray.font.ttf.TtfTable;
import org.foray.primitive.BitUtils;
import org.axsl.constants.PrimitiveConstants;
@@ -41,7 +42,7 @@
/**
* Class representing a TTF "kern" (kerning) table.
*/
-public class KernTable extends TtfTable {
+public class KernTable extends RwTable {
/** Constant indicating the 0-based bit number in the "coverage" value that
* containts the "horizontal" boolean, that is bit 0. */
@@ -79,7 +80,7 @@
raInput.seek(dirEntry.getOffset());
final KernTable kern = new KernTable(dirEntry);
/* Skip the Table Version. */
- raInput.skipBytes(USHORT_BYTES);
+ raInput.skipBytes(RoTable.USHORT_BYTES);
final int qtySubtables = raInput.readUnsignedShort();
for (int i = 0; i < qtySubtables; i++) {
readNextSubtable(kern, raInput, cmap);
@@ -101,14 +102,14 @@
final CmapTable cmap) throws IOException {
int headerSize = 0;
/* Skip Kern subtable version number. */
- raInput.skipBytes(USHORT_BYTES);
- headerSize += USHORT_BYTES;
+ 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 += USHORT_BYTES;
+ headerSize += RoTable.USHORT_BYTES;
/* Read what type of information is contained in this table. */
final short coverage = (short) raInput.readUnsignedShort();
- headerSize += USHORT_BYTES;
+ headerSize += RoTable.USHORT_BYTES;
final int remainingSize = length - headerSize;
@@ -143,11 +144,11 @@
kern.kerning.addCapacity(numPairs);
}
/* Skip Search range. */
- raInput.skipBytes(USHORT_BYTES);
+ raInput.skipBytes(RoTable.USHORT_BYTES);
/* Skip Entry selector. */
- raInput.skipBytes(USHORT_BYTES);
+ raInput.skipBytes(RoTable.USHORT_BYTES);
/* Skip Range shift. */
- raInput.skipBytes(USHORT_BYTES);
+ raInput.skipBytes(RoTable.USHORT_BYTES);
if (cmap == null) {
return;
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/LocaTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/LocaTable.java 2025-04-21 12:02:44 UTC (rev 13467)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/LocaTable.java 2025-04-21 14:42:24 UTC (rev 13468)
@@ -29,8 +29,8 @@
package org.foray.font.ttf.table;
import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.RwTable;
import org.foray.font.ttf.TtfOffsetTableRecord;
-import org.foray.font.ttf.TtfTable;
import java.io.IOException;
@@ -38,7 +38,7 @@
* A TrueType/OpenType "loca" (Index to location) table.
* This table is used only in fonts that contain TrueType outlines.
*/
-public class LocaTable extends TtfTable {
+public class LocaTable extends RwTable {
/** The last offset value in the table, which points to no glyph, but
* exists to be able to compute the size of the previous entry. */
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-21 12:02:44 UTC (rev 13467)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/MathTable.java 2025-04-21 14:42:24 UTC (rev 13468)
@@ -29,8 +29,8 @@
package org.foray.font.ttf.table;
import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.RwTable;
import org.foray.font.ttf.TtfOffsetTableRecord;
-import org.foray.font.ttf.TtfTable;
import java.io.IOException;
@@ -38,7 +38,7 @@
* An OpenType "MATH" (Math Layout Data) table.
* This table is an Advanced Typographic Table.
*/
-public class MathTable extends TtfTable {
+public class MathTable extends RwTable {
/**
* Constructor.
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/MaxpTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/MaxpTable.java 2025-04-21 12:02:44 UTC (rev 13467)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/MaxpTable.java 2025-04-21 14:42:24 UTC (rev 13468)
@@ -29,8 +29,9 @@
package org.foray.font.ttf.table;
import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.RoTable;
+import org.foray.font.ttf.RwTable;
import org.foray.font.ttf.TtfOffsetTableRecord;
-import org.foray.font.ttf.TtfTable;
import java.io.IOException;
@@ -37,7 +38,7 @@
/**
* Class representing a TTF "maxp" (maximum profile) table.
*/
-public class MaxpTable extends TtfTable {
+public class MaxpTable extends RwTable {
/** The number of glyphs in the font. */
private int numGlyphs;
@@ -62,7 +63,7 @@
raInput.seek(dirEntry.getOffset());
final MaxpTable maxp = new MaxpTable(dirEntry);
/* Skip Table version number. */
- raInput.skipBytes(FIXED_BYTES);
+ raInput.skipBytes(RoTable.FIXED_BYTES);
maxp.numGlyphs = raInput.readUnsignedShort();
return maxp;
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/NameTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/NameTable.java 2025-04-21 12:02:44 UTC (rev 13467)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/NameTable.java 2025-04-21 14:42:24 UTC (rev 13468)
@@ -29,8 +29,9 @@
package org.foray.font.ttf.table;
import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.RoTable;
+import org.foray.font.ttf.RwTable;
import org.foray.font.ttf.TtfOffsetTableRecord;
-import org.foray.font.ttf.TtfTable;
import org.foray.primitive.StringUtils;
import java.io.IOException;
@@ -40,7 +41,7 @@
/**
* Class representing a TTF "name" (naming) table.
*/
-public class NameTable extends TtfTable {
+public class NameTable extends RwTable {
/** Constant documented in the TTF "name" table doc as indicating the
* Macintosh platform. */
@@ -392,11 +393,11 @@
long offsetOfThisNameRecord = name.getTableDirEntry().getOffset();
/* Skip the bytes before name records. */
/* Skip the Format selector. */
- offsetOfThisNameRecord += USHORT_BYTES;
+ offsetOfThisNameRecord += RoTable.USHORT_BYTES;
/* Skip the Number of NameRecords that follow. */
- offsetOfThisNameRecord += USHORT_BYTES;
+ offsetOfThisNameRecord += RoTable.USHORT_BYTES;
/* Skip the Offset to start of string storage. */
- offsetOfThisNameRecord += USHORT_BYTES;
+ offsetOfThisNameRecord += RoTable.USHORT_BYTES;
/* Skip 12 bytes for each name record that precedes the one sought. */
offsetOfThisNameRecord += (nameRecordNum - 1)
* NameTable.NAME_RECORD_BYTES;
@@ -416,13 +417,13 @@
final int arrayIndex = nameRecordNum - 1;
seekNameRecord(name, raInput, nameRecordNum);
/* Skip the Platform ID. */
- raInput.skipBytes(USHORT_BYTES);
+ raInput.skipBytes(RoTable.USHORT_BYTES);
/* Skip the Platform-specific encoding ID. */
- raInput.skipBytes(USHORT_BYTES);
+ raInput.skipBytes(RoTable.USHORT_BYTES);
/* Skip the Language ID. */
- raInput.skipBytes(USHORT_BYTES);
+ raInput.skipBytes(RoTable.USHORT_BYTES);
/* Skip the Name ID. */
- raInput.skipBytes(USHORT_BYTES);
+ raInput.skipBytes(RoTable.USHORT_BYTES);
/* Read the String length (in bytes). */
final int stringLength = raInput.readUnsignedShort();
/* Read the String offset from start of storage area (in bytes). */
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Os2Table.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Os2Table.java 2025-04-21 12:02:44 UTC (rev 13467)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Os2Table.java 2025-04-21 14:42:24 UTC (rev 13468)
@@ -31,9 +31,9 @@
import org.foray.common.primitive.PrimitiveFerry;
import org.foray.font.FontContentHandler;
import org.foray.font.format.Panose4a;
+import org.foray.font.ttf.RwTable;
import org.foray.font.ttf.TtfOffsetTableRecord;
import org.foray.font.ttf.TtfRandomAccessInput;
-import org.foray.font.ttf.TtfTable;
import org.foray.font.ttf.parse.Os2TableParser;
import org.checkerframework.checker.signedness.qual.Unsigned;
@@ -43,7 +43,7 @@
/**
* Class representing a TTF "OS/2" (OS/2 and Windows metrics) table.
*/
-public class Os2Table extends TtfTable {
+public class Os2Table extends RwTable {
/**
* The handler of events from the parser.
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PcltTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PcltTable.java 2025-04-21 12:02:44 UTC (rev 13467)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PcltTable.java 2025-04-21 14:42:24 UTC (rev 13468)
@@ -30,9 +30,9 @@
import org.foray.common.primitive.PrimitiveFerry;
import org.foray.font.FontContentHandler;
+import org.foray.font.ttf.RwTable;
import org.foray.font.ttf.TtfOffsetTableRecord;
import org.foray.font.ttf.TtfRandomAccessInput;
-import org.foray.font.ttf.TtfTable;
import org.foray.font.ttf.parse.PcltTableParser;
import java.io.IOException;
@@ -40,7 +40,7 @@
/**
* Class representing a TTF "PCLT" (PCL 5) table.
*/
-public class PcltTable extends TtfTable {
+public class PcltTable extends RwTable {
/**
* The handler of events from the parser.
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PostTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PostTable.java 2025-04-21 12:02:44 UTC (rev 13467)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PostTable.java 2025-04-21 14:42:24 UTC (rev 13468)
@@ -29,9 +29,10 @@
package org.foray.font.ttf.table;
import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.RoTable;
+import org.foray.font.ttf.RwTable;
import org.foray.font.ttf.TtfOffsetTableRecord;
import org.foray.font.ttf.TtfRandomAccessInput;
-import org.foray.font.ttf.TtfTable;
import org.axsl.ps.PsEncoding;
import org.axsl.ps.PsServer;
@@ -43,7 +44,7 @@
/**
* Class representing a TTF "post" (PostScript) table.
*/
-public class PostTable extends TtfTable {
+public class PostTable extends RwTable {
/** Constant indicating that the post table uses format 1. */
private static final int PS_FORMAT_1 = 0x00010000;
@@ -116,10 +117,10 @@
post.underlinePosition = raInput.readShort();
post.underlineThickness = raInput.readShort();
post.isFixedPitch = raInput.readUnsignedInt();
- raInput.skipBytes(ULONG_BYTES); // minMemType42 (4)
- raInput.skipBytes(ULONG_BYTES); // maxMemType42 (4)
- raInput.skipBytes(ULONG_BYTES); // minMemType1 (4)
- raInput.skipBytes(ULONG_BYTES); // maxMemType1 (4)
+ raInput.skipBytes(RoTable.ULONG_BYTES); // minMemType42 (4)
+ raInput.skipBytes(RoTable.ULONG_BYTES); // maxMemType42 (4)
+ raInput.skipBytes(RoTable.ULONG_BYTES); // minMemType1 (4)
+ ...
[truncated message content] |
|
From: <vic...@us...> - 2025-04-21 12:03:05
|
Revision: 13467
http://sourceforge.net/p/foray/code/13467
Author: victormote
Date: 2025-04-21 12:02:44 +0000 (Mon, 21 Apr 2025)
Log Message:
-----------
Add startTable and endTable methods to FontContentHandler.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/FontContentHandler.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HeadTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Os2Table.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PcltTable.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FontContentHandler.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FontContentHandler.java 2025-04-21 11:51:20 UTC (rev 13466)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FontContentHandler.java 2025-04-21 12:02:44 UTC (rev 13467)
@@ -32,10 +32,23 @@
/**
* Implementations receive events from a {@link FontParser}.
+ * Analogous to the {@link org.xml.sax.ContentHandler SAX ContentHandler}.
*/
public interface FontContentHandler {
/**
+ * Parsing of table is beginning.
+ * @param tableName The context-sensitive name of the table about to be parsed.
+ */
+ void startTable(String tableName);
+
+ /**
+ * Parsing of a table is ending.
+ * @param tableName The context-sensitive name of the table just parsed.
+ */
+ void endTable(String tableName);
+
+ /**
* An Object field has been parsed.
* @param fieldName The name of the field parsed.
* @param value The parsed value.
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseTable.java 2025-04-21 11:51:20 UTC (rev 13466)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseTable.java 2025-04-21 12:02:44 UTC (rev 13467)
@@ -60,6 +60,14 @@
}
@Override
+ public void startTable(final String tableName) {
+ }
+
+ @Override
+ public void endTable(final String tableName) {
+ }
+
+ @Override
public void objectField(final String fieldName, final Object value) {
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HeadTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HeadTable.java 2025-04-21 11:51:20 UTC (rev 13466)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HeadTable.java 2025-04-21 12:02:44 UTC (rev 13467)
@@ -63,6 +63,14 @@
}
@Override
+ public void startTable(final String tableName) {
+ }
+
+ @Override
+ public void endTable(final String tableName) {
+ }
+
+ @Override
public void objectField(final String fieldName, final Object value) {
switch (fieldName) {
case "boundingBox": {
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Os2Table.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Os2Table.java 2025-04-21 11:51:20 UTC (rev 13466)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Os2Table.java 2025-04-21 12:02:44 UTC (rev 13467)
@@ -62,6 +62,14 @@
}
@Override
+ public void startTable(final String tableName) {
+ }
+
+ @Override
+ public void endTable(final String tableName) {
+ }
+
+ @Override
public void objectField(final String fieldName, final Object value) {
switch (fieldName) {
case "panose": client.panose = Panose4a.forceInstance((@Unsigned byte[]) value);
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PcltTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PcltTable.java 2025-04-21 11:51:20 UTC (rev 13466)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PcltTable.java 2025-04-21 12:02:44 UTC (rev 13467)
@@ -59,6 +59,14 @@
}
@Override
+ public void startTable(final String tableName) {
+ }
+
+ @Override
+ public void endTable(final String tableName) {
+ }
+
+ @Override
public void objectField(final String fieldName, final Object value) {
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-21 11:51:38
|
Revision: 13466
http://sourceforge.net/p/foray/code/13466
Author: victormote
Date: 2025-04-21 11:51:20 +0000 (Mon, 21 Apr 2025)
Log Message:
-----------
Rename interface for clarity.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/FontParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseTableParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/HeadTableParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/Os2TableParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/PcltTableParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HeadTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Os2Table.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PcltTable.java
Added Paths:
-----------
trunk/foray/foray-font/src/main/java/org/foray/font/FontContentHandler.java
Removed Paths:
-------------
trunk/foray/foray-font/src/main/java/org/foray/font/FontParserConsumer.java
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/FontContentHandler.java (from rev 13455, trunk/foray/foray-font/src/main/java/org/foray/font/FontParserConsumer.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FontContentHandler.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FontContentHandler.java 2025-04-21 11:51:20 UTC (rev 13466)
@@ -0,0 +1,52 @@
+/*
+ * 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;
+
+import org.foray.common.primitive.PrimitiveFerry;
+
+/**
+ * Implementations receive events from a {@link FontParser}.
+ */
+public interface FontContentHandler {
+
+ /**
+ * An Object field has been parsed.
+ * @param fieldName The name of the field parsed.
+ * @param value The parsed value.
+ */
+ void objectField(String fieldName, Object value);
+
+ /**
+ * An primitive field has been parsed.
+ * @param fieldName The name of the field parsed.
+ * @param value The parsed value.
+ */
+ void primitiveField(String fieldName, PrimitiveFerry value);
+
+}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FontParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FontParser.java 2025-04-21 11:45:08 UTC (rev 13465)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FontParser.java 2025-04-21 11:51:20 UTC (rev 13466)
@@ -33,7 +33,7 @@
import java.io.IOException;
/**
- * Parses font files and produces events to be consumed by a {@link FontParserConsumer}.
+ * Parses font files and produces events to be consumed by a {@link FontContentHandler}.
* Making font parsing an event-driven process separates the concerns of parsing and using the font data.
* The parser parses everything consistently, regardless of the consumer.
* The consumer does what it wishes with the results.
@@ -50,6 +50,6 @@
* @throws IOException For errors reading the input.
*/
public abstract void parse(String tableName, TtfRandomAccessInput input, int offset, int size,
- FontParserConsumer consumer) throws IOException;
+ FontContentHandler consumer) throws IOException;
}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/FontParserConsumer.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FontParserConsumer.java 2025-04-21 11:45:08 UTC (rev 13465)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FontParserConsumer.java 2025-04-21 11:51:20 UTC (rev 13466)
@@ -1,52 +0,0 @@
-/*
- * 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;
-
-import org.foray.common.primitive.PrimitiveFerry;
-
-/**
- * Implementations receive events from a {@link FontParser}.
- */
-public interface FontParserConsumer {
-
- /**
- * An Object field has been parsed.
- * @param fieldName The name of the field parsed.
- * @param value The parsed value.
- */
- void objectField(String fieldName, Object value);
-
- /**
- * An primitive field has been parsed.
- * @param fieldName The name of the field parsed.
- * @param value The parsed value.
- */
- void primitiveField(String fieldName, PrimitiveFerry value);
-
-}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseTableParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseTableParser.java 2025-04-21 11:45:08 UTC (rev 13465)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseTableParser.java 2025-04-21 11:51:20 UTC (rev 13466)
@@ -29,8 +29,8 @@
package org.foray.font.ttf.parse;
import org.foray.common.primitive.PrimitiveFerry;
+import org.foray.font.FontContentHandler;
import org.foray.font.FontParser;
-import org.foray.font.FontParserConsumer;
import org.foray.font.ttf.TtfRandomAccessInput;
import java.io.IOException;
@@ -43,7 +43,7 @@
@Override
public void parse(final String tableName, final TtfRandomAccessInput input, final int offset, final int size,
- final FontParserConsumer consumer) throws IOException {
+ final FontContentHandler consumer) throws IOException {
final PrimitiveFerry ferry = new PrimitiveFerry();
input.seek(offset);
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/HeadTableParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/HeadTableParser.java 2025-04-21 11:45:08 UTC (rev 13465)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/HeadTableParser.java 2025-04-21 11:51:20 UTC (rev 13466)
@@ -29,8 +29,8 @@
package org.foray.font.ttf.parse;
import org.foray.common.primitive.PrimitiveFerry;
+import org.foray.font.FontContentHandler;
import org.foray.font.FontParser;
-import org.foray.font.FontParserConsumer;
import org.foray.font.ttf.TtfRandomAccessInput;
import java.io.IOException;
@@ -43,7 +43,7 @@
@Override
public void parse(final String tableName, final TtfRandomAccessInput input, final int offset, final int size,
- final FontParserConsumer consumer) throws IOException {
+ final FontContentHandler consumer) throws IOException {
final PrimitiveFerry ferry = new PrimitiveFerry();
input.seek(offset);
final int majorVersion = input.read_uint16(); // 2 bytes, total 2
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/Os2TableParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/Os2TableParser.java 2025-04-21 11:45:08 UTC (rev 13465)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/Os2TableParser.java 2025-04-21 11:51:20 UTC (rev 13466)
@@ -29,8 +29,8 @@
package org.foray.font.ttf.parse;
import org.foray.common.primitive.PrimitiveFerry;
+import org.foray.font.FontContentHandler;
import org.foray.font.FontParser;
-import org.foray.font.FontParserConsumer;
import org.foray.font.format.Panose4a;
import org.foray.font.ttf.TtfRandomAccessInput;
import org.foray.font.ttf.TtfTable;
@@ -47,7 +47,7 @@
@Override
public void parse(final String tableName, final TtfRandomAccessInput input, final int offset, final int size,
- final FontParserConsumer consumer) throws IOException {
+ final FontContentHandler consumer) throws IOException {
final PrimitiveFerry ferry = new PrimitiveFerry();
input.seek(offset);
final short version = input.read_uint16();
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/PcltTableParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/PcltTableParser.java 2025-04-21 11:45:08 UTC (rev 13465)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/PcltTableParser.java 2025-04-21 11:51:20 UTC (rev 13466)
@@ -29,8 +29,8 @@
package org.foray.font.ttf.parse;
import org.foray.common.primitive.PrimitiveFerry;
+import org.foray.font.FontContentHandler;
import org.foray.font.FontParser;
-import org.foray.font.FontParserConsumer;
import org.foray.font.ttf.TtfRandomAccessInput;
import org.foray.font.ttf.table.PcltTable;
@@ -44,7 +44,7 @@
@Override
public void parse(final String tableName, final TtfRandomAccessInput input, final int offset, final int size,
- final FontParserConsumer consumer) throws IOException {
+ final FontContentHandler consumer) throws IOException {
final PrimitiveFerry ferry = new PrimitiveFerry();
input.seek(offset);
final int majorVersion = input.read_uint16();
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseTable.java 2025-04-21 11:45:08 UTC (rev 13465)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseTable.java 2025-04-21 11:51:20 UTC (rev 13466)
@@ -29,7 +29,7 @@
package org.foray.font.ttf.table;
import org.foray.common.primitive.PrimitiveFerry;
-import org.foray.font.FontParserConsumer;
+import org.foray.font.FontContentHandler;
import org.foray.font.ttf.TtfOffsetTableRecord;
import org.foray.font.ttf.TtfRandomAccessInput;
import org.foray.font.ttf.TtfTable;
@@ -46,7 +46,7 @@
/**
* The handler of events from the parser.
*/
- private final class ParserConsumer implements FontParserConsumer {
+ private final class ParserConsumer implements FontContentHandler {
/** The client being built from the parser results. */
private BaseTable client;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HeadTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HeadTable.java 2025-04-21 11:45:08 UTC (rev 13465)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HeadTable.java 2025-04-21 11:51:20 UTC (rev 13466)
@@ -31,7 +31,7 @@
import org.foray.common.data.BoundingBoxShort;
import org.foray.common.data.BoundingBoxUtils;
import org.foray.common.primitive.PrimitiveFerry;
-import org.foray.font.FontParserConsumer;
+import org.foray.font.FontContentHandler;
import org.foray.font.ttf.TtfOffsetTableRecord;
import org.foray.font.ttf.TtfRandomAccessInput;
import org.foray.font.ttf.TtfTable;
@@ -49,7 +49,7 @@
/**
* The handler of events from the parser.
*/
- private final class ParserConsumer implements FontParserConsumer {
+ private final class ParserConsumer implements FontContentHandler {
/** The client being built from the parser results. */
private HeadTable client;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Os2Table.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Os2Table.java 2025-04-21 11:45:08 UTC (rev 13465)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Os2Table.java 2025-04-21 11:51:20 UTC (rev 13466)
@@ -29,7 +29,7 @@
package org.foray.font.ttf.table;
import org.foray.common.primitive.PrimitiveFerry;
-import org.foray.font.FontParserConsumer;
+import org.foray.font.FontContentHandler;
import org.foray.font.format.Panose4a;
import org.foray.font.ttf.TtfOffsetTableRecord;
import org.foray.font.ttf.TtfRandomAccessInput;
@@ -48,7 +48,7 @@
/**
* The handler of events from the parser.
*/
- private final class ParserConsumer implements FontParserConsumer {
+ private final class ParserConsumer implements FontContentHandler {
/** The client being built from the parser results. */
private Os2Table client;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PcltTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PcltTable.java 2025-04-21 11:45:08 UTC (rev 13465)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PcltTable.java 2025-04-21 11:51:20 UTC (rev 13466)
@@ -29,7 +29,7 @@
package org.foray.font.ttf.table;
import org.foray.common.primitive.PrimitiveFerry;
-import org.foray.font.FontParserConsumer;
+import org.foray.font.FontContentHandler;
import org.foray.font.ttf.TtfOffsetTableRecord;
import org.foray.font.ttf.TtfRandomAccessInput;
import org.foray.font.ttf.TtfTable;
@@ -45,7 +45,7 @@
/**
* The handler of events from the parser.
*/
- private final class ParserConsumer implements FontParserConsumer {
+ private final class ParserConsumer implements FontContentHandler {
/** The client being built from the parser results. */
private PcltTable client;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-21 11:45:26
|
Revision: 13465
http://sourceforge.net/p/foray/code/13465
Author: victormote
Date: 2025-04-21 11:45:08 +0000 (Mon, 21 Apr 2025)
Log Message:
-----------
Require a table name for each parse method, mostly so that the parse method can be extended to subtables.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/FontParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseTableParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/HeadTableParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/Os2TableParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/PcltTableParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HeadTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Os2Table.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PcltTable.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FontParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FontParser.java 2025-04-21 10:36:34 UTC (rev 13464)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FontParser.java 2025-04-21 11:45:08 UTC (rev 13465)
@@ -42,6 +42,7 @@
/**
* Parses the input.
+ * @param tableName The name of the table or subtable being parsed.
* @param input The input to be parsed.
* @param offset The offset, in bytes, into {@code input} at which parsing should begin.
* @param size The size, in bytes, of {@code input} that should be parsed.
@@ -48,7 +49,7 @@
* @param consumer The consumer of the parsing.
* @throws IOException For errors reading the input.
*/
- public abstract void parse(TtfRandomAccessInput input, int offset, int size, FontParserConsumer consumer)
- throws IOException;
+ public abstract void parse(String tableName, TtfRandomAccessInput input, int offset, int size,
+ FontParserConsumer consumer) throws IOException;
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseTableParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseTableParser.java 2025-04-21 10:36:34 UTC (rev 13464)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseTableParser.java 2025-04-21 11:45:08 UTC (rev 13465)
@@ -42,7 +42,7 @@
public class BaseTableParser extends FontParser {
@Override
- public void parse(final TtfRandomAccessInput input, final int offset, final int size,
+ public void parse(final String tableName, final TtfRandomAccessInput input, final int offset, final int size,
final FontParserConsumer consumer) throws IOException {
final PrimitiveFerry ferry = new PrimitiveFerry();
input.seek(offset);
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/HeadTableParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/HeadTableParser.java 2025-04-21 10:36:34 UTC (rev 13464)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/HeadTableParser.java 2025-04-21 11:45:08 UTC (rev 13465)
@@ -42,7 +42,7 @@
public class HeadTableParser extends FontParser {
@Override
- public void parse(final TtfRandomAccessInput input, final int offset, final int size,
+ public void parse(final String tableName, final TtfRandomAccessInput input, final int offset, final int size,
final FontParserConsumer consumer) throws IOException {
final PrimitiveFerry ferry = new PrimitiveFerry();
input.seek(offset);
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/Os2TableParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/Os2TableParser.java 2025-04-21 10:36:34 UTC (rev 13464)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/Os2TableParser.java 2025-04-21 11:45:08 UTC (rev 13465)
@@ -46,7 +46,7 @@
public class Os2TableParser extends FontParser {
@Override
- public void parse(final TtfRandomAccessInput input, final int offset, final int size,
+ public void parse(final String tableName, final TtfRandomAccessInput input, final int offset, final int size,
final FontParserConsumer consumer) throws IOException {
final PrimitiveFerry ferry = new PrimitiveFerry();
input.seek(offset);
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/PcltTableParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/PcltTableParser.java 2025-04-21 10:36:34 UTC (rev 13464)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/PcltTableParser.java 2025-04-21 11:45:08 UTC (rev 13465)
@@ -43,7 +43,7 @@
public class PcltTableParser extends FontParser {
@Override
- public void parse(final TtfRandomAccessInput input, final int offset, final int size,
+ public void parse(final String tableName, final TtfRandomAccessInput input, final int offset, final int size,
final FontParserConsumer consumer) throws IOException {
final PrimitiveFerry ferry = new PrimitiveFerry();
input.seek(offset);
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseTable.java 2025-04-21 10:36:34 UTC (rev 13464)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseTable.java 2025-04-21 11:45:08 UTC (rev 13465)
@@ -94,7 +94,7 @@
throws IOException {
final BaseTable table = new BaseTable(dirEntry);
final BaseTableParser parser = new BaseTableParser();
- parser.parse(input, dirEntry.getOffset(), dirEntry.getLength(), table.new ParserConsumer(table));
+ parser.parse("BASE", input, dirEntry.getOffset(), dirEntry.getLength(), table.new ParserConsumer(table));
return table;
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HeadTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HeadTable.java 2025-04-21 10:36:34 UTC (rev 13464)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HeadTable.java 2025-04-21 11:45:08 UTC (rev 13465)
@@ -122,7 +122,7 @@
throws IOException {
final HeadTable head = new HeadTable(dirEntry);
final HeadTableParser parser = new HeadTableParser();
- parser.parse(input, dirEntry.getOffset(), dirEntry.getLength(), head.new ParserConsumer(head));
+ parser.parse("head", input, dirEntry.getOffset(), dirEntry.getLength(), head.new ParserConsumer(head));
return head;
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Os2Table.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Os2Table.java 2025-04-21 10:36:34 UTC (rev 13464)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Os2Table.java 2025-04-21 11:45:08 UTC (rev 13465)
@@ -130,7 +130,7 @@
throws IOException {
final Os2Table os2 = new Os2Table(dirEntry);
final Os2TableParser parser = new Os2TableParser();
- parser.parse(input, dirEntry.getOffset(), dirEntry.getLength(), os2.new ParserConsumer(os2));
+ parser.parse("OS/2", input, dirEntry.getOffset(), dirEntry.getLength(), os2.new ParserConsumer(os2));
return os2;
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PcltTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PcltTable.java 2025-04-21 10:36:34 UTC (rev 13464)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PcltTable.java 2025-04-21 11:45:08 UTC (rev 13465)
@@ -117,7 +117,7 @@
throws IOException {
final PcltTable pclt = new PcltTable(dirEntry);
final PcltTableParser parser = new PcltTableParser();
- parser.parse(input, dirEntry.getOffset(), dirEntry.getLength(), pclt.new ParserConsumer(pclt));
+ parser.parse("PCLT", input, dirEntry.getOffset(), dirEntry.getLength(), pclt.new ParserConsumer(pclt));
return pclt;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-21 10:36:53
|
Revision: 13464
http://sourceforge.net/p/foray/code/13464
Author: victormote
Date: 2025-04-21 10:36:34 +0000 (Mon, 21 Apr 2025)
Log Message:
-----------
Move more TTF Table classes to new directory.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/FontUse4a.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfScript.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java
Added Paths:
-----------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/AbstractOtfLayoutTable.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/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
trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/
trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/OtfLookupGsubTests.java
Removed Paths:
-------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/AbstractOtfLayoutTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsub.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubSubtable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx01x01.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx01x02.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx02x01.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx03x01.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx04x01.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx05x01.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx05x02.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx05x03.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx06x01.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx06x02.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx06x03.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx07x01.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx08x01.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableGsub.java
trunk/foray/foray-font/src/test/java/org/foray/font/ttf/OtfLookupGsubTests.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FontUse4a.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FontUse4a.java 2025-04-21 10:06:33 UTC (rev 13463)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FontUse4a.java 2025-04-21 10:36:34 UTC (rev 13464)
@@ -32,7 +32,7 @@
import org.foray.common.primitive.UnicodeCharUtils;
import org.foray.font.config.RegisteredFont;
import org.foray.font.ttf.TrueTypeFont;
-import org.foray.font.ttf.TtfTableGsub;
+import org.foray.font.ttf.table.GsubTable;
import org.foray.font.type1.Type1Font;
import org.foray.primitive.sequence.ByteArray;
import org.foray.primitive.sequence.IntArrayBuilder;
@@ -171,7 +171,7 @@
* glyphs. */
final TrueTypeFont ttf = getTrueTypeFont();
- TtfTableGsub gsub = null;
+ GsubTable gsub = null;
if (ttf != null) {
gsub = ttf.getGsubTable();
}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/AbstractOtfLayoutTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/AbstractOtfLayoutTable.java 2025-04-21 10:06:33 UTC (rev 13463)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/AbstractOtfLayoutTable.java 2025-04-21 10:36:34 UTC (rev 13464)
@@ -1,166 +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.HashMap;
-import java.util.Map;
-
-/**
- * Abstract superclass for the OpenType layout tables.
- */
-public abstract class AbstractOtfLayoutTable extends TtfTable {
-
- /** Map of OpenType scripts for this table. The key is the script tag, and the value is the OtfScript instance for
- * that tag. */
- private Map<String, OtfScript> scriptMap;
-
- /** Map of OpenType features for this table. The key is the feature tag, and the value is the OtfFeature instance
- * for that tag. */
- private Map<String, OtfFeature> featureMap;
-
- /**
- * Constructor.
- * @param offsetTableRecord The offset table record that defines this table.
- * @param scriptMap The script map for this table.
- * @param featureMap The feature map for this table.
- */
- AbstractOtfLayoutTable(final TtfOffsetTableRecord offsetTableRecord, final Map<String, OtfScript> scriptMap,
- final Map<String, OtfFeature> featureMap) {
- super(offsetTableRecord);
- this.scriptMap = scriptMap;
- this.featureMap = featureMap;
- }
-
- /**
- * Parses the script list.
- * @param raInput The input from which the script list is being parsed.
- * @param offset The offset in {@code raInput} for the start of the script list.
- * @return The parsed map of scripts.
- * @throws IOException For I/O errors during parsing.
- */
- protected static Map<String, OtfScript> parseScriptList(final RandomAccessInput raInput, final int offset)
- throws IOException {
- raInput.seek(offset);
- final int scriptCount = raInput.readUnsignedShort();
- final String[] scriptTableTags = new String[scriptCount];
- final int[] scriptTableOffsets = new int[scriptCount];
- for (int index = 0; index < scriptCount; index ++) {
- scriptTableTags[index] = raInput.readStringASCII(OtfScript.TAG_SIZE);
- scriptTableOffsets[index] = raInput.readUnsignedShort();
- }
-
- final Map<String, OtfScript> scriptMap = new HashMap<String, OtfScript>();
- for (int index = 0; index < scriptCount; index ++) {
- final OtfScript script = OtfScript.parse(raInput, offset + scriptTableOffsets[index]);
- scriptMap.put(scriptTableTags[index], script);
- }
- return scriptMap;
- }
-
- /**
- * Parses the feature list.
- * @param raInput The input from which the feature list is being parsed.
- * @param offset The offset in {@code raInput} for the start of the feature list.
- * @return The parsed map of features.
- * @throws IOException For I/O errors during parsing.
- */
- protected static Map<String, OtfFeature> parseFeatureList(final RandomAccessInput raInput, final int offset)
- throws IOException {
- raInput.seek(offset);
- final int featureCount = raInput.readUnsignedShort();
- final String[] featureTags = new String[featureCount];
- final int[] featureOffsets = new int[featureCount];
- for (int index = 0; index < featureCount; index ++) {
- featureTags[index] = raInput.readStringASCII(OtfFeature.TAG_SIZE);
- featureOffsets[index] = raInput.readUnsignedShort();
- }
- final Map<String, OtfFeature> featureMap = new HashMap<String, OtfFeature>();
- for (int index = 0; index < featureCount; index ++) {
- final OtfFeature feature = OtfFeature.parse(raInput, offset + featureOffsets[index]);
- featureMap.put(featureTags[index], feature);
- }
- return featureMap;
- }
-
- /**
- * Parses the feature variations.
- * @param raInput The input from which the feature variations is being parsed.
- * @param offset The offset in {@code raInput} for the start of the feature variations.
- * @throws IOException For I/O errors during parsing.
- */
- protected static void parseFeatureVariations(final RandomAccessInput raInput, final int offset) throws IOException {
- if (offset < 0) {
- return;
- }
- }
-
- /**
- * Returns the script instance for a given tag.
- * @param scriptTag The script tag to be retrieved.
- * @return The script instance referenced by {@code scriptTag}, or null if that reference does not exist.
- */
- public OtfScript getScript(final String scriptTag) {
- if (this.scriptMap == null) {
- return null;
- }
- return this.scriptMap.get(scriptTag);
- }
-
- /**
- * Returns the feature instance for a given tag.
- * @param featureTag The feature tag to be retrieved.
- * @return The feature instance referenced by {@code featureTag}, or null if that reference does not exist.
- */
- public OtfFeature getFeature(final String featureTag) {
- if (this.featureMap == null) {
- return null;
- }
- return this.featureMap.get(featureTag);
- }
-
- /**
- * Package-visible method for testing.
- * @return The script map.
- */
- Map<String, OtfScript> getScriptMap() {
- return this.scriptMap;
- }
-
- /**
- * Package-visible method for testing.
- * @return The feature map.
- */
- Map<String, OtfFeature> getFeatureMap() {
- return this.featureMap;
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsub.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsub.java 2025-04-21 10:06:33 UTC (rev 13463)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsub.java 2025-04-21 10:36:34 UTC (rev 13464)
@@ -1,241 +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;
-
-/**
- * An OpenType lookup for the GSUB table.
- */
-public class OtfLookupGsub {
-
- /**
- * Enumeration of possible LookupType values in a GSUB table.
- */
- public enum LookupType {
-
- /** Replace one glyph with one glyph. */
- SINGLE(1),
-
- /** Replace one glyph with more than one glyph. */
- MULTIPLE(2),
-
- /** Replace one glyph with one of many glyphs. */
- ALTERNATE(3),
-
- /** Replace multiple glyphs with one glyph. */
- LIGATURE(4),
-
- /** Replace one or more glyphs in context. */
- CONTEXT(5),
-
- /** Replace one or more glyphs in chained context. */
- CHAINING_CONTEXT(6),
-
- /** Extension mechanism for other substitutions (i.e. this excludes the Extension type substitution itself). */
- EXTENSION_SUBSTITUTION(7),
-
- /** Applied in reverse order, replace single glyph in chaining context. */
- REVERSE_CHAINING_CONTEXT_SINGLE(8);
-
- /** The number this enumerated item is stored as in a font file. */
- private byte value;
-
- /**
- * Constructor.
- * @param value The number this enumerated item is stored as in a font file.
- */
- LookupType(final int value) {
- this.value = (byte) value;
- }
-
- /**
- * Finds the enumerated item from its value.
- * @param value The value for which the enumerated item is needed.
- * @return The enumerated item matching {@code value}, or null if it is not found.
- */
- public static LookupType fromValue(final int value) {
- for (LookupType lookupType : values()) {
- if (lookupType.value == value) {
- return lookupType;
- }
- }
- return null;
- }
- }
-
- /** Constant identifying a format number. */
- private static final byte FORMAT_1 = 1;
-
- /** Constant identifying a format number. */
- private static final byte FORMAT_2 = 2;
-
- /** Constant identifying a format number. */
- private static final byte FORMAT_3 = 3;
-
- /** The lookup type for this lookup. */
- private LookupType lookupType;
-
- /** The lookup flag. */
- private int lookupFlag;
-
- /** The subtables. */
- private OtfLookupGsubSubtable[] subtables;
-
- /**
- * Constructor.
- */
- public OtfLookupGsub() {
- }
-
- /**
- * Parses a lookup.
- * @param raInput The input from which the lookup is being parsed.
- * @param offset The offset in {@code raInput} for the start of the lookup table.
- * @return The parsed lookup table instance.
- * @throws IOException For I/O errors during parsing.
- */
- public static OtfLookupGsub parse(final RandomAccessInput raInput, final int offset) throws IOException {
- raInput.seek(offset);
- final OtfLookupGsub lookup = new OtfLookupGsub();
- final int lookupTypeInteger = raInput.readUnsignedShort();
- lookup.lookupType = LookupType.fromValue(lookupTypeInteger);
- lookup.lookupFlag = raInput.readUnsignedShort();
- final int subTableCount = raInput.readUnsignedShort();
- final int[] subTableOffsets = new int[subTableCount];
- for (int index = 0; index < subTableCount; index ++) {
- subTableOffsets[index] = raInput.readUnsignedShort();
- }
- /* TODO: The last item in the table is named "MarkFilteringSet" with a type of "unit16". Although this is
- * probably a 16-bit type of some sort, we don't recognize it, and, for now, therefore skip parsing it. */
-
- lookup.subtables = new OtfLookupGsubSubtable[subTableCount];
- for (int index = 0; index < subTableCount; index ++) {
- final OtfLookupGsubSubtable subtable =
- parseSubtable(raInput, offset + subTableOffsets[index], lookup.lookupType);
- lookup.subtables[index] = subtable;
- }
-
- return lookup;
- }
-
- /**
- * Parses a subtable.
- * @param raInput The input from which the subtable is being parsed.
- * @param offset The offset in {@code raInput} for the start of the subtable.
- * @param lookupType The lookup type being parsed.
- * @return The parsed subtable instance.
- * @throws IOException For I/O errors during parsing.
- */
- private static OtfLookupGsubSubtable parseSubtable(final RandomAccessInput raInput, final int offset,
- final OtfLookupGsub.LookupType lookupType) throws IOException {
- raInput.seek(offset);
-
- final int formatId = raInput.readUnsignedShort();
-
- switch (lookupType) {
- case SINGLE: {
- switch (formatId) {
- case FORMAT_1: return OtfLookupGsubx01x01.parse(raInput, offset);
- case FORMAT_2: return OtfLookupGsubx01x02.parse(raInput, offset);
- default: throw new UnsupportedOperationException("Unrecognized GSUB lookup type 1: " + formatId);
- }
- }
- case MULTIPLE:
- switch (formatId) {
- case FORMAT_1: return OtfLookupGsubx02x01.parse(raInput, offset);
- default: throw new UnsupportedOperationException("Unrecognized GSUB lookup type 2: " + formatId);
- }
- case ALTERNATE:
- switch (formatId) {
- case FORMAT_1: return OtfLookupGsubx03x01.parse(raInput, offset);
- default: throw new UnsupportedOperationException("Unrecognized GSUB lookup type 3: " + formatId);
- }
- case LIGATURE:
- switch (formatId) {
- case FORMAT_1: return OtfLookupGsubx04x01.parse(raInput, offset);
- default: throw new UnsupportedOperationException("Unrecognized GSUB lookup type 4: " + formatId);
- }
- case CONTEXT:
- switch (formatId) {
- case FORMAT_1: return OtfLookupGsubx05x01.parse(raInput, offset);
- case FORMAT_2: return OtfLookupGsubx05x02.parse(raInput, offset);
- case FORMAT_3: return OtfLookupGsubx05x03.parse(raInput, offset);
- default: throw new UnsupportedOperationException("Unrecognized GSUB lookup type 5: " + formatId);
- }
- case CHAINING_CONTEXT:
- switch (formatId) {
- case FORMAT_1: return OtfLookupGsubx06x01.parse(raInput, offset);
- case FORMAT_2: return OtfLookupGsubx06x02.parse(raInput, offset);
- case FORMAT_3: return OtfLookupGsubx06x03.parse(raInput, offset);
- default: throw new UnsupportedOperationException("Unrecognized GSUB lookup type 6: " + formatId);
- }
- case EXTENSION_SUBSTITUTION:
- switch (formatId) {
- case FORMAT_1: return OtfLookupGsubx07x01.parse(raInput, offset);
- default: throw new UnsupportedOperationException("Unrecognized GSUB lookup type 7: " + formatId);
- }
- case REVERSE_CHAINING_CONTEXT_SINGLE:
- switch (formatId) {
- case FORMAT_1: return OtfLookupGsubx08x01.parse(raInput, offset);
- default: throw new UnsupportedOperationException("Unrecognized GSUB lookup type 8: " + formatId);
- }
- default: {
- throw new UnsupportedOperationException("Unrecognized GSUB lookup type: " + lookupType);
- }
- }
- }
-
- /**
- * Returns the lookup type.
- * @return The lookupType.
- */
- protected LookupType getLookupType() {
- return this.lookupType;
- }
-
- /**
- * Returns the lookup flag.
- * @return The lookupFlag.
- */
- protected int getLookupFlag() {
- return this.lookupFlag;
- }
-
- /**
- * Returns the subtables.
- * @return The subtables.
- */
- protected OtfLookupGsubSubtable[] getSubtables() {
- return this.subtables;
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubSubtable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubSubtable.java 2025-04-21 10:06:33 UTC (rev 13463)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubSubtable.java 2025-04-21 10:36:34 UTC (rev 13464)
@@ -1,50 +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.primitive.sequence.IntArrayBuilder;
-
-import org.axsl.font.FontContext;
-
-/**
- * Abstract superclass for all GSUB subtables.
- */
-public abstract class OtfLookupGsubSubtable {
-
- /**
- * Process the substitution for this subtable.
- * Looks through the possible substitution in this font, and for those that the client wants, converts the glyph
- * indexes for those subsitutions.
- * @param glyphIndexes The glyph indexes for which substitutions are being considered.
- * @param fontContext The font context, such as ligatures and small-caps that should be used when computing the
- * glyphs for this word.
- */
- abstract void makeSubstitutions(IntArrayBuilder glyphIndexes, FontContext fontContext);
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx01x01.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx01x01.java 2025-04-21 10:06:33 UTC (rev 13463)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx01x01.java 2025-04-21 10:36:34 UTC (rev 13464)
@@ -1,67 +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 org.foray.primitive.sequence.IntArrayBuilder;
-
-import org.axsl.font.FontContext;
-
-import java.io.IOException;
-
-/**
- * A Single Substitution Format 1 GSUB Subtable.
- */
-public class OtfLookupGsubx01x01 extends OtfLookupGsubSubtable {
-
- /**
- * Constructor.
- */
- public OtfLookupGsubx01x01() {
- }
-
- /**
- * 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 OtfLookupGsubx01x01 parse(final RandomAccessInput raInput, final int offset) throws IOException {
- raInput.seek(offset);
- final OtfLookupGsubx01x01 subtable = new OtfLookupGsubx01x01();
- return subtable;
- }
-
- @Override
- void makeSubstitutions(final IntArrayBuilder glyphIndexes, final FontContext fontContext) {
- /* TODO: Implement this. */
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx01x02.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx01x02.java 2025-04-21 10:06:33 UTC (rev 13463)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx01x02.java 2025-04-21 10:36:34 UTC (rev 13464)
@@ -1,67 +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 org.foray.primitive.sequence.IntArrayBuilder;
-
-import org.axsl.font.FontContext;
-
-import java.io.IOException;
-
-/**
- * A Single Substitution Format 2 GSUB Subtable.
- */
-public class OtfLookupGsubx01x02 extends OtfLookupGsubSubtable {
-
- /**
- * Constructor.
- */
- public OtfLookupGsubx01x02() {
- }
-
- /**
- * 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 OtfLookupGsubx01x02 parse(final RandomAccessInput raInput, final int offset) throws IOException {
- raInput.seek(offset);
- final OtfLookupGsubx01x02 subtable = new OtfLookupGsubx01x02();
- return subtable;
- }
-
- @Override
- void makeSubstitutions(final IntArrayBuilder glyphIndexes, final FontContext fontContext) {
- /* TODO: Implement this. */
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx02x01.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx02x01.java 2025-04-21 10:06:33 UTC (rev 13463)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx02x01.java 2025-04-21 10:36:34 UTC (rev 13464)
@@ -1,67 +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 org.foray.primitive.sequence.IntArrayBuilder;
-
-import org.axsl.font.FontContext;
-
-import java.io.IOException;
-
-/**
- * A Multiple Substitution Format 1 GSUB Subtable.
- */
-public class OtfLookupGsubx02x01 extends OtfLookupGsubSubtable {
-
- /**
- * Constructor.
- */
- public OtfLookupGsubx02x01() {
- }
-
- /**
- * 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 OtfLookupGsubx02x01 parse(final RandomAccessInput raInput, final int offset) throws IOException {
- raInput.seek(offset);
- final OtfLookupGsubx02x01 subtable = new OtfLookupGsubx02x01();
- return subtable;
- }
-
- @Override
- void makeSubstitutions(final IntArrayBuilder glyphIndexes, final FontContext fontContext) {
- /* TODO: Implement this. */
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx03x01.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx03x01.java 2025-04-21 10:06:33 UTC (rev 13463)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx03x01.java 2025-04-21 10:36:34 UTC (rev 13464)
@@ -1,67 +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 org.foray.primitive.sequence.IntArrayBuilder;
-
-import org.axsl.font.FontContext;
-
-import java.io.IOException;
-
-/**
- * An Alternate Substitution Format 1 GSUB Subtable.
- */
-public class OtfLookupGsubx03x01 extends OtfLookupGsubSubtable {
-
- /**
- * Constructor.
- */
- public OtfLookupGsubx03x01() {
- }
-
- /**
- * 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 OtfLookupGsubx03x01 parse(final RandomAccessInput raInput, final int offset) throws IOException {
- raInput.seek(offset);
- final OtfLookupGsubx03x01 subtable = new OtfLookupGsubx03x01();
- return subtable;
- }
-
- @Override
- void makeSubstitutions(final IntArrayBuilder glyphIndexes, final FontContext fontContext) {
- /* TODO: Implement this. */
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx04x01.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx04x01.java 2025-04-21 10:06:33 UTC (rev 13463)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx04x01.java 2025-04-21 10:36:34 UTC (rev 13464)
@@ -1,255 +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 org.foray.primitive.sequence.IntArrayBuilder;
-
-import org.axsl.font.FontContext;
-
-import java.io.IOException;
-
-/**
- * A Ligature Substitution Format 1 GSUB Subtable.
- */
-public class OtfLookupGsubx04x01 extends OtfLookupGsubSubtable {
-
- /**
- * One ligature.
- */
- public class Ligature {
-
- /** The glyph index of the ligature to substitute, i.e. the output. */
- private char ligGlyph;
-
- /** Array of component glyph indexes, starting with the second component (the first is in the Coverage table),
- * and ordered according to the writing direction of the font. For text written from left-to-right, the
- * left-most glyph will be the first, and vice versa. */
- private char[] components;
-
- /**
- * Returns the glyph index of the ligature to substitute, i.e. the output.
- * @return The output glyph index.
- */
- public char getLigGlyph() {
- return this.ligGlyph;
- }
-
- /**
- * Returns the array of component glyph indexes, starting with the second component (the first is in the
- * Coverage table), and ordered according to the writing direction of the font.
- * For text written from left-to-right, the left-most glyph will be the first, and vice versa.
- * @return The array of component glyph indexes.
- */
- public char[] getComponents() {
- return this.components;
- }
-
- /**
- * Checks this ligature to see if it matches the current position in a sequence of glyphIndexes, and if so,
- * makes the substitution.
- * @param glyphIndexes The sequence of glyphe indexes being examined.
- * @param index The index into {@code glyphIndexes} marking the current glyphs being compared.
- * @return The number of glyphs that were deleted, if any. If a subsitution was made, the number of glyphs in
- * this ligature. If no substitution was made, zero.
- */
- public int checkSubstitution(final IntArrayBuilder glyphIndexes, final int index) {
- if (index + this.components.length < glyphIndexes.length()) {
- boolean isMatch = true;
- for (int componentIndex = 0; componentIndex < this.components.length; componentIndex ++) {
- isMatch &= glyphIndexes.intAt(index + componentIndex + 1) == this.components[componentIndex];
- }
- if (isMatch) {
- /* Make the replacement. */
- glyphIndexes.setIntAt(index, this.ligGlyph);
- /* Delete the other glyph indexes. */
- glyphIndexes.delete(index + 1, index + 1 + this.components.length);
- /* Adjust the index. */
- return this.components.length;
- }
- }
- return 0;
- }
- }
-
- /**
- * A set of ligatures.
- */
- public class LigatureSet {
-
- /** The ligatures in this set. */
- private Ligature[] ligatures;
-
- /**
- * Returns the ligatures.
- * @return The ligatures.
- */
- public Ligature[] getLigatures() {
- return this.ligatures;
- }
- }
-
- /** The coverage for this subtable. */
- private OtfCoverage coverage;
-
- /** The ligature sets for this subtable. */
- private LigatureSet[] ligatureSets;
-
- /**
- * Constructor.
- */
- public OtfLookupGsubx04x01() {
- }
-
- /**
- * 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 OtfLookupGsubx04x01 parse(final RandomAccessInput raInput, final int offset) throws IOException {
- raInput.seek(offset);
- final OtfLookupGsubx04x01 subtable = new OtfLookupGsubx04x01();
- /* Skip the format identifier. We already parsed it to get here. */
- raInput.skipBytes(TtfTable.USHORT_BYTES);
- 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 = OtfCoverage.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 OtfLookupGsubx04x01 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 OtfLookupGsubx04x01 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.
- */
- protected OtfCoverage getCoverage() {
- return this.coverage;
- }
-
- /**
- * Returns the ligatures sets for this subtable.
- * @return The ligature sets.
- */
- protected LigatureSet[] getLigatureSets() {
- return this.ligatureSets;
- }
-
- @Override
- public void makeSubstitutions(final IntArrayBuilder glyphIndexes, final FontContext fontContext) {
- final OtfCoverage coverage = getCoverage();
- final LigatureSet[] ligatureSets = getLigatureSets();
-
- /* Only search through length - 1, as a ligature must apply to two or more glyphs. */
- for (int index = 0; index < glyphIndexes.length() - 1; index ++) {
- final int glyphIndex = glyphIndexes.intAt(index);
- final int coverageIndex = coverage.coverageIndex(glyphIndex);
- int glyphsDeleted = 0;
- if (coverageIndex > -1) {
- final LigatureSet ligatureSet = ligatureSets[coverageIndex];
- for (int ligatureIndex = 0; ligatureIndex < ligatureSet.ligatures.length; ligatureIndex ++) {
- final Ligature ligature = ligatureSet.getLigatures()[ligatureIndex];
- glyphsDeleted = ligature.checkSubstitution(glyphIndexes, index);
- if (glyphsDeleted > 0) {
- break;
- }
- }
- }
- }
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx05x01.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx05x01.java 2025-04-21 10:06:33 UTC (rev 13463)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx05x01.java 2025-04-21 10:36:34 UTC (rev 13464)
@@ -1,67 +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 org.foray.primitive.sequence.IntArrayBuilder;
-
-import org.axsl.font.FontContext;
-
-import java.io.IOException;
-
-/**
- * A Contextual Substitution Format 1 GSUB Subtable.
- */
-public class OtfLookupGsubx05x01 extends OtfLookupGsubSubtable {
-
- /**
- * Constructor.
- */
- public OtfLookupGsubx05x01() {
- }
-
- /**
- * 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 OtfLookupGsubx05x01 parse(final RandomAccessInput raInput, final int offset) throws IOException {
- raInput.seek(offset);
- final OtfLookupGsubx05x01 subtable = new OtfLookupGsubx05x01();
- return subtable;
- }
-
- @Override
- void makeSubstitutions(final IntArrayBuilder glyphIndexes, final FontContext fontContext) {
- /* TODO: Implement this. */
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx05x02.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx05x02.java 2025-04-21 10:06:33 UTC (rev 13463)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx05x02.java 2025-04-21 10:36:34 UTC (rev 13464)
@@ -1,67 +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 org.foray.primitive.sequence.IntArrayBuilder;
-
-import org.axsl.font.FontContext;
-
-import java.io.IOException;
-
-/**
- * A Contextual Substitution Format 2 GSUB Subtable.
- */
-public class OtfLookupGsubx05x02 extends OtfLookupGsubSubtable {
-
- /**
- * Constructor.
- */
- public OtfLookupGsubx05x02() {
- }
-
- /**
- * 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 OtfLookupGsubx05x02 parse(final RandomAccessInput raInput, final int offset) throws IOException {
- raInput.seek(offset);
- final OtfLookupGsubx05x02 subtable = new OtfLookupGsubx05x02();
- return subtable;
- }
-
- @Override
- void makeSubstitutions(final IntArrayBuilder glyphIndexes, final FontContext fontContext) {
- /* TODO: Implement this. */
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx05x03.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx05x03.java 2025-04-21 10:06:33 UTC (rev 13463)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx05x03.java 2025-04-21 10:36:34 UTC (rev 13464)
@@ -1,67 +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 org.foray.primitive.sequence.IntArrayBuilder;
-
-import org.axsl.font.FontContext;
-
-import java.io.IOException;
-
-/**
- * A Contextual Substitution Format 3 GSUB Subtable.
- */
-public class OtfLookupGsubx05x03 extends OtfLookupGsubSubtable {
-
- /**
- * Constructor.
- */
- public OtfLookupGsubx05x03() {
- }
-
- /**
- * 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 OtfLookupGsubx05x03 parse(final RandomAccessInput raInput, final int offset) throws IOException {
- raInput.seek(offset);
- final OtfLookupGsubx05x03 subtable = new OtfLookupGsubx05x03();
- return subtable;
- }
-
- @Override
- void makeSubstitutions(final IntArrayBuilder glyphIndexes, final FontContext fontContext) {
- /* TODO: Implement this. */
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx06x01.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx06x01.java 2025-04-21 10:06:33 UTC (rev 13463)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx06x01.java 2025-04-21 10:36:34 UTC (rev 13464)
@@ -1,67 +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 org.foray.primitive.sequence.IntArrayBuilder;
-
-import org.axsl.font.FontContext;
-
-import java.io.IOException;
-
-/**
- * A Chaining Context Substitution Format 1 GSUB Subtable.
- */
-public class OtfLookupGsubx06x01 extends OtfLookupGsubSubtable {
-
- /**
- * Constructor.
- */
- public OtfLookupGsubx06x01() {
- }
-
- /**
- * 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 OtfLookupGsubx06x01 parse(final RandomAccessInput raInput, final int offset) throws IOException {
- raInput.seek(offset);
- final OtfLookupGsubx06x01 subtable = new OtfLookupGsubx06x01();
- return subtable;
- }
-
- @Override
- void makeSubstitutions(final IntArrayBuilder glyphIndexes, final FontContext fontContext) {
- /* TODO: Implement this. */
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx06x02.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx06x02.java 2025-04-21 10:06:33 UTC (rev 13463)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx06x02.java 2025-04-21 10:36:34 UTC (rev 13464)
@@ -1,67 +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 org.foray.primitive.sequence.IntArrayBuilder;
-
-import org.axsl.font.FontContext;
-
-import java.io.IOException;
-
-/**
- * A Chaining Context Format 2 GSUB Subtable.
- */
-public class OtfLookupGsubx06x02 extends OtfLookupGsubSubtable {
-
- /**
- * Constructor.
- */
- public OtfLookupGsubx06x02() {
- }
-
- /**
- * 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 OtfLookupGsubx06x02 parse(final RandomAccessInput raInput, final int offset) throws IOException {
- raInput.seek(offset);
- final OtfLookupGsubx06x02 subtable = new OtfLookupGsubx06x02();
- return subtable;
- }
-
- @Override
- void makeSubstitutions(final IntArrayBuilder glyphIndexes, final FontContext fontContext) {
- /* TODO: Implement this. */
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx06x03.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx06x03.java 2025-04-21 10:06:33 UTC (rev 13463)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx06x03.java 2025-04-21 10:36:34 UTC (rev 13464)
@@ -1,67 +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 org.foray.primitive.sequence.IntArrayBuilder;
-
-import org.axsl.font.FontContext;
-
-import java.io.IOException;
-
-/**
- * A Chaining Context Format 3 GSUB Subtable.
- */
-public class OtfLookupGsubx06x03 extends OtfLookupGsubSubtable {
-
- /**
- * Constructor.
- */
- public OtfLookupGsubx06x03() {
- }
-
- /**
- * 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 OtfLookupGsubx06x03 parse(final RandomAccessInput raInput, final int offset) throws IOException {
- raInput.seek(offset);
- final OtfLookupGsubx06x03 subtable = new OtfLookupGsubx06x03();
- return subtable;
- }
-
- @Override
- void makeSubstitutions(final IntArrayBuilder glyphIndexes, final FontContext fontContext) {
- /* TODO: Implement this. */
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx07x01.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx07x01.java 2025-04-21 10:06:33 UTC (rev 13463)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx07x01.java 2025-04-21 10:36:34 UTC (rev 13464)
@@ -1,67 +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 org.foray.primitive.sequence.IntArrayBuilder;
-
-import org.axsl.font.FontContext;
-
-import java.io.IOException;
-
-/**
- * An Extension Substitution Format 1 GSUB Subtable.
- */
-public class OtfLookupGsubx07x01 extends OtfLookupGsubSubtable {
-
- /**
- * Constructor.
- */
- public OtfLookupGsubx07x01() {
- }
-
- /**
- * 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 OtfLookupGsubx07x01 parse(final RandomAccessInput raInput, final int offset) throws IOException {
- raInput.seek(offset);
- final OtfLookupGsubx07x01 subtable = new OtfLookupGsubx07x01();
- return subtable;
- }
-
- @Override
- void makeSubstitutions(final IntArrayBuilder glyphInd...
[truncated message content] |
|
From: <vic...@us...> - 2025-04-21 10:06:50
|
Revision: 13463
http://sourceforge.net/p/foray/code/13463
Author: victormote
Date: 2025-04-21 10:06:33 +0000 (Mon, 21 Apr 2025)
Log Message:
-----------
Move more TTF Table classes to new directory.
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/TtfSubSetFile.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GlyfTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/LocaTable.java
Added Paths:
-----------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HtmxTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/MtxEntry.java
Removed Paths:
-------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfMtxEntry.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableHmtx.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-21 01:00:28 UTC (rev 13462)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-04-21 10:06:33 UTC (rev 13463)
@@ -44,11 +44,13 @@
import org.foray.font.ttf.table.GposTable;
import org.foray.font.ttf.table.HeadTable;
import org.foray.font.ttf.table.HheaTable;
+import org.foray.font.ttf.table.HtmxTable;
import org.foray.font.ttf.table.JstfTable;
import org.foray.font.ttf.table.KernTable;
import org.foray.font.ttf.table.LocaTable;
import org.foray.font.ttf.table.MathTable;
import org.foray.font.ttf.table.MaxpTable;
+import org.foray.font.ttf.table.MtxEntry;
import org.foray.font.ttf.table.NameTable;
import org.foray.font.ttf.table.Os2Table;
import org.foray.font.ttf.table.PcltTable;
@@ -90,7 +92,7 @@
private HheaTable hheaTable = null;
/** The (required) "hmtx" table instance. */
- private TtfTableHmtx hmtxTable = null;
+ private HtmxTable hmtxTable = null;
/** The (required) "maxp" table instance. */
private MaxpTable maxpTable = null;
@@ -207,7 +209,7 @@
dirEntry = ttfTableDir.getTableDirectoryEntry("hmtx");
final int numberOfGlyphs = font.maxpTable.getNumberOfGlyphs();
final int numberOfHMetrics = font.hheaTable.getNumberOfHMetrics();
- font.hmtxTable = TtfTableHmtx.parse(dirEntry, raInput, numberOfGlyphs, numberOfHMetrics);
+ font.hmtxTable = HtmxTable.parse(dirEntry, raInput, numberOfGlyphs, numberOfHMetrics);
dirEntry = ttfTableDir.getTableDirectoryEntry("post");
font.postTable = PostTable.parse(dirEntry, raInput);
@@ -348,7 +350,7 @@
* Returns the "hmtx" table.
* @return The "hmtx" table.
*/
- public TtfTableHmtx getHmtxTable() {
+ public HtmxTable getHmtxTable() {
return this.hmtxTable;
}
@@ -621,7 +623,7 @@
/* No metrics for "H". */
return -1;
} else {
- final TtfMtxEntry mtx = this.hmtxTable.getMtxEntry(metricIndex);
+ final MtxEntry mtx = this.hmtxTable.getMtxEntry(metricIndex);
return mtx.getBoundingBox().computeHeightAsInt();
}
}
@@ -644,7 +646,7 @@
/* No metrics for "x". */
return -1;
} else {
- final TtfMtxEntry mtx = this.hmtxTable.getMtxEntry(metricIndex);
+ final MtxEntry mtx = this.hmtxTable.getMtxEntry(metricIndex);
return mtx.getBoundingBox().computeHeightAsInt();
}
}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfMtxEntry.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfMtxEntry.java 2025-04-21 01:00:28 UTC (rev 13462)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfMtxEntry.java 2025-04-21 10:06:33 UTC (rev 13463)
@@ -1,131 +0,0 @@
-/*
- * Copyright 2004 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.axsl.ps.BoundingBox;
-
-/**
- * A TTF Font Mtx entry.
- */
-public class TtfMtxEntry {
-
- /** The glyph width. */
- private int wx;
-
- /** The glyph left side bearing. */
- private int lsb;
-
- /** The glyph bounding box. */
- private BoundingBox bbox;
-
- /** Obtained from the "loca" table. */
- private long offset;
-
- /**
- * Constructor.
- */
- TtfMtxEntry() {
- }
-
- /**
- * Returns the total vertical size of this character.
- * @return The total vertical size, in millipoints, of this character.
- */
- public int getHeight() {
- if (this.bbox == null) {
- return 0;
- }
- return this.bbox.computeHeightAsInt();
- }
-
- /**
- * Set the width of this entry, in text space units.
- * @param width The new width for this entry.
- */
- public void setWidth(final int width) {
- this.wx = width;
- }
-
- /**
- * Returns the width of this entry, in text space units.
- * @return The width of this entry.
- */
- public int getWidth() {
- return this.wx;
- }
-
- /**
- * Returns the offset of the glyf information for this entry.
- * @return The offset of the glyf information for this entry.
- */
- public long getOffset() {
- return this.offset;
- }
-
- /**
- * Sets the offset of the glyf information for this entry.
- * @param offset The new offset to the glyf information for this entry.
- */
- public void setOffset(final long offset) {
- this.offset = offset;
- }
-
- /**
- * Returns the left side bearing for this entry.
- * @return The left side bearing for this entry.
- */
- public int getLeftSideBearing() {
- return this.lsb;
- }
-
- /**
- * Sets the left side bearing for this entry.
- * @param leftSideBearing The new left side bearing value.
- */
- public void setLeftSideBearing(final int leftSideBearing) {
- this.lsb = leftSideBearing;
- }
-
- /**
- * Returns the bounding box for this entry.
- * @return The bounding box.
- */
- public BoundingBox getBoundingBox() {
- return this.bbox;
- }
-
- /**
- * Sets the bounding box for this entry.
- * @param boundingBox The new bounding box.
- */
- public void setBoundingBox(final BoundingBox boundingBox) {
- this.bbox = boundingBox;
- }
-
-}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfSubSetFile.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfSubSetFile.java 2025-04-21 01:00:28 UTC (rev 13462)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfSubSetFile.java 2025-04-21 10:06:33 UTC (rev 13463)
@@ -33,6 +33,8 @@
import org.foray.font.ttf.table.CffTable;
import org.foray.font.ttf.table.GlyfTable;
import org.foray.font.ttf.table.HeadTable;
+import org.foray.font.ttf.table.HtmxTable;
+import org.foray.font.ttf.table.MtxEntry;
import org.axsl.constants.PrimitiveConstants;
@@ -459,11 +461,11 @@
final byte[] byteArray = createTableByteArray(arraySize);
int cumulativeSize = 0;
- final TtfTableHmtx hmtx = this.ttfFont.getHmtxTable();
+ final HtmxTable hmtx = this.ttfFont.getHmtxTable();
for (int i = 0; i < this.subset.numGlyphsUsed(); i++) {
final int origGlyphIndex = this.subset.decodeSubsetIndex(i);
final int glyphLength = computeGlyphLength(origGlyphIndex);
- final TtfMtxEntry mtx = hmtx.getMtxEntry(origGlyphIndex);
+ final MtxEntry mtx = hmtx.getMtxEntry(origGlyphIndex);
final int glyphOffset = (int) mtx.getOffset();
final int fileOffset = entry.getOffset() + glyphOffset;
// Copy glyph
@@ -505,7 +507,7 @@
private int computeGlyphLength(final int origGlyphIndex)
throws IOException {
int nextOffset = 0;
- final TtfTableHmtx hmtx = this.ttfFont.getHmtxTable();
+ final HtmxTable hmtx = this.ttfFont.getHmtxTable();
if (origGlyphIndex >= (hmtx.numMtxEntries() - 1)) {
nextOffset = (int) this.ttfFont.getLocaTable().lastOffset();
} else {
@@ -535,10 +537,10 @@
final int entrySize = widthSize + lsbSize;
final int arraySize = this.subset.numGlyphsUsed() * entrySize;
final byte[] byteArray = createTableByteArray(arraySize);
- final TtfTableHmtx hmtx = this.ttfFont.getHmtxTable();
+ final HtmxTable hmtx = this.ttfFont.getHmtxTable();
for (int i = 0; i < this.subset.numGlyphsUsed(); i ++) {
final int originalIndex = this.subset.decodeSubsetIndex(i);
- final TtfMtxEntry metricEntry = hmtx.getMtxEntry(originalIndex);
+ final MtxEntry metricEntry = hmtx.getMtxEntry(originalIndex);
writeUShort(byteArray, i * entrySize, metricEntry.getWidth());
writeUShort(byteArray, (i * entrySize) + widthSize,
metricEntry.getLeftSideBearing());
@@ -559,8 +561,8 @@
final List<Integer> ret = new ArrayList<Integer>();
ret.add(glyphIdx);
int offset = glyphOffset;
- final TtfTableHmtx hmtxTable = this.ttfFont.getHmtxTable();
- final TtfMtxEntry mtxEntry = hmtxTable.getMtxEntry(glyphIdx.intValue());
+ final HtmxTable hmtxTable = this.ttfFont.getHmtxTable();
+ final MtxEntry mtxEntry = hmtxTable.getMtxEntry(glyphIdx.intValue());
offset += (int) mtxEntry.getOffset();
offset += GlyfTable.HEADER_SIZE;
Integer compositeIdx = null;
@@ -651,7 +653,7 @@
final Map<Integer, Integer> usedCompositeGlyphs
= new HashMap<Integer, Integer>();
boolean stillCheckingForCompositeGlyphs = true;
- final TtfTableHmtx hmtx = this.ttfFont.getHmtxTable();
+ final HtmxTable hmtx = this.ttfFont.getHmtxTable();
while (stillCheckingForCompositeGlyphs) {
boolean anyGlyphsAdded = false;
for (int i = 0; i < this.subset.numGlyphsUsed(); i++) {
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableHmtx.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableHmtx.java 2025-04-21 01:00:28 UTC (rev 13462)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableHmtx.java 2025-04-21 10:06:33 UTC (rev 13463)
@@ -1,121 +0,0 @@
-/*
- * Copyright 2004 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;
-
-/**
- * Class representing a TTF "hmtx" (horizontal metrics) table.
- */
-public class TtfTableHmtx extends TtfTable {
-
- /** The metrics entries for this table. */
- private TtfMtxEntry[] metrics;
-
- /**
- * Constructor.
- * @param dirEntry The parent table directory entry.
- */
- public TtfTableHmtx(final TtfOffsetTableRecord dirEntry) {
- super(dirEntry);
- }
-
- /**
- * Read "hmtx" table and put the horizontal metrics in the metrics array.
- * If the number of metrics is less than the number of glyphs (eg fixed size fonts), extend the metrics array and
- * fill in the missing widths.
- * @param dirEntry The parent table directory entry.
- * @param raInput The input which is being parsed.
- * @param numberOfGlyphs The number of glyphs in the font.
- * This information is derived from the "maxp" table.
- * @param numberOfHMetrics The number of horizontal metrics in the font.
- * This information is derived from the "hhea" table.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
- */
- public static TtfTableHmtx parse(final TtfOffsetTableRecord dirEntry, final RandomAccessInput raInput,
- final int numberOfGlyphs, final int numberOfHMetrics)
- throws IOException {
- raInput.seek(dirEntry.getOffset());
- final TtfTableHmtx hmtx = new TtfTableHmtx(dirEntry);
- final int metricsSize = Math.max(numberOfGlyphs, numberOfHMetrics);
- hmtx.metrics = new TtfMtxEntry[metricsSize];
-
- for (int i = 0; i < metricsSize; i++) {
- hmtx.metrics[i] = new TtfMtxEntry();
- }
- for (int i = 0; i < numberOfHMetrics; i++) {
- hmtx.metrics[i].setWidth(raInput.readUnsignedShort());
- hmtx.metrics[i].setLeftSideBearing(raInput.readShort());
- }
-
- if (numberOfHMetrics < metricsSize) {
- // Fill in the missing widths
- final int lastWidth = hmtx.metrics[numberOfHMetrics - 1].getWidth();
- for (int i = numberOfHMetrics; i < metricsSize; i++) {
- hmtx.metrics[i].setWidth(lastWidth);
- hmtx.metrics[i].setLeftSideBearing(raInput.readShort());
- }
- }
- return hmtx;
- }
-
- @Override
- public String getTableTag() {
- return "hmtx";
- }
-
- /**
- * Return a specific metric record.
- * @param index The index to the desired metric record.
- * @return The metric record corresponding to {@code index}.
- */
- public TtfMtxEntry getMtxEntry(final int index) {
- if (this.metrics == null
- || index < 0
- || index > this.metrics.length - 1) {
- return null;
- }
- return this.metrics[index];
- }
-
- /**
- * Returns the number of metric records in this table.
- * @return The number of metric records in this table.
- */
- public int numMtxEntries() {
- if (this.metrics == null) {
- return 0;
- }
- return this.metrics.length;
- }
-
-}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GlyfTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GlyfTable.java 2025-04-21 01:00:28 UTC (rev 13462)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GlyfTable.java 2025-04-21 10:06:33 UTC (rev 13463)
@@ -30,10 +30,8 @@
import org.foray.common.RandomAccessInput;
import org.foray.common.data.BoundingBoxShort;
-import org.foray.font.ttf.TtfMtxEntry;
import org.foray.font.ttf.TtfOffsetTableRecord;
import org.foray.font.ttf.TtfTable;
-import org.foray.font.ttf.TtfTableHmtx;
import org.foray.primitive.BitUtils;
import org.axsl.ps.BoundingBox;
@@ -96,13 +94,13 @@
* @throws IOException For I/O Error.
*/
public static GlyfTable parse(final TtfOffsetTableRecord dirEntry, final RandomAccessInput raInput,
- final int numberOfGlyphs, final TtfTableHmtx hmtx) throws IOException {
+ final int numberOfGlyphs, final HtmxTable hmtx) throws IOException {
raInput.seek(dirEntry.getOffset());
final GlyfTable glyf = new GlyfTable(dirEntry);
- final TtfMtxEntry firstMetric = hmtx.getMtxEntry(0);
+ final MtxEntry firstMetric = hmtx.getMtxEntry(0);
for (int i = 0; i < (numberOfGlyphs - 1); i++) {
- final TtfMtxEntry thisMetric = hmtx.getMtxEntry(i);
- final TtfMtxEntry nextMetric = hmtx.getMtxEntry(i + 1);
+ final MtxEntry thisMetric = hmtx.getMtxEntry(i);
+ final MtxEntry nextMetric = hmtx.getMtxEntry(i + 1);
if (thisMetric.getOffset() != nextMetric.getOffset()) {
raInput.seek(dirEntry.getOffset() + thisMetric.getOffset());
raInput.skipBytes(2);
@@ -118,8 +116,8 @@
final int n = dirEntry.getOffset();
for (int i = 0; i < numberOfGlyphs; i++) {
- final TtfMtxEntry thisMetric = hmtx.getMtxEntry(i);
- final TtfMtxEntry nextMetric = hmtx.getMtxEntry(i + 1);
+ final MtxEntry thisMetric = hmtx.getMtxEntry(i);
+ final MtxEntry nextMetric = hmtx.getMtxEntry(i + 1);
if ((i + 1) >= hmtx.numMtxEntries()
|| thisMetric.getOffset() != nextMetric.getOffset()) {
raInput.seek(n + thisMetric.getOffset());
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HtmxTable.java (from rev 13455, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableHmtx.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HtmxTable.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HtmxTable.java 2025-04-21 10:06:33 UTC (rev 13463)
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2004 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.TtfOffsetTableRecord;
+import org.foray.font.ttf.TtfTable;
+
+import java.io.IOException;
+
+/**
+ * Class representing a TTF "hmtx" (horizontal metrics) table.
+ */
+public class HtmxTable extends TtfTable {
+
+ /** The metrics entries for this table. */
+ private MtxEntry[] metrics;
+
+ /**
+ * Constructor.
+ * @param dirEntry The parent table directory entry.
+ */
+ public HtmxTable(final TtfOffsetTableRecord dirEntry) {
+ super(dirEntry);
+ }
+
+ /**
+ * Read "hmtx" table and put the horizontal metrics in the metrics array.
+ * If the number of metrics is less than the number of glyphs (eg fixed size fonts), extend the metrics array and
+ * fill in the missing widths.
+ * @param dirEntry The parent table directory entry.
+ * @param raInput The input which is being parsed.
+ * @param numberOfGlyphs The number of glyphs in the font.
+ * This information is derived from the "maxp" table.
+ * @param numberOfHMetrics The number of horizontal metrics in the font.
+ * This information is derived from the "hhea" table.
+ * @return The parsed instance.
+ * @throws IOException For I/O Error.
+ */
+ public static HtmxTable parse(final TtfOffsetTableRecord dirEntry, final RandomAccessInput raInput,
+ final int numberOfGlyphs, final int numberOfHMetrics)
+ throws IOException {
+ raInput.seek(dirEntry.getOffset());
+ final HtmxTable hmtx = new HtmxTable(dirEntry);
+ final int metricsSize = Math.max(numberOfGlyphs, numberOfHMetrics);
+ hmtx.metrics = new MtxEntry[metricsSize];
+
+ for (int i = 0; i < metricsSize; i++) {
+ hmtx.metrics[i] = new MtxEntry();
+ }
+ for (int i = 0; i < numberOfHMetrics; i++) {
+ hmtx.metrics[i].setWidth(raInput.readUnsignedShort());
+ hmtx.metrics[i].setLeftSideBearing(raInput.readShort());
+ }
+
+ if (numberOfHMetrics < metricsSize) {
+ // Fill in the missing widths
+ final int lastWidth = hmtx.metrics[numberOfHMetrics - 1].getWidth();
+ for (int i = numberOfHMetrics; i < metricsSize; i++) {
+ hmtx.metrics[i].setWidth(lastWidth);
+ hmtx.metrics[i].setLeftSideBearing(raInput.readShort());
+ }
+ }
+ return hmtx;
+ }
+
+ @Override
+ public String getTableTag() {
+ return "hmtx";
+ }
+
+ /**
+ * Return a specific metric record.
+ * @param index The index to the desired metric record.
+ * @return The metric record corresponding to {@code index}.
+ */
+ public MtxEntry getMtxEntry(final int index) {
+ if (this.metrics == null
+ || index < 0
+ || index > this.metrics.length - 1) {
+ return null;
+ }
+ return this.metrics[index];
+ }
+
+ /**
+ * Returns the number of metric records in this table.
+ * @return The number of metric records in this table.
+ */
+ public int numMtxEntries() {
+ if (this.metrics == null) {
+ return 0;
+ }
+ return this.metrics.length;
+ }
+
+}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/LocaTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/LocaTable.java 2025-04-21 01:00:28 UTC (rev 13462)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/LocaTable.java 2025-04-21 10:06:33 UTC (rev 13463)
@@ -31,7 +31,6 @@
import org.foray.common.RandomAccessInput;
import org.foray.font.ttf.TtfOffsetTableRecord;
import org.foray.font.ttf.TtfTable;
-import org.foray.font.ttf.TtfTableHmtx;
import java.io.IOException;
@@ -66,7 +65,7 @@
* @throws IOException For I/O Error.
*/
public static LocaTable parse(final TtfOffsetTableRecord dirEntry, final RandomAccessInput raInput,
- final boolean isLongFormat, final int numberOfGlyphs, final TtfTableHmtx hmtx) throws IOException {
+ final boolean isLongFormat, final int numberOfGlyphs, final HtmxTable hmtx) throws IOException {
raInput.seek(dirEntry.getOffset());
final LocaTable loca = new LocaTable(dirEntry);
for (int i = 0; i < numberOfGlyphs; i++) {
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/MtxEntry.java (from rev 13455, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfMtxEntry.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/MtxEntry.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/MtxEntry.java 2025-04-21 10:06:33 UTC (rev 13463)
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2004 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.axsl.ps.BoundingBox;
+
+/**
+ * A TTF Font Mtx entry.
+ */
+public class MtxEntry {
+
+ /** The glyph width. */
+ private int wx;
+
+ /** The glyph left side bearing. */
+ private int lsb;
+
+ /** The glyph bounding box. */
+ private BoundingBox bbox;
+
+ /** Obtained from the "loca" table. */
+ private long offset;
+
+ /**
+ * Constructor.
+ */
+ MtxEntry() {
+ }
+
+ /**
+ * Returns the total vertical size of this character.
+ * @return The total vertical size, in millipoints, of this character.
+ */
+ public int getHeight() {
+ if (this.bbox == null) {
+ return 0;
+ }
+ return this.bbox.computeHeightAsInt();
+ }
+
+ /**
+ * Set the width of this entry, in text space units.
+ * @param width The new width for this entry.
+ */
+ public void setWidth(final int width) {
+ this.wx = width;
+ }
+
+ /**
+ * Returns the width of this entry, in text space units.
+ * @return The width of this entry.
+ */
+ public int getWidth() {
+ return this.wx;
+ }
+
+ /**
+ * Returns the offset of the glyf information for this entry.
+ * @return The offset of the glyf information for this entry.
+ */
+ public long getOffset() {
+ return this.offset;
+ }
+
+ /**
+ * Sets the offset of the glyf information for this entry.
+ * @param offset The new offset to the glyf information for this entry.
+ */
+ public void setOffset(final long offset) {
+ this.offset = offset;
+ }
+
+ /**
+ * Returns the left side bearing for this entry.
+ * @return The left side bearing for this entry.
+ */
+ public int getLeftSideBearing() {
+ return this.lsb;
+ }
+
+ /**
+ * Sets the left side bearing for this entry.
+ * @param leftSideBearing The new left side bearing value.
+ */
+ public void setLeftSideBearing(final int leftSideBearing) {
+ this.lsb = leftSideBearing;
+ }
+
+ /**
+ * Returns the bounding box for this entry.
+ * @return The bounding box.
+ */
+ public BoundingBox getBoundingBox() {
+ return this.bbox;
+ }
+
+ /**
+ * Sets the bounding box for this entry.
+ * @param boundingBox The new bounding box.
+ */
+ public void setBoundingBox(final BoundingBox boundingBox) {
+ this.bbox = boundingBox;
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-21 01:00:46
|
Revision: 13462
http://sourceforge.net/p/foray/code/13462
Author: victormote
Date: 2025-04-21 01:00:28 +0000 (Mon, 21 Apr 2025)
Log Message:
-----------
Move more TTF Table classes to new directory.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java
Added Paths:
-----------
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/HheaTable.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/KernTable.java
Removed Paths:
-------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableGpos.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableHhea.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableJstf.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableKern.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-21 00:51:16 UTC (rev 13461)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-04-21 01:00:28 UTC (rev 13462)
@@ -41,7 +41,11 @@
import org.foray.font.ttf.table.GaspTable;
import org.foray.font.ttf.table.GdefTable;
import org.foray.font.ttf.table.GlyfTable;
+import org.foray.font.ttf.table.GposTable;
import org.foray.font.ttf.table.HeadTable;
+import org.foray.font.ttf.table.HheaTable;
+import org.foray.font.ttf.table.JstfTable;
+import org.foray.font.ttf.table.KernTable;
import org.foray.font.ttf.table.LocaTable;
import org.foray.font.ttf.table.MathTable;
import org.foray.font.ttf.table.MaxpTable;
@@ -83,7 +87,7 @@
private HeadTable headTable = null;
/** The (required) "hhea" table instance. */
- private TtfTableHhea hheaTable = null;
+ private HheaTable hheaTable = null;
/** The (required) "hmtx" table instance. */
private TtfTableHmtx hmtxTable = null;
@@ -134,19 +138,19 @@
private GdefTable gdefTable = null;
/** The (OTF, Advanced Typographic Table) "GPOS" table instance. */
- private TtfTableGpos gposTable = null;
+ private GposTable gposTable = null;
/** The (OTF, Advanced Typographic Table) "GSUB" table instance. */
private TtfTableGsub gsubTable = null;
/** The (OTF, Advanced Typographic Table) "JSTF" table instance. */
- private TtfTableJstf jstfTable = null;
+ private JstfTable jstfTable = null;
/** The (OTF, Advanced Typographic Table) "MATH" table instance. */
private MathTable mathTable = null;
/** The (optional) "kern" table instance. */
- private TtfTableKern kernTable = null;
+ private KernTable kernTable = null;
/** The (optional) "PCLT" table instance. */
private PcltTable pcltTable = null;
@@ -196,7 +200,7 @@
/* Read the Horizontal Header before the Horizontal Metrics. */
dirEntry = ttfTableDir.getTableDirectoryEntry("hhea");
- font.hheaTable = TtfTableHhea.parse(dirEntry, raInput);
+ font.hheaTable = HheaTable.parse(dirEntry, raInput);
/* After this point, the order may not matter. */
@@ -275,7 +279,7 @@
dirEntry = ttfTableDir.getTableDirectoryEntry("GPOS");
if (dirEntry != null) {
- font.gposTable = TtfTableGpos.parse(dirEntry, raInput);
+ font.gposTable = GposTable.parse(dirEntry, raInput);
}
dirEntry = ttfTableDir.getTableDirectoryEntry("GSUB");
@@ -285,7 +289,7 @@
dirEntry = ttfTableDir.getTableDirectoryEntry("JSTF");
if (dirEntry != null) {
- font.jstfTable = TtfTableJstf.parse(dirEntry, raInput);
+ font.jstfTable = JstfTable.parse(dirEntry, raInput);
}
dirEntry = ttfTableDir.getTableDirectoryEntry("MATH");
@@ -302,7 +306,7 @@
dirEntry = ttfTableDir.getTableDirectoryEntry("kern");
if (dirEntry != null) {
- font.kernTable = TtfTableKern.parse(dirEntry, raInput, font.cmapTable);
+ font.kernTable = KernTable.parse(dirEntry, raInput, font.cmapTable);
}
return font;
@@ -336,7 +340,7 @@
* Returns the "hhea" table.
* @return The "hhea" table.
*/
- public TtfTableHhea getHheaTable() {
+ public HheaTable getHheaTable() {
return this.hheaTable;
}
@@ -472,7 +476,7 @@
* Returns the "GPOS" table.
* @return The "GPOS" table.
*/
- public TtfTableGpos getGposTable() {
+ public GposTable getGposTable() {
return this.gposTable;
}
@@ -488,7 +492,7 @@
* Returns the "JSTF" table.
* @return The "JSTF" table.
*/
- public TtfTableJstf getJstfTable() {
+ public JstfTable getJstfTable() {
return this.jstfTable;
}
@@ -512,7 +516,7 @@
* Returns the "kern" table.
* @return The "kern" table.
*/
- public TtfTableKern getKernTable() {
+ public KernTable getKernTable() {
return this.kernTable;
}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableGpos.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableGpos.java 2025-04-21 00:51:16 UTC (rev 13461)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableGpos.java 2025-04-21 01:00:28 UTC (rev 13462)
@@ -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;
-
-/**
- * An OpenType "GPOS" (Glyph Positioning Data) table.
- * This table is an Advanced Typographic Table.
- */
-public class TtfTableGpos extends TtfTable {
-
- /**
- * Constructor.
- * @param offsetRecord The parent table directory entry.
- */
- public TtfTableGpos(final TtfOffsetTableRecord offsetRecord) {
- super(offsetRecord);
- }
-
- /**
- * Parse the table from the table content.
- * @param offsetRecord The parent offset table record.
- * @param raInput The input which is being parsed.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
- */
- public static TtfTableGpos parse(final TtfOffsetTableRecord offsetRecord, final RandomAccessInput raInput)
- throws IOException {
- raInput.seek(offsetRecord.getOffset());
- final TtfTableGpos table = new TtfTableGpos(offsetRecord);
- return table;
- }
-
- @Override
- public String getTableTag() {
- return "GPOS";
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableHhea.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableHhea.java 2025-04-21 00:51:16 UTC (rev 13461)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableHhea.java 2025-04-21 01:00:28 UTC (rev 13462)
@@ -1,136 +0,0 @@
-/*
- * Copyright 2004 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;
-
-/**
- * Class representing a TTF "hhea" (horizontal header) table.
- */
-public class TtfTableHhea extends TtfTable {
-
- /** Typographic ascent. */
- private int ascender = 0;
-
- /** Typographic descent. */
- private int descender = 0;
-
- /**
- * Number of hMetric entries in "hmtx" table; may be smaller than the total
- * number of glyphs in the font (e.g. a fixed-width font like Courier).
- */
- private int numberOfHMetrics;
-
- /**
- * Constructor.
- * @param dirEntry The parent table directory entry.
- */
- public TtfTableHhea(final TtfOffsetTableRecord dirEntry) {
- super(dirEntry);
- }
-
- /**
- * Parse the table.
- * @param dirEntry The parent table directory entry.
- * @param raInput The input which is being parsed.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
- */
- public static TtfTableHhea parse(final TtfOffsetTableRecord dirEntry, final RandomAccessInput raInput)
- throws IOException {
- raInput.seek(dirEntry.getOffset());
- final TtfTableHhea hhea = new TtfTableHhea(dirEntry);
- /* Skip the table version number. */
- raInput.skipBytes(FIXED_BYTES);
- hhea.ascender = raInput.readShort();
- hhea.descender = raInput.readShort();
- /* Skip the lineGap. */
- raInput.skipBytes(FWORD_BYTES);
- /* Skip the advanceWidthMax*/
- raInput.skipBytes(UFWORD_BYTES);
- /* Skip the minLeftSideBearing*/
- raInput.skipBytes(FWORD_BYTES);
- /* Skip the minRightSideBearing*/
- raInput.skipBytes(FWORD_BYTES);
- /* Skip the xMaxExtent*/
- raInput.skipBytes(FWORD_BYTES);
- /* Skip the caretSlopeRise*/
- raInput.skipBytes(SHORT_BYTES);
- /* Skip the caretSlopeRun*/
- raInput.skipBytes(SHORT_BYTES);
- /* Skip this reserved area. */
- raInput.skipBytes(SHORT_BYTES);
- /* Skip this reserved area. */
- raInput.skipBytes(SHORT_BYTES);
- /* Skip this reserved area. */
- raInput.skipBytes(SHORT_BYTES);
- /* Skip this reserved area. */
- raInput.skipBytes(SHORT_BYTES);
- /* Skip this reserved area. */
- raInput.skipBytes(SHORT_BYTES);
- /* Skip the metricDataFormat. */
- raInput.skipBytes(SHORT_BYTES);
- hhea.numberOfHMetrics = raInput.readUnsignedShort();
- return hhea;
- }
-
- @Override
- public String getTableTag() {
- return "hhea";
- }
-
- /**
- * Returns the ascender.
- * @return The ascender.
- */
- public int getAscender() {
- return this.ascender;
- }
-
- /**
- * Returns the descender.
- * @return The descender.
- */
- public int getDescender() {
- return this.descender;
- }
-
- /**
- * Returns the number of metrics in the HHEA table.
- * Note that this may be smaller than the total number of glyphs in the font
- * (e.g. a fixed-width font like Courier).
- * @return The number of metrics.
- */
- public int getNumberOfHMetrics() {
- return this.numberOfHMetrics;
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableJstf.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableJstf.java 2025-04-21 00:51:16 UTC (rev 13461)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableJstf.java 2025-04-21 01:00:28 UTC (rev 13462)
@@ -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;
-
-/**
- * An OpenType "JSTF" (Justification Data) table.
- * This table is an Advanced Typographic Table.
- */
-public class TtfTableJstf extends TtfTable {
-
- /**
- * Constructor.
- * @param offsetRecord The parent table directory entry.
- */
- public TtfTableJstf(final TtfOffsetTableRecord offsetRecord) {
- super(offsetRecord);
- }
-
- /**
- * Parse the table from the table content.
- * @param offsetRecord The parent offset table record.
- * @param raInput The input which is being parsed.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
- */
- public static TtfTableJstf parse(final TtfOffsetTableRecord offsetRecord, final RandomAccessInput raInput)
- throws IOException {
- raInput.seek(offsetRecord.getOffset());
- final TtfTableJstf table = new TtfTableJstf(offsetRecord);
- return table;
- }
-
- @Override
- public String getTableTag() {
- return "JSTF";
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableKern.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableKern.java 2025-04-21 00:51:16 UTC (rev 13461)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableKern.java 2025-04-21 01:00:28 UTC (rev 13462)
@@ -1,215 +0,0 @@
-/*
- * Copyright 2004 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 org.foray.font.format.Kerning;
-import org.foray.font.ttf.table.CmapTable;
-import org.foray.primitive.BitUtils;
-
-import org.axsl.constants.PrimitiveConstants;
-
-import java.io.IOException;
-
-/**
- * Class representing a TTF "kern" (kerning) table.
- */
-public class TtfTableKern extends TtfTable {
-
- /** 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;
-
- /**
- * Constructor.
- * @param dirEntry The parent table directory entry.
- */
- public TtfTableKern(final TtfOffsetTableRecord dirEntry) {
- super(dirEntry);
- }
-
- /**
- * Parse the needed information from the table contents.
- * @param dirEntry The parent table directory entry.
- * @param raInput The input which is being parsed.
- * @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 TtfTableKern parse(final TtfOffsetTableRecord dirEntry, final RandomAccessInput raInput,
- final CmapTable cmap) throws IOException {
- raInput.seek(dirEntry.getOffset());
- final TtfTableKern kern = new TtfTableKern(dirEntry);
- /* Skip the Table Version. */
- raInput.skipBytes(USHORT_BYTES);
- final int qtySubtables = raInput.readUnsignedShort();
- for (int i = 0; i < qtySubtables; i++) {
- readNextSubtable(kern, raInput, 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 TtfTableKern kern, final RandomAccessInput raInput,
- final CmapTable cmap) throws IOException {
- int headerSize = 0;
- /* Skip Kern subtable version number. */
- raInput.skipBytes(USHORT_BYTES);
- headerSize += USHORT_BYTES;
- /* Read the length of the subtable, in bytes (including this header). */
- final char length = (char) raInput.readUnsignedShort();
- headerSize += USHORT_BYTES;
- /* Read what type of information is contained in this table. */
- final short coverage = (short) raInput.readUnsignedShort();
- headerSize += 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(USHORT_BYTES);
- /* Skip Entry selector. */
- raInput.skipBytes(USHORT_BYTES);
- /* Skip Range shift. */
- raInput.skipBytes(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, TtfTableKern.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, TtfTableKern.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, TtfTableKern.COVERAGE_BIT_CROSS_STREAM);
- }
-
- /**
- * Converts the parsed subtable coverage value to its usable value.
- * @param coverage The parsed coverage value.
- * @return The shifted value.
- */
- private static short subtableFormat(final short coverage) {
- return (short) (coverage >> PrimitiveConstants.SHIFT_1_BYTE);
- }
-
- @Override
- public String getTableTag() {
- return "kern";
- }
-
- /**
- * Returns the parsed kerning information for this table.
- * @return The parsed kerning information for this table.
- */
- public Kerning getKerning() {
- return this.kerning;
- }
-
-}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GposTable.java (from rev 13455, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableGpos.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GposTable.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GposTable.java 2025-04-21 01:00:28 UTC (rev 13462)
@@ -0,0 +1,70 @@
+/*
+ * 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.TtfOffsetTableRecord;
+import org.foray.font.ttf.TtfTable;
+
+import java.io.IOException;
+
+/**
+ * An OpenType "GPOS" (Glyph Positioning Data) table.
+ * This table is an Advanced Typographic Table.
+ */
+public class GposTable extends TtfTable {
+
+ /**
+ * Constructor.
+ * @param offsetRecord The parent table directory entry.
+ */
+ public GposTable(final TtfOffsetTableRecord offsetRecord) {
+ super(offsetRecord);
+ }
+
+ /**
+ * Parse the table from the table content.
+ * @param offsetRecord The parent offset table record.
+ * @param raInput The input which is being parsed.
+ * @return The parsed instance.
+ * @throws IOException For I/O Error.
+ */
+ public static GposTable parse(final TtfOffsetTableRecord offsetRecord, final RandomAccessInput raInput)
+ throws IOException {
+ raInput.seek(offsetRecord.getOffset());
+ final GposTable table = new GposTable(offsetRecord);
+ return table;
+ }
+
+ @Override
+ public String getTableTag() {
+ return "GPOS";
+ }
+
+}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HheaTable.java (from rev 13455, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableHhea.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HheaTable.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HheaTable.java 2025-04-21 01:00:28 UTC (rev 13462)
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2004 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.TtfOffsetTableRecord;
+import org.foray.font.ttf.TtfTable;
+
+import java.io.IOException;
+
+/**
+ * Class representing a TTF "hhea" (horizontal header) table.
+ */
+public class HheaTable extends TtfTable {
+
+ /** Typographic ascent. */
+ private int ascender = 0;
+
+ /** Typographic descent. */
+ private int descender = 0;
+
+ /**
+ * Number of hMetric entries in "hmtx" table; may be smaller than the total
+ * number of glyphs in the font (e.g. a fixed-width font like Courier).
+ */
+ private int numberOfHMetrics;
+
+ /**
+ * Constructor.
+ * @param dirEntry The parent table directory entry.
+ */
+ public HheaTable(final TtfOffsetTableRecord dirEntry) {
+ super(dirEntry);
+ }
+
+ /**
+ * Parse the table.
+ * @param dirEntry The parent table directory entry.
+ * @param raInput The input which is being parsed.
+ * @return The parsed instance.
+ * @throws IOException For I/O Error.
+ */
+ public static HheaTable parse(final TtfOffsetTableRecord dirEntry, final RandomAccessInput raInput)
+ throws IOException {
+ raInput.seek(dirEntry.getOffset());
+ final HheaTable hhea = new HheaTable(dirEntry);
+ /* Skip the table version number. */
+ raInput.skipBytes(FIXED_BYTES);
+ hhea.ascender = raInput.readShort();
+ hhea.descender = raInput.readShort();
+ /* Skip the lineGap. */
+ raInput.skipBytes(FWORD_BYTES);
+ /* Skip the advanceWidthMax*/
+ raInput.skipBytes(UFWORD_BYTES);
+ /* Skip the minLeftSideBearing*/
+ raInput.skipBytes(FWORD_BYTES);
+ /* Skip the minRightSideBearing*/
+ raInput.skipBytes(FWORD_BYTES);
+ /* Skip the xMaxExtent*/
+ raInput.skipBytes(FWORD_BYTES);
+ /* Skip the caretSlopeRise*/
+ raInput.skipBytes(SHORT_BYTES);
+ /* Skip the caretSlopeRun*/
+ raInput.skipBytes(SHORT_BYTES);
+ /* Skip this reserved area. */
+ raInput.skipBytes(SHORT_BYTES);
+ /* Skip this reserved area. */
+ raInput.skipBytes(SHORT_BYTES);
+ /* Skip this reserved area. */
+ raInput.skipBytes(SHORT_BYTES);
+ /* Skip this reserved area. */
+ raInput.skipBytes(SHORT_BYTES);
+ /* Skip this reserved area. */
+ raInput.skipBytes(SHORT_BYTES);
+ /* Skip the metricDataFormat. */
+ raInput.skipBytes(SHORT_BYTES);
+ hhea.numberOfHMetrics = raInput.readUnsignedShort();
+ return hhea;
+ }
+
+ @Override
+ public String getTableTag() {
+ return "hhea";
+ }
+
+ /**
+ * Returns the ascender.
+ * @return The ascender.
+ */
+ public int getAscender() {
+ return this.ascender;
+ }
+
+ /**
+ * Returns the descender.
+ * @return The descender.
+ */
+ public int getDescender() {
+ return this.descender;
+ }
+
+ /**
+ * Returns the number of metrics in the HHEA table.
+ * Note that this may be smaller than the total number of glyphs in the font
+ * (e.g. a fixed-width font like Courier).
+ * @return The number of metrics.
+ */
+ public int getNumberOfHMetrics() {
+ return this.numberOfHMetrics;
+ }
+
+}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/JstfTable.java (from rev 13455, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableJstf.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/JstfTable.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/JstfTable.java 2025-04-21 01:00:28 UTC (rev 13462)
@@ -0,0 +1,70 @@
+/*
+ * 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.TtfOffsetTableRecord;
+import org.foray.font.ttf.TtfTable;
+
+import java.io.IOException;
+
+/**
+ * An OpenType "JSTF" (Justification Data) table.
+ * This table is an Advanced Typographic Table.
+ */
+public class JstfTable extends TtfTable {
+
+ /**
+ * Constructor.
+ * @param offsetRecord The parent table directory entry.
+ */
+ public JstfTable(final TtfOffsetTableRecord offsetRecord) {
+ super(offsetRecord);
+ }
+
+ /**
+ * Parse the table from the table content.
+ * @param offsetRecord The parent offset table record.
+ * @param raInput The input which is being parsed.
+ * @return The parsed instance.
+ * @throws IOException For I/O Error.
+ */
+ public static JstfTable parse(final TtfOffsetTableRecord offsetRecord, final RandomAccessInput raInput)
+ throws IOException {
+ raInput.seek(offsetRecord.getOffset());
+ final JstfTable table = new JstfTable(offsetRecord);
+ return table;
+ }
+
+ @Override
+ public String getTableTag() {
+ return "JSTF";
+ }
+
+}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/KernTable.java (from rev 13461, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableKern.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/KernTable.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/KernTable.java 2025-04-21 01:00:28 UTC (rev 13462)
@@ -0,0 +1,216 @@
+/*
+ * Copyright 2004 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.format.Kerning;
+import org.foray.font.ttf.TtfOffsetTableRecord;
+import org.foray.font.ttf.TtfTable;
+import org.foray.primitive.BitUtils;
+
+import org.axsl.constants.PrimitiveConstants;
+
+import java.io.IOException;
+
+/**
+ * Class representing a TTF "kern" (kerning) table.
+ */
+public class KernTable extends TtfTable {
+
+ /** 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;
+
+ /**
+ * Constructor.
+ * @param dirEntry The parent table directory entry.
+ */
+ public KernTable(final TtfOffsetTableRecord dirEntry) {
+ super(dirEntry);
+ }
+
+ /**
+ * Parse the needed information from the table contents.
+ * @param dirEntry The parent table directory entry.
+ * @param raInput The input which is being parsed.
+ * @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 TtfOffsetTableRecord dirEntry, final RandomAccessInput raInput,
+ final CmapTable cmap) throws IOException {
+ raInput.seek(dirEntry.getOffset());
+ final KernTable kern = new KernTable(dirEntry);
+ /* Skip the Table Version. */
+ raInput.skipBytes(USHORT_BYTES);
+ final int qtySubtables = raInput.readUnsignedShort();
+ for (int i = 0; i < qtySubtables; i++) {
+ readNextSubtable(kern, raInput, 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(USHORT_BYTES);
+ headerSize += USHORT_BYTES;
+ /* Read the length of the subtable, in bytes (including this header). */
+ final char length = (char) raInput.readUnsignedShort();
+ headerSize += USHORT_BYTES;
+ /* Read what type of information is contained in this table. */
+ final short coverage = (short) raInput.readUnsignedShort();
+ headerSize += 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(USHORT_BYTES);
+ /* Skip Entry selector. */
+ raInput.skipBytes(USHORT_BYTES);
+ /* Skip Range shift. */
+ raInput.skipBytes(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);
+ }
+
+ /**
+ * Converts the parsed subtable coverage value to its usable value.
+ * @param coverage The parsed coverage value.
+ * @return The shifted value.
+ */
+ private static short subtableFormat(final short coverage) {
+ return (short) (coverage >> PrimitiveConstants.SHIFT_1_BYTE);
+ }
+
+ @Override
+ public String getTableTag() {
+ return "kern";
+ }
+
+ /**
+ * Returns the parsed kerning information for this table.
+ * @return The parsed kerning information for this table.
+ */
+ public Kerning getKerning() {
+ return this.kerning;
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-21 00:51:34
|
Revision: 13461
http://sourceforge.net/p/foray/code/13461
Author: victormote
Date: 2025-04-21 00:51:16 +0000 (Mon, 21 Apr 2025)
Log Message:
-----------
Move more TTF Table classes to new directory.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeCollection.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfSubSetFile.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableKern.java
Added 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/GlyfTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/NameTable.java
Removed Paths:
-------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableCmap.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableGlyf.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableName.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeCollection.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeCollection.java 2025-04-21 00:47:07 UTC (rev 13460)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeCollection.java 2025-04-21 00:51:16 UTC (rev 13461)
@@ -31,6 +31,7 @@
import org.foray.common.RandomAccessInput;
import org.foray.font.format.FontParser;
+import org.foray.font.ttf.table.NameTable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -105,7 +106,7 @@
// Get the "name" table
final TtfOffsetTableRecord tableDirEntry
= tableDir.getTableDirectoryEntry("name");
- final TtfTableName nameTable = TtfTableName.parse(tableDirEntry, this.raInput);
+ final NameTable nameTable = NameTable.parse(tableDirEntry, this.raInput);
fontNames[i] = nameTable.getFullName();
}
return fontNames;
@@ -122,7 +123,7 @@
final TtfOffsetTableRecord tableDirEntry
= tableDir.getTableDirectoryEntry("name");
this.getReader().getRandomInput().seek(tableDirEntry.getOffset());
- final TtfTableName nameTable = TtfTableName.parse(tableDirEntry, this.raInput);
+ final NameTable nameTable = NameTable.parse(tableDirEntry, this.raInput);
if (nameTable.getFullName().equals(fontName)) {
tableDir.parseFont();
return tableDir.getTTFFont();
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-21 00:47:07 UTC (rev 13460)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-04-21 00:51:16 UTC (rev 13461)
@@ -35,14 +35,17 @@
import org.foray.font.ttf.table.BaseTable;
import org.foray.font.ttf.table.Cff2Table;
import org.foray.font.ttf.table.CffTable;
+import org.foray.font.ttf.table.CmapTable;
import org.foray.font.ttf.table.CvtTable;
import org.foray.font.ttf.table.FpgmTable;
import org.foray.font.ttf.table.GaspTable;
import org.foray.font.ttf.table.GdefTable;
+import org.foray.font.ttf.table.GlyfTable;
import org.foray.font.ttf.table.HeadTable;
import org.foray.font.ttf.table.LocaTable;
import org.foray.font.ttf.table.MathTable;
import org.foray.font.ttf.table.MaxpTable;
+import org.foray.font.ttf.table.NameTable;
import org.foray.font.ttf.table.Os2Table;
import org.foray.font.ttf.table.PcltTable;
import org.foray.font.ttf.table.PostTable;
@@ -74,7 +77,7 @@
private TtfOffsetTable ttfTableDir = null;
/** The (required) "cmap" table instance. */
- private TtfTableCmap cmapTable = null;
+ private CmapTable cmapTable = null;
/** The (required) "head" table instance. */
private HeadTable headTable = null;
@@ -89,7 +92,7 @@
private MaxpTable maxpTable = null;
/** The (required) "name" table instance. */
- private TtfTableName nameTable = null;
+ private NameTable nameTable = null;
/** The (required) "OS/2" table instance. */
private Os2Table os2Table = null;
@@ -104,7 +107,7 @@
private FpgmTable fpgmTable = null;
/** The (TrueType-outlines only) "glyf" table instance. */
- private TtfTableGlyf glyfTable = null;
+ private GlyfTable glyfTable = null;
/** The (TrueType-outlines only) "loca" table instance. */
private LocaTable locaTable = null;
@@ -185,11 +188,11 @@
/* The NAME table needs to be read before the CMAP. */
dirEntry = ttfTableDir.getTableDirectoryEntry("name");
- font.nameTable = TtfTableName.parse(dirEntry, raInput);
+ font.nameTable = NameTable.parse(dirEntry, raInput);
/* Then the CMAP, so that glyph indexes can be computed. */
dirEntry = ttfTableDir.getTableDirectoryEntry("cmap");
- font.cmapTable = TtfTableCmap.parse(dirEntry, raInput, font.nameTable.getPostscriptName());
+ font.cmapTable = CmapTable.parse(dirEntry, raInput, font.nameTable.getPostscriptName());
/* Read the Horizontal Header before the Horizontal Metrics. */
dirEntry = ttfTableDir.getTableDirectoryEntry("hhea");
@@ -228,7 +231,7 @@
dirEntry = ttfTableDir.getTableDirectoryEntry("glyf");
if (dirEntry != null) {
- font.glyfTable = TtfTableGlyf.parse(dirEntry, raInput, numberOfGlyphs, font.hmtxTable);
+ font.glyfTable = GlyfTable.parse(dirEntry, raInput, numberOfGlyphs, font.hmtxTable);
}
dirEntry = ttfTableDir.getTableDirectoryEntry("prep");
@@ -309,7 +312,7 @@
* Returns the "cmap" table.
* @return The "cmap" table.
*/
- public TtfTableCmap getCmapTable() {
+ public CmapTable getCmapTable() {
return this.cmapTable;
}
@@ -357,7 +360,7 @@
* Returns the "name" table.
* @return The "name" table.
*/
- public TtfTableName getNameTable() {
+ public NameTable getNameTable() {
return this.nameTable;
}
@@ -405,7 +408,7 @@
* Returns the "glyf" table.
* @return The "glyf" table.
*/
- public TtfTableGlyf getGlyfTable() {
+ public GlyfTable getGlyfTable() {
return this.glyfTable;
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfSubSetFile.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfSubSetFile.java 2025-04-21 00:47:07 UTC (rev 13460)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfSubSetFile.java 2025-04-21 00:51:16 UTC (rev 13461)
@@ -31,6 +31,7 @@
import org.foray.font.Subset;
import org.foray.font.format.FontParser;
import org.foray.font.ttf.table.CffTable;
+import org.foray.font.ttf.table.GlyfTable;
import org.foray.font.ttf.table.HeadTable;
import org.axsl.constants.PrimitiveConstants;
@@ -116,7 +117,7 @@
* @throws IOException For I/O Error.
*/
public byte[] buildEmbeddableSubset() throws IOException {
- final TtfTableGlyf glyfTable = this.ttfFont.getGlyfTable();
+ final GlyfTable glyfTable = this.ttfFont.getGlyfTable();
if (glyfTable != null) {
return embeddableSubsetTTF();
}
@@ -561,7 +562,7 @@
final TtfTableHmtx hmtxTable = this.ttfFont.getHmtxTable();
final TtfMtxEntry mtxEntry = hmtxTable.getMtxEntry(glyphIdx.intValue());
offset += (int) mtxEntry.getOffset();
- offset += TtfTableGlyf.HEADER_SIZE;
+ offset += GlyfTable.HEADER_SIZE;
Integer compositeIdx = null;
int flags = 0;
boolean moreComposites = true;
@@ -570,8 +571,8 @@
flags = this.in.getRandomInput().readUnsignedShort();
compositeIdx = this.in.getRandomInput().readUnsignedShort();
ret.add(compositeIdx);
- offset += TtfTableGlyf.computeCompositeEntrySize(flags);
- moreComposites = TtfTableGlyf.hasMoreComponents(flags);
+ offset += GlyfTable.computeCompositeEntrySize(flags);
+ moreComposites = GlyfTable.hasMoreComponents(flags);
}
return ret;
}
@@ -598,7 +599,7 @@
return byteArray;
}
/* Skip the glyph header. */
- int offset = TtfTableGlyf.HEADER_SIZE;
+ int offset = GlyfTable.HEADER_SIZE;
boolean moreComposites = true;
while (moreComposites) {
@@ -608,8 +609,8 @@
indexOffset);
final int newIndex = this.subset.encodeSubsetIndex(compositeIdx);
writeUShort(byteArray, indexOffset, newIndex);
- offset += TtfTableGlyf.computeCompositeEntrySize(flags);
- moreComposites = TtfTableGlyf.hasMoreComponents(flags);
+ offset += GlyfTable.computeCompositeEntrySize(flags);
+ moreComposites = GlyfTable.hasMoreComponents(flags);
}
return byteArray;
}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableCmap.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableCmap.java 2025-04-21 00:47:07 UTC (rev 13460)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableCmap.java 2025-04-21 00:51:16 UTC (rev 13461)
@@ -1,316 +0,0 @@
-/*
- * Copyright 2004 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 org.foray.ps.encode.Cmap04Ttf4a;
-import org.foray.ps.encode.Cmap12Ttf4a;
-
-import org.axsl.ps.Cmap;
-import org.axsl.ps.Cmap04Ttf;
-import org.axsl.ps.Cmap12Ttf;
-
-import java.io.IOException;
-
-/**
- * Class representing a TTF "cmap" (character-to-glyph index mapping) table.
- */
-public class TtfTableCmap extends TtfTable {
-
- /** 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;
-
- /** Constant indicating that the encoding is Unicode. */
- protected static final int ENCODING_UNICODE = 1;
-
- /** Constant indicating that the encoding is Unicode UCS-4. */
- protected static final int ENCODING_UCS_4 = 10;
-
- /** The Cmap4a instance that was parsed from this table. */
- private Cmap unicodeCMap;
-
- /**
- * Constructor.
- * @param dirEntry The parent table directory entry.
- */
- public TtfTableCmap(final TtfOffsetTableRecord dirEntry) {
- super(dirEntry);
- }
-
- /**
- * Parse the cmap table.
- * Currently only unicode cmaps are supported.
- * @param dirEntry The parent table directory entry.
- * @param raInput The input which is being parsed.
- * @param fontPostScriptName The PostScript name of this font.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
- */
- public static TtfTableCmap parse(final TtfOffsetTableRecord dirEntry, final RandomAccessInput raInput,
- final String fontPostScriptName) throws IOException {
- raInput.seek(dirEntry.getOffset());
- final TtfTableCmap cmap = new TtfTableCmap(dirEntry);
- /* Skip table version. */
- raInput.skipBytes(USHORT_BYTES);
- final int numSubtables = raInput.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 = raInput.readUnsignedShort();
- final int encodingID = raInput.readUnsignedShort();
- final long subtableOffset = raInput.readUnsignedInt();
- if (platformID == TtfTableCmap.PLATFORM_MICROSOFT
- && encodingID == TtfTableCmap.ENCODING_UNICODE) {
- /* Platform is Microsoft, encoding is Unicode. */
- offsetToCMap04 = subtableOffset;
- }
- if (platformID == TtfTableCmap.PLATFORM_MICROSOFT
- && encodingID == TtfTableCmap.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(dirEntry, raInput, offsetToParse, fontPostScriptName);
- return cmap;
- }
-
- /**
- * Parse one cmap table.
- * @param dirEntry The parent table directory entry.
- * @param raInput The input which is being parsed.
- * @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.
- */
- private static Cmap parseCMap(final TtfOffsetTableRecord dirEntry, final RandomAccessInput raInput,
- final long offsetToParse, final String fontPostScriptName) throws IOException {
- int tableOffset = dirEntry.getOffset();
- tableOffset += offsetToParse;
- raInput.seek(tableOffset);
- final int formatHigh = raInput.readUnsignedShort();
-// int formatLow = 0;
-// long length = 0;
- if (formatHigh > TtfTableCmap.CMAP_FORMAT_6) {
- /*formatLow = */raInput.readUnsignedShort();
- /*length = */raInput.readUnsignedInt();
- } else {
- /*length = */raInput.readUnsignedShort();
- }
- switch (formatHigh) {
- case TtfTableCmap.CMAP_FORMAT_4: {
- return parseCMap04(raInput, fontPostScriptName);
- }
- case TtfTableCmap.CMAP_FORMAT_12: {
- return parseCMap12(raInput, fontPostScriptName);
- }
- }
- 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 Cmap04Ttf parseCMap04(final RandomAccessInput raInput, final String fontPostScriptName)
- throws IOException {
- /* Format and Length have already been read. */
- /* Skip version */
- raInput.skipBytes(USHORT_BYTES);
- final int segCountX2 = raInput.readUnsignedShort();
- /* Skip searchRange. */
- raInput.skipBytes(USHORT_BYTES);
- /* Skip entrySelector. */
- raInput.skipBytes(USHORT_BYTES);
- /* Skip rangeShift. */
- raInput.skipBytes(USHORT_BYTES);
-
- final int[] endCount = new int[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] = (char) raInput.readUnsignedShort();
- }
-
- /* Skip reservedPad. */
- raInput.skipBytes(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 String encodingName = "internal-" + fontPostScriptName;
- final Cmap04Ttf cmap04 = new Cmap04Ttf4a(encodingName, segCountX2 / 2);
- for (int i = 0; i < startCount.length; i++) {
- if (rangeOffset[i] == 0) {
- cmap04.addEntry(startCount[i],
- endCount[i],
- (char) (startCount[i] + deltas[i]));
- } else {
- final char[] computedIndexes = new char[endCount[i]
- - startCount[i] + 1];
- for (int j = startCount[i]; j <= endCount[i]; j++) {
- final int glyphOffset
- = glyphIdArrayOffset
- + ((rangeOffset[i] / 2)
- + (j - startCount[i])
- + i - segCountX2 / 2)
- * 2;
- raInput.seek(glyphOffset);
- final char glyphIndex =
- (char) ((raInput.readUnsignedShort()
- + deltas[i]) & Character.MAX_VALUE);
- computedIndexes[j - startCount[i]] = glyphIndex;
- }
- cmap04.addEntry(startCount[i], endCount[i], new String(computedIndexes));
- }
- }
- return cmap04;
- }
-
- /**
- * 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 Cmap12Ttf parseCMap12(final RandomAccessInput raInput, final String fontPostScriptName)
- throws IOException {
- /* Format and Length have already been read. */
- /* Skip language. */
- raInput.skipBytes(ULONG_BYTES);
- final int nGroups = (int) raInput.readUnsignedInt();
-
- final String encodingName = "internal-" + fontPostScriptName;
- final Cmap12Ttf cmap12 = new Cmap12Ttf4a(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;
- }
-
- @Override
- public String getTableTag() {
- return "cmap";
- }
-
- /**
- * Returns the Unicode Cmap4a instance parsed from this table.
- * @return The Unicode Cmap4a instance parsed from this table.
- */
- public Cmap getUnicodeCMap() {
- return this.unicodeCMap;
- }
-
- /**
- * 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}.
- */
- public int encodeCharacter(final int codePoint) {
- if (this.unicodeCMap == null) {
- return -1;
- }
- return this.unicodeCMap.encode(codePoint);
- }
-
- /**
- * 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}.
- */
- public int decodeCharacter(final int glyphIndex) {
- if (this.unicodeCMap == null) {
- return -1;
- }
- return this.unicodeCMap.decode(glyphIndex);
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableGlyf.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableGlyf.java 2025-04-21 00:47:07 UTC (rev 13460)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableGlyf.java 2025-04-21 00:51:16 UTC (rev 13461)
@@ -1,183 +0,0 @@
-/*
- * Copyright 2004 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 org.foray.common.data.BoundingBoxShort;
-import org.foray.primitive.BitUtils;
-
-import org.axsl.ps.BoundingBox;
-
-import java.io.IOException;
-
-/**
- * A TrueType/OpenType "glyf" (Glyph Data) table.
- * This table is used only in fonts that contain TrueType outlines.
- */
-public class TtfTableGlyf extends TtfTable {
-
- /** The size, in bytes, of the header portion of this table. */
- public static final byte HEADER_SIZE = SHORT_BYTES + FWORD_BYTES
- + FWORD_BYTES + FWORD_BYTES + FWORD_BYTES;
-
- /** The bit in the composite flag indicating ARG_1_AND_2_ARE_WORDS. */
- public static final byte CF_BIT_ARG_1_AND_2_ARE_WORDS = 0;
-
- /** The bit in the composite flag indicating ARGS_ARE_XY_VALUES. */
- public static final byte CF_BIT_ARGS_ARE_XY_VALUES = 1;
-
- /** The bit in the composite flag indicating ROUND_XY_TO_GRID. */
- public static final byte CF_BIT_ROUND_XY_TO_GRID = 2;
-
- /** The bit in the composite flag indicating WE_HAVE_A_SCALE. */
- public static final byte CF_BIT_WE_HAVE_A_SCALE = 3;
-
- /** The bit in the composite flag indicating MORE_COMPONENTS. */
- public static final byte CF_BIT_MORE_COMPONENTS = 5;
-
- /** The bit in the composite flag indicating WE_HAVE_AN_X_AND_Y_SCALE. */
- public static final byte CF_BIT_WE_HAVE_AN_X_AND_Y_SCALE = 6;
-
- /** The bit in the composite flag indicating WE_HAVE_A_TWO_BY_TWO. */
- public static final byte CF_BIT_WE_HAVE_A_TWO_BY_TWO = 7;
-
- /** The bit in the composite flag indicating WE_HAVE_INSTRUCTIONS. */
- public static final byte CF_BIT_WE_HAVE_INSTRUCTIONS = 8;
-
- /** The bit in the composite flag indicating USE_MY_METRICS. */
- public static final byte CF_BIT_USE_MY_METRICS = 9;
-
- /**
- * Constructor.
- * @param dirEntry The parent table directory entry.
- */
- public TtfTableGlyf(final TtfOffsetTableRecord dirEntry) {
- super(dirEntry);
- }
-
- /**
- * Reads the "glyf" table to find the bounding boxes.
- * @param dirEntry The parent table directory entry.
- * @param raInput The input which is being parsed.
- * @param numberOfGlyphs The number of glyphs to be parsed.
- * This data is derived from the "maxp" table.
- * @param hmtx The related horizontal metrics (hmtx) table.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
- */
- public static TtfTableGlyf parse(final TtfOffsetTableRecord dirEntry, final RandomAccessInput raInput,
- final int numberOfGlyphs, final TtfTableHmtx hmtx) throws IOException {
- raInput.seek(dirEntry.getOffset());
- final TtfTableGlyf glyf = new TtfTableGlyf(dirEntry);
- final TtfMtxEntry firstMetric = hmtx.getMtxEntry(0);
- for (int i = 0; i < (numberOfGlyphs - 1); i++) {
- final TtfMtxEntry thisMetric = hmtx.getMtxEntry(i);
- final TtfMtxEntry nextMetric = hmtx.getMtxEntry(i + 1);
- if (thisMetric.getOffset() != nextMetric.getOffset()) {
- raInput.seek(dirEntry.getOffset() + thisMetric.getOffset());
- raInput.skipBytes(2);
- final short[] bboxEntries = new short[BoundingBox.QTY_ENTRIES];
- for (int j = 0; j < BoundingBox.QTY_ENTRIES; j++) {
- bboxEntries[j] = raInput.readShort();
- }
- thisMetric.setBoundingBox(new BoundingBoxShort(bboxEntries));
- } else {
- thisMetric.setBoundingBox(firstMetric.getBoundingBox());
- }
- }
-
- final int n = dirEntry.getOffset();
- for (int i = 0; i < numberOfGlyphs; i++) {
- final TtfMtxEntry thisMetric = hmtx.getMtxEntry(i);
- final TtfMtxEntry nextMetric = hmtx.getMtxEntry(i + 1);
- if ((i + 1) >= hmtx.numMtxEntries()
- || thisMetric.getOffset() != nextMetric.getOffset()) {
- raInput.seek(n + thisMetric.getOffset());
- raInput.skipBytes(2);
- final short[] bboxEntries = new short[BoundingBox.QTY_ENTRIES];
- for (int j = 0; j < BoundingBox.QTY_ENTRIES; j++) {
- bboxEntries[j] = raInput.readShort();
- }
- thisMetric.setBoundingBox(new BoundingBoxShort(bboxEntries));
- } else {
- thisMetric.setBoundingBox(firstMetric.getBoundingBox());
- }
- }
- return glyf;
- }
-
- @Override
- public String getTableTag() {
- return "glyf";
- }
-
- /**
- * Computes the size, in bytes, of a composite entry, based on the flags for that entry.
- * @param compositeFlags The flags for the entry.
- * @return The size, in bytes, of the composite entry.
- */
- public static int computeCompositeEntrySize(final int compositeFlags) {
- int size = 0;
- /* The size of the flag itself. */
- size += TtfTable.USHORT_BYTES;
- /* The size of the glyph index. */
- size += TtfTable.USHORT_BYTES;
-
- /* The remainder of this logic is from the standard itself. */
- if (BitUtils.getBit(compositeFlags, TtfTableGlyf.CF_BIT_ARG_1_AND_2_ARE_WORDS)) {
- size += TtfTable.SHORT_BYTES;
- size += TtfTable.SHORT_BYTES;
- } else {
- size += TtfTable.USHORT_BYTES;
- }
-
- if (BitUtils.getBit(compositeFlags, TtfTableGlyf.CF_BIT_WE_HAVE_A_SCALE)) {
- size += TtfTable.F2DOT14_BYTES;
- } else if (BitUtils.getBit(compositeFlags, TtfTableGlyf.CF_BIT_WE_HAVE_AN_X_AND_Y_SCALE)) {
- size += TtfTable.F2DOT14_BYTES;
- size += TtfTable.F2DOT14_BYTES;
- } else if (BitUtils.getBit(compositeFlags, TtfTableGlyf.CF_BIT_WE_HAVE_A_TWO_BY_TWO)) {
- size += TtfTable.F2DOT14_BYTES;
- size += TtfTable.F2DOT14_BYTES;
- size += TtfTable.F2DOT14_BYTES;
- size += TtfTable.F2DOT14_BYTES;
- }
- return size;
- }
-
- /**
- * Indicates, from the flags, whether there are additional composite entries.
- * @param compositeFlags The flags value.
- * @return True if and only if there are more composite entries.
- */
- public static boolean hasMoreComponents(final int compositeFlags) {
- return BitUtils.getBit(compositeFlags, TtfTableGlyf.CF_BIT_MORE_COMPONENTS);
- }
-
-}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableKern.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableKern.java 2025-04-21 00:47:07 UTC (rev 13460)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableKern.java 2025-04-21 00:51:16 UTC (rev 13461)
@@ -30,6 +30,7 @@
import org.foray.common.RandomAccessInput;
import org.foray.font.format.Kerning;
+import org.foray.font.ttf.table.CmapTable;
import org.foray.primitive.BitUtils;
import org.axsl.constants.PrimitiveConstants;
@@ -73,7 +74,7 @@
* @throws IOException For I/O Error.
*/
public static TtfTableKern parse(final TtfOffsetTableRecord dirEntry, final RandomAccessInput raInput,
- final TtfTableCmap cmap) throws IOException {
+ final CmapTable cmap) throws IOException {
raInput.seek(dirEntry.getOffset());
final TtfTableKern kern = new TtfTableKern(dirEntry);
/* Skip the Table Version. */
@@ -96,7 +97,7 @@
* @throws IOException For I/O Error.
*/
private static void readNextSubtable(final TtfTableKern kern, final RandomAccessInput raInput,
- final TtfTableCmap cmap) throws IOException {
+ final CmapTable cmap) throws IOException {
int headerSize = 0;
/* Skip Kern subtable version number. */
raInput.skipBytes(USHORT_BYTES);
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableName.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableName.java 2025-04-21 00:47:07 UTC (rev 13460)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableName.java 2025-04-21 00:51:16 UTC (rev 13461)
@@ -1,555 +0,0 @@
-/*
- * Copyright 2004 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 org.foray.primitive.StringUtils;
-
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-
-/**
- * Class representing a TTF "name" (naming) table.
- */
-public class TtfTableName extends TtfTable {
-
- /** Constant documented in the TTF "name" table doc as indicating the
- * Macintosh platform. */
- public static final byte PLATFORM_MACINTOSH = 1;
-
- /** Constant documented in the TTF "name" table doc as indicating the
- * Microsoft platform. */
- public static final byte PLATFORM_MICROSOFT = 3;
-
- /** Constant documented in the TTF "name" table doc as indicating an
- * "undefined" character set or indexing scheme for the Microsoft
- * platform. */
- public static final byte ENCODING_MICROSOFT_UNDEFINED = 0;
-
- /** Constant documented in the TTF "name" table doc as indicating a
- * "Roman" script for the Macintosh platform. */
- public static final byte ENCODING_MICROSOFT_UGL = 1;
-
- /** Constant documented in the TTF "name" table doc as indicating a
- * "UGL character set with Unicode indexing scheme" for the Microsoft
- * platform. */
- public static final byte ENCODING_MACINTOSH_ROMAN = 0;
-
- /** Constant documented in the TTF "name" table doc as indicating the
- * "American English" language and locale. */
- public static final short LANGUAGE_MICROSOFT_ENGLISH_AMERICAN = 0x0409;
-
- /** Constant documented in the TTF "name" table doc as indicating the
- * "English" language for the Macintosh platform. */
- public static final byte LANGUAGE_MACINTOSH_ENGLISH = 0;
-
- /** Constant documented in the TTF "name" table doc as indicating the name
- * id for "Copyright notice". */
- public static final byte NAME_COPYRIGHT = 0;
-
- /** Constant documented in the TTF "name" table doc as indicating the name
- * id for "Font Family name". */
- public static final byte NAME_FONT_FAMILY = 1;
-
- /** Constant documented in the TTF "name" table doc as indicating the name
- * id for "Font Subfamily name". */
- public static final byte NAME_FONT_SUBFAMILY = 2;
-
- /** Constant documented in the TTF "name" table doc as indicating the name
- * id for "Unique font identifier". */
- public static final byte NAME_UNIQUE_ID = 3;
-
- /** Constant documented in the TTF "name" table doc as indicating the name
- * id for "Full font name". */
- public static final byte NAME_FULL_FONT_NAME = 4;
-
- /** Constant documented in the TTF "name" table doc as indicating the name
- * id for "Version string". */
- public static final byte NAME_VERSION = 5;
-
- /** Constant documented in the TTF "name" table doc as indicating the name
- * id for "Postscript name". */
- public static final byte NAME_POSTSCRIPT_NAME = 6;
-
- /** Constant documented in the TTF "name" table doc as indicating the name
- * id for "Trademark". */
- public static final byte NAME_TRADEMARK = 7;
-
- /** Array containing the specific names that are sought by this parsing
- * process. */
- public static final byte[] NAMES_TO_TEST = new byte[] {
- TtfTableName.NAME_COPYRIGHT,
- TtfTableName.NAME_FONT_FAMILY,
- TtfTableName.NAME_FONT_SUBFAMILY,
- TtfTableName.NAME_FULL_FONT_NAME,
- TtfTableName.NAME_POSTSCRIPT_NAME
- };
-
- /** The length, in bytes, of each name record. */
- private static final int NAME_RECORD_BYTES = 12;
-
- /** The parsed offset to the table strings, in bytes, relative to the
- * beginning of the table. */
- private int offsetToStrings;
-
- /** The number of name records in the table, as parsed. */
- private int numNameRecords;
-
- /** The "copyright notice" field parsed from this font. */
- private String copyrightNotice = StringUtils.EMPTY_STRING;
-
- /** The "Font Family name" parsed from this font. */
- private String familyName = StringUtils.EMPTY_STRING;
-
- /** The "Font Subfamily name" parsed from this font. */
- private String subFamilyName = StringUtils.EMPTY_STRING;
-
- /** The "Full font name" parsed from this font. */
- private String fullName = StringUtils.EMPTY_STRING;
-
- /** The "Postscript name" parsed from this font. */
- private String postscriptName = StringUtils.EMPTY_STRING;
-
- /**
- * Array containing the first of four items that comprise the "key" to
- * the name table.
- * The four arrays are parallel, that a given index into one array is the
- * same index that should be used to obtain the values from the other
- * arrays.
- * @see #encodingArray
- * @see #languageArray
- * @see #nameArray
- */
- private int[] platformArray;
-
- /**
- * Array containing the second of four items that compreise the "key" to
- * the name table.
- * @see #platformArray
- * @see #languageArray
- * @see #nameArray
- */
- private int[] encodingArray;
-
- /**
- * Array containing the third of four items that compreise the "key" to
- * the name table.
- * @see #platformArray
- * @see #encodingArray
- * @see #nameArray
- */
- private int[] languageArray;
-
- /**
- * Array containing the fourth of four items that compreise the "key" to
- * the name table.
- * @see #platformArray
- * @see #encodingArray
- * @see #languageArray
- */
- private int[] nameArray;
-
- /**
- * Constructor.
- * @param dirEntry The table directory entry for this table.
- */
- public TtfTableName(final TtfOffsetTableRecord dirEntry) {
- super(dirEntry);
- }
-
- /**
- * Reads the "name" table.
- * @param dirEntry The table directory entry for this table.
- * @param raInput The input which is being parsed.
- * @return The parsed instance.
- * @throws IOException For I/O error.
- */
- public static TtfTableName parse(final TtfOffsetTableRecord dirEntry, final RandomAccessInput raInput)
- throws IOException {
- raInput.seek(dirEntry.getOffset());
- final TtfTableName name = new TtfTableName(dirEntry);
- /* Skip the format selector. */
- raInput.skipBytes(2);
- name.numNameRecords = raInput.readUnsignedShort();
- name.offsetToStrings = raInput.readUnsignedShort();
-
- /* Create empty arrays for the keys. */
- name.platformArray = new int[name.numNameRecords];
- name.encodingArray = new int[name.numNameRecords];
- name.languageArray = new int[name.numNameRecords];
- name.nameArray = new int[name.numNameRecords];
- /* Populate the key arrays. */
- for (int i = 1; i <= name.numNameRecords; i++) {
- seekNameRecord(name, raInput, i);
- parseNameRecordKey(name, raInput, i);
- }
- /*
- * The TrueType Font Format Specification, in the chapter entitled
- * "Recommendations for Windows Fonts", in the section entitled "'name'
- * table" says that every font should contain entries for U.S. English.
- * We'll try the Microsoft keys first, since we think we know what
- * encoding they use.
- */
- findForKeySet(name, raInput, TtfTableName.PLATFORM_MICROSOFT,
- TtfTableName.ENCODING_MICROSOFT_UGL,
- TtfTableName.LANGUAGE_MICROSOFT_ENGLISH_AMERICAN);
- findForKeySet(name, raInput, TtfTableName.PLATFORM_MICROSOFT,
- TtfTableName.ENCODING_MICROSOFT_UNDEFINED,
- TtfTableName.LANGUAGE_MICROSOFT_ENGLISH_AMERICAN);
- /* Now try Macintosh. */
- findForKeySet(name, raInput, TtfTableName.PLATFORM_MACINTOSH,
- TtfTableName.ENCODING_MACINTOSH_ROMAN,
- TtfTableName.LANGUAGE_MACINTOSH_ENGLISH);
- /* If we haven't found it yet, take anything you can get. */
- findAny(name, raInput);
- return name;
- }
-
- /**
- * Try to find name records for a set of key parameters, filling in the
- * instance variables if they are found. Enter a -1 for any parameters for
- * which any value should be accepted.
- * @param name The table being parsed.
- * @param raInput The input which is being parsed.
- * @param platformID The platform ID portion of the key.
- * @param encodingID The encoding ID portion of the key.
- * @param languageID The language ID portion of the key.
- * @throws IOException For I/O error.
- */
- private static void findForKeySet(final TtfTableName name, final RandomAccessInput raInput, final int platformID,
- final int encodingID, final int languageID) throws IOException {
- for (int i = 0; i < TtfTableName.NAMES_TO_TEST.length; i++) {
- if (nameRecorded(name, TtfTableName.NAMES_TO_TEST[i])) {
- continue;
- }
- final int nameRecordNumber = name.findNameRecord(platformID, encodingID,
- languageID, TtfTableName.NAMES_TO_TEST[i]);
- parseNameRecord(name, raInput, nameRecordNumber);
- }
- }
-
- /**
- * Tries all name records, filling in any missing values in the instance
- * variables.
- * @param name The table being parsed.
- * @param raInput The input which is being parsed.
- * @throws IOException For I/O error.
- */
- private static void findAny(final TtfTableName name, final RandomAccessInput raInput) throws IOException {
- for (int i = 1; i <= name.numNameRecords && ! name.allStringsFound(); i++) {
- parseNameRecord(name, raInput, i);
- }
- }
-
- /**
- * Parses one name record.
- * @param name The table being parsed.
- * @param raInput The input which is being parsed.
- * @param nameRecordNum The name record number.
- * @throws IOException For I/O error.
- */
- private static void parseNameRecord(final TtfTableName name, final RandomAccessInput raInput,
- final int nameRecordNum) throws IOException {
- if (nameRecordNum < 1 || nameRecordNum > name.platformArray.length) {
- return;
- }
- final int arrayIndex = nameRecordNum - 1;
- final String txt = readString(name, raInput, nameRecordNum);
- if (name.platformArray[arrayIndex] != TtfTableName.PLATFORM_MACINTOSH
- && name.platformArray[arrayIndex]
- != TtfTableName.PLATFORM_MICROSOFT) {
- return;
- }
- if (name.encodingArray[arrayIndex] != 0
- && name.encodingArray[arrayIndex] != 1) {
- return;
- }
- updateOfficialString(name, name.nameArray[arrayIndex], txt);
- }
-
- /**
- * Updates a specific official string.
- * @param name The table being parsed.
- * @param nameID The ID of the name to update.
- * @param updateString The String to which the name should be updated.
- */
- private static void updateOfficialString(final TtfTableName name, final int nameID, final String updateString) {
- if (nameRecorded(name, nameID)) {
- return;
- }
- switch (nameID) {
- case TtfTableName.NAME_COPYRIGHT:
- name.copyrightNotice = updateString;
- break;
- case TtfTableName.NAME_FONT_FAMILY:
- name.familyName = updateString;
- break;
- case TtfTableName.NAME_FONT_SUBFAMILY:
- name.subFamilyName = updateString;
- break;
- case TtfTableName.NAME_FULL_FONT_NAME:
- name.fullName = updateString;
- break;
- case TtfTableName.NAME_POSTSCRIPT_NAME:
- name.postscriptName = updateString;
- break;
- }
- }
-
- /**
- * Indicates whether an official name has already been recorded.
- * @param name The table being parsed.
- * @param nameID The ID for the official name.
- * @return True if and only if the name has already been recorded.
- */
- private static boolean nameRecorded(final TtfTableName name, final int nameID) {
- switch (nameID) {
- case TtfTableName.NAME_COPYRIGHT:
- if (name.copyrightNotice.equals(StringUtils.EMPTY_STRING)) {
- return false;
- }
- break;
- case TtfTableName.NAME_FONT_FAMILY:
- if (name.familyName.equals(StringUtils.EMPTY_STRING)) {
- return false;
- }
- break;
- case TtfTableName.NAME_FONT_SUBFAMILY:
- if (name.subFamilyName.equals(StringUtils.EMPTY_STRING)) {
- return false;
- }
- break;
- case TtfTableName.NAME_FULL_FONT_NAME:
- if (name.fullName.equals(StringUtils.EMPTY_STRING)) {
- return false;
- }
- break;
- case TtfTableName.NAME_POSTSCRIPT_NAME:
- if (name.postscriptName.equals(StringUtils.EMPTY_STRING)) {
- return false;
- }
- break;
- }
- return true;
- }
-
- /**
- * Parses one name record key.
- * @param name The table being parsed.
- * @param raInput The input which is being parsed.
- * @param nameRecordNum The record number to be parsed.
- * @throws IOException For I/O Error.
- */
- private static void parseNameRecordKey(final TtfTableName name, final RandomAccessInput raInput,
- final int nameRecordNum)
- throws IOException {
- final int arrayIndex = nameRecordNum - 1;
- name.platformArray[arrayIndex] = (byte) raInput.readUnsignedShort();
- name.encodingArray[arrayIndex] = (byte) raInput.readUnsignedShort();
- name.languageArray[arrayIndex] = raInput.readUnsignedShort();
- name.nameArray[arrayIndex] = (byte) raInput.readUnsignedShort();
- }
-
- /**
- * Seeks to the beginning of a specific name record.
- * @param name The table being parsed.
- * @param raInput The input which is being parsed.
- * @param nameRecordNum The record number to be sought.
- * @throws IOException For I/O Error.
- */
- private static void seekNameRecord(final TtfTableName name, final RandomAccessInput raInput,
- final int nameRecordNum) throws IOException {
- /* Start at the beginning of the table. */
- long offsetOfThisNameRecord = name.getTableDirEntry().getOffset();
- /* Skip the bytes before name records. */
- /* Skip the Format selector. */
- offsetOfThisNameRecord += USHORT_BYTES;
- /* Skip the Number of NameRecords that follow. */
- offsetOfThisNameRecord += USHORT_BYTES;
- /* Skip the Offset to start of string storage. */
- offsetOfThisNameRecord += USHORT_BYTES;
- /* Skip 12 bytes for each name record that precedes the one sought. */
- offsetOfThisNameRecord += (nameRecordNum - 1)
- * TtfTableName.NAME_RECORD_BYTES;
- raInput.seek(offsetOfThisNameRecord);
- }
-
- /**
- * Reads a specific name record.
- * @param name The table being parsed.
- * @param raInput The input which is being parsed.
- * @param nameRecordNum The record number to be read.
- * @return The parsed name.
- * @throws IOException For I/O Error.
- */
- private static String readString(final TtfTableName name, final RandomAccessInput raInput, final int nameRecordNum)
- throws IOException {
- final int arrayIndex = nameRecordNum - 1;
- seekNameRecord(name, raInput, nameRecordNum);
- /* Skip the Platform ID. */
- raInput.skipBytes(USHORT_BYTES);
- /* Skip the Platform-specific encoding ID. */
- raInput.skipBytes(USHORT_BYTES);
- /* Skip the Language ID. */
- raInput.skipBytes(USHORT_BYTES);
- /* Skip the Name ID. */
- raInput.skipBytes(USHORT_BYTES);
- /* Read the String length (in bytes). */
- final int stringLength = raInput.readUnsignedShort();
- /* Read the String offset from start of storage area (in bytes). */
- final int stringOffset = raInput.readUnsignedShort();
- final Charset charset = getStringEncoding(
- name.platformArray[arrayIndex], name.encodingArray[arrayIndex],
- name.languageArray[arrayIndex]);
- final long stringOffsetInFile
- = name.getTableDirEntry().getOffset()// start of table
- + name.offsetToStrings // start of string area
- + stringOffset; // start of this string
- raInput.seek(stringOffsetInFile);
- final String txt = raInput.readString(stringLength, charset);
- return txt;
- }
-
- /**
- * Returns the encoding to be used for reading a specific name.
- * @param platformID The platform ID portion of the key.
- * @param encodingID The encoding ID portion of the key.
- * @param languageID The language ID portion of the key.
- * @return The name of the encoding to be used when reading the key.
- */
- private static Charset getStringEncoding(final int platformID, final int encodingID,
- final int languageID) {
- /* The Microsoft platform. Return value obtained by trial-and-error.
- * Per the TrueType Font File Specification, in the "name" table
- * section, name strings for the Microsoft platform require two bytes
- * per character. */
- if (platformID == TtfTableName.PLATFORM_MICROSOFT) {
- return StandardCharsets.UTF_16BE;
- }
-
- /* Per the TrueType Font File Specification, in the "name" table
- * section, Macintosh fonts require single-byte strings. Also, this is
- * the best known default. */
- return StandardCharsets.ISO_8859_1;
- }
-
- /**
- * Find the name record that matches the given parameters. Enter a negative
- * number in any of the parameters to indicate that any value matches for
- * that paramater.
- * @param platformID The platform ID portion of the key.
- * @param encodingID The encoding ID portion of the key.
- * @param languageID The language ID portion of the key.
- * @param nameID The name ID whose record is sought.
- * @return The name record number for the matching record, or a -1 if no
- * record is found. Caveat: this number is one greater than the array index.
- */
- private int findNameRecord(final int platformID, final int encodingID,
- final int languageID, final int nameID) {
- for (int i = 0; i < this.platformArray.length; i++) {
- if (platformID > -1 && this.platformArray[i] != platformID) {
- continue;
- }
- if (encodingID > -1 && this.encodingArray[i] != encodingID) {
- continue;
- }
- if (languageID > -1 && this.languageArray[i] != languageID) {
- continue;
- }
- if (nameID > -1 && this.nameArray[i] != nameID) {
- continue;
- }
- return i + 1;
- }
- return -1;
- }
-
- /**
- * Indicates whether all of the strings that we want have been parsed from
- * this table.
- * @return True if and only if all strings that we want have been parsed.
- */
- private boolean allStringsFound() {
- if (this.copyrightNotice.equals(StringUtils.EMPTY_STRING)
- || this.fullName.equals(StringUtils.EMPTY_STRING)
- || this.postscriptName.equals(StringUtils.EMPTY_STRING)
- || this.familyName.equals(StringUtils.EMPTY_STRING)
- || this.subFamilyName.equals(StringUtils.EMPTY_STRING)) {
- return false;
- }
- return true;
- }
-
- @Override
- public String getTableTag() {
- return "name";
- }
-
- /**
- * Returns the postscript name of this font.
- * @return The postscript name.
- */
- public String getPostscriptName() {
- return this.postscriptName;
- }
-
- /**
- * Returns the copyright notice for this font.
- * @return The copyright notice.
- */
- public String getCopyrightNotice() {
- return this.copyrightNotice;
- }
-
- /**
- * Returns the family name for this font.
- * @return The family name.
- */
- public String getFamilyName() {
- return this.familyName;
- }
-
- /**
- * Returns the full name for this font.
- * @return The full name.
- */
- public String getFullName() {
- return this.fullName;
- }
-
- /**
- * Returns the sub-family name.
- * @return The sub-family name.
- */
- public String getSubFamilyName() {
- return this.subFamilyName;
- }
-
-}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java (from rev 13455, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableCmap.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java 2025-04-21 00:51:16 UTC (rev 13461)
@@ -0,0 +1,318 @@
+/*
+ * Copyright 2004 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.TtfOffsetTableRecord;
+import org.foray.font.ttf.TtfTable;
+import org.foray.ps.encode.Cmap04Ttf4a;
+import org.foray.ps.encode.Cmap12Ttf4a;
+
+import org.axsl.ps.Cmap;
+import org.axsl.ps.Cmap04Ttf;
+import org.axsl.ps.Cmap12Ttf;
+
+import java.io.IOException;
+
+/**
+ * Class representing a TTF "cmap" (character-to-glyph index mapping) table.
+ */
+public class CmapTable extends TtfTable {
+
+ /** 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;
+
+ /** Constant indicating that the encoding is Unicode. */
+ protected static final int ENCODING_UNICODE = 1;
+
+ /** Constant indicating that the encoding is Unicode UCS-4. */
+ protected static final int ENCODING_UCS_4 = 10;
+
+ /** The Cmap4a instance that was parsed from this table. */
+ private Cmap unicodeCMap;
+
+ /**
+ * Constructor.
+ * @param dirEntry The parent table directory entry.
+ */
+ public CmapTable(final TtfOffsetTableRecord dirEntry) {
+ super(dirEntry);
+ }
+
+ /**
+ * Parse the cmap table.
+ * Currently only unicode cmaps are supported.
+ * @param dirEntry The parent table directory entry.
+ * @param raInput The input which is being parsed.
+ * @param fontPostScriptName The PostScript name of this font.
+ * @return The parsed instance.
+ * @throws IOException For I/O Error.
+ */
+ public static CmapTable parse(final TtfOffsetTableRecord dirEntry, final RandomAccessInput raInput,
+ final String fontPostScriptName) throws IOException {
+ raInput.seek(dirEntry.getOffset());
+ final CmapTable cmap = new CmapTable(dirEntry);
+ /* Skip table version. */
+ raInput.skipBytes(USHORT_BYTES);
+ final int numSubtables = raInput.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 = raInput.readUnsignedShort();
+ final int encodingID = raInput.readUnsignedShort();
+ final long subtableOffset = raInput.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(dirEntry, raInput, offsetToParse, fontPostScriptName);
+ return cmap;
+ }
+
+ /**
+ * Parse one cmap table.
+ * @param dirEntry The parent table directory entry.
+ * @param raInput The input which is being parsed.
+ * @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.
+ */
+ private static Cmap parseCMap(final TtfOffsetTableRecord dirEntry, final RandomAccessInput raInput,
+ final long offsetToParse, final String fontPostScriptName) throws IOException {
+ int tableOffset = dirEntry.getOffset();
+ tableOffset += offsetToParse;
+ raInput.seek(tableOffset);
+ final int formatHigh = raInput.readUnsignedShort();
+// int formatLow = 0;
+// long length = 0;
+ if (formatHigh > CmapTable.CMAP_FORMAT_6) {
+ /*formatLow = */raInput.readUnsignedShort();
+ /*length = */raInput.readUnsignedInt();
+ } else {
+ /*length = */raInput.readUnsignedShort();
+ }
+ switch (formatHigh) {
+ case CmapTable.CMAP_FORMAT_4: {
+ return parseCMap04(raInput, fontPostScriptName);
+ }
+ case CmapT...
[truncated message content] |
|
From: <vic...@us...> - 2025-04-21 00:47:25
|
Revision: 13460
http://sourceforge.net/p/foray/code/13460
Author: victormote
Date: 2025-04-21 00:47:07 +0000 (Mon, 21 Apr 2025)
Log Message:
-----------
Move more TTF Table classes to new directory.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java
Added Paths:
-----------
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
Removed Paths:
-------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableFpgm.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableGasp.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableGdef.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-21 00:44:21 UTC (rev 13459)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-04-21 00:47:07 UTC (rev 13460)
@@ -36,6 +36,9 @@
import org.foray.font.ttf.table.Cff2Table;
import org.foray.font.ttf.table.CffTable;
import org.foray.font.ttf.table.CvtTable;
+import org.foray.font.ttf.table.FpgmTable;
+import org.foray.font.ttf.table.GaspTable;
+import org.foray.font.ttf.table.GdefTable;
import org.foray.font.ttf.table.HeadTable;
import org.foray.font.ttf.table.LocaTable;
import org.foray.font.ttf.table.MathTable;
@@ -98,7 +101,7 @@
private CvtTable cvtTable = null;
/** The (TrueType-outlines only) "fpgm" table instance. */
- private TtfTableFpgm fpgmTable = null;
+ private FpgmTable fpgmTable = null;
/** The (TrueType-outlines only) "glyf" table instance. */
private TtfTableGlyf glyfTable = null;
@@ -110,7 +113,7 @@
private PrepTable prepTable = null;
/** The (TrueType-outlines only) "gasp" table instance. */
- private TtfTableGasp gaspTable = null;
+ private GaspTable gaspTable = null;
/** The (PS-Outlines-only) "CFF" table instance. */
private CffTable cffTable = null;
@@ -125,7 +128,7 @@
private BaseTable baseTable = null;
/** The (OTF, Advanced Typographic Table) "GDEF" table instance. */
- private TtfTableGdef gdefTable = null;
+ private GdefTable gdefTable = null;
/** The (OTF, Advanced Typographic Table) "GPOS" table instance. */
private TtfTableGpos gposTable = null;
@@ -214,7 +217,7 @@
dirEntry = ttfTableDir.getTableDirectoryEntry("fpgm");
if (dirEntry != null) {
- font.fpgmTable = TtfTableFpgm.parse(dirEntry, raInput);
+ font.fpgmTable = FpgmTable.parse(dirEntry, raInput);
}
dirEntry = ttfTableDir.getTableDirectoryEntry("loca");
@@ -235,7 +238,7 @@
dirEntry = ttfTableDir.getTableDirectoryEntry("gasp");
if (dirEntry != null) {
- font.gaspTable = TtfTableGasp.parse(dirEntry, raInput);
+ font.gaspTable = GaspTable.parse(dirEntry, raInput);
}
/* BEGIN POSTSCRIPT-OUTLINE TABLES ************************************************************************** */
@@ -264,7 +267,7 @@
dirEntry = ttfTableDir.getTableDirectoryEntry("GDEF");
if (dirEntry != null) {
- font.gdefTable = TtfTableGdef.parse(dirEntry, raInput);
+ font.gdefTable = GdefTable.parse(dirEntry, raInput);
}
dirEntry = ttfTableDir.getTableDirectoryEntry("GPOS");
@@ -386,7 +389,7 @@
* Returns the "fpgm" table.
* @return The "fpgm" table.
*/
- public TtfTableFpgm getFpgmTable() {
+ public FpgmTable getFpgmTable() {
return this.fpgmTable;
}
@@ -418,7 +421,7 @@
* Returns the "gasp" table.
* @return The "gasp" table.
*/
- public TtfTableGasp getGaspTable() {
+ public GaspTable getGaspTable() {
return this.gaspTable;
}
@@ -458,7 +461,7 @@
* Returns the "GDEF" table.
* @return The "GDEF" table.
*/
- public TtfTableGdef getGdefTable() {
+ public GdefTable getGdefTable() {
return this.gdefTable;
}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableFpgm.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableFpgm.java 2025-04-21 00:44:21 UTC (rev 13459)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableFpgm.java 2025-04-21 00:47:07 UTC (rev 13460)
@@ -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;
-
-/**
- * A TrueType/OpenType "fpgm" (Font Program) table.
- * This table is used only in fonts that contain TrueType outlines.
- */
-public class TtfTableFpgm extends TtfTable {
-
- /**
- * Constructor.
- * @param offsetRecord The parent table directory entry.
- */
- public TtfTableFpgm(final TtfOffsetTableRecord offsetRecord) {
- super(offsetRecord);
- }
-
- /**
- * Parse the table from the table content.
- * @param offsetRecord The parent offset table record.
- * @param raInput The input which is being parsed.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
- */
- public static TtfTableFpgm parse(final TtfOffsetTableRecord offsetRecord, final RandomAccessInput raInput)
- throws IOException {
- raInput.seek(offsetRecord.getOffset());
- final TtfTableFpgm table = new TtfTableFpgm(offsetRecord);
- return table;
- }
-
- @Override
- public String getTableTag() {
- return "fpgm";
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableGasp.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableGasp.java 2025-04-21 00:44:21 UTC (rev 13459)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableGasp.java 2025-04-21 00:47:07 UTC (rev 13460)
@@ -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;
-
-/**
- * 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.
- */
-public class TtfTableGasp extends TtfTable {
-
- /**
- * Constructor.
- * @param offsetRecord The parent table directory entry.
- */
- public TtfTableGasp(final TtfOffsetTableRecord offsetRecord) {
- super(offsetRecord);
- }
-
- /**
- * Parse the table from the table content.
- * @param offsetRecord The parent offset table record.
- * @param raInput The input which is being parsed.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
- */
- public static TtfTableGasp parse(final TtfOffsetTableRecord offsetRecord, final RandomAccessInput raInput)
- throws IOException {
- raInput.seek(offsetRecord.getOffset());
- final TtfTableGasp table = new TtfTableGasp(offsetRecord);
- return table;
- }
-
- @Override
- public String getTableTag() {
- return "cvt";
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableGdef.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableGdef.java 2025-04-21 00:44:21 UTC (rev 13459)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableGdef.java 2025-04-21 00:47:07 UTC (rev 13460)
@@ -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;
-
-/**
- * An OpenType "GDEF" (Glyph Definition Data) table.
- * This table is an Advanced Typographic Table.
- */
-public class TtfTableGdef extends TtfTable {
-
- /**
- * Constructor.
- * @param offsetRecord The parent table directory entry.
- */
- public TtfTableGdef(final TtfOffsetTableRecord offsetRecord) {
- super(offsetRecord);
- }
-
- /**
- * Parse the table from the table content.
- * @param offsetRecord The parent offset table record.
- * @param raInput The input which is being parsed.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
- */
- public static TtfTableGdef parse(final TtfOffsetTableRecord offsetRecord, final RandomAccessInput raInput)
- throws IOException {
- raInput.seek(offsetRecord.getOffset());
- final TtfTableGdef table = new TtfTableGdef(offsetRecord);
- return table;
- }
-
- @Override
- public String getTableTag() {
- return "GDEF";
- }
-
-}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/FpgmTable.java (from rev 13455, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableFpgm.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/FpgmTable.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/FpgmTable.java 2025-04-21 00:47:07 UTC (rev 13460)
@@ -0,0 +1,70 @@
+/*
+ * 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.TtfOffsetTableRecord;
+import org.foray.font.ttf.TtfTable;
+
+import java.io.IOException;
+
+/**
+ * A TrueType/OpenType "fpgm" (Font Program) table.
+ * This table is used only in fonts that contain TrueType outlines.
+ */
+public class FpgmTable extends TtfTable {
+
+ /**
+ * Constructor.
+ * @param offsetRecord The parent table directory entry.
+ */
+ public FpgmTable(final TtfOffsetTableRecord offsetRecord) {
+ super(offsetRecord);
+ }
+
+ /**
+ * Parse the table from the table content.
+ * @param offsetRecord The parent offset table record.
+ * @param raInput The input which is being parsed.
+ * @return The parsed instance.
+ * @throws IOException For I/O Error.
+ */
+ public static FpgmTable parse(final TtfOffsetTableRecord offsetRecord, final RandomAccessInput raInput)
+ throws IOException {
+ raInput.seek(offsetRecord.getOffset());
+ final FpgmTable table = new FpgmTable(offsetRecord);
+ return table;
+ }
+
+ @Override
+ public String getTableTag() {
+ return "fpgm";
+ }
+
+}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GaspTable.java (from rev 13455, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableGasp.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GaspTable.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GaspTable.java 2025-04-21 00:47:07 UTC (rev 13460)
@@ -0,0 +1,70 @@
+/*
+ * 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.TtfOffsetTableRecord;
+import org.foray.font.ttf.TtfTable;
+
+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.
+ */
+public class GaspTable extends TtfTable {
+
+ /**
+ * Constructor.
+ * @param offsetRecord The parent table directory entry.
+ */
+ public GaspTable(final TtfOffsetTableRecord offsetRecord) {
+ super(offsetRecord);
+ }
+
+ /**
+ * Parse the table from the table content.
+ * @param offsetRecord The parent offset table record.
+ * @param raInput The input which is being parsed.
+ * @return The parsed instance.
+ * @throws IOException For I/O Error.
+ */
+ public static GaspTable parse(final TtfOffsetTableRecord offsetRecord, final RandomAccessInput raInput)
+ throws IOException {
+ raInput.seek(offsetRecord.getOffset());
+ final GaspTable table = new GaspTable(offsetRecord);
+ return table;
+ }
+
+ @Override
+ public String getTableTag() {
+ return "cvt";
+ }
+
+}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GdefTable.java (from rev 13455, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableGdef.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GdefTable.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GdefTable.java 2025-04-21 00:47:07 UTC (rev 13460)
@@ -0,0 +1,70 @@
+/*
+ * 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.TtfOffsetTableRecord;
+import org.foray.font.ttf.TtfTable;
+
+import java.io.IOException;
+
+/**
+ * An OpenType "GDEF" (Glyph Definition Data) table.
+ * This table is an Advanced Typographic Table.
+ */
+public class GdefTable extends TtfTable {
+
+ /**
+ * Constructor.
+ * @param offsetRecord The parent table directory entry.
+ */
+ public GdefTable(final TtfOffsetTableRecord offsetRecord) {
+ super(offsetRecord);
+ }
+
+ /**
+ * Parse the table from the table content.
+ * @param offsetRecord The parent offset table record.
+ * @param raInput The input which is being parsed.
+ * @return The parsed instance.
+ * @throws IOException For I/O Error.
+ */
+ public static GdefTable parse(final TtfOffsetTableRecord offsetRecord, final RandomAccessInput raInput)
+ throws IOException {
+ raInput.seek(offsetRecord.getOffset());
+ final GdefTable table = new GdefTable(offsetRecord);
+ return table;
+ }
+
+ @Override
+ public String getTableTag() {
+ return "GDEF";
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-21 00:44:38
|
Revision: 13459
http://sourceforge.net/p/foray/code/13459
Author: victormote
Date: 2025-04-21 00:44:21 +0000 (Mon, 21 Apr 2025)
Log Message:
-----------
Move more TTF Table classes to new directory.
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/TtfSubSetFile.java
Added Paths:
-----------
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
Removed Paths:
-------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableCff.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableCff2.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableCvt.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-21 00:41:10 UTC (rev 13458)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-04-21 00:44:21 UTC (rev 13459)
@@ -33,6 +33,9 @@
import org.foray.font.format.Panose4a;
import org.foray.font.output.FontPdfUtilities;
import org.foray.font.ttf.table.BaseTable;
+import org.foray.font.ttf.table.Cff2Table;
+import org.foray.font.ttf.table.CffTable;
+import org.foray.font.ttf.table.CvtTable;
import org.foray.font.ttf.table.HeadTable;
import org.foray.font.ttf.table.LocaTable;
import org.foray.font.ttf.table.MathTable;
@@ -92,7 +95,7 @@
private PostTable postTable = null;
/** The (TrueType-outlines only) "cvt" table instance. */
- private TtfTableCvt cvtTable = null;
+ private CvtTable cvtTable = null;
/** The (TrueType-outlines only) "fpgm" table instance. */
private TtfTableFpgm fpgmTable = null;
@@ -110,10 +113,10 @@
private TtfTableGasp gaspTable = null;
/** The (PS-Outlines-only) "CFF" table instance. */
- private TtfTableCff cffTable = null;
+ private CffTable cffTable = null;
/** The (PS-Outlines-only) "CFF2" table instance. */
- private TtfTableCff2 cff2Table = null;
+ private Cff2Table cff2Table = null;
/** The (PS-Outlines-only, optional) "VORG" table instance. */
private VorgTable vorgTable = null;
@@ -206,7 +209,7 @@
dirEntry = ttfTableDir.getTableDirectoryEntry("cvt");
if (dirEntry != null) {
- font.cvtTable = TtfTableCvt.parse(dirEntry, raInput);
+ font.cvtTable = CvtTable.parse(dirEntry, raInput);
}
dirEntry = ttfTableDir.getTableDirectoryEntry("fpgm");
@@ -239,12 +242,12 @@
dirEntry = ttfTableDir.getTableDirectoryEntry("CFF");
if (dirEntry != null) {
- font.cffTable = TtfTableCff.parse(dirEntry, raInput);
+ font.cffTable = CffTable.parse(dirEntry, raInput);
}
dirEntry = ttfTableDir.getTableDirectoryEntry("CFF2");
if (dirEntry != null) {
- font.cff2Table = TtfTableCff2.parse(dirEntry, raInput);
+ font.cff2Table = Cff2Table.parse(dirEntry, raInput);
}
dirEntry = ttfTableDir.getTableDirectoryEntry("VORG");
@@ -375,7 +378,7 @@
* Returns the "cvt" table.
* @return The "cvt" table.
*/
- public TtfTableCvt getCvtTable() {
+ public CvtTable getCvtTable() {
return this.cvtTable;
}
@@ -423,7 +426,7 @@
* Returns the "CFF" table.
* @return The "CFF" table.
*/
- public TtfTableCff getCffTable() {
+ public CffTable getCffTable() {
return this.cffTable;
}
@@ -431,7 +434,7 @@
* Returns the "CFF2" table.
* @return The "CFF2" table.
*/
- public TtfTableCff2 getCff2Table() {
+ public Cff2Table getCff2Table() {
return this.cff2Table;
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfSubSetFile.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfSubSetFile.java 2025-04-21 00:41:10 UTC (rev 13458)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfSubSetFile.java 2025-04-21 00:44:21 UTC (rev 13459)
@@ -30,6 +30,7 @@
import org.foray.font.Subset;
import org.foray.font.format.FontParser;
+import org.foray.font.ttf.table.CffTable;
import org.foray.font.ttf.table.HeadTable;
import org.axsl.constants.PrimitiveConstants;
@@ -119,7 +120,7 @@
if (glyfTable != null) {
return embeddableSubsetTTF();
}
- final TtfTableCff cffTable = this.ttfFont.getCffTable();
+ final CffTable cffTable = this.ttfFont.getCffTable();
if (cffTable != null) {
return embeddableSubsetCFF();
}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableCff.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableCff.java 2025-04-21 00:41:10 UTC (rev 13458)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableCff.java 2025-04-21 00:44:21 UTC (rev 13459)
@@ -1,68 +0,0 @@
-/*
- * 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;
-
-import org.foray.common.RandomAccessInput;
-
-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.
- */
-public class TtfTableCff extends TtfTable {
-
- /**
- * Constructor.
- * @param offsetRecord The parent table directory entry.
- */
- public TtfTableCff(final TtfOffsetTableRecord offsetRecord) {
- super(offsetRecord);
- }
-
- /**
- * Parse the table from the table content.
- * @param offsetRecord The parent offset table record.
- * @param raInput The input which is being parsed.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
- */
- public static TtfTableCff parse(final TtfOffsetTableRecord offsetRecord, final RandomAccessInput raInput)
- throws IOException {
- raInput.seek(offsetRecord.getOffset());
- final TtfTableCff table = new TtfTableCff(offsetRecord);
- return table;
- }
-
- @Override
- public String getTableTag() {
- return "CFF";
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableCff2.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableCff2.java 2025-04-21 00:41:10 UTC (rev 13458)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableCff2.java 2025-04-21 00:44:21 UTC (rev 13459)
@@ -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;
-
-/**
- * An OpenType "CFF2" (Compact File Format 2.0 PostScript Outlines) table.
- * This table is used only in OpenType fonts that contain PostScript outlines.
- */
-public class TtfTableCff2 extends TtfTable {
-
- /**
- * Constructor.
- * @param offsetRecord The parent offset table record.
- */
- public TtfTableCff2(final TtfOffsetTableRecord offsetRecord) {
- super(offsetRecord);
- }
-
- /**
- * Parse the table from the table content.
- * @param offsetRecord The parent offset table record.
- * @param raInput The input which is being parsed.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
- */
- public static TtfTableCff2 parse(final TtfOffsetTableRecord offsetRecord, final RandomAccessInput raInput)
- throws IOException {
- raInput.seek(offsetRecord.getOffset());
- final TtfTableCff2 table = new TtfTableCff2(offsetRecord);
- return table;
- }
-
- @Override
- public String getTableTag() {
- return "CFF2";
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableCvt.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableCvt.java 2025-04-21 00:41:10 UTC (rev 13458)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableCvt.java 2025-04-21 00:44:21 UTC (rev 13459)
@@ -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;
-
-/**
- * A TrueType/OpenType "cvt" (Control Value Table) table.
- * This table is used only in fonts that contain TrueType outlines.
- */
-public class TtfTableCvt extends TtfTable {
-
- /**
- * Constructor.
- * @param offsetRecord The parent table directory entry.
- */
- public TtfTableCvt(final TtfOffsetTableRecord offsetRecord) {
- super(offsetRecord);
- }
-
- /**
- * Parse the table from the table content.
- * @param offsetRecord The parent offset table record.
- * @param raInput The input which is being parsed.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
- */
- public static TtfTableCvt parse(final TtfOffsetTableRecord offsetRecord, final RandomAccessInput raInput)
- throws IOException {
- raInput.seek(offsetRecord.getOffset());
- final TtfTableCvt table = new TtfTableCvt(offsetRecord);
- return table;
- }
-
- @Override
- public String getTableTag() {
- return "cvt";
- }
-
-}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cff2Table.java (from rev 13455, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableCff2.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cff2Table.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cff2Table.java 2025-04-21 00:44:21 UTC (rev 13459)
@@ -0,0 +1,70 @@
+/*
+ * 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.TtfOffsetTableRecord;
+import org.foray.font.ttf.TtfTable;
+
+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.
+ */
+public class Cff2Table extends TtfTable {
+
+ /**
+ * Constructor.
+ * @param offsetRecord The parent offset table record.
+ */
+ public Cff2Table(final TtfOffsetTableRecord offsetRecord) {
+ super(offsetRecord);
+ }
+
+ /**
+ * Parse the table from the table content.
+ * @param offsetRecord The parent offset table record.
+ * @param raInput The input which is being parsed.
+ * @return The parsed instance.
+ * @throws IOException For I/O Error.
+ */
+ public static Cff2Table parse(final TtfOffsetTableRecord offsetRecord, final RandomAccessInput raInput)
+ throws IOException {
+ raInput.seek(offsetRecord.getOffset());
+ final Cff2Table table = new Cff2Table(offsetRecord);
+ return table;
+ }
+
+ @Override
+ public String getTableTag() {
+ return "CFF2";
+ }
+
+}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CffTable.java (from rev 13455, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableCff.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CffTable.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CffTable.java 2025-04-21 00:44:21 UTC (rev 13459)
@@ -0,0 +1,70 @@
+/*
+ * 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.common.RandomAccessInput;
+import org.foray.font.ttf.TtfOffsetTableRecord;
+import org.foray.font.ttf.TtfTable;
+
+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.
+ */
+public class CffTable extends TtfTable {
+
+ /**
+ * Constructor.
+ * @param offsetRecord The parent table directory entry.
+ */
+ public CffTable(final TtfOffsetTableRecord offsetRecord) {
+ super(offsetRecord);
+ }
+
+ /**
+ * Parse the table from the table content.
+ * @param offsetRecord The parent offset table record.
+ * @param raInput The input which is being parsed.
+ * @return The parsed instance.
+ * @throws IOException For I/O Error.
+ */
+ public static CffTable parse(final TtfOffsetTableRecord offsetRecord, final RandomAccessInput raInput)
+ throws IOException {
+ raInput.seek(offsetRecord.getOffset());
+ final CffTable table = new CffTable(offsetRecord);
+ return table;
+ }
+
+ @Override
+ public String getTableTag() {
+ return "CFF";
+ }
+
+}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CvtTable.java (from rev 13455, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableCvt.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CvtTable.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CvtTable.java 2025-04-21 00:44:21 UTC (rev 13459)
@@ -0,0 +1,70 @@
+/*
+ * 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.TtfOffsetTableRecord;
+import org.foray.font.ttf.TtfTable;
+
+import java.io.IOException;
+
+/**
+ * A TrueType/OpenType "cvt" (Control Value Table) table.
+ * This table is used only in fonts that contain TrueType outlines.
+ */
+public class CvtTable extends TtfTable {
+
+ /**
+ * Constructor.
+ * @param offsetRecord The parent table directory entry.
+ */
+ public CvtTable(final TtfOffsetTableRecord offsetRecord) {
+ super(offsetRecord);
+ }
+
+ /**
+ * Parse the table from the table content.
+ * @param offsetRecord The parent offset table record.
+ * @param raInput The input which is being parsed.
+ * @return The parsed instance.
+ * @throws IOException For I/O Error.
+ */
+ public static CvtTable parse(final TtfOffsetTableRecord offsetRecord, final RandomAccessInput raInput)
+ throws IOException {
+ raInput.seek(offsetRecord.getOffset());
+ final CvtTable table = new CvtTable(offsetRecord);
+ return table;
+ }
+
+ @Override
+ public String getTableTag() {
+ return "cvt";
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-21 00:41:28
|
Revision: 13458
http://sourceforge.net/p/foray/code/13458
Author: victormote
Date: 2025-04-21 00:41:10 +0000 (Mon, 21 Apr 2025)
Log Message:
-----------
Move more TTF Table classes to new directory.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java
Added Paths:
-----------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/LocaTable.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/MaxpTable.java
Removed Paths:
-------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableLoca.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableMath.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableMaxp.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-21 00:37:55 UTC (rev 13457)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-04-21 00:41:10 UTC (rev 13458)
@@ -34,6 +34,9 @@
import org.foray.font.output.FontPdfUtilities;
import org.foray.font.ttf.table.BaseTable;
import org.foray.font.ttf.table.HeadTable;
+import org.foray.font.ttf.table.LocaTable;
+import org.foray.font.ttf.table.MathTable;
+import org.foray.font.ttf.table.MaxpTable;
import org.foray.font.ttf.table.Os2Table;
import org.foray.font.ttf.table.PcltTable;
import org.foray.font.ttf.table.PostTable;
@@ -77,7 +80,7 @@
private TtfTableHmtx hmtxTable = null;
/** The (required) "maxp" table instance. */
- private TtfTableMaxp maxpTable = null;
+ private MaxpTable maxpTable = null;
/** The (required) "name" table instance. */
private TtfTableName nameTable = null;
@@ -98,7 +101,7 @@
private TtfTableGlyf glyfTable = null;
/** The (TrueType-outlines only) "loca" table instance. */
- private TtfTableLoca locaTable = null;
+ private LocaTable locaTable = null;
/** The (TrueType-outlines only) "prep" table instance. */
private PrepTable prepTable = null;
@@ -131,7 +134,7 @@
private TtfTableJstf jstfTable = null;
/** The (OTF, Advanced Typographic Table) "MATH" table instance. */
- private TtfTableMath mathTable = null;
+ private MathTable mathTable = null;
/** The (optional) "kern" table instance. */
private TtfTableKern kernTable = null;
@@ -172,7 +175,7 @@
/* Then the Maximum Profile, so general sizes are known. */
dirEntry = ttfTableDir.getTableDirectoryEntry("maxp");
- font.maxpTable = TtfTableMaxp.parse(dirEntry, raInput);
+ font.maxpTable = MaxpTable.parse(dirEntry, raInput);
/* The NAME table needs to be read before the CMAP. */
dirEntry = ttfTableDir.getTableDirectoryEntry("name");
@@ -214,7 +217,7 @@
dirEntry = ttfTableDir.getTableDirectoryEntry("loca");
if (dirEntry != null) {
final boolean isLongFormat = font.headTable.longLocaFormat();
- font.locaTable = TtfTableLoca.parse(dirEntry, raInput, isLongFormat, numberOfGlyphs, font.hmtxTable);
+ font.locaTable = LocaTable.parse(dirEntry, raInput, isLongFormat, numberOfGlyphs, font.hmtxTable);
}
dirEntry = ttfTableDir.getTableDirectoryEntry("glyf");
@@ -278,7 +281,7 @@
dirEntry = ttfTableDir.getTableDirectoryEntry("MATH");
if (dirEntry != null) {
- font.mathTable = TtfTableMath.parse(dirEntry, raInput);
+ font.mathTable = MathTable.parse(dirEntry, raInput);
}
/* BEGIN OPTIONAL TABLES ************************************************************************************ */
@@ -340,7 +343,7 @@
* Returns the "maxp" table.
* @return The "maxp" table.
*/
- public TtfTableMaxp getMaxpTable() {
+ public MaxpTable getMaxpTable() {
return this.maxpTable;
}
@@ -388,7 +391,7 @@
* Returns the "loca" table.
* @return The "loca" table.
*/
- public TtfTableLoca getLocaTable() {
+ public LocaTable getLocaTable() {
return this.locaTable;
}
@@ -484,7 +487,7 @@
* Returns the "MATH" table.
* @return The "MATH" table.
*/
- public TtfTableMath getMathTable() {
+ public MathTable getMathTable() {
return this.mathTable;
}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableLoca.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableLoca.java 2025-04-21 00:37:55 UTC (rev 13457)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableLoca.java 2025-04-21 00:41:10 UTC (rev 13458)
@@ -1,97 +0,0 @@
-/*
- * Copyright 2004 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 TrueType/OpenType "loca" (Index to location) table.
- * This table is used only in fonts that contain TrueType outlines.
- */
-public class TtfTableLoca extends TtfTable {
-
- /** The last offset value in the table, which points to no glyph, but
- * exists to be able to compute the size of the previous entry. */
- private long lastOffset = 0;
-
- /**
- * Constructor.
- * @param dirEntry The parent table directory entry.
- */
- public TtfTableLoca(final TtfOffsetTableRecord dirEntry) {
- super(dirEntry);
- }
-
- /**
- * Reads the "loca" table.
- * @param dirEntry The parent table directory entry.
- * @param raInput The input which is being parsed.
- * @param isLongFormat Indicates whether the long format (true) or the short format (false) should be used.
- * This information is derived from the "head" table.
- * @param numberOfGlyphs The number of glyph entries to be parsed.
- * This information is derived from the "maxp" table.
- * @param hmtx The horizontal metrics ("hmtx") table.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
- */
- public static TtfTableLoca parse(final TtfOffsetTableRecord dirEntry, final RandomAccessInput raInput,
- final boolean isLongFormat, final int numberOfGlyphs, final TtfTableHmtx hmtx) throws IOException {
- raInput.seek(dirEntry.getOffset());
- final TtfTableLoca loca = new TtfTableLoca(dirEntry);
- for (int i = 0; i < numberOfGlyphs; i++) {
- final long entry;
- if (isLongFormat) {
- entry = raInput.readUnsignedInt();
- } else {
- entry = raInput.readUnsignedShort() << 1;
- }
- hmtx.getMtxEntry(i).setOffset(entry);
- }
- loca.lastOffset = raInput.readUnsignedInt();
- return loca;
- }
-
- @Override
- public String getTableTag() {
- return "loca";
- }
-
- /**
- * Returns the last offset value in the table.
- * Note that this offset points to no glyph, but exists only for purposes
- * of computing the size of the last valid item.
- * @return The last offset value in the table.
- */
- public long lastOffset() {
- return this.lastOffset;
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableMath.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableMath.java 2025-04-21 00:37:55 UTC (rev 13457)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableMath.java 2025-04-21 00:41:10 UTC (rev 13458)
@@ -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;
-
-/**
- * An OpenType "MATH" (Math Layout Data) table.
- * This table is an Advanced Typographic Table.
- */
-public class TtfTableMath extends TtfTable {
-
- /**
- * Constructor.
- * @param offsetRecord The parent table directory entry.
- */
- public TtfTableMath(final TtfOffsetTableRecord offsetRecord) {
- super(offsetRecord);
- }
-
- /**
- * Parse the table from the table content.
- * @param offsetRecord The parent offset table record.
- * @param raInput The input which is being parsed.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
- */
- public static TtfTableMath parse(final TtfOffsetTableRecord offsetRecord, final RandomAccessInput raInput)
- throws IOException {
- raInput.seek(offsetRecord.getOffset());
- final TtfTableMath table = new TtfTableMath(offsetRecord);
- return table;
- }
-
- @Override
- public String getTableTag() {
- return "MATH";
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableMaxp.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableMaxp.java 2025-04-21 00:37:55 UTC (rev 13457)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableMaxp.java 2025-04-21 00:41:10 UTC (rev 13458)
@@ -1,81 +0,0 @@
-/*
- * Copyright 2004 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;
-
-/**
- * Class representing a TTF "maxp" (maximum profile) table.
- */
-public class TtfTableMaxp extends TtfTable {
-
- /** The number of glyphs in the font. */
- private int numGlyphs;
-
- /**
- * Constructor.
- * @param dirEntry The parent table directory entry.
- */
- public TtfTableMaxp(final TtfOffsetTableRecord dirEntry) {
- super(dirEntry);
- }
-
- /**
- * Reads the number of glyphs from the "maxp" table.
- * @param dirEntry The parent table directory entry.
- * @param raInput The input which is being parsed.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
- */
- public static TtfTableMaxp parse(final TtfOffsetTableRecord dirEntry, final RandomAccessInput raInput)
- throws IOException {
- raInput.seek(dirEntry.getOffset());
- final TtfTableMaxp maxp = new TtfTableMaxp(dirEntry);
- /* Skip Table version number. */
- raInput.skipBytes(FIXED_BYTES);
- maxp.numGlyphs = raInput.readUnsignedShort();
- return maxp;
- }
-
- @Override
- public String getTableTag() {
- return "maxp";
- }
-
- /**
- * Returns the parsed number of glyphs.
- * @return The number of glyphs in this font.
- */
- public int getNumberOfGlyphs() {
- return this.numGlyphs;
- }
-
-}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/LocaTable.java (from rev 13455, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableLoca.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/LocaTable.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/LocaTable.java 2025-04-21 00:41:10 UTC (rev 13458)
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2004 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.TtfOffsetTableRecord;
+import org.foray.font.ttf.TtfTable;
+import org.foray.font.ttf.TtfTableHmtx;
+
+import java.io.IOException;
+
+/**
+ * A TrueType/OpenType "loca" (Index to location) table.
+ * This table is used only in fonts that contain TrueType outlines.
+ */
+public class LocaTable extends TtfTable {
+
+ /** The last offset value in the table, which points to no glyph, but
+ * exists to be able to compute the size of the previous entry. */
+ private long lastOffset = 0;
+
+ /**
+ * Constructor.
+ * @param dirEntry The parent table directory entry.
+ */
+ public LocaTable(final TtfOffsetTableRecord dirEntry) {
+ super(dirEntry);
+ }
+
+ /**
+ * Reads the "loca" table.
+ * @param dirEntry The parent table directory entry.
+ * @param raInput The input which is being parsed.
+ * @param isLongFormat Indicates whether the long format (true) or the short format (false) should be used.
+ * This information is derived from the "head" table.
+ * @param numberOfGlyphs The number of glyph entries to be parsed.
+ * This information is derived from the "maxp" table.
+ * @param hmtx The horizontal metrics ("hmtx") table.
+ * @return The parsed instance.
+ * @throws IOException For I/O Error.
+ */
+ public static LocaTable parse(final TtfOffsetTableRecord dirEntry, final RandomAccessInput raInput,
+ final boolean isLongFormat, final int numberOfGlyphs, final TtfTableHmtx hmtx) throws IOException {
+ raInput.seek(dirEntry.getOffset());
+ final LocaTable loca = new LocaTable(dirEntry);
+ for (int i = 0; i < numberOfGlyphs; i++) {
+ final long entry;
+ if (isLongFormat) {
+ entry = raInput.readUnsignedInt();
+ } else {
+ entry = raInput.readUnsignedShort() << 1;
+ }
+ hmtx.getMtxEntry(i).setOffset(entry);
+ }
+ loca.lastOffset = raInput.readUnsignedInt();
+ return loca;
+ }
+
+ @Override
+ public String getTableTag() {
+ return "loca";
+ }
+
+ /**
+ * Returns the last offset value in the table.
+ * Note that this offset points to no glyph, but exists only for purposes
+ * of computing the size of the last valid item.
+ * @return The last offset value in the table.
+ */
+ public long lastOffset() {
+ return this.lastOffset;
+ }
+
+}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/MathTable.java (from rev 13455, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableMath.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/MathTable.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/MathTable.java 2025-04-21 00:41:10 UTC (rev 13458)
@@ -0,0 +1,70 @@
+/*
+ * 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.TtfOffsetTableRecord;
+import org.foray.font.ttf.TtfTable;
+
+import java.io.IOException;
+
+/**
+ * An OpenType "MATH" (Math Layout Data) table.
+ * This table is an Advanced Typographic Table.
+ */
+public class MathTable extends TtfTable {
+
+ /**
+ * Constructor.
+ * @param offsetRecord The parent table directory entry.
+ */
+ public MathTable(final TtfOffsetTableRecord offsetRecord) {
+ super(offsetRecord);
+ }
+
+ /**
+ * Parse the table from the table content.
+ * @param offsetRecord The parent offset table record.
+ * @param raInput The input which is being parsed.
+ * @return The parsed instance.
+ * @throws IOException For I/O Error.
+ */
+ public static MathTable parse(final TtfOffsetTableRecord offsetRecord, final RandomAccessInput raInput)
+ throws IOException {
+ raInput.seek(offsetRecord.getOffset());
+ final MathTable table = new MathTable(offsetRecord);
+ return table;
+ }
+
+ @Override
+ public String getTableTag() {
+ return "MATH";
+ }
+
+}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/MaxpTable.java (from rev 13455, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableMaxp.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/MaxpTable.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/MaxpTable.java 2025-04-21 00:41:10 UTC (rev 13458)
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2004 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.TtfOffsetTableRecord;
+import org.foray.font.ttf.TtfTable;
+
+import java.io.IOException;
+
+/**
+ * Class representing a TTF "maxp" (maximum profile) table.
+ */
+public class MaxpTable extends TtfTable {
+
+ /** The number of glyphs in the font. */
+ private int numGlyphs;
+
+ /**
+ * Constructor.
+ * @param dirEntry The parent table directory entry.
+ */
+ public MaxpTable(final TtfOffsetTableRecord dirEntry) {
+ super(dirEntry);
+ }
+
+ /**
+ * Reads the number of glyphs from the "maxp" table.
+ * @param dirEntry The parent table directory entry.
+ * @param raInput The input which is being parsed.
+ * @return The parsed instance.
+ * @throws IOException For I/O Error.
+ */
+ public static MaxpTable parse(final TtfOffsetTableRecord dirEntry, final RandomAccessInput raInput)
+ throws IOException {
+ raInput.seek(dirEntry.getOffset());
+ final MaxpTable maxp = new MaxpTable(dirEntry);
+ /* Skip Table version number. */
+ raInput.skipBytes(FIXED_BYTES);
+ maxp.numGlyphs = raInput.readUnsignedShort();
+ return maxp;
+ }
+
+ @Override
+ public String getTableTag() {
+ return "maxp";
+ }
+
+ /**
+ * Returns the parsed number of glyphs.
+ * @return The number of glyphs in this font.
+ */
+ public int getNumberOfGlyphs() {
+ return this.numGlyphs;
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-21 00:38:12
|
Revision: 13457
http://sourceforge.net/p/foray/code/13457
Author: victormote
Date: 2025-04-21 00:37:55 +0000 (Mon, 21 Apr 2025)
Log Message:
-----------
Move more TTF Table classes to new directory.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java
Added Paths:
-----------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PostTable.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
Removed Paths:
-------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTablePost.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTablePrep.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableVorg.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-21 00:32:00 UTC (rev 13456)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-04-21 00:37:55 UTC (rev 13457)
@@ -36,6 +36,9 @@
import org.foray.font.ttf.table.HeadTable;
import org.foray.font.ttf.table.Os2Table;
import org.foray.font.ttf.table.PcltTable;
+import org.foray.font.ttf.table.PostTable;
+import org.foray.font.ttf.table.PrepTable;
+import org.foray.font.ttf.table.VorgTable;
import org.foray.primitive.BitUtils;
import org.foray.primitive.sequence.ShortArrayBuilder;
@@ -83,7 +86,7 @@
private Os2Table os2Table = null;
/** The (required) "post" table instance. */
- private TtfTablePost postTable = null;
+ private PostTable postTable = null;
/** The (TrueType-outlines only) "cvt" table instance. */
private TtfTableCvt cvtTable = null;
@@ -98,7 +101,7 @@
private TtfTableLoca locaTable = null;
/** The (TrueType-outlines only) "prep" table instance. */
- private TtfTablePrep prepTable = null;
+ private PrepTable prepTable = null;
/** The (TrueType-outlines only) "gasp" table instance. */
private TtfTableGasp gaspTable = null;
@@ -110,7 +113,7 @@
private TtfTableCff2 cff2Table = null;
/** The (PS-Outlines-only, optional) "VORG" table instance. */
- private TtfTableVorg vorgTable = null;
+ private VorgTable vorgTable = null;
/** The (OTF, Advanced Typographic Table) "BASE" table instance. */
private BaseTable baseTable = null;
@@ -191,7 +194,7 @@
font.hmtxTable = TtfTableHmtx.parse(dirEntry, raInput, numberOfGlyphs, numberOfHMetrics);
dirEntry = ttfTableDir.getTableDirectoryEntry("post");
- font.postTable = TtfTablePost.parse(dirEntry, raInput);
+ font.postTable = PostTable.parse(dirEntry, raInput);
dirEntry = ttfTableDir.getTableDirectoryEntry("OS/2");
font.os2Table = Os2Table.parse(dirEntry, raInput);
@@ -221,7 +224,7 @@
dirEntry = ttfTableDir.getTableDirectoryEntry("prep");
if (dirEntry != null) {
- font.prepTable = TtfTablePrep.parse(dirEntry, raInput);
+ font.prepTable = PrepTable.parse(dirEntry, raInput);
}
dirEntry = ttfTableDir.getTableDirectoryEntry("gasp");
@@ -243,7 +246,7 @@
dirEntry = ttfTableDir.getTableDirectoryEntry("VORG");
if (dirEntry != null) {
- font.vorgTable = TtfTableVorg.parse(dirEntry, raInput);
+ font.vorgTable = VorgTable.parse(dirEntry, raInput);
}
/* BEGIN OPENTYPE ADVANCED TYPOGRAPHIC TABLES *************************************************************** */
@@ -361,7 +364,7 @@
* Returns the "post" table.
* @return The "post" table.
*/
- public TtfTablePost getPostTable() {
+ public PostTable getPostTable() {
return this.postTable;
}
@@ -401,7 +404,7 @@
* Returns the "prep" table.
* @return The "prep" table.
*/
- public TtfTablePrep getPrepTable() {
+ public PrepTable getPrepTable() {
return this.prepTable;
}
@@ -433,7 +436,7 @@
* Returns the "VORG" table.
* @return The "VORG" table.
*/
- public TtfTableVorg getVorgTable() {
+ public VorgTable getVorgTable() {
return this.vorgTable;
}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTablePost.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTablePost.java 2025-04-21 00:32:00 UTC (rev 13456)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTablePost.java 2025-04-21 00:37:55 UTC (rev 13457)
@@ -1,253 +0,0 @@
-/*
- * Copyright 2004 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 org.axsl.ps.PsEncoding;
-import org.axsl.ps.PsServer;
-
-import java.io.IOException;
-import java.math.BigDecimal;
-import java.nio.charset.StandardCharsets;
-
-/**
- * Class representing a TTF "post" (PostScript) table.
- */
-public class TtfTablePost extends TtfTable {
-
- /** Constant indicating that the post table uses format 1. */
- private static final int PS_FORMAT_1 = 0x00010000;
-
- /** Constant indicating that the post table uses format 2. */
- private static final int PS_FORMAT_2 = 0x00020000;
-
- /** Constant indicating that the post table uses format 3. */
- private static final int PS_FORMAT_3 = 0x00030000;
-
- /** Constant indicating the maximum glyph index that can be referenced in
- * the "Macintosh standard order" portion of the glyph names. */
- private static final int MAX_GLYPH_INDEX = 257;
-
- /** Constant indicating the beginning of the range of glyph indexes that
- * are reserved for future use. */
- private static final int FIRST_RESERVED_INDEX = 32768;
-
- /** The format for this table.
- * The format type is not really an integer, it is a FIXED.
- * However, it is more convenient to work with it as an integer. */
- private int postFormat;
-
- /** Italic angle for this font, expressed in degrees counterclockwise from
- * vertical. */
- private BigDecimal italicAngle = BigDecimal.ZERO;
-
- /** The parsed underline position for this font, in text space units. */
- private int underlinePosition = 0;
-
- /** The parsed underline thickness for this font, in text space units. */
- private int underlineThickness = 0;
-
- /** A zero value indicates that the font is proportionally spaced. Any other
- * value indicates that the font is monospaced (all glyphs have the same
- * width). */
- private long isFixedPitch = 0;
-
- /** The characters in the "Macintosh standard order" portion of the
- * names.*/
- private char[] glyphNameIndex;
-
- /** The parsed PostScript glyph names. */
- private String[] glyphNames;
-
- /** Set this to true if the PostScript names should be read. */
- private boolean readingPostScriptNames = false;
-
- /**
- * Constructor.
- * @param dirEntry The parent table directory entry.
- */
- public TtfTablePost(final TtfOffsetTableRecord dirEntry) {
- super(dirEntry);
- }
-
- /**
- * Parse the "post" table.
- * @param dirEntry The parent table directory entry.
- * @param raInput The input which is being parsed.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
- */
- public static TtfTablePost parse(final TtfOffsetTableRecord dirEntry, final TtfRandomAccessInput raInput)
- throws IOException {
- raInput.seek(dirEntry.getOffset());
- final TtfTablePost post = new TtfTablePost(dirEntry);
- post.postFormat = raInput.readInt();
- post.italicAngle = raInput.read_Fixed();
- post.underlinePosition = raInput.readShort();
- post.underlineThickness = raInput.readShort();
- post.isFixedPitch = raInput.readUnsignedInt();
- raInput.skipBytes(ULONG_BYTES); // minMemType42 (4)
- raInput.skipBytes(ULONG_BYTES); // maxMemType42 (4)
- raInput.skipBytes(ULONG_BYTES); // minMemType1 (4)
- raInput.skipBytes(ULONG_BYTES); // maxMemType1 (4)
- /* Actual reading of the names is turned off for now since it is not
- * used. However, it can be turned back on just by setting
- * this.readingPostScriptNames to true. */
- if (post.readingPostScriptNames) {
- readPostScriptNames(post, raInput);
- }
- return post;
- }
-
- /**
- * Reads the Postscript names found in this font.
- * @param post The table being parsed.
- * @param raInput The input which is being parsed.
- * @throws IOException For I/O error.
- */
- private static void readPostScriptNames(final TtfTablePost post, final RandomAccessInput raInput)
- throws IOException {
- switch (post.postFormat) {
- case TtfTablePost.PS_FORMAT_1:
- // Nothing needs to be read for this format.
- break;
- case TtfTablePost.PS_FORMAT_2:
- /* Num Glyphs */
- final int numGlyphs = raInput.readUnsignedShort();
-
- // Read the Indexes.
- post.glyphNameIndex = new char[numGlyphs];
- int numGlyphStrings = 0;
- for (int i = 0; i < numGlyphs; i++) {
- final char glyphIndex = (char) raInput.readUnsignedShort();
- post.glyphNameIndex[i] = glyphIndex;
- if (glyphIndex > TtfTablePost.MAX_GLYPH_INDEX) {
- numGlyphStrings++;
- }
- }
-
- // Read the glyph names.
- post.glyphNames = new String[numGlyphStrings];
- for (int i = 0; i < post.glyphNames.length; i++) {
- final int length = raInput.readUnsignedByte();
- post.glyphNames[i] = raInput.readString(length, StandardCharsets.ISO_8859_1);
- }
- break;
- case TtfTablePost.PS_FORMAT_3:
- // Postscript format 3 contains no glyph names
- break;
- default:
- throw new IllegalStateException("Unknown Postscript format : " + post.postFormat);
- }
- }
-
- @Override
- public String getTableTag() {
- return "post";
- }
-
- /**
- * Returns the parsed italic angle value.
- * @return The italic angle.
- */
- public BigDecimal getItalicAngle() {
- return this.italicAngle;
- }
-
- /**
- * Returns the parsed underline position.
- * @return The underline position.
- */
- public int getUnderlinePosition() {
- return this.underlinePosition;
- }
-
- /**
- * Returns the parsed underline thickness.
- * @return The underline thickness.
- */
- public int getUnderlineThickness() {
- return this.underlineThickness;
- }
-
- /**
- * Indicates whether this font is fixed pitch or proportional.
- * @return True if and only if this font is fixed pitch, false if it is proportional.
- */
- public boolean isFixedPitch() {
- if (this.isFixedPitch == 0) {
- return false;
- }
- return true;
- }
-
- /**
- * Returns the parsed PostScript name for a given glyph index.
- * @param psServer The PostScript server.
- * @param glyphIndex The glyph index whose PostScript name is sought.
- * @return The PostScript name for {@code glyphIndex}.
- */
- public String getPostScriptName(final PsServer psServer, final char glyphIndex) {
- final PsEncoding macOrdering = psServer.getPredefinedEncoding(
- PsEncoding.Predefined.STANDARD_MACINTOSH_ORDERING);
- final int codePoint = macOrdering.decode(glyphIndex);
- switch (this.postFormat) {
- case TtfTablePost.PS_FORMAT_1:
- return macOrdering.mapCodePointToGlyphName(codePoint);
- case TtfTablePost.PS_FORMAT_2:
- if (codePoint > -1) {
- return macOrdering.mapCodePointToGlyphName(codePoint);
- }
- if (this.glyphNameIndex == null
- || this.glyphNames == null) {
- return null;
- }
- if (! TtfTablePost.isIndexReserved(glyphIndex)) {
- for (int i = 0; i < this.glyphNameIndex.length; i++) {
- if (this.glyphNameIndex[i] == glyphIndex) {
- return this.glyphNames[i];
- }
- }
- }
- }
- return null;
- }
-
- /**
- * Determines whether this index represents a reserved character.
- * @param index The index value to be checked.
- * @return True if {@code index} is reserved.
- */
- public static boolean isIndexReserved(final char index) {
- return (index >= TtfTablePost.FIRST_RESERVED_INDEX)
- && (index <= Character.MAX_VALUE);
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTablePrep.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTablePrep.java 2025-04-21 00:32:00 UTC (rev 13456)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTablePrep.java 2025-04-21 00:37:55 UTC (rev 13457)
@@ -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;
-
-/**
- * A TrueType/OpenType "prep" (CVT Program) table.
- * This table is used only in fonts that contain TrueType outlines.
- */
-public class TtfTablePrep extends TtfTable {
-
- /**
- * Constructor.
- * @param offsetRecord The parent table directory entry.
- */
- public TtfTablePrep(final TtfOffsetTableRecord offsetRecord) {
- super(offsetRecord);
- }
-
- /**
- * Parse the table from the table content.
- * @param offsetRecord The parent offset table record.
- * @param raInput The input which is being parsed.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
- */
- public static TtfTablePrep parse(final TtfOffsetTableRecord offsetRecord, final RandomAccessInput raInput)
- throws IOException {
- raInput.seek(offsetRecord.getOffset());
- final TtfTablePrep table = new TtfTablePrep(offsetRecord);
- return table;
- }
-
- @Override
- public String getTableTag() {
- return "prep";
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableVorg.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableVorg.java 2025-04-21 00:32:00 UTC (rev 13456)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableVorg.java 2025-04-21 00:37:55 UTC (rev 13457)
@@ -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;
-
-/**
- * An OpenType "VORG" (Vertical Origin) table.
- * This table is used only in OpenType fonts that contain PostScript outlines, and is optional in those.
- */
-public class TtfTableVorg extends TtfTable {
-
- /**
- * Constructor.
- * @param offsetRecord The parent offset table record.
- */
- public TtfTableVorg(final TtfOffsetTableRecord offsetRecord) {
- super(offsetRecord);
- }
-
- /**
- * Parse the table from the table content.
- * @param offsetRecord The parent offset table record.
- * @param raInput The input which is being parsed.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
- */
- public static TtfTableVorg parse(final TtfOffsetTableRecord offsetRecord, final RandomAccessInput raInput)
- throws IOException {
- raInput.seek(offsetRecord.getOffset());
- final TtfTableVorg table = new TtfTableVorg(offsetRecord);
- return table;
- }
-
- @Override
- public String getTableTag() {
- return "VORG";
- }
-
-}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PostTable.java (from rev 13455, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTablePost.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PostTable.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PostTable.java 2025-04-21 00:37:55 UTC (rev 13457)
@@ -0,0 +1,256 @@
+/*
+ * Copyright 2004 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.TtfOffsetTableRecord;
+import org.foray.font.ttf.TtfRandomAccessInput;
+import org.foray.font.ttf.TtfTable;
+
+import org.axsl.ps.PsEncoding;
+import org.axsl.ps.PsServer;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
+
+/**
+ * Class representing a TTF "post" (PostScript) table.
+ */
+public class PostTable extends TtfTable {
+
+ /** Constant indicating that the post table uses format 1. */
+ private static final int PS_FORMAT_1 = 0x00010000;
+
+ /** Constant indicating that the post table uses format 2. */
+ private static final int PS_FORMAT_2 = 0x00020000;
+
+ /** Constant indicating that the post table uses format 3. */
+ private static final int PS_FORMAT_3 = 0x00030000;
+
+ /** Constant indicating the maximum glyph index that can be referenced in
+ * the "Macintosh standard order" portion of the glyph names. */
+ private static final int MAX_GLYPH_INDEX = 257;
+
+ /** Constant indicating the beginning of the range of glyph indexes that
+ * are reserved for future use. */
+ private static final int FIRST_RESERVED_INDEX = 32768;
+
+ /** The format for this table.
+ * The format type is not really an integer, it is a FIXED.
+ * However, it is more convenient to work with it as an integer. */
+ private int postFormat;
+
+ /** Italic angle for this font, expressed in degrees counterclockwise from
+ * vertical. */
+ private BigDecimal italicAngle = BigDecimal.ZERO;
+
+ /** The parsed underline position for this font, in text space units. */
+ private int underlinePosition = 0;
+
+ /** The parsed underline thickness for this font, in text space units. */
+ private int underlineThickness = 0;
+
+ /** A zero value indicates that the font is proportionally spaced. Any other
+ * value indicates that the font is monospaced (all glyphs have the same
+ * width). */
+ private long isFixedPitch = 0;
+
+ /** The characters in the "Macintosh standard order" portion of the
+ * names.*/
+ private char[] glyphNameIndex;
+
+ /** The parsed PostScript glyph names. */
+ private String[] glyphNames;
+
+ /** Set this to true if the PostScript names should be read. */
+ private boolean readingPostScriptNames = false;
+
+ /**
+ * Constructor.
+ * @param dirEntry The parent table directory entry.
+ */
+ public PostTable(final TtfOffsetTableRecord dirEntry) {
+ super(dirEntry);
+ }
+
+ /**
+ * Parse the "post" table.
+ * @param dirEntry The parent table directory entry.
+ * @param raInput The input which is being parsed.
+ * @return The parsed instance.
+ * @throws IOException For I/O Error.
+ */
+ public static PostTable parse(final TtfOffsetTableRecord dirEntry, final TtfRandomAccessInput raInput)
+ throws IOException {
+ raInput.seek(dirEntry.getOffset());
+ final PostTable post = new PostTable(dirEntry);
+ post.postFormat = raInput.readInt();
+ post.italicAngle = raInput.read_Fixed();
+ post.underlinePosition = raInput.readShort();
+ post.underlineThickness = raInput.readShort();
+ post.isFixedPitch = raInput.readUnsignedInt();
+ raInput.skipBytes(ULONG_BYTES); // minMemType42 (4)
+ raInput.skipBytes(ULONG_BYTES); // maxMemType42 (4)
+ raInput.skipBytes(ULONG_BYTES); // minMemType1 (4)
+ raInput.skipBytes(ULONG_BYTES); // maxMemType1 (4)
+ /* Actual reading of the names is turned off for now since it is not
+ * used. However, it can be turned back on just by setting
+ * this.readingPostScriptNames to true. */
+ if (post.readingPostScriptNames) {
+ readPostScriptNames(post, raInput);
+ }
+ return post;
+ }
+
+ /**
+ * Reads the Postscript names found in this font.
+ * @param post The table being parsed.
+ * @param raInput The input which is being parsed.
+ * @throws IOException For I/O error.
+ */
+ private static void readPostScriptNames(final PostTable post, final RandomAccessInput raInput)
+ throws IOException {
+ switch (post.postFormat) {
+ case PostTable.PS_FORMAT_1:
+ // Nothing needs to be read for this format.
+ break;
+ case PostTable.PS_FORMAT_2:
+ /* Num Glyphs */
+ final int numGlyphs = raInput.readUnsignedShort();
+
+ // Read the Indexes.
+ post.glyphNameIndex = new char[numGlyphs];
+ int numGlyphStrings = 0;
+ for (int i = 0; i < numGlyphs; i++) {
+ final char glyphIndex = (char) raInput.readUnsignedShort();
+ post.glyphNameIndex[i] = glyphIndex;
+ if (glyphIndex > PostTable.MAX_GLYPH_INDEX) {
+ numGlyphStrings++;
+ }
+ }
+
+ // Read the glyph names.
+ post.glyphNames = new String[numGlyphStrings];
+ for (int i = 0; i < post.glyphNames.length; i++) {
+ final int length = raInput.readUnsignedByte();
+ post.glyphNames[i] = raInput.readString(length, StandardCharsets.ISO_8859_1);
+ }
+ break;
+ case PostTable.PS_FORMAT_3:
+ // Postscript format 3 contains no glyph names
+ break;
+ default:
+ throw new IllegalStateException("Unknown Postscript format : " + post.postFormat);
+ }
+ }
+
+ @Override
+ public String getTableTag() {
+ return "post";
+ }
+
+ /**
+ * Returns the parsed italic angle value.
+ * @return The italic angle.
+ */
+ public BigDecimal getItalicAngle() {
+ return this.italicAngle;
+ }
+
+ /**
+ * Returns the parsed underline position.
+ * @return The underline position.
+ */
+ public int getUnderlinePosition() {
+ return this.underlinePosition;
+ }
+
+ /**
+ * Returns the parsed underline thickness.
+ * @return The underline thickness.
+ */
+ public int getUnderlineThickness() {
+ return this.underlineThickness;
+ }
+
+ /**
+ * Indicates whether this font is fixed pitch or proportional.
+ * @return True if and only if this font is fixed pitch, false if it is proportional.
+ */
+ public boolean isFixedPitch() {
+ if (this.isFixedPitch == 0) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Returns the parsed PostScript name for a given glyph index.
+ * @param psServer The PostScript server.
+ * @param glyphIndex The glyph index whose PostScript name is sought.
+ * @return The PostScript name for {@code glyphIndex}.
+ */
+ public String getPostScriptName(final PsServer psServer, final char glyphIndex) {
+ final PsEncoding macOrdering = psServer.getPredefinedEncoding(
+ PsEncoding.Predefined.STANDARD_MACINTOSH_ORDERING);
+ final int codePoint = macOrdering.decode(glyphIndex);
+ switch (this.postFormat) {
+ case PostTable.PS_FORMAT_1:
+ return macOrdering.mapCodePointToGlyphName(codePoint);
+ case PostTable.PS_FORMAT_2:
+ if (codePoint > -1) {
+ return macOrdering.mapCodePointToGlyphName(codePoint);
+ }
+ if (this.glyphNameIndex == null
+ || this.glyphNames == null) {
+ return null;
+ }
+ if (! PostTable.isIndexReserved(glyphIndex)) {
+ for (int i = 0; i < this.glyphNameIndex.length; i++) {
+ if (this.glyphNameIndex[i] == glyphIndex) {
+ return this.glyphNames[i];
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Determines whether this index represents a reserved character.
+ * @param index The index value to be checked.
+ * @return True if {@code index} is reserved.
+ */
+ public static boolean isIndexReserved(final char index) {
+ return (index >= PostTable.FIRST_RESERVED_INDEX)
+ && (index <= Character.MAX_VALUE);
+ }
+
+}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PrepTable.java (from rev 13455, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTablePrep.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PrepTable.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PrepTable.java 2025-04-21 00:37:55 UTC (rev 13457)
@@ -0,0 +1,70 @@
+/*
+ * 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.TtfOffsetTableRecord;
+import org.foray.font.ttf.TtfTable;
+
+import java.io.IOException;
+
+/**
+ * A TrueType/OpenType "prep" (CVT Program) table.
+ * This table is used only in fonts that contain TrueType outlines.
+ */
+public class PrepTable extends TtfTable {
+
+ /**
+ * Constructor.
+ * @param offsetRecord The parent table directory entry.
+ */
+ public PrepTable(final TtfOffsetTableRecord offsetRecord) {
+ super(offsetRecord);
+ }
+
+ /**
+ * Parse the table from the table content.
+ * @param offsetRecord The parent offset table record.
+ * @param raInput The input which is being parsed.
+ * @return The parsed instance.
+ * @throws IOException For I/O Error.
+ */
+ public static PrepTable parse(final TtfOffsetTableRecord offsetRecord, final RandomAccessInput raInput)
+ throws IOException {
+ raInput.seek(offsetRecord.getOffset());
+ final PrepTable table = new PrepTable(offsetRecord);
+ return table;
+ }
+
+ @Override
+ public String getTableTag() {
+ return "prep";
+ }
+
+}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/VorgTable.java (from rev 13455, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableVorg.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/VorgTable.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/VorgTable.java 2025-04-21 00:37:55 UTC (rev 13457)
@@ -0,0 +1,70 @@
+/*
+ * 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.TtfOffsetTableRecord;
+import org.foray.font.ttf.TtfTable;
+
+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.
+ */
+public class VorgTable extends TtfTable {
+
+ /**
+ * Constructor.
+ * @param offsetRecord The parent offset table record.
+ */
+ public VorgTable(final TtfOffsetTableRecord offsetRecord) {
+ super(offsetRecord);
+ }
+
+ /**
+ * Parse the table from the table content.
+ * @param offsetRecord The parent offset table record.
+ * @param raInput The input which is being parsed.
+ * @return The parsed instance.
+ * @throws IOException For I/O Error.
+ */
+ public static VorgTable parse(final TtfOffsetTableRecord offsetRecord, final RandomAccessInput raInput)
+ throws IOException {
+ raInput.seek(offsetRecord.getOffset());
+ final VorgTable table = new VorgTable(offsetRecord);
+ return table;
+ }
+
+ @Override
+ public String getTableTag() {
+ return "VORG";
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-21 00:32:17
|
Revision: 13456
http://sourceforge.net/p/foray/code/13456
Author: victormote
Date: 2025-04-21 00:32:00 +0000 (Mon, 21 Apr 2025)
Log Message:
-----------
Rename table classes using the new parsing scheme to new package.
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/TtfSubSetFile.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseTableParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/HeadTableParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/Os2TableParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/PcltTableParser.java
trunk/foray/foray-font/src/test/java/org/foray/font/ttf/TrueTypeFontTests.java
Added Paths:
-----------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HeadTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Os2Table.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PcltTable.java
Removed Paths:
-------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTableBase.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTableHead.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTableOs2.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTablePclt.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-21 00:29:07 UTC (rev 13455)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-04-21 00:32:00 UTC (rev 13456)
@@ -32,10 +32,10 @@
import org.foray.font.format.Kerning;
import org.foray.font.format.Panose4a;
import org.foray.font.output.FontPdfUtilities;
-import org.foray.font.ttf.table.TtfTableBase;
-import org.foray.font.ttf.table.TtfTableHead;
-import org.foray.font.ttf.table.TtfTableOs2;
-import org.foray.font.ttf.table.TtfTablePclt;
+import org.foray.font.ttf.table.BaseTable;
+import org.foray.font.ttf.table.HeadTable;
+import org.foray.font.ttf.table.Os2Table;
+import org.foray.font.ttf.table.PcltTable;
import org.foray.primitive.BitUtils;
import org.foray.primitive.sequence.ShortArrayBuilder;
@@ -65,7 +65,7 @@
private TtfTableCmap cmapTable = null;
/** The (required) "head" table instance. */
- private TtfTableHead headTable = null;
+ private HeadTable headTable = null;
/** The (required) "hhea" table instance. */
private TtfTableHhea hheaTable = null;
@@ -80,7 +80,7 @@
private TtfTableName nameTable = null;
/** The (required) "OS/2" table instance. */
- private TtfTableOs2 os2Table = null;
+ private Os2Table os2Table = null;
/** The (required) "post" table instance. */
private TtfTablePost postTable = null;
@@ -113,7 +113,7 @@
private TtfTableVorg vorgTable = null;
/** The (OTF, Advanced Typographic Table) "BASE" table instance. */
- private TtfTableBase baseTable = null;
+ private BaseTable baseTable = null;
/** The (OTF, Advanced Typographic Table) "GDEF" table instance. */
private TtfTableGdef gdefTable = null;
@@ -134,7 +134,7 @@
private TtfTableKern kernTable = null;
/** The (optional) "PCLT" table instance. */
- private TtfTablePclt pcltTable = null;
+ private PcltTable pcltTable = null;
/**
* Constructor.
@@ -165,7 +165,7 @@
/* Read the Font Header first. */
TtfOffsetTableRecord dirEntry = ttfTableDir.getTableDirectoryEntry("head");
- font.headTable = TtfTableHead.parse(dirEntry, raInput);
+ font.headTable = HeadTable.parse(dirEntry, raInput);
/* Then the Maximum Profile, so general sizes are known. */
dirEntry = ttfTableDir.getTableDirectoryEntry("maxp");
@@ -194,7 +194,7 @@
font.postTable = TtfTablePost.parse(dirEntry, raInput);
dirEntry = ttfTableDir.getTableDirectoryEntry("OS/2");
- font.os2Table = TtfTableOs2.parse(dirEntry, raInput);
+ font.os2Table = Os2Table.parse(dirEntry, raInput);
/* BEGIN TRUETYPE-OUTLINE TABLES **************************************************************************** */
@@ -250,7 +250,7 @@
dirEntry = ttfTableDir.getTableDirectoryEntry("BASE");
if (dirEntry != null) {
- font.baseTable = TtfTableBase.parse(dirEntry, raInput);
+ font.baseTable = BaseTable.parse(dirEntry, raInput);
}
dirEntry = ttfTableDir.getTableDirectoryEntry("GDEF");
@@ -282,7 +282,7 @@
dirEntry = ttfTableDir.getTableDirectoryEntry("PCLT");
if (dirEntry != null) {
- font.pcltTable = TtfTablePclt.parse(dirEntry, raInput);
+ font.pcltTable = PcltTable.parse(dirEntry, raInput);
}
dirEntry = ttfTableDir.getTableDirectoryEntry("kern");
@@ -305,7 +305,7 @@
* Package-visible setter, intended for testing.
* @param headTable The headTable value to set.
*/
- void setHeadTable(final TtfTableHead headTable) {
+ void setHeadTable(final HeadTable headTable) {
this.headTable = headTable;
}
@@ -313,7 +313,7 @@
* Returns the "head" table.
* @return The "head" table.
*/
- public TtfTableHead getHeadTable() {
+ public HeadTable getHeadTable() {
return this.headTable;
}
@@ -353,7 +353,7 @@
* Returns the "OS/2" table.
* @return The "OS/2" table.
*/
- public TtfTableOs2 getOs2Table() {
+ public Os2Table getOs2Table() {
return this.os2Table;
}
@@ -441,7 +441,7 @@
* Returns the "BASE" table.
* @return The "BASE" table.
*/
- public TtfTableBase getBaseTable() {
+ public BaseTable getBaseTable() {
return this.baseTable;
}
@@ -489,7 +489,7 @@
* Returns the "pclt" table.
* @return The "pclt" table.
*/
- public TtfTablePclt getPcltTable() {
+ public PcltTable getPcltTable() {
return this.pcltTable;
}
@@ -535,7 +535,7 @@
*/
/* Use the getter here to facilitate testing with a mock object. */
- final TtfTableHead headTable = this.getHeadTable();
+ final HeadTable headTable = this.getHeadTable();
final int unitsPerEm = headTable.unitsPerEm();
final double result = ((float) fUnits) * TypographicConstants.MILLIPOINTS_PER_POINT / unitsPerEm;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfSubSetFile.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfSubSetFile.java 2025-04-21 00:29:07 UTC (rev 13455)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfSubSetFile.java 2025-04-21 00:32:00 UTC (rev 13456)
@@ -30,7 +30,7 @@
import org.foray.font.Subset;
import org.foray.font.format.FontParser;
-import org.foray.font.ttf.table.TtfTableHead;
+import org.foray.font.ttf.table.HeadTable;
import org.axsl.constants.PrimitiveConstants;
@@ -152,7 +152,7 @@
this.offsetTableArray = createOffsetTable();
final byte[] headTable = this.tableMap.get("head");
- writeULong(headTable, TtfTableHead.CHECK_SUM_ADJUSTMENT_OFFSET,
+ writeULong(headTable, HeadTable.CHECK_SUM_ADJUSTMENT_OFFSET,
computeCheckSumAdjustment());
final List<byte[]> returnList = new ArrayList<byte[]>();
@@ -427,9 +427,9 @@
this.ttfFont.seekTab("head");
final byte[] byteArray = copyTableToByteArray(entry.getLength());
/* Set checkSumAdjustment to 0. */
- writeULong(byteArray, TtfTableHead.CHECK_SUM_ADJUSTMENT_OFFSET, 0);
+ writeULong(byteArray, HeadTable.CHECK_SUM_ADJUSTMENT_OFFSET, 0);
/* Write the index to loc format, setting it to "1". */
- int arrayIndex = TtfTableHead.INDEX_TO_LOC_FORMAT_OFFSET;
+ int arrayIndex = HeadTable.INDEX_TO_LOC_FORMAT_OFFSET;
byteArray[arrayIndex] = 0;
arrayIndex ++;
byteArray[arrayIndex] = 1;
@@ -909,7 +909,7 @@
sum = getCheckSum(byteArray, 0, byteArray.length);
sum = correctCheckSumForMax(sum);
}
- return (int) (TtfTableHead.CHECK_SUM_CONSTANT - sum);
+ return (int) (HeadTable.CHECK_SUM_CONSTANT - sum);
}
/**
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseTableParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseTableParser.java 2025-04-21 00:29:07 UTC (rev 13455)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseTableParser.java 2025-04-21 00:32:00 UTC (rev 13456)
@@ -37,7 +37,7 @@
/**
* Parses a TTF BASE table.
- * @see org.foray.font.ttf.table.TtfTableBase
+ * @see org.foray.font.ttf.table.BaseTable
*/
public class BaseTableParser extends FontParser {
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/HeadTableParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/HeadTableParser.java 2025-04-21 00:29:07 UTC (rev 13455)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/HeadTableParser.java 2025-04-21 00:32:00 UTC (rev 13456)
@@ -37,7 +37,7 @@
/**
* Parses a TTF HEAD table.
- * @see org.foray.font.ttf.table.TtfTableHead
+ * @see org.foray.font.ttf.table.HeadTable
*/
public class HeadTableParser extends FontParser {
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/Os2TableParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/Os2TableParser.java 2025-04-21 00:29:07 UTC (rev 13455)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/Os2TableParser.java 2025-04-21 00:32:00 UTC (rev 13456)
@@ -41,7 +41,7 @@
/**
* Parses a TTF OS/2 table.
- * @see org.foray.font.ttf.table.TtfTableOs2
+ * @see org.foray.font.ttf.table.Os2Table
*/
public class Os2TableParser extends FontParser {
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/PcltTableParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/PcltTableParser.java 2025-04-21 00:29:07 UTC (rev 13455)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/PcltTableParser.java 2025-04-21 00:32:00 UTC (rev 13456)
@@ -32,13 +32,13 @@
import org.foray.font.FontParser;
import org.foray.font.FontParserConsumer;
import org.foray.font.ttf.TtfRandomAccessInput;
-import org.foray.font.ttf.table.TtfTablePclt;
+import org.foray.font.ttf.table.PcltTable;
import java.io.IOException;
/**
* Parses a TTF PCLT table.
- * @see org.foray.font.ttf.table.TtfTablePclt
+ * @see org.foray.font.ttf.table.PcltTable
*/
public class PcltTableParser extends FontParser {
@@ -61,11 +61,11 @@
consumer.primitiveField("typeFamily", ferry.setInt(input.read_uint16())); // 2 bytes, total 16
consumer.primitiveField("capHeight", ferry.setInt(input.read_uint16())); // 2 bytes, total 18
consumer.primitiveField("symbolSet", ferry.setInt(input.read_uint16())); // 2 bytes, total 20
- consumer.objectField("typeface", input.readStringASCII(TtfTablePclt.TYPEFACE_CHARS));
+ consumer.objectField("typeface", input.readStringASCII(PcltTable.TYPEFACE_CHARS));
// 16 bytes, total 36
- consumer.objectField("characterComplement", input.readStringASCII(TtfTablePclt.CHARACTER_COMPLEMENT_CHARS));
+ consumer.objectField("characterComplement", input.readStringASCII(PcltTable.CHARACTER_COMPLEMENT_CHARS));
// 8 bytes, total 44
- consumer.objectField("fileName", input.readStringASCII(TtfTablePclt.FILE_NAME_CHARS));
+ consumer.objectField("fileName", input.readStringASCII(PcltTable.FILE_NAME_CHARS));
// 6 bytes, total 50
consumer.primitiveField("strokeWeight", ferry.setByte(input.read_int8())); // 1 bytes, total 51
consumer.primitiveField("widthType", ferry.setByte(input.read_int8())); // 1 bytes, total 52
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseTable.java (from rev 13455, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTableBase.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseTable.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/BaseTable.java 2025-04-21 00:32:00 UTC (rev 13456)
@@ -0,0 +1,114 @@
+/*
+ * 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.primitive.PrimitiveFerry;
+import org.foray.font.FontParserConsumer;
+import org.foray.font.ttf.TtfOffsetTableRecord;
+import org.foray.font.ttf.TtfRandomAccessInput;
+import org.foray.font.ttf.TtfTable;
+import org.foray.font.ttf.parse.BaseTableParser;
+
+import java.io.IOException;
+
+/**
+ * An OpenType "BASE" (Baseline Data) table.
+ * This table is an Advanced Typographic Table.
+ */
+public class BaseTable extends TtfTable {
+
+ /**
+ * The handler of events from the parser.
+ */
+ private final class ParserConsumer implements FontParserConsumer {
+
+ /** The client being built from the parser results. */
+ private BaseTable client;
+
+ /**
+ * Constructor.
+ * @param client The client being built from the parser results.
+ */
+ private ParserConsumer(final BaseTable client) {
+ this.client = client;
+ }
+
+ @Override
+ public void objectField(final String fieldName, final Object value) {
+ }
+
+ @Override
+ public void primitiveField(final String fieldName, final PrimitiveFerry value) {
+ switch (fieldName) {
+ case "majorVersion": client.majorVersion = (byte) value.getInt(); break;
+ }
+ }
+
+ }
+
+ /** The major verions of this table. */
+ private byte majorVersion;
+
+ /**
+ * Constructor.
+ * @param offsetRecord The parent table directory entry.
+ */
+ public BaseTable(final TtfOffsetTableRecord offsetRecord) {
+ super(offsetRecord);
+ }
+
+ /**
+ * Parse the table from the table content.
+ * @param dirEntry The parent table directory entry.
+ * @param input The input which is being parsed.
+ * @return The parsed instance.
+ * @throws IOException For I/O Error.
+ */
+ public static BaseTable parse(final TtfOffsetTableRecord dirEntry, final TtfRandomAccessInput input)
+ throws IOException {
+ final BaseTable table = new BaseTable(dirEntry);
+ final BaseTableParser parser = new BaseTableParser();
+ parser.parse(input, dirEntry.getOffset(), dirEntry.getLength(), table.new ParserConsumer(table));
+ return table;
+ }
+
+ @Override
+ public String getTableTag() {
+ return "BASE";
+ }
+
+ /**
+ * Returns the major version of this table.
+ * @return The major version of this table.
+ */
+ public int getMajorVersion() {
+ return this.majorVersion;
+ }
+
+}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HeadTable.java (from rev 13455, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTableHead.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HeadTable.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HeadTable.java 2025-04-21 00:32:00 UTC (rev 13456)
@@ -0,0 +1,158 @@
+/*
+ * Copyright 2004 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.data.BoundingBoxShort;
+import org.foray.common.data.BoundingBoxUtils;
+import org.foray.common.primitive.PrimitiveFerry;
+import org.foray.font.FontParserConsumer;
+import org.foray.font.ttf.TtfOffsetTableRecord;
+import org.foray.font.ttf.TtfRandomAccessInput;
+import org.foray.font.ttf.TtfTable;
+import org.foray.font.ttf.parse.HeadTableParser;
+
+import org.axsl.ps.BoundingBox;
+
+import java.io.IOException;
+
+/**
+ * Class representing a TTF "head" table.
+ */
+public class HeadTable extends TtfTable {
+
+ /**
+ * The handler of events from the parser.
+ */
+ private final class ParserConsumer implements FontParserConsumer {
+
+ /** The client being built from the parser results. */
+ private HeadTable client;
+
+ /**
+ * Constructor.
+ * @param client The client being built from the parser results.
+ */
+ private ParserConsumer(final HeadTable client) {
+ this.client = client;
+ }
+
+ @Override
+ public void objectField(final String fieldName, final Object value) {
+ switch (fieldName) {
+ case "boundingBox": {
+ final short[] boundingBoxArray = (short[]) value;
+ client.boundingBox = new BoundingBoxShort(boundingBoxArray);
+ break;
+ }
+ }
+ }
+
+ @Override
+ public void primitiveField(final String fieldName, final PrimitiveFerry value) {
+ switch (fieldName) {
+ case "unitsPerEm": client.unitsPerEm = value.getInt(); break;
+ case "indexToLocFormat": client.indexToLocFormat = value.getShort(); break;
+ }
+ }
+
+ }
+
+
+
+ /** Constant for the offset to the "checkSumAdjustment" in this table. */
+ public static final byte CHECK_SUM_ADJUSTMENT_OFFSET = 8;
+
+ /** Constant for the "indexToLocFormat" entry in this table. */
+ public static final byte INDEX_TO_LOC_FORMAT_OFFSET = 50;
+
+ /** A magic number used in the checksum computation. */
+ public static final int CHECK_SUM_CONSTANT = 0xB1B0AFBA;
+
+ /** The parsed "unitsPerEm". */
+ private int unitsPerEm;
+
+ /** The parsed bounding box. */
+ private BoundingBox boundingBox = BoundingBoxUtils.ZEROES;
+
+ /** The parsed "indexToLocFormat" value from this table. */
+ private short indexToLocFormat;
+
+ /**
+ * Constructor.
+ * @param dirEntry The parent table directory entry.
+ */
+ public HeadTable(final TtfOffsetTableRecord dirEntry) {
+ super(dirEntry);
+ }
+
+ /**
+ * Read the "head" table.
+ * @param dirEntry The parent table directory entry.
+ * @param input The input which is being parsed.
+ * @return The parsed instance.
+ * @throws IOException For I/O Error.
+ */
+ public static HeadTable parse(final TtfOffsetTableRecord dirEntry, final TtfRandomAccessInput input)
+ throws IOException {
+ final HeadTable head = new HeadTable(dirEntry);
+ final HeadTableParser parser = new HeadTableParser();
+ parser.parse(input, dirEntry.getOffset(), dirEntry.getLength(), head.new ParserConsumer(head));
+ return head;
+ }
+
+ @Override
+ public String getTableTag() {
+ return "head";
+ }
+
+ /**
+ * Indicates whether the "long" or "short" version of the "loca" table is used.
+ * @return True if and only if the "long" version of the "loca" table is used.
+ */
+ public boolean longLocaFormat() {
+ return this.indexToLocFormat == 1;
+ }
+
+ /**
+ * Returns the units-per-em value for this font.
+ * @return The units-per-em value.
+ */
+ public int unitsPerEm() {
+ return this.unitsPerEm;
+ }
+
+ /**
+ * Returns the bounding box for this font.
+ * @return The bounding box for this font.
+ */
+ public BoundingBox getBbox() {
+ return this.boundingBox;
+ }
+
+}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Os2Table.java (from rev 13455, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTableOs2.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Os2Table.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Os2Table.java 2025-04-21 00:32:00 UTC (rev 13456)
@@ -0,0 +1,220 @@
+/*
+ * Copyright 2004 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.primitive.PrimitiveFerry;
+import org.foray.font.FontParserConsumer;
+import org.foray.font.format.Panose4a;
+import org.foray.font.ttf.TtfOffsetTableRecord;
+import org.foray.font.ttf.TtfRandomAccessInput;
+import org.foray.font.ttf.TtfTable;
+import org.foray.font.ttf.parse.Os2TableParser;
+
+import org.checkerframework.checker.signedness.qual.Unsigned;
+
+import java.io.IOException;
+
+/**
+ * Class representing a TTF "OS/2" (OS/2 and Windows metrics) table.
+ */
+public class Os2Table extends TtfTable {
+
+ /**
+ * The handler of events from the parser.
+ */
+ private final class ParserConsumer implements FontParserConsumer {
+
+ /** The client being built from the parser results. */
+ private Os2Table client;
+
+ /**
+ * Constructor.
+ * @param client The client being built from the parser results.
+ */
+ private ParserConsumer(final Os2Table client) {
+ this.client = client;
+ }
+
+ @Override
+ public void objectField(final String fieldName, final Object value) {
+ switch (fieldName) {
+ case "panose": client.panose = Panose4a.forceInstance((@Unsigned byte[]) value);
+ }
+ }
+
+ @Override
+ public void primitiveField(final String fieldName, final PrimitiveFerry value) {
+ switch (fieldName) {
+ case "version": client.version = (byte) value.getShort(); break;
+ case "fstype": client.fsType = value.getInt(); break;
+ case "yStrikeoutSize": client.yStrikeoutSize = value.getShort(); break;
+ case "yStrikeoutPosition": client.yStrikeoutPosition = value.getShort(); break;
+ case "sTypoAscender": client.sTypoAscender = value.getShort(); break;
+ case "sTypoDescender": client.sTypoDescender = value.getShort(); break;
+ case "sxHeight": client.sxHeight = value.getShort(); break;
+ case "sCapHeight": client.sCapHeight = value.getShort(); break;
+ }
+ }
+
+ }
+
+ /** The version number of this table. */
+ private byte version;
+
+ /** The fsType value parsed from this table. */
+ private int fsType;
+
+ /** The yStrikeoutSize parsed from this table. */
+ private short yStrikeoutSize;
+
+ /** The yStrikeoutPosition parsed from this table. */
+ private short yStrikeoutPosition;
+
+ /** Array containing the Panose information. */
+ private Panose4a panose;
+
+ /** The parsed typographic ascender for this font. */
+ private int sTypoAscender;
+
+ /** The parsed typographic descender for this font. */
+ private int sTypoDescender;
+
+ /** The parsed x-height for this font. */
+ private short sxHeight;
+
+ /** The parsed Caps height for this font. */
+ private short sCapHeight;
+
+ /**
+ * Constructor.
+ * @param dirEntry The parent table directory entry.
+ */
+ public Os2Table(final TtfOffsetTableRecord dirEntry) {
+ super(dirEntry);
+ }
+
+ /**
+ * Reads the "OS/2" table.
+ * @param dirEntry The parent table directory entry.
+ * @param input The input which is being parsed.
+ * @return The parsed instance.
+ * @throws IOException For I/O Error.
+ */
+ public static Os2Table parse(final TtfOffsetTableRecord dirEntry, final TtfRandomAccessInput input)
+ throws IOException {
+ final Os2Table os2 = new Os2Table(dirEntry);
+ final Os2TableParser parser = new Os2TableParser();
+ parser.parse(input, dirEntry.getOffset(), dirEntry.getLength(), os2.new ParserConsumer(os2));
+ return os2;
+ }
+
+ @Override
+ public String getTableTag() {
+ return "OS/2";
+ }
+
+ /**
+ * Indicates whether this font is embeddable.
+ * @return True if and only if this font is embeddable.
+ */
+ public boolean isEmbeddable() {
+ if (this.fsType == 2) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ /**
+ * Returns the version of this table.
+ * @return The version of this table.
+ */
+ public int getVersion() {
+ return this.version;
+ }
+
+ /**
+ * Returns the typographic ascender value, in text space units.
+ * @return The typographic ascender.
+ */
+ public int getTypoAscender() {
+ return this.sTypoAscender;
+ }
+
+ /**
+ * Returns the typographic descender value, in text space units.
+ * @return The typographic descender.
+ */
+ public int getTypoDescender() {
+ return this.sTypoDescender;
+ }
+
+ /**
+ * Returns the parsed PANOSE information from the font file.
+ * @return The parsed PANOSE information.
+ */
+ public Panose4a getPanose() {
+ return this.panose;
+ }
+
+ /**
+ * Returns the parsed yStrikeoutSize value from the font file.
+ * @return The parsed yStrikeoutSize value.
+ */
+ public short getStrikeoutSize() {
+ return this.yStrikeoutSize;
+ }
+
+ /**
+ * Returns the parsed yStrikeoutPosition value from the font file.
+ * @return The parsed yStrikeoutPosition value.
+ */
+ public short getStrikeoutPosition() {
+ return this.yStrikeoutPosition;
+ }
+
+ /**
+ * Returns the parsed x-height value.
+ * This is only valid for OS/2 tables versions 2 and higher.
+ * @return The parsed x-height value.
+ */
+ public short getXHeight() {
+ return this.sxHeight;
+ }
+
+ /**
+ * Returns the parsed Cap-height value.
+ * This is only valid for OS/2 tables versions 2 and higher.
+ * @return The parsed Cap-height value.
+ */
+ public short getCapHeight() {
+ return this.sCapHeight;
+ }
+
+}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PcltTable.java (from rev 13455, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTablePclt.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PcltTable.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PcltTable.java 2025-04-21 00:32:00 UTC (rev 13456)
@@ -0,0 +1,157 @@
+/*
+ * Copyright 2004 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.primitive.PrimitiveFerry;
+import org.foray.font.FontParserConsumer;
+import org.foray.font.ttf.TtfOffsetTableRecord;
+import org.foray.font.ttf.TtfRandomAccessInput;
+import org.foray.font.ttf.TtfTable;
+import org.foray.font.ttf.parse.PcltTableParser;
+
+import java.io.IOException;
+
+/**
+ * Class representing a TTF "PCLT" (PCL 5) table.
+ */
+public class PcltTable extends TtfTable {
+
+ /**
+ * The handler of events from the parser.
+ */
+ private final class ParserConsumer implements FontParserConsumer {
+
+ /** The client being built from the parser results. */
+ private PcltTable client;
+
+ /**
+ * Constructor.
+ * @param client The client being built from the parser results.
+ */
+ private ParserConsumer(final PcltTable client) {
+ this.client = client;
+ }
+
+ @Override
+ public void objectField(final String fieldName, final Object value) {
+ }
+
+ @Override
+ public void primitiveField(final String fieldName, final PrimitiveFerry value) {
+ switch (fieldName) {
+ case "xHeight": client.xHeight = value.getInt(); break;
+ case "capHeight": client.capHeight = value.getInt(); break;
+ case "serifStyle": client.serifStyle = value.getShort(); break;
+ }
+ }
+
+ }
+
+ /** The size, in bytes, of the "typeface" field. */
+ public static final byte TYPEFACE_CHARS = 16;
+
+ /** The size, in bytes, of the "characterComplement" field. */
+ public static final byte CHARACTER_COMPLEMENT_CHARS = 8;
+
+ /** The size, in TTF "char"s of the "FileName" field. */
+ public static final byte FILE_NAME_CHARS = 6;
+
+ /** Mask suitable for determining whether the font has serifs by applying
+ * it against the "SerifStyle" byte.
+ * According to the PCLT doc, the font has serifs if the top two bits
+ * of the "SerifStyle" byte is equal to 2.
+ * The mask is therefore 1000,0000. */
+ private static final byte SERIF_STYLE_MASK = (byte) 0x80;
+
+ /** The cap height as parsed from this table, in text space units. */
+ private int capHeight;
+
+ /** The x-height as parsed from this table, in text spaces units. */
+ private int xHeight;
+
+ /** The serif style as parsed from this table. */
+ private short serifStyle;
+
+ /**
+ * Constructor.
+ * @param dirEntry The parent table directory entry.
+ */
+ public PcltTable(final TtfOffsetTableRecord dirEntry) {
+ super(dirEntry);
+ }
+
+ /**
+ * Reads the "PCLT" table to find xHeight and capHeight.
+ * @param dirEntry The parent table directory entry.
+ * @param input The input which is being parsed.
+ * @return The parsed instance.
+ * @throws IOException For I/O Error.
+ */
+ public static PcltTable parse(final TtfOffsetTableRecord dirEntry, final TtfRandomAccessInput input)
+ throws IOException {
+ final PcltTable pclt = new PcltTable(dirEntry);
+ final PcltTableParser parser = new PcltTableParser();
+ parser.parse(input, dirEntry.getOffset(), dirEntry.getLength(), pclt.new ParserConsumer(pclt));
+ return pclt;
+ }
+
+ @Override
+ public String getTableTag() {
+ return "PCLT";
+ }
+
+ /**
+ * Returns the cap height for this font.
+ * @return The cap height for this font.
+ */
+ public int getCapHeight() {
+ return this.capHeight;
+ }
+
+ /**
+ * Indicates whether this font has serifs.
+ * @return True if and only if this font has serifs.
+ */
+ public boolean hasSerifs() {
+ if ((this.serifStyle & PcltTable.SERIF_STYLE_MASK) == 0) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ /**
+ * Returns the x-height for this font.
+ * @return The x-height for this font.
+ */
+ public int getXHeight() {
+ return this.xHeight;
+ }
+
+}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTableBase.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTableBase.java 2025-04-21 00:29:07 UTC (rev 13455)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTableBase.java 2025-04-21 00:32:00 UTC (rev 13456)
@@ -1,114 +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.table;
-
-import org.foray.common.primitive.PrimitiveFerry;
-import org.foray.font.FontParserConsumer;
-import org.foray.font.ttf.TtfOffsetTableRecord;
-import org.foray.font.ttf.TtfRandomAccessInput;
-import org.foray.font.ttf.TtfTable;
-import org.foray.font.ttf.parse.BaseTableParser;
-
-import java.io.IOException;
-
-/**
- * An OpenType "BASE" (Baseline Data) table.
- * This table is an Advanced Typographic Table.
- */
-public class TtfTableBase extends TtfTable {
-
- /**
- * The handler of events from the parser.
- */
- private final class ParserConsumer implements FontParserConsumer {
-
- /** The client being built from the parser results. */
- private TtfTableBase client;
-
- /**
- * Constructor.
- * @param client The client being built from the parser results.
- */
- private ParserConsumer(final TtfTableBase client) {
- this.client = client;
- }
-
- @Override
- public void objectField(final String fieldName, final Object value) {
- }
-
- @Override
- public void primitiveField(final String fieldName, final PrimitiveFerry value) {
- switch (fieldName) {
- case "majorVersion": client.majorVersion = (byte) value.getInt(); break;
- }
- }
-
- }
-
- /** The major verions of this table. */
- private byte majorVersion;
-
- /**
- * Constructor.
- * @param offsetRecord The parent table directory entry.
- */
- public TtfTableBase(final TtfOffsetTableRecord offsetRecord) {
- super(offsetRecord);
- }
-
- /**
- * Parse the table from the table content.
- * @param dirEntry The parent table directory entry.
- * @param input The input which is being parsed.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
- */
- public static TtfTableBase parse(final TtfOffsetTableRecord dirEntry, final TtfRandomAccessInput input)
- throws IOException {
- final TtfTableBase table = new TtfTableBase(dirEntry);
- final BaseTableParser parser = new BaseTableParser();
- parser.parse(input, dirEntry.getOffset(), dirEntry.getLength(), table.new ParserConsumer(table));
- return table;
- }
-
- @Override
- public String getTableTag() {
- return "BASE";
- }
-
- /**
- * Returns the major version of this table.
- * @return The major version of this table.
- */
- public int getMajorVersion() {
- return this.majorVersion;
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTableHead.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTableHead.java 2025-04-21 00:29:07 UTC (rev 13455)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTableHead.java 2025-04-21 00:32:00 UTC (rev 13456)
@@ -1,158 +0,0 @@
-/*
- * Copyright 2004 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.data.BoundingBoxShort;
-import org.foray.common.data.BoundingBoxUtils;
-import org.foray.common.primitive.PrimitiveFerry;
-import org.foray.font.FontParserConsumer;
-import org.foray.font.ttf.TtfOffsetTableRecord;
-import org.foray.font.ttf.TtfRandomAccessInput;
-import org.foray.font.ttf.TtfTable;
-import org.foray.font.ttf.parse.HeadTableParser;
-
-import org.axsl.ps.BoundingBox;
-
-import java.io.IOException;
-
-/**
- * Class representing a TTF "head" table.
- */
-public class TtfTableHead extends TtfTable {
-
- /**
- * The handler of events from the parser.
- */
- private final class ParserConsumer implements FontParserConsumer {
-
- /** The client being built from the parser results. */
- private TtfTableHead client;
-
- /**
- * Constructor.
- * @param client The client being built from the parser results.
- */
- private ParserConsumer(final TtfTableHead client) {
- this.client = client;
- }
-
- @Override
- public void objectField(final String fieldName, final Object value) {
- switch (fieldName) {
- case "boundingBox": {
- final short[] boundingBoxArray = (short[]) value;
- client.boundingBox = new BoundingBoxShort(boundingBoxArray);
- break;
- }
- }
- }
-
- @Override
- public void primitiveField(final String fieldName, final PrimitiveFerry value) {
- switch (fieldName) {
- case "unitsPerEm": client.unitsPerEm = value.getInt(); break;
- case "indexToLocFormat": client.indexToLocFormat = value.getShort(); break;
- }
- }
-
- }
-
-
-
- /** Constant for the offset to the "checkSumAdjustment" in this table. */
- public static final byte CHECK_SUM_ADJUSTMENT_OFFSET = 8;
-
- /** Constant for the "indexToLocFormat" entry in this table. */
- public static final byte INDEX_TO_LOC_FORMAT_OFFSET = 50;
-
- /** A magic number used in the checksum computation. */
- public static final int CHECK_SUM_CONSTANT = 0xB1B0AFBA;
-
- /** The parsed "unitsPerEm". */
- private int unitsPerEm;
-
- /** The parsed bounding box. */
- private BoundingBox boundingBox = BoundingBoxUtils.ZEROES;
-
- /** The parsed "indexToLocFormat" value from this table. */
- private short indexToLocFormat;
-
- /**
- * Constructor.
- * @param dirEntry The parent table directory entry.
- */
- public TtfTableHead(final TtfOffsetTableRecord dirEntry) {
- super(dirEntry);
- }
-
- /**
- * Read the "head" table.
- * @param dirEntry The parent table directory entry.
- * @param input The input which is being parsed.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
- */
- public static TtfTableHead parse(final TtfOffsetTableRecord dirEntry, final TtfRandomAccessInput input)
- throws IOException {
- final TtfTableHead head = new TtfTableHead(dirEntry);
- final HeadTableParser parser = new HeadTableParser();
- parser.parse(input, dirEntry.getOffset(), dirEntry.getLength(), head.new ParserConsumer(head));
- return head;
- }
-
- @Override
- public String getTableTag() {
- return "head";
- }
-
- /**
- * Indicates whether the "long" or "short" version of the "loca" table is used.
- * @return True if and only if the "long" version of the "loca" table is used.
- */
- public boolean longLocaFormat() {
- return this.indexToLocFormat == 1;
- }
-
- /**
- * Returns the units-per-em value for this font.
- * @return The units-per-em value.
- */
- public int unitsPerEm() {
- return this.unitsPerEm;
- }
-
- /**
- * Returns the bounding box for this font.
- * @return The bounding box for this font.
- */
- public BoundingBox getBbox() {
- return this.boundingBox;
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTableOs2.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTableOs2.java 2025-04-21 00:29:07 UTC (rev 13455)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTableOs2.java 2025-04-21 00:32:00 UTC (rev 13456)
@@ -1,220 +0,0 @@
-/*
- * Copyright 2004 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.primitive.PrimitiveFerry;
-import org.foray.font.FontParserConsumer;
-import org.foray.font.format.Panose4a;
-import org.foray.font.ttf.TtfOffsetTableRecord;
-import org.foray.font.ttf.TtfRandomAccessInput;
-import org.foray.font.ttf.TtfTable;
-import org.foray.font.ttf.parse.Os2TableParser;
-
-import org.checkerframework.checker.signedness.qual.Unsigned;
-
-import java.io.IOException;
-
-/**
- * Class representing a TTF "OS/2" (OS/2 and Windows metrics) table.
- */
-public class TtfTableOs2 extends TtfTable {
-
- /**
- * The handler of events from the parser.
- */
- private final class ParserConsumer implements FontParserConsumer {
-
- /** The client being built from the parser results. */
- private TtfTableOs2 client;
-
- /**
- * Constructor.
- * @param client The client being built from the parser results.
- */
- private ParserConsumer(final TtfTableOs2 client) {
- this.client = client;
- }
-
- @Override
- public void objectField(final String fieldName, final Object value) {
- switch (fieldName) {
- case "panose": client.panose = Panose4a.forceInstance((@Unsigned byte[]) value);
- }
- }
-
- @Override
- public void primitiveField(final String fieldName, final PrimitiveFerry value) {
- switch (fieldName) {
- case "version": client.version = (byte) value.getShort(); break;
- case "fstype": client.fsType = value.getInt(); break;
- case "yStrikeoutSize": client.yStrikeoutSize = value.getShort(); break;
- case "yStrikeoutPosition": client.yStrikeoutPosition = value.getShort(); break;
- case "sTypoAscender": client.sTypoAscender = value.getShort(); break;
- case "sTypoDescender": client.sTypoDescender = value.getShort(); break;
- case "sxHeight": client.sxHeight = value.getShort(); break;
- case "sCapHeight": client.sCapHeight = value.getShort(); break;
- }
- }
-
- }
-
- /** The version number of this table. */
- private byte version;
-
- /** The fsType value parsed from this table. */
- private int fsType;
-
- /** The yStrikeoutSize parsed from this table. */
- private short yStrikeoutSize;
-
- /** The yStrikeoutPosition parsed from this table. */
- private short yStrikeoutPosition;
-
- /** Array containing the Panose information. */
- private Panose4a panose;
-
- /** The parsed typographic ascender for this font. */
- private int sTypoAscender;
-
- /** The parsed typographic descender for this font. */
- private int sTypoDescender;
-
- /** The parsed x-height for this font. */
- private short sxHeight;
-
- /** The parsed Caps height for this font. */
- private short sCapHeight;
-
- /**
- * Constructor.
- * @param dirEntry The parent table directory entry.
- */
- public TtfTableOs2(final TtfOffsetTableRecord dirEntry) {
- super(dirEntry);
- }
-
- /**
- * Reads the "OS/2" table.
- * @param dirEntry The parent table directory entry.
- * @param input The input which is being parsed.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
- */
- public static TtfTableOs2 parse(final TtfOffsetTableRecord dirEntry, final TtfRandomAccessInput input)
- throws IOException {
- final TtfTableOs2 os2 = new TtfTableOs2(dirEntry);
- final Os2TableParser parser = new Os2TableParser();
- parser.parse(input, dirEntry.getOffset(), dirEntry.getLength(), os2.new ParserConsumer(os2));
- return os2;
- }
-
- @Override
- public String getTableTag() {
- return "OS/2";
- }
-
- /**
- * Indicates whether this font is embeddable.
- * @return True if and only if this font is embeddable.
- */
- public boolean isEmbeddable() {
- if (this.fsType == 2) {
- return false;
- } else {
- return true;
- }
- }
-
- /**
- * Returns the version of this table.
- * @return The version of this table.
- */
- public int getVersion() {
- return this.version;
- }
-
- /**
- * Returns the typographic ascender value, in text space units.
- * @return The typographic ascender.
- */
- public int getTypoAscender() {
- return this.sTypoAscender;
- }
-
- /**
- * Returns the typographic descender value, in text space units.
- * @return The typographic descender.
- */
- public int getTypoDescender() {
- return this.sTypoDescender;
- }
-
- /**
- * Returns the parsed PANOSE information from the font file.
- * @return The parsed PANOSE information.
- */
- public Panose4a getPanose() {
- return this.panose;
- }
-
- /**
- * Returns the parsed yStrikeoutSize value from the font file.
- * @return The parsed yStrikeoutSize value.
- */
- public short getStrikeoutSize() {
- return this.yStrikeoutSize;
- }
-
- /**
- * Returns the parsed yStrikeoutPosition value from the font file.
- * @return The parsed yStrikeoutPosition value.
- */
- public short getStrikeoutPosition() {
- return this.yStrikeoutPosition;
- }
-
- /**
- * Returns the parsed x-height value.
- * This is only valid for OS/2 tables versions 2 and higher.
- * @return The parsed x-height value.
- */
- public short getXHeight() {
- return this.sxHeight;
- }
-
- /**
- * Returns the parsed Cap-height value.
- * This is only valid for OS/2 tables versions 2 and higher.
- * @return The parsed Cap-height value.
- */
- public short getCapHeight() {
- return this.sCapHeight;
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTablePclt.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTablePclt.java 2025-04-21 00:29:07 UTC (rev 13455)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTablePclt.java 2025-04-21 00:32:00 UTC (rev 13456)
@@ -1,157 +0,0 @@
-/*
- * Copyright 2004 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.primitive.PrimitiveFerry;
-import org.foray.font.FontParserConsumer;
-import org.foray.font.ttf.TtfOffsetTableRecord;
-import org.foray.font.ttf.TtfRandomAccessInput;
-import org.foray.font.ttf.TtfTable;
-import org.foray.font.ttf.parse.PcltTableParser;
-
-import java.io.IOException;
-
-/**
- * Class representing a TTF "PCLT" (PCL 5) table.
- */
-public class TtfTablePclt extends TtfTable {
-
- /**
- * The handler of events from the parser.
- */
- private final class ParserConsumer implements FontParserConsumer {
-
- /** The client being built from the parser results. */
- private TtfTablePclt client;
-
- /**
- * Constructor.
- * @param client The client being built from the parser results.
- */
- private ParserConsumer(final TtfTablePclt client) {
- this.client = client;
- }
-
- @Override
- public void objectField(final String fieldName, final Object value) {
- }
-
- @Override
- public void primitiveField(final String fieldName, final PrimitiveFerry value) {
- switch (fieldName) {
- case "xHeight": client.xHeight = value.getInt(); break;
- case "capHeight": client.capHeight = value.getInt(); break;
- case "serifStyle": client.serifStyle = value.getShort(); break;
- }
- }
-
- }
-
- /** The size, in bytes, of the "typeface" field. */
- public static final byte TYPEFACE_CHARS = 16;
-
- /** The size, in bytes, of the "characterComplement" field. */
- public static final byte CHARACTER_COMPLEMENT_CHARS = 8;
-
- /** The size, in TTF "char"s of the "FileName" field. */
- public static final byte FILE_NAME_CHARS = 6;
-
- /** Mask suitable for determining whether the font has serifs by applying
- * it against the "SerifStyle" byte.
- * According to the PCLT doc, the font has serifs if the top two bits
- * of the "SerifStyle" byte is equal to 2.
- * The mask is therefore 1000,0000. */
- private static final byte SERIF_STYLE_MASK = (byte) 0x80;
-
- /** The cap height as parsed from this table, in text space units. */
- private int capHeight;
-
- /** The x-height as parsed from this table, in text spaces units. */
- private int xHeight;
-
- /** The serif style as parsed from this table. */
- private short serifStyle;
-
- /**
- * Constructor.
- * @param dirEntry The parent table directory entry.
- */
- public TtfTablePclt(final TtfOffsetTableRecord dirEntry) {
- super(dirEntry);
- }
-
- /**
- * Reads the "PCLT" table to find xHeight and capHeight.
- * @param dirEntry The parent table directory entry.
- * @param input The input which is being parsed.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
- */
- public static TtfTablePclt parse(final TtfOffsetTableRecord dirEntry, final TtfRandomAccessInput input)
- throws IOException {
- final TtfTablePclt pclt = new TtfTablePclt(dirEntry);
- final PcltTableParser parser = new PcltTableParser();
- parser.parse(input, dirEntry.getOffset(), dirEntry.getLength(), pclt.new ParserConsumer(pclt));
- return pclt;
- }
-
- @Override
- public String getTableTag() {
- return "PCLT";
- }
-
- /**
- * Returns the cap height for this font.
- * @return The cap height for this font.
- */
- public int getCapHeight() {
- return this.capHeight;
- }
-
- /**
- * Indicates whether this font has serifs.
- * @return True if and only if this font has serifs.
- */
- public boolean hasSerifs() {
- if ((this.serifStyle & TtfTablePclt.SERIF_STYLE_MASK) == 0) {
- return false;
- } else {
- return true;
- }
- }
-
- /**
- * Returns the x-height for this font.
- * @return The x-height for this font.
- */
- public int getXHeight() {
- return this.xHeight;
- }
-
-}
Modified: trunk/foray/foray-font/src/test/java/org/foray/font/ttf/TrueTypeFontTests.java
===================================================================
--- trunk/foray/foray-font/src/test/java/org/foray/font/ttf/TrueTypeFontTests.java 2025-04-21 00:29:07 UTC (rev 13455)
+++ trunk/foray/foray-font/src/test/java/org/foray/font/ttf/TrueTypeFontTests.java 2025-04-21 00:32:00 UTC (rev 13456)
@@ -28,7 +28,7 @@
package org.foray.font.ttf;
-import org.foray.font.ttf.table.TtfTableHead;
+import org.foray.font.ttf.table.HeadTable;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
@@ -52,7 +52,7 @@
* long." We are not converting to pixels, but to a more abstract calculation of millipoints. Nevertheless, we
* will use this example in this test. */
- final TtfTableHead headTable = Mockito.mock(TtfTableHead.class);
+ final HeadTable headTable = Mockito.mock(HeadTable.class);
Mockito.when(headTable.unitsPerEm()).thenReturn(2048);
final TrueTypeFont out = new TrueTypeFont(null);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-21 00:29:25
|
Revision: 13455
http://sourceforge.net/p/foray/code/13455
Author: victormote
Date: 2025-04-21 00:29:07 +0000 (Mon, 21 Apr 2025)
Log Message:
-----------
Move table classes using the new parsing scheme to new package.
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/TtfSubSetFile.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseTableParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/HeadTableParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/Os2TableParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/PcltTableParser.java
trunk/foray/foray-font/src/test/java/org/foray/font/ttf/TrueTypeFontTests.java
Added Paths:
-----------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTableBase.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTableHead.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTableOs2.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTablePclt.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/package-info.java
Removed Paths:
-------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableBase.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableHead.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableOs2.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTablePclt.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-21 00:06:37 UTC (rev 13454)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-04-21 00:29:07 UTC (rev 13455)
@@ -32,6 +32,10 @@
import org.foray.font.format.Kerning;
import org.foray.font.format.Panose4a;
import org.foray.font.output.FontPdfUtilities;
+import org.foray.font.ttf.table.TtfTableBase;
+import org.foray.font.ttf.table.TtfTableHead;
+import org.foray.font.ttf.table.TtfTableOs2;
+import org.foray.font.ttf.table.TtfTablePclt;
import org.foray.primitive.BitUtils;
import org.foray.primitive.sequence.ShortArrayBuilder;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfSubSetFile.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfSubSetFile.java 2025-04-21 00:06:37 UTC (rev 13454)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfSubSetFile.java 2025-04-21 00:29:07 UTC (rev 13455)
@@ -30,6 +30,7 @@
import org.foray.font.Subset;
import org.foray.font.format.FontParser;
+import org.foray.font.ttf.table.TtfTableHead;
import org.axsl.constants.PrimitiveConstants;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTable.java 2025-04-21 00:06:37 UTC (rev 13454)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTable.java 2025-04-21 00:29:07 UTC (rev 13455)
@@ -119,7 +119,7 @@
* Constructor.
* @param tableDirEntry The TTFTableDirEntry that defines this table.
*/
- TtfTable(final TtfOffsetTableRecord tableDirEntry) {
+ public TtfTable(final TtfOffsetTableRecord tableDirEntry) {
this.tableDirEntry = tableDirEntry;
tableDirEntry.setTable(this);
}
@@ -128,13 +128,13 @@
* Return the 4-character name of this table, for example, "post" or "glyf".
* @return The name of this table.
*/
- abstract String getTableTag();
+ public abstract String getTableTag();
/**
* Returns the TTFTableDirEntry that goes with this table.
* @return The TTFTableDirEntry related to this table.
*/
- TtfOffsetTableRecord getTableDirEntry() {
+ public TtfOffsetTableRecord getTableDirEntry() {
return this.tableDirEntry;
}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableBase.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableBase.java 2025-04-21 00:06:37 UTC (rev 13454)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableBase.java 2025-04-21 00:29:07 UTC (rev 13455)
@@ -1,111 +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.primitive.PrimitiveFerry;
-import org.foray.font.FontParserConsumer;
-import org.foray.font.ttf.parse.BaseTableParser;
-
-import java.io.IOException;
-
-/**
- * An OpenType "BASE" (Baseline Data) table.
- * This table is an Advanced Typographic Table.
- */
-public class TtfTableBase extends TtfTable {
-
- /**
- * The handler of events from the parser.
- */
- private final class ParserConsumer implements FontParserConsumer {
-
- /** The client being built from the parser results. */
- private TtfTableBase client;
-
- /**
- * Constructor.
- * @param client The client being built from the parser results.
- */
- private ParserConsumer(final TtfTableBase client) {
- this.client = client;
- }
-
- @Override
- public void objectField(final String fieldName, final Object value) {
- }
-
- @Override
- public void primitiveField(final String fieldName, final PrimitiveFerry value) {
- switch (fieldName) {
- case "majorVersion": client.majorVersion = (byte) value.getInt(); break;
- }
- }
-
- }
-
- /** The major verions of this table. */
- private byte majorVersion;
-
- /**
- * Constructor.
- * @param offsetRecord The parent table directory entry.
- */
- public TtfTableBase(final TtfOffsetTableRecord offsetRecord) {
- super(offsetRecord);
- }
-
- /**
- * Parse the table from the table content.
- * @param dirEntry The parent table directory entry.
- * @param input The input which is being parsed.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
- */
- public static TtfTableBase parse(final TtfOffsetTableRecord dirEntry, final TtfRandomAccessInput input)
- throws IOException {
- final TtfTableBase table = new TtfTableBase(dirEntry);
- final BaseTableParser parser = new BaseTableParser();
- parser.parse(input, dirEntry.getOffset(), dirEntry.getLength(), table.new ParserConsumer(table));
- return table;
- }
-
- @Override
- public String getTableTag() {
- return "BASE";
- }
-
- /**
- * Returns the major version of this table.
- * @return The major version of this table.
- */
- public int getMajorVersion() {
- return this.majorVersion;
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableHead.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableHead.java 2025-04-21 00:06:37 UTC (rev 13454)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableHead.java 2025-04-21 00:29:07 UTC (rev 13455)
@@ -1,155 +0,0 @@
-/*
- * Copyright 2004 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.data.BoundingBoxShort;
-import org.foray.common.data.BoundingBoxUtils;
-import org.foray.common.primitive.PrimitiveFerry;
-import org.foray.font.FontParserConsumer;
-import org.foray.font.ttf.parse.HeadTableParser;
-
-import org.axsl.ps.BoundingBox;
-
-import java.io.IOException;
-
-/**
- * Class representing a TTF "head" table.
- */
-public class TtfTableHead extends TtfTable {
-
- /**
- * The handler of events from the parser.
- */
- private final class ParserConsumer implements FontParserConsumer {
-
- /** The client being built from the parser results. */
- private TtfTableHead client;
-
- /**
- * Constructor.
- * @param client The client being built from the parser results.
- */
- private ParserConsumer(final TtfTableHead client) {
- this.client = client;
- }
-
- @Override
- public void objectField(final String fieldName, final Object value) {
- switch (fieldName) {
- case "boundingBox": {
- final short[] boundingBoxArray = (short[]) value;
- client.boundingBox = new BoundingBoxShort(boundingBoxArray);
- break;
- }
- }
- }
-
- @Override
- public void primitiveField(final String fieldName, final PrimitiveFerry value) {
- switch (fieldName) {
- case "unitsPerEm": client.unitsPerEm = value.getInt(); break;
- case "indexToLocFormat": client.indexToLocFormat = value.getShort(); break;
- }
- }
-
- }
-
-
-
- /** Constant for the offset to the "checkSumAdjustment" in this table. */
- public static final byte CHECK_SUM_ADJUSTMENT_OFFSET = 8;
-
- /** Constant for the "indexToLocFormat" entry in this table. */
- public static final byte INDEX_TO_LOC_FORMAT_OFFSET = 50;
-
- /** A magic number used in the checksum computation. */
- public static final int CHECK_SUM_CONSTANT = 0xB1B0AFBA;
-
- /** The parsed "unitsPerEm". */
- private int unitsPerEm;
-
- /** The parsed bounding box. */
- private BoundingBox boundingBox = BoundingBoxUtils.ZEROES;
-
- /** The parsed "indexToLocFormat" value from this table. */
- private short indexToLocFormat;
-
- /**
- * Constructor.
- * @param dirEntry The parent table directory entry.
- */
- public TtfTableHead(final TtfOffsetTableRecord dirEntry) {
- super(dirEntry);
- }
-
- /**
- * Read the "head" table.
- * @param dirEntry The parent table directory entry.
- * @param input The input which is being parsed.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
- */
- public static TtfTableHead parse(final TtfOffsetTableRecord dirEntry, final TtfRandomAccessInput input)
- throws IOException {
- final TtfTableHead head = new TtfTableHead(dirEntry);
- final HeadTableParser parser = new HeadTableParser();
- parser.parse(input, dirEntry.getOffset(), dirEntry.getLength(), head.new ParserConsumer(head));
- return head;
- }
-
- @Override
- public String getTableTag() {
- return "head";
- }
-
- /**
- * Indicates whether the "long" or "short" version of the "loca" table is used.
- * @return True if and only if the "long" version of the "loca" table is used.
- */
- public boolean longLocaFormat() {
- return this.indexToLocFormat == 1;
- }
-
- /**
- * Returns the units-per-em value for this font.
- * @return The units-per-em value.
- */
- public int unitsPerEm() {
- return this.unitsPerEm;
- }
-
- /**
- * Returns the bounding box for this font.
- * @return The bounding box for this font.
- */
- public BoundingBox getBbox() {
- return this.boundingBox;
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableOs2.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableOs2.java 2025-04-21 00:06:37 UTC (rev 13454)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableOs2.java 2025-04-21 00:29:07 UTC (rev 13455)
@@ -1,217 +0,0 @@
-/*
- * Copyright 2004 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.primitive.PrimitiveFerry;
-import org.foray.font.FontParserConsumer;
-import org.foray.font.format.Panose4a;
-import org.foray.font.ttf.parse.Os2TableParser;
-
-import org.checkerframework.checker.signedness.qual.Unsigned;
-
-import java.io.IOException;
-
-/**
- * Class representing a TTF "OS/2" (OS/2 and Windows metrics) table.
- */
-public class TtfTableOs2 extends TtfTable {
-
- /**
- * The handler of events from the parser.
- */
- private final class ParserConsumer implements FontParserConsumer {
-
- /** The client being built from the parser results. */
- private TtfTableOs2 client;
-
- /**
- * Constructor.
- * @param client The client being built from the parser results.
- */
- private ParserConsumer(final TtfTableOs2 client) {
- this.client = client;
- }
-
- @Override
- public void objectField(final String fieldName, final Object value) {
- switch (fieldName) {
- case "panose": client.panose = Panose4a.forceInstance((@Unsigned byte[]) value);
- }
- }
-
- @Override
- public void primitiveField(final String fieldName, final PrimitiveFerry value) {
- switch (fieldName) {
- case "version": client.version = (byte) value.getShort(); break;
- case "fstype": client.fsType = value.getInt(); break;
- case "yStrikeoutSize": client.yStrikeoutSize = value.getShort(); break;
- case "yStrikeoutPosition": client.yStrikeoutPosition = value.getShort(); break;
- case "sTypoAscender": client.sTypoAscender = value.getShort(); break;
- case "sTypoDescender": client.sTypoDescender = value.getShort(); break;
- case "sxHeight": client.sxHeight = value.getShort(); break;
- case "sCapHeight": client.sCapHeight = value.getShort(); break;
- }
- }
-
- }
-
- /** The version number of this table. */
- private byte version;
-
- /** The fsType value parsed from this table. */
- private int fsType;
-
- /** The yStrikeoutSize parsed from this table. */
- private short yStrikeoutSize;
-
- /** The yStrikeoutPosition parsed from this table. */
- private short yStrikeoutPosition;
-
- /** Array containing the Panose information. */
- private Panose4a panose;
-
- /** The parsed typographic ascender for this font. */
- private int sTypoAscender;
-
- /** The parsed typographic descender for this font. */
- private int sTypoDescender;
-
- /** The parsed x-height for this font. */
- private short sxHeight;
-
- /** The parsed Caps height for this font. */
- private short sCapHeight;
-
- /**
- * Constructor.
- * @param dirEntry The parent table directory entry.
- */
- public TtfTableOs2(final TtfOffsetTableRecord dirEntry) {
- super(dirEntry);
- }
-
- /**
- * Reads the "OS/2" table.
- * @param dirEntry The parent table directory entry.
- * @param input The input which is being parsed.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
- */
- public static TtfTableOs2 parse(final TtfOffsetTableRecord dirEntry, final TtfRandomAccessInput input)
- throws IOException {
- final TtfTableOs2 os2 = new TtfTableOs2(dirEntry);
- final Os2TableParser parser = new Os2TableParser();
- parser.parse(input, dirEntry.getOffset(), dirEntry.getLength(), os2.new ParserConsumer(os2));
- return os2;
- }
-
- @Override
- public String getTableTag() {
- return "OS/2";
- }
-
- /**
- * Indicates whether this font is embeddable.
- * @return True if and only if this font is embeddable.
- */
- public boolean isEmbeddable() {
- if (this.fsType == 2) {
- return false;
- } else {
- return true;
- }
- }
-
- /**
- * Returns the version of this table.
- * @return The version of this table.
- */
- public int getVersion() {
- return this.version;
- }
-
- /**
- * Returns the typographic ascender value, in text space units.
- * @return The typographic ascender.
- */
- public int getTypoAscender() {
- return this.sTypoAscender;
- }
-
- /**
- * Returns the typographic descender value, in text space units.
- * @return The typographic descender.
- */
- public int getTypoDescender() {
- return this.sTypoDescender;
- }
-
- /**
- * Returns the parsed PANOSE information from the font file.
- * @return The parsed PANOSE information.
- */
- public Panose4a getPanose() {
- return this.panose;
- }
-
- /**
- * Returns the parsed yStrikeoutSize value from the font file.
- * @return The parsed yStrikeoutSize value.
- */
- public short getStrikeoutSize() {
- return this.yStrikeoutSize;
- }
-
- /**
- * Returns the parsed yStrikeoutPosition value from the font file.
- * @return The parsed yStrikeoutPosition value.
- */
- public short getStrikeoutPosition() {
- return this.yStrikeoutPosition;
- }
-
- /**
- * Returns the parsed x-height value.
- * This is only valid for OS/2 tables versions 2 and higher.
- * @return The parsed x-height value.
- */
- public short getXHeight() {
- return this.sxHeight;
- }
-
- /**
- * Returns the parsed Cap-height value.
- * This is only valid for OS/2 tables versions 2 and higher.
- * @return The parsed Cap-height value.
- */
- public short getCapHeight() {
- return this.sCapHeight;
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTablePclt.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTablePclt.java 2025-04-21 00:06:37 UTC (rev 13454)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTablePclt.java 2025-04-21 00:29:07 UTC (rev 13455)
@@ -1,154 +0,0 @@
-/*
- * Copyright 2004 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.primitive.PrimitiveFerry;
-import org.foray.font.FontParserConsumer;
-import org.foray.font.ttf.parse.PcltTableParser;
-
-import java.io.IOException;
-
-/**
- * Class representing a TTF "PCLT" (PCL 5) table.
- */
-public class TtfTablePclt extends TtfTable {
-
- /**
- * The handler of events from the parser.
- */
- private final class ParserConsumer implements FontParserConsumer {
-
- /** The client being built from the parser results. */
- private TtfTablePclt client;
-
- /**
- * Constructor.
- * @param client The client being built from the parser results.
- */
- private ParserConsumer(final TtfTablePclt client) {
- this.client = client;
- }
-
- @Override
- public void objectField(final String fieldName, final Object value) {
- }
-
- @Override
- public void primitiveField(final String fieldName, final PrimitiveFerry value) {
- switch (fieldName) {
- case "xHeight": client.xHeight = value.getInt(); break;
- case "capHeight": client.capHeight = value.getInt(); break;
- case "serifStyle": client.serifStyle = value.getShort(); break;
- }
- }
-
- }
-
- /** The size, in bytes, of the "typeface" field. */
- public static final byte TYPEFACE_CHARS = 16;
-
- /** The size, in bytes, of the "characterComplement" field. */
- public static final byte CHARACTER_COMPLEMENT_CHARS = 8;
-
- /** The size, in TTF "char"s of the "FileName" field. */
- public static final byte FILE_NAME_CHARS = 6;
-
- /** Mask suitable for determining whether the font has serifs by applying
- * it against the "SerifStyle" byte.
- * According to the PCLT doc, the font has serifs if the top two bits
- * of the "SerifStyle" byte is equal to 2.
- * The mask is therefore 1000,0000. */
- private static final byte SERIF_STYLE_MASK = (byte) 0x80;
-
- /** The cap height as parsed from this table, in text space units. */
- private int capHeight;
-
- /** The x-height as parsed from this table, in text spaces units. */
- private int xHeight;
-
- /** The serif style as parsed from this table. */
- private short serifStyle;
-
- /**
- * Constructor.
- * @param dirEntry The parent table directory entry.
- */
- public TtfTablePclt(final TtfOffsetTableRecord dirEntry) {
- super(dirEntry);
- }
-
- /**
- * Reads the "PCLT" table to find xHeight and capHeight.
- * @param dirEntry The parent table directory entry.
- * @param input The input which is being parsed.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
- */
- public static TtfTablePclt parse(final TtfOffsetTableRecord dirEntry, final TtfRandomAccessInput input)
- throws IOException {
- final TtfTablePclt pclt = new TtfTablePclt(dirEntry);
- final PcltTableParser parser = new PcltTableParser();
- parser.parse(input, dirEntry.getOffset(), dirEntry.getLength(), pclt.new ParserConsumer(pclt));
- return pclt;
- }
-
- @Override
- public String getTableTag() {
- return "PCLT";
- }
-
- /**
- * Returns the cap height for this font.
- * @return The cap height for this font.
- */
- public int getCapHeight() {
- return this.capHeight;
- }
-
- /**
- * Indicates whether this font has serifs.
- * @return True if and only if this font has serifs.
- */
- public boolean hasSerifs() {
- if ((this.serifStyle & TtfTablePclt.SERIF_STYLE_MASK) == 0) {
- return false;
- } else {
- return true;
- }
- }
-
- /**
- * Returns the x-height for this font.
- * @return The x-height for this font.
- */
- public int getXHeight() {
- return this.xHeight;
- }
-
-}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseTableParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseTableParser.java 2025-04-21 00:06:37 UTC (rev 13454)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseTableParser.java 2025-04-21 00:29:07 UTC (rev 13455)
@@ -37,7 +37,7 @@
/**
* Parses a TTF BASE table.
- * @see org.foray.font.ttf.TtfTableBase
+ * @see org.foray.font.ttf.table.TtfTableBase
*/
public class BaseTableParser extends FontParser {
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/HeadTableParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/HeadTableParser.java 2025-04-21 00:06:37 UTC (rev 13454)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/HeadTableParser.java 2025-04-21 00:29:07 UTC (rev 13455)
@@ -37,7 +37,7 @@
/**
* Parses a TTF HEAD table.
- * @see org.foray.font.ttf.TtfTableHead
+ * @see org.foray.font.ttf.table.TtfTableHead
*/
public class HeadTableParser extends FontParser {
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/Os2TableParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/Os2TableParser.java 2025-04-21 00:06:37 UTC (rev 13454)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/Os2TableParser.java 2025-04-21 00:29:07 UTC (rev 13455)
@@ -41,7 +41,7 @@
/**
* Parses a TTF OS/2 table.
- * @see org.foray.font.ttf.TtfTableOs2
+ * @see org.foray.font.ttf.table.TtfTableOs2
*/
public class Os2TableParser extends FontParser {
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/PcltTableParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/PcltTableParser.java 2025-04-21 00:06:37 UTC (rev 13454)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/PcltTableParser.java 2025-04-21 00:29:07 UTC (rev 13455)
@@ -32,13 +32,13 @@
import org.foray.font.FontParser;
import org.foray.font.FontParserConsumer;
import org.foray.font.ttf.TtfRandomAccessInput;
-import org.foray.font.ttf.TtfTablePclt;
+import org.foray.font.ttf.table.TtfTablePclt;
import java.io.IOException;
/**
* Parses a TTF PCLT table.
- * @see org.foray.font.ttf.TtfTablePclt
+ * @see org.foray.font.ttf.table.TtfTablePclt
*/
public class PcltTableParser extends FontParser {
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTableBase.java (from rev 13453, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableBase.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTableBase.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTableBase.java 2025-04-21 00:29:07 UTC (rev 13455)
@@ -0,0 +1,114 @@
+/*
+ * 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.primitive.PrimitiveFerry;
+import org.foray.font.FontParserConsumer;
+import org.foray.font.ttf.TtfOffsetTableRecord;
+import org.foray.font.ttf.TtfRandomAccessInput;
+import org.foray.font.ttf.TtfTable;
+import org.foray.font.ttf.parse.BaseTableParser;
+
+import java.io.IOException;
+
+/**
+ * An OpenType "BASE" (Baseline Data) table.
+ * This table is an Advanced Typographic Table.
+ */
+public class TtfTableBase extends TtfTable {
+
+ /**
+ * The handler of events from the parser.
+ */
+ private final class ParserConsumer implements FontParserConsumer {
+
+ /** The client being built from the parser results. */
+ private TtfTableBase client;
+
+ /**
+ * Constructor.
+ * @param client The client being built from the parser results.
+ */
+ private ParserConsumer(final TtfTableBase client) {
+ this.client = client;
+ }
+
+ @Override
+ public void objectField(final String fieldName, final Object value) {
+ }
+
+ @Override
+ public void primitiveField(final String fieldName, final PrimitiveFerry value) {
+ switch (fieldName) {
+ case "majorVersion": client.majorVersion = (byte) value.getInt(); break;
+ }
+ }
+
+ }
+
+ /** The major verions of this table. */
+ private byte majorVersion;
+
+ /**
+ * Constructor.
+ * @param offsetRecord The parent table directory entry.
+ */
+ public TtfTableBase(final TtfOffsetTableRecord offsetRecord) {
+ super(offsetRecord);
+ }
+
+ /**
+ * Parse the table from the table content.
+ * @param dirEntry The parent table directory entry.
+ * @param input The input which is being parsed.
+ * @return The parsed instance.
+ * @throws IOException For I/O Error.
+ */
+ public static TtfTableBase parse(final TtfOffsetTableRecord dirEntry, final TtfRandomAccessInput input)
+ throws IOException {
+ final TtfTableBase table = new TtfTableBase(dirEntry);
+ final BaseTableParser parser = new BaseTableParser();
+ parser.parse(input, dirEntry.getOffset(), dirEntry.getLength(), table.new ParserConsumer(table));
+ return table;
+ }
+
+ @Override
+ public String getTableTag() {
+ return "BASE";
+ }
+
+ /**
+ * Returns the major version of this table.
+ * @return The major version of this table.
+ */
+ public int getMajorVersion() {
+ return this.majorVersion;
+ }
+
+}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTableHead.java (from rev 13453, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableHead.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTableHead.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTableHead.java 2025-04-21 00:29:07 UTC (rev 13455)
@@ -0,0 +1,158 @@
+/*
+ * Copyright 2004 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.data.BoundingBoxShort;
+import org.foray.common.data.BoundingBoxUtils;
+import org.foray.common.primitive.PrimitiveFerry;
+import org.foray.font.FontParserConsumer;
+import org.foray.font.ttf.TtfOffsetTableRecord;
+import org.foray.font.ttf.TtfRandomAccessInput;
+import org.foray.font.ttf.TtfTable;
+import org.foray.font.ttf.parse.HeadTableParser;
+
+import org.axsl.ps.BoundingBox;
+
+import java.io.IOException;
+
+/**
+ * Class representing a TTF "head" table.
+ */
+public class TtfTableHead extends TtfTable {
+
+ /**
+ * The handler of events from the parser.
+ */
+ private final class ParserConsumer implements FontParserConsumer {
+
+ /** The client being built from the parser results. */
+ private TtfTableHead client;
+
+ /**
+ * Constructor.
+ * @param client The client being built from the parser results.
+ */
+ private ParserConsumer(final TtfTableHead client) {
+ this.client = client;
+ }
+
+ @Override
+ public void objectField(final String fieldName, final Object value) {
+ switch (fieldName) {
+ case "boundingBox": {
+ final short[] boundingBoxArray = (short[]) value;
+ client.boundingBox = new BoundingBoxShort(boundingBoxArray);
+ break;
+ }
+ }
+ }
+
+ @Override
+ public void primitiveField(final String fieldName, final PrimitiveFerry value) {
+ switch (fieldName) {
+ case "unitsPerEm": client.unitsPerEm = value.getInt(); break;
+ case "indexToLocFormat": client.indexToLocFormat = value.getShort(); break;
+ }
+ }
+
+ }
+
+
+
+ /** Constant for the offset to the "checkSumAdjustment" in this table. */
+ public static final byte CHECK_SUM_ADJUSTMENT_OFFSET = 8;
+
+ /** Constant for the "indexToLocFormat" entry in this table. */
+ public static final byte INDEX_TO_LOC_FORMAT_OFFSET = 50;
+
+ /** A magic number used in the checksum computation. */
+ public static final int CHECK_SUM_CONSTANT = 0xB1B0AFBA;
+
+ /** The parsed "unitsPerEm". */
+ private int unitsPerEm;
+
+ /** The parsed bounding box. */
+ private BoundingBox boundingBox = BoundingBoxUtils.ZEROES;
+
+ /** The parsed "indexToLocFormat" value from this table. */
+ private short indexToLocFormat;
+
+ /**
+ * Constructor.
+ * @param dirEntry The parent table directory entry.
+ */
+ public TtfTableHead(final TtfOffsetTableRecord dirEntry) {
+ super(dirEntry);
+ }
+
+ /**
+ * Read the "head" table.
+ * @param dirEntry The parent table directory entry.
+ * @param input The input which is being parsed.
+ * @return The parsed instance.
+ * @throws IOException For I/O Error.
+ */
+ public static TtfTableHead parse(final TtfOffsetTableRecord dirEntry, final TtfRandomAccessInput input)
+ throws IOException {
+ final TtfTableHead head = new TtfTableHead(dirEntry);
+ final HeadTableParser parser = new HeadTableParser();
+ parser.parse(input, dirEntry.getOffset(), dirEntry.getLength(), head.new ParserConsumer(head));
+ return head;
+ }
+
+ @Override
+ public String getTableTag() {
+ return "head";
+ }
+
+ /**
+ * Indicates whether the "long" or "short" version of the "loca" table is used.
+ * @return True if and only if the "long" version of the "loca" table is used.
+ */
+ public boolean longLocaFormat() {
+ return this.indexToLocFormat == 1;
+ }
+
+ /**
+ * Returns the units-per-em value for this font.
+ * @return The units-per-em value.
+ */
+ public int unitsPerEm() {
+ return this.unitsPerEm;
+ }
+
+ /**
+ * Returns the bounding box for this font.
+ * @return The bounding box for this font.
+ */
+ public BoundingBox getBbox() {
+ return this.boundingBox;
+ }
+
+}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTableOs2.java (from rev 13453, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableOs2.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTableOs2.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTableOs2.java 2025-04-21 00:29:07 UTC (rev 13455)
@@ -0,0 +1,220 @@
+/*
+ * Copyright 2004 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.primitive.PrimitiveFerry;
+import org.foray.font.FontParserConsumer;
+import org.foray.font.format.Panose4a;
+import org.foray.font.ttf.TtfOffsetTableRecord;
+import org.foray.font.ttf.TtfRandomAccessInput;
+import org.foray.font.ttf.TtfTable;
+import org.foray.font.ttf.parse.Os2TableParser;
+
+import org.checkerframework.checker.signedness.qual.Unsigned;
+
+import java.io.IOException;
+
+/**
+ * Class representing a TTF "OS/2" (OS/2 and Windows metrics) table.
+ */
+public class TtfTableOs2 extends TtfTable {
+
+ /**
+ * The handler of events from the parser.
+ */
+ private final class ParserConsumer implements FontParserConsumer {
+
+ /** The client being built from the parser results. */
+ private TtfTableOs2 client;
+
+ /**
+ * Constructor.
+ * @param client The client being built from the parser results.
+ */
+ private ParserConsumer(final TtfTableOs2 client) {
+ this.client = client;
+ }
+
+ @Override
+ public void objectField(final String fieldName, final Object value) {
+ switch (fieldName) {
+ case "panose": client.panose = Panose4a.forceInstance((@Unsigned byte[]) value);
+ }
+ }
+
+ @Override
+ public void primitiveField(final String fieldName, final PrimitiveFerry value) {
+ switch (fieldName) {
+ case "version": client.version = (byte) value.getShort(); break;
+ case "fstype": client.fsType = value.getInt(); break;
+ case "yStrikeoutSize": client.yStrikeoutSize = value.getShort(); break;
+ case "yStrikeoutPosition": client.yStrikeoutPosition = value.getShort(); break;
+ case "sTypoAscender": client.sTypoAscender = value.getShort(); break;
+ case "sTypoDescender": client.sTypoDescender = value.getShort(); break;
+ case "sxHeight": client.sxHeight = value.getShort(); break;
+ case "sCapHeight": client.sCapHeight = value.getShort(); break;
+ }
+ }
+
+ }
+
+ /** The version number of this table. */
+ private byte version;
+
+ /** The fsType value parsed from this table. */
+ private int fsType;
+
+ /** The yStrikeoutSize parsed from this table. */
+ private short yStrikeoutSize;
+
+ /** The yStrikeoutPosition parsed from this table. */
+ private short yStrikeoutPosition;
+
+ /** Array containing the Panose information. */
+ private Panose4a panose;
+
+ /** The parsed typographic ascender for this font. */
+ private int sTypoAscender;
+
+ /** The parsed typographic descender for this font. */
+ private int sTypoDescender;
+
+ /** The parsed x-height for this font. */
+ private short sxHeight;
+
+ /** The parsed Caps height for this font. */
+ private short sCapHeight;
+
+ /**
+ * Constructor.
+ * @param dirEntry The parent table directory entry.
+ */
+ public TtfTableOs2(final TtfOffsetTableRecord dirEntry) {
+ super(dirEntry);
+ }
+
+ /**
+ * Reads the "OS/2" table.
+ * @param dirEntry The parent table directory entry.
+ * @param input The input which is being parsed.
+ * @return The parsed instance.
+ * @throws IOException For I/O Error.
+ */
+ public static TtfTableOs2 parse(final TtfOffsetTableRecord dirEntry, final TtfRandomAccessInput input)
+ throws IOException {
+ final TtfTableOs2 os2 = new TtfTableOs2(dirEntry);
+ final Os2TableParser parser = new Os2TableParser();
+ parser.parse(input, dirEntry.getOffset(), dirEntry.getLength(), os2.new ParserConsumer(os2));
+ return os2;
+ }
+
+ @Override
+ public String getTableTag() {
+ return "OS/2";
+ }
+
+ /**
+ * Indicates whether this font is embeddable.
+ * @return True if and only if this font is embeddable.
+ */
+ public boolean isEmbeddable() {
+ if (this.fsType == 2) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ /**
+ * Returns the version of this table.
+ * @return The version of this table.
+ */
+ public int getVersion() {
+ return this.version;
+ }
+
+ /**
+ * Returns the typographic ascender value, in text space units.
+ * @return The typographic ascender.
+ */
+ public int getTypoAscender() {
+ return this.sTypoAscender;
+ }
+
+ /**
+ * Returns the typographic descender value, in text space units.
+ * @return The typographic descender.
+ */
+ public int getTypoDescender() {
+ return this.sTypoDescender;
+ }
+
+ /**
+ * Returns the parsed PANOSE information from the font file.
+ * @return The parsed PANOSE information.
+ */
+ public Panose4a getPanose() {
+ return this.panose;
+ }
+
+ /**
+ * Returns the parsed yStrikeoutSize value from the font file.
+ * @return The parsed yStrikeoutSize value.
+ */
+ public short getStrikeoutSize() {
+ return this.yStrikeoutSize;
+ }
+
+ /**
+ * Returns the parsed yStrikeoutPosition value from the font file.
+ * @return The parsed yStrikeoutPosition value.
+ */
+ public short getStrikeoutPosition() {
+ return this.yStrikeoutPosition;
+ }
+
+ /**
+ * Returns the parsed x-height value.
+ * This is only valid for OS/2 tables versions 2 and higher.
+ * @return The parsed x-height value.
+ */
+ public short getXHeight() {
+ return this.sxHeight;
+ }
+
+ /**
+ * Returns the parsed Cap-height value.
+ * This is only valid for OS/2 tables versions 2 and higher.
+ * @return The parsed Cap-height value.
+ */
+ public short getCapHeight() {
+ return this.sCapHeight;
+ }
+
+}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTablePclt.java (from rev 13453, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTablePclt.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTablePclt.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/TtfTablePclt.java 2025-04-21 00:29:07 UTC (rev 13455)
@@ -0,0 +1,157 @@
+/*
+ * Copyright 2004 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.primitive.PrimitiveFerry;
+import org.foray.font.FontParserConsumer;
+import org.foray.font.ttf.TtfOffsetTableRecord;
+import org.foray.font.ttf.TtfRandomAccessInput;
+import org.foray.font.ttf.TtfTable;
+import org.foray.font.ttf.parse.PcltTableParser;
+
+import java.io.IOException;
+
+/**
+ * Class representing a TTF "PCLT" (PCL 5) table.
+ */
+public class TtfTablePclt extends TtfTable {
+
+ /**
+ * The handler of events from the parser.
+ */
+ private final class ParserConsumer implements FontParserConsumer {
+
+ /** The client being built from the parser results. */
+ private TtfTablePclt client;
+
+ /**
+ * Constructor.
+ * @param client The client being built from the parser results.
+ */
+ private ParserConsumer(final TtfTablePclt client) {
+ this.client = client;
+ }
+
+ @Override
+ public void objectField(final String fieldName, final Object value) {
+ }
+
+ @Override
+ public void primitiveField(final String fieldName, final PrimitiveFerry value) {
+ switch (fieldName) {
+ case "xHeight": client.xHeight = value.getInt(); break;
+ case "capHeight": client.capHeight = value.getInt(); break;
+ case "serifStyle": client.serifStyle = value.getShort(); break;
+ }
+ }
+
+ }
+
+ /** The size, in bytes, of the "typeface" field. */
+ public static final byte TYPEFACE_CHARS = 16;
+
+ /** The size, in bytes, of the "characterComplement" field. */
+ public static final byte CHARACTER_COMPLEMENT_CHARS = 8;
+
+ /** The size, in TTF "char"s of the "FileName" field. */
+ public static final byte FILE_NAME_CHARS = 6;
+
+ /** Mask suitable for determining whether the font has serifs by applying
+ * it against the "SerifStyle" byte.
+ * According to the PCLT doc, the font has serifs if the top two bits
+ * of the "SerifStyle" byte is equal to 2.
+ * The mask is therefore 1000,0000. */
+ private static final byte SERIF_STYLE_MASK = (byte) 0x80;
+
+ /** The cap height as parsed from this table, in text space units. */
+ private int capHeight;
+
+ /** The x-height as parsed from this table, in text spaces units. */
+ private int xHeight;
+
+ /** The serif style as parsed from this table. */
+ private short serifStyle;
+
+ /**
+ * Constructor.
+ * @param dirEntry The parent table directory entry.
+ */
+ public TtfTablePclt(final TtfOffsetTableRecord dirEntry) {
+ super(dirEntry);
+ }
+
+ /**
+ * Reads the "PCLT" table to find xHeight and capHeight.
+ * @param dirEntry The parent table directory entry.
+ * @param input The input which is being parsed.
+ * @return The parsed instance.
+ * @throws IOException For I/O Error.
+ */
+ public static TtfTablePclt parse(final TtfOffsetTableRecord dirEntry, final TtfRandomAccessInput input)
+ throws IOException {
+ final TtfTablePclt pclt = new TtfTablePclt(dirEntry);
+ final PcltTableParser parser = new PcltTableParser();
+ parser.parse(input, dirEntry.getOffset(), dirEntry.getLength(), pclt.new ParserConsumer(pclt));
+ return pclt;
+ }
+
+ @Override
+ public String getTableTag() {
+ return "PCLT";
+ }
+
+ /**
+ * Returns the cap height for this font.
+ * @return The cap height for this font.
+ */
+ public int getCapHeight() {
+ return this.capHeight;
+ }
+
+ /**
+ * Indicates whether this font has serifs.
+ * @return True if and only if this font has serifs.
+ */
+ public boolean hasSerifs() {
+ if ((this.serifStyle & TtfTablePclt.SERIF_STYLE_MASK) == 0) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ /**
+ * Returns the x-height for this font.
+ * @return The x-height for this font.
+ */
+ public int getXHeight() {
+ return this.xHeight;
+ }
+
+}
Added: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/package-info.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/package-info.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/package-info.java 2025-04-21 00:29:07 UTC (rev 13455)
@@ -0,0 +1,32 @@
+/*
+ * 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$
+ */
+
+/**
+ * Class for the TTF tables.
+ */
+package org.foray.font.ttf.table;
Property changes on: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/package-info.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-font/src/test/java/org/foray/font/ttf/TrueTypeFontTests.java
===================================================================
--- trunk/foray/foray-font/src/test/java/org/foray/font/ttf/TrueTypeFontTests.java 2025-04-21 00:06:37 UTC (rev 13454)
+++ trunk/foray/foray-font/src/test/java/org/foray/font/ttf/TrueTypeFontTests.java 2025-04-21 00:29:07 UTC (rev 13455)
@@ -28,6 +28,8 @@
package org.foray.font.ttf;
+import org.foray.font.ttf.table.TtfTableHead;
+
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-21 00:06:55
|
Revision: 13454
http://sourceforge.net/p/foray/code/13454
Author: victormote
Date: 2025-04-21 00:06:37 +0000 (Mon, 21 Apr 2025)
Log Message:
-----------
Rename package, for eventual clarity.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/FontUse4a.java
trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java
trunk/foray/foray-font/src/main/java/org/foray/font/config/ConfigGenerator.java
trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontContent.java
trunk/foray/foray-font/src/main/java/org/foray/font/format/FontParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeCollectionLister.java
trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1Font.java
trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1FontParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1FontParserPfa.java
trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1FontParserPfb.java
trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1Metrics.java
trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1MetricsParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1MetricsParserAfm.java
trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1MetricsParserPfm.java
trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1MetricsSerializer.java
trunk/foray/foray-font/src/main/java/org/foray/font/type1/package-info.java
trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Courier-Bold.jbso
trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Courier-BoldOblique.jbso
trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Courier-Oblique.jbso
trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Courier.jbso
trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Helvetica-Bold.jbso
trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Helvetica-BoldOblique.jbso
trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Helvetica-Oblique.jbso
trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Helvetica.jbso
trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Symbol.jbso
trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Times-Bold.jbso
trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Times-BoldItalic.jbso
trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Times-Italic.jbso
trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Times-Roman.jbso
trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/ZapfDingbats.jbso
trunk/foray/foray-font/src/test/java/org/foray/font/type1/Type1MetricsParserAfmTests.java
Added Paths:
-----------
trunk/foray/foray-font/src/main/java/org/foray/font/type1/
trunk/foray/foray-font/src/test/java/org/foray/font/type1/
trunk/foray/foray-font/src/test/java/org/foray/font/type1/Type1FontParserPfaTests.java
trunk/foray/foray-font/src/test/java/org/foray/font/type1/Type1FontParserPfbTests.java
Removed Paths:
-------------
trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/
trunk/foray/foray-font/src/test/java/org/foray/font/format/type1/
trunk/foray/foray-font/src/test/java/org/foray/font/type1/Type1FontParserPfaTests.java
trunk/foray/foray-font/src/test/java/org/foray/font/type1/Type1FontParserPfbTests.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FontUse4a.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FontUse4a.java 2025-04-20 23:58:42 UTC (rev 13453)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FontUse4a.java 2025-04-21 00:06:37 UTC (rev 13454)
@@ -31,9 +31,9 @@
import org.foray.common.primitive.CharSequenceUtils;
import org.foray.common.primitive.UnicodeCharUtils;
import org.foray.font.config.RegisteredFont;
-import org.foray.font.format.type1.Type1Font;
import org.foray.font.ttf.TrueTypeFont;
import org.foray.font.ttf.TtfTableGsub;
+import org.foray.font.type1.Type1Font;
import org.foray.primitive.sequence.ByteArray;
import org.foray.primitive.sequence.IntArrayBuilder;
import org.foray.primitive.sequence.ShortArrayBuilder;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java 2025-04-20 23:58:42 UTC (rev 13453)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java 2025-04-21 00:06:37 UTC (rev 13454)
@@ -32,12 +32,12 @@
import org.foray.font.config.RegisteredFontContent;
import org.foray.font.format.FontFileFormat;
import org.foray.font.format.FontParser;
-import org.foray.font.format.type1.Type1Font;
-import org.foray.font.format.type1.Type1FontParser;
-import org.foray.font.format.type1.Type1FontParserPfa;
-import org.foray.font.format.type1.Type1FontParserPfb;
-import org.foray.font.format.type1.Type1Metrics;
-import org.foray.font.format.type1.Type1MetricsParser;
+import org.foray.font.type1.Type1Font;
+import org.foray.font.type1.Type1FontParser;
+import org.foray.font.type1.Type1FontParserPfa;
+import org.foray.font.type1.Type1FontParserPfb;
+import org.foray.font.type1.Type1Metrics;
+import org.foray.font.type1.Type1MetricsParser;
import org.axsl.constants.TypographicConstants;
import org.axsl.font.Font;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/config/ConfigGenerator.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/config/ConfigGenerator.java 2025-04-20 23:58:42 UTC (rev 13453)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/config/ConfigGenerator.java 2025-04-21 00:06:37 UTC (rev 13454)
@@ -31,9 +31,9 @@
import org.foray.font.FontServer4a;
import org.foray.font.format.FontContent;
import org.foray.font.format.FontParser;
-import org.foray.font.format.type1.Type1Font;
import org.foray.font.ttf.TrueTypeContainer;
import org.foray.font.ttf.TrueTypeFont;
+import org.foray.font.type1.Type1Font;
import org.axsl.font.FontException;
import org.axsl.value.FontStyle;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontContent.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontContent.java 2025-04-20 23:58:42 UTC (rev 13453)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontContent.java 2025-04-21 00:06:37 UTC (rev 13454)
@@ -38,8 +38,8 @@
import org.foray.font.format.FontParser;
import org.foray.font.format.FontParserClient;
import org.foray.font.format.Panose4a;
-import org.foray.font.format.type1.Type1MetricsParser;
import org.foray.font.ttf.TtfRandomAccessInput;
+import org.foray.font.type1.Type1MetricsParser;
import org.foray.primitive.sequence.ByteArray;
import org.axsl.font.Font;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/format/FontParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/FontParser.java 2025-04-20 23:58:42 UTC (rev 13453)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/FontParser.java 2025-04-21 00:06:37 UTC (rev 13454)
@@ -28,13 +28,13 @@
package org.foray.font.format;
-import org.foray.font.format.type1.Type1FontParser;
-import org.foray.font.format.type1.Type1FontParserPfa;
-import org.foray.font.format.type1.Type1FontParserPfb;
import org.foray.font.ttf.TrueTypeCollection;
import org.foray.font.ttf.TrueTypeSingle;
import org.foray.font.ttf.TtfOffsetTable;
import org.foray.font.ttf.TtfRandomAccessInput;
+import org.foray.font.type1.Type1FontParser;
+import org.foray.font.type1.Type1FontParserPfa;
+import org.foray.font.type1.Type1FontParserPfb;
import org.axsl.font.Font;
import org.axsl.font.FontException;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeCollectionLister.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeCollectionLister.java 2025-04-20 23:58:42 UTC (rev 13453)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeCollectionLister.java 2025-04-21 00:06:37 UTC (rev 13454)
@@ -33,7 +33,7 @@
import org.foray.font.format.FontContent;
import org.foray.font.format.FontParser;
import org.foray.font.format.FontParserClient;
-import org.foray.font.format.type1.Type1MetricsSerializer;
+import org.foray.font.type1.Type1MetricsSerializer;
import org.axsl.font.FontException;
import org.axsl.ps.BoundingBox;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1Font.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1Font.java 2025-04-20 23:58:42 UTC (rev 13453)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1Font.java 2025-04-21 00:06:37 UTC (rev 13454)
@@ -26,7 +26,7 @@
* $LastChangedBy$
*/
-package org.foray.font.format.type1;
+package org.foray.font.type1;
import org.foray.font.format.FontContent;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1FontParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1FontParser.java 2025-04-20 23:58:42 UTC (rev 13453)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1FontParser.java 2025-04-21 00:06:37 UTC (rev 13454)
@@ -26,7 +26,7 @@
* $LastChangedBy$
*/
-package org.foray.font.format.type1;
+package org.foray.font.type1;
import org.foray.common.RandomAccessInput;
import org.foray.font.format.FontParser;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1FontParserPfa.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1FontParserPfa.java 2025-04-20 23:58:42 UTC (rev 13453)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1FontParserPfa.java 2025-04-21 00:06:37 UTC (rev 13454)
@@ -26,7 +26,7 @@
* $LastChangedBy$
*/
-package org.foray.font.format.type1;
+package org.foray.font.type1;
import org.foray.common.ByteSequenceSearcher;
import org.foray.font.format.FontParser;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1FontParserPfb.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1FontParserPfb.java 2025-04-20 23:58:42 UTC (rev 13453)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1FontParserPfb.java 2025-04-21 00:06:37 UTC (rev 13454)
@@ -26,7 +26,7 @@
* $LastChangedBy$
*/
-package org.foray.font.format.type1;
+package org.foray.font.type1;
import org.foray.font.format.FontParser;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1Metrics.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1Metrics.java 2025-04-20 23:58:42 UTC (rev 13453)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1Metrics.java 2025-04-21 00:06:37 UTC (rev 13454)
@@ -26,7 +26,7 @@
* $LastChangedBy$
*/
-package org.foray.font.format.type1;
+package org.foray.font.type1;
import org.foray.common.data.BoundingBoxUtils;
import org.foray.font.format.Kerning;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1MetricsParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1MetricsParser.java 2025-04-20 23:58:42 UTC (rev 13453)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1MetricsParser.java 2025-04-21 00:06:37 UTC (rev 13454)
@@ -26,7 +26,7 @@
* $LastChangedBy$
*/
-package org.foray.font.format.type1;
+package org.foray.font.type1;
import org.foray.common.RandomAccessInput;
import org.foray.common.sequence.ByteSequenceParser;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1MetricsParserAfm.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1MetricsParserAfm.java 2025-04-20 23:58:42 UTC (rev 13453)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1MetricsParserAfm.java 2025-04-21 00:06:37 UTC (rev 13454)
@@ -26,7 +26,7 @@
* $LastChangedBy$
*/
-package org.foray.font.format.type1;
+package org.foray.font.type1;
import org.foray.common.RandomAccessInput;
import org.foray.common.data.BoundingBoxUtils;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1MetricsParserPfm.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1MetricsParserPfm.java 2025-04-20 23:58:42 UTC (rev 13453)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1MetricsParserPfm.java 2025-04-21 00:06:37 UTC (rev 13454)
@@ -26,7 +26,7 @@
* $LastChangedBy$
*/
-package org.foray.font.format.type1;
+package org.foray.font.type1;
import org.foray.common.RandomAccessInput;
import org.foray.font.FontServer4a;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1MetricsSerializer.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/Type1MetricsSerializer.java 2025-04-20 23:58:42 UTC (rev 13453)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1MetricsSerializer.java 2025-04-21 00:06:37 UTC (rev 13454)
@@ -26,7 +26,7 @@
* $LastChangedBy$
*/
-package org.foray.font.format.type1;
+package org.foray.font.type1;
import org.foray.common.ForayConstants;
import org.foray.common.IoUtil;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/type1/package-info.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/type1/package-info.java 2025-04-20 23:58:42 UTC (rev 13453)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/type1/package-info.java 2025-04-21 00:06:37 UTC (rev 13454)
@@ -29,4 +29,4 @@
/**
* <p>Classes handling the parsing and content of Type1 fonts and metrics.</p>
*/
-package org.foray.font.format.type1;
+package org.foray.font.type1;
Modified: trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Courier-Bold.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Courier-BoldOblique.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Courier-Oblique.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Courier.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Helvetica-Bold.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Helvetica-BoldOblique.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Helvetica-Oblique.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Helvetica.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Symbol.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Times-Bold.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Times-BoldItalic.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Times-Italic.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/Times-Roman.jbso
===================================================================
(Binary files differ)
Modified: trunk/foray/foray-font/src/main/resources/resources/org/foray/font/base14/ZapfDingbats.jbso
===================================================================
(Binary files differ)
Deleted: trunk/foray/foray-font/src/test/java/org/foray/font/type1/Type1FontParserPfaTests.java
===================================================================
--- trunk/foray/foray-font/src/test/java/org/foray/font/format/type1/Type1FontParserPfaTests.java 2025-04-20 23:51:44 UTC (rev 13452)
+++ trunk/foray/foray-font/src/test/java/org/foray/font/type1/Type1FontParserPfaTests.java 2025-04-21 00:06:37 UTC (rev 13454)
@@ -1,107 +0,0 @@
-/*
- * Copyright 2007 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.format.type1;
-
-import org.foray.font.FontServer4a;
-import org.foray.font.format.FontParser;
-import org.foray.font.format.ttf.TtfRandomAccessInput;
-
-import org.axsl.font.FontException;
-import org.axsl.ps.BoundingBox;
-import org.axsl.ps.PsCharStringsDictionary;
-import org.axsl.ps.PsFontDictionary;
-import org.axsl.ps.PsFontInfoDictionary;
-import org.axsl.ps.PsFontPrivateDictionary;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.jupiter.api.Test;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.math.BigDecimal;
-
-/**
- * JUnit test class for the class {@link Type1FontParserPfaTests}.
- */
-public class Type1FontParserPfaTests {
-
- /**
- * Tests basic ability to parse a Type 1 PFA file.
- * @throws FontException For font system errors.
- * @throws IOException For errors reading the test file.
- */
- @Test
- public void testParse() throws FontException, IOException {
- final String path = "/source-utah.edu/utopia-1.0/putr.pfa";
- final InputStream inputStream = getClass().getResourceAsStream(path);
- assertNotNull(inputStream);
- final FontServer4a fontServer = new FontServer4a();
- final TtfRandomAccessInput bsp = new TtfRandomAccessInput.Impl(inputStream);
- final FontParser reader = new FontParser(fontServer, bsp);
- assertNotNull(reader);
- final Type1FontParserPfa parser = new Type1FontParserPfa(reader);
- assertNotNull(parser);
-
- final Type1Font font = parser.parse();
- assertNotNull(font);
- assertEquals(866, font.getLength1());
- assertEquals(70956, font.getLength2());
- assertEquals(532, font.getLength3());
-
- final PsFontDictionary fontDict = font.getFontDictionary();
- assertNotNull(fontDict);
-
- assertEquals(1, fontDict.getFontType());
- assertEquals("Utopia-Regular", fontDict.getFontName());
-
- /* Expected values in this section obtained from observation of the AFM file. */
- final PsFontInfoDictionary fontInfoDict = fontDict.getFontInfoDictionary();
- assertNotNull(fontInfoDict);
-
- assertEquals("Utopia-Regular", fontDict.getFontName());
-
- final BoundingBox fontBBox = fontDict.getFontBbox();
- assertEquals(-158, fontBBox.getCoordinateAsInt(0));
- assertEquals(-250, fontBBox.getCoordinateAsInt(1));
- assertEquals(1158, fontBBox.getCoordinateAsInt(2));
- assertEquals(890, fontBBox.getCoordinateAsInt(3));
-
- assertEquals("Regular", fontInfoDict.getWeight());
- assertEquals(BigDecimal.ZERO, fontInfoDict.getItalicAngle());
- assertEquals(false, fontInfoDict.isFixedPitch());
-
- final PsFontPrivateDictionary privateDict = fontDict.getPrivateDictionary();
- assertNotNull(privateDict);
-
- final PsCharStringsDictionary charStringsDict = fontDict.getCharStringsDictionary();
- assertNotNull(charStringsDict);
- }
-
-}
Copied: trunk/foray/foray-font/src/test/java/org/foray/font/type1/Type1FontParserPfaTests.java (from rev 13453, trunk/foray/foray-font/src/test/java/org/foray/font/format/type1/Type1FontParserPfaTests.java)
===================================================================
--- trunk/foray/foray-font/src/test/java/org/foray/font/type1/Type1FontParserPfaTests.java (rev 0)
+++ trunk/foray/foray-font/src/test/java/org/foray/font/type1/Type1FontParserPfaTests.java 2025-04-21 00:06:37 UTC (rev 13454)
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2007 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.type1;
+
+import org.foray.font.FontServer4a;
+import org.foray.font.format.FontParser;
+import org.foray.font.ttf.TtfRandomAccessInput;
+
+import org.axsl.font.FontException;
+import org.axsl.ps.BoundingBox;
+import org.axsl.ps.PsCharStringsDictionary;
+import org.axsl.ps.PsFontDictionary;
+import org.axsl.ps.PsFontInfoDictionary;
+import org.axsl.ps.PsFontPrivateDictionary;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigDecimal;
+
+/**
+ * JUnit test class for the class {@link Type1FontParserPfaTests}.
+ */
+public class Type1FontParserPfaTests {
+
+ /**
+ * Tests basic ability to parse a Type 1 PFA file.
+ * @throws FontException For font system errors.
+ * @throws IOException For errors reading the test file.
+ */
+ @Test
+ public void testParse() throws FontException, IOException {
+ final String path = "/source-utah.edu/utopia-1.0/putr.pfa";
+ final InputStream inputStream = getClass().getResourceAsStream(path);
+ assertNotNull(inputStream);
+ final FontServer4a fontServer = new FontServer4a();
+ final TtfRandomAccessInput bsp = new TtfRandomAccessInput.Impl(inputStream);
+ final FontParser reader = new FontParser(fontServer, bsp);
+ assertNotNull(reader);
+ final Type1FontParserPfa parser = new Type1FontParserPfa(reader);
+ assertNotNull(parser);
+
+ final Type1Font font = parser.parse();
+ assertNotNull(font);
+ assertEquals(866, font.getLength1());
+ assertEquals(70956, font.getLength2());
+ assertEquals(532, font.getLength3());
+
+ final PsFontDictionary fontDict = font.getFontDictionary();
+ assertNotNull(fontDict);
+
+ assertEquals(1, fontDict.getFontType());
+ assertEquals("Utopia-Regular", fontDict.getFontName());
+
+ /* Expected values in this section obtained from observation of the AFM file. */
+ final PsFontInfoDictionary fontInfoDict = fontDict.getFontInfoDictionary();
+ assertNotNull(fontInfoDict);
+
+ assertEquals("Utopia-Regular", fontDict.getFontName());
+
+ final BoundingBox fontBBox = fontDict.getFontBbox();
+ assertEquals(-158, fontBBox.getCoordinateAsInt(0));
+ assertEquals(-250, fontBBox.getCoordinateAsInt(1));
+ assertEquals(1158, fontBBox.getCoordinateAsInt(2));
+ assertEquals(890, fontBBox.getCoordinateAsInt(3));
+
+ assertEquals("Regular", fontInfoDict.getWeight());
+ assertEquals(BigDecimal.ZERO, fontInfoDict.getItalicAngle());
+ assertEquals(false, fontInfoDict.isFixedPitch());
+
+ final PsFontPrivateDictionary privateDict = fontDict.getPrivateDictionary();
+ assertNotNull(privateDict);
+
+ final PsCharStringsDictionary charStringsDict = fontDict.getCharStringsDictionary();
+ assertNotNull(charStringsDict);
+ }
+
+}
Deleted: trunk/foray/foray-font/src/test/java/org/foray/font/type1/Type1FontParserPfbTests.java
===================================================================
--- trunk/foray/foray-font/src/test/java/org/foray/font/format/type1/Type1FontParserPfbTests.java 2025-04-20 23:51:44 UTC (rev 13452)
+++ trunk/foray/foray-font/src/test/java/org/foray/font/type1/Type1FontParserPfbTests.java 2025-04-21 00:06:37 UTC (rev 13454)
@@ -1,107 +0,0 @@
-/*
- * Copyright 2007 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.format.type1;
-
-import org.foray.font.FontServer4a;
-import org.foray.font.format.FontParser;
-import org.foray.font.format.ttf.TtfRandomAccessInput;
-
-import org.axsl.font.FontException;
-import org.axsl.ps.BoundingBox;
-import org.axsl.ps.PsCharStringsDictionary;
-import org.axsl.ps.PsFontDictionary;
-import org.axsl.ps.PsFontInfoDictionary;
-import org.axsl.ps.PsFontPrivateDictionary;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.jupiter.api.Test;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.math.BigDecimal;
-
-/**
- * JUnit test class for the class {@link Type1FontParserPfbTests}.
- */
-public class Type1FontParserPfbTests {
-
- /**
- * Tests basic ability to parse a Type 1 PFB file.
- * @throws FontException For font system errors.
- * @throws IOException For errors reading the test file.
- */
- @Test
- public void testParse() throws FontException, IOException {
- final String path = "/source-ams/computer-modern/cmps-pc/cmpsfont/fonts/cmr10.pfb";
- final InputStream inputStream = getClass().getResourceAsStream(path);
- assertNotNull(inputStream);
- final FontServer4a fontServer = new FontServer4a();
- final TtfRandomAccessInput bsp = new TtfRandomAccessInput.Impl(inputStream);
- final FontParser reader = new FontParser(fontServer, bsp);
- assertNotNull(reader);
- final Type1FontParserPfb parser = new Type1FontParserPfb(reader);
- assertNotNull(parser);
-
- final Type1Font font = parser.parse();
- assertNotNull(font);
- assertEquals(3611, font.getLength1());
- assertEquals(22718, font.getLength2());
- assertEquals(533, font.getLength3());
-
- final PsFontDictionary fontDict = font.getFontDictionary();
- assertNotNull(fontDict);
-
- assertEquals(1, fontDict.getFontType());
- assertEquals("CMR10", fontDict.getFontName());
-
- /* Expected values in this section obtained from observation of the PFB file. */
- final PsFontInfoDictionary fontInfoDict = fontDict.getFontInfoDictionary();
- assertNotNull(fontInfoDict);
-
- assertEquals("CMR10", fontDict.getFontName());
-
- final BoundingBox fontBBox = fontDict.getFontBbox();
- assertEquals(-251, fontBBox.getCoordinateAsInt(0));
- assertEquals(-250, fontBBox.getCoordinateAsInt(1));
- assertEquals(1009, fontBBox.getCoordinateAsInt(2));
- assertEquals(969, fontBBox.getCoordinateAsInt(3));
-
- assertEquals("Medium", fontInfoDict.getWeight());
- assertEquals(BigDecimal.ZERO, fontInfoDict.getItalicAngle());
- assertEquals(false, fontInfoDict.isFixedPitch());
-
- final PsFontPrivateDictionary privateDict = fontDict.getPrivateDictionary();
- assertNotNull(privateDict);
-
- final PsCharStringsDictionary charStringsDict = fontDict.getCharStringsDictionary();
- assertNotNull(charStringsDict);
- }
-
-}
Copied: trunk/foray/foray-font/src/test/java/org/foray/font/type1/Type1FontParserPfbTests.java (from rev 13453, trunk/foray/foray-font/src/test/java/org/foray/font/format/type1/Type1FontParserPfbTests.java)
===================================================================
--- trunk/foray/foray-font/src/test/java/org/foray/font/type1/Type1FontParserPfbTests.java (rev 0)
+++ trunk/foray/foray-font/src/test/java/org/foray/font/type1/Type1FontParserPfbTests.java 2025-04-21 00:06:37 UTC (rev 13454)
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2007 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.type1;
+
+import org.foray.font.FontServer4a;
+import org.foray.font.format.FontParser;
+import org.foray.font.ttf.TtfRandomAccessInput;
+
+import org.axsl.font.FontException;
+import org.axsl.ps.BoundingBox;
+import org.axsl.ps.PsCharStringsDictionary;
+import org.axsl.ps.PsFontDictionary;
+import org.axsl.ps.PsFontInfoDictionary;
+import org.axsl.ps.PsFontPrivateDictionary;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigDecimal;
+
+/**
+ * JUnit test class for the class {@link Type1FontParserPfbTests}.
+ */
+public class Type1FontParserPfbTests {
+
+ /**
+ * Tests basic ability to parse a Type 1 PFB file.
+ * @throws FontException For font system errors.
+ * @throws IOException For errors reading the test file.
+ */
+ @Test
+ public void testParse() throws FontException, IOException {
+ final String path = "/source-ams/computer-modern/cmps-pc/cmpsfont/fonts/cmr10.pfb";
+ final InputStream inputStream = getClass().getResourceAsStream(path);
+ assertNotNull(inputStream);
+ final FontServer4a fontServer = new FontServer4a();
+ final TtfRandomAccessInput bsp = new TtfRandomAccessInput.Impl(inputStream);
+ final FontParser reader = new FontParser(fontServer, bsp);
+ assertNotNull(reader);
+ final Type1FontParserPfb parser = new Type1FontParserPfb(reader);
+ assertNotNull(parser);
+
+ final Type1Font font = parser.parse();
+ assertNotNull(font);
+ assertEquals(3611, font.getLength1());
+ assertEquals(22718, font.getLength2());
+ assertEquals(533, font.getLength3());
+
+ final PsFontDictionary fontDict = font.getFontDictionary();
+ assertNotNull(fontDict);
+
+ assertEquals(1, fontDict.getFontType());
+ assertEquals("CMR10", fontDict.getFontName());
+
+ /* Expected values in this section obtained from observation of the PFB file. */
+ final PsFontInfoDictionary fontInfoDict = fontDict.getFontInfoDictionary();
+ assertNotNull(fontInfoDict);
+
+ assertEquals("CMR10", fontDict.getFontName());
+
+ final BoundingBox fontBBox = fontDict.getFontBbox();
+ assertEquals(-251, fontBBox.getCoordinateAsInt(0));
+ assertEquals(-250, fontBBox.getCoordinateAsInt(1));
+ assertEquals(1009, fontBBox.getCoordinateAsInt(2));
+ assertEquals(969, fontBBox.getCoordinateAsInt(3));
+
+ assertEquals("Medium", fontInfoDict.getWeight());
+ assertEquals(BigDecimal.ZERO, fontInfoDict.getItalicAngle());
+ assertEquals(false, fontInfoDict.isFixedPitch());
+
+ final PsFontPrivateDictionary privateDict = fontDict.getPrivateDictionary();
+ assertNotNull(privateDict);
+
+ final PsCharStringsDictionary charStringsDict = fontDict.getCharStringsDictionary();
+ assertNotNull(charStringsDict);
+ }
+
+}
Modified: trunk/foray/foray-font/src/test/java/org/foray/font/type1/Type1MetricsParserAfmTests.java
===================================================================
--- trunk/foray/foray-font/src/test/java/org/foray/font/format/type1/Type1MetricsParserAfmTests.java 2025-04-20 23:51:44 UTC (rev 13452)
+++ trunk/foray/foray-font/src/test/java/org/foray/font/type1/Type1MetricsParserAfmTests.java 2025-04-21 00:06:37 UTC (rev 13454)
@@ -26,7 +26,7 @@
* $LastChangedBy$
*/
-package org.foray.font.format.type1;
+package org.foray.font.type1;
import org.foray.common.sequence.ByteSequenceParser;
import org.foray.font.FontServer4a;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-20 23:59:03
|
Revision: 13453
http://sourceforge.net/p/foray/code/13453
Author: victormote
Date: 2025-04-20 23:58:42 +0000 (Sun, 20 Apr 2025)
Log Message:
-----------
Rename package, for eventual clarity.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/FontParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/FontUse4a.java
trunk/foray/foray-font/src/main/java/org/foray/font/FsTrueTypeFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/config/ConfigGenerator.java
trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontContent.java
trunk/foray/foray-font/src/main/java/org/foray/font/format/FontParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/package-info.java
trunk/foray/foray-font/src/test/java/org/foray/font/FsTrueTypeFontTests.java
trunk/foray/foray-font/src/test/java/org/foray/font/format/type1/Type1FontParserPfaTests.java
trunk/foray/foray-font/src/test/java/org/foray/font/format/type1/Type1FontParserPfbTests.java
trunk/foray/foray-font/src/test/java/org/foray/font/ttf/OtfLookupGsubTests.java
trunk/foray/foray-font/src/test/java/org/foray/font/ttf/TrueTypeCollectionParserTests.java
trunk/foray/foray-font/src/test/java/org/foray/font/ttf/TrueTypeFontTests.java
Added Paths:
-----------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/AbstractOtfLayoutTable.java
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
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfFeature.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLanguageSystem.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsub.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubSubtable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx01x01.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx01x02.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx02x01.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx03x01.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx04x01.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx05x01.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx05x02.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx05x03.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx06x01.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx06x02.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx06x03.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx07x01.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx08x01.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfScript.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeCollection.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeCollectionLister.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeContainer.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeSingle.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtcTableHeader.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfMtxEntry.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfOffsetTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfOffsetTableRecord.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfRandomAccessInput.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfSubSetFile.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTable.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableBase.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableCff.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableCff2.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableCmap.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableCvt.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableFpgm.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableGasp.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableGdef.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableGlyf.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableGpos.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableGsub.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableHead.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableHhea.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableHmtx.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableJstf.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableKern.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableLoca.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableMath.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableMaxp.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableName.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableOs2.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTablePclt.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTablePost.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTablePrep.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfTableVorg.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfType.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/package-info.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/BaseTableParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/HeadTableParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/Os2TableParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/PcltTableParser.java
trunk/foray/foray-font/src/test/java/org/foray/font/ttf/
trunk/foray/foray-font/src/test/java/org/foray/font/ttf/TrueTypeFontParserTests.java
Removed Paths:
-------------
trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/parse/TtfTableOs2Parser.java
trunk/foray/foray-font/src/test/java/org/foray/font/format/ttf/
trunk/foray/foray-font/src/test/java/org/foray/font/ttf/TrueTypeFontParserTests.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FontParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FontParser.java 2025-04-20 23:51:44 UTC (rev 13452)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FontParser.java 2025-04-20 23:58:42 UTC (rev 13453)
@@ -28,7 +28,7 @@
package org.foray.font;
-import org.foray.font.format.ttf.TtfRandomAccessInput;
+import org.foray.font.ttf.TtfRandomAccessInput;
import java.io.IOException;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FontUse4a.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FontUse4a.java 2025-04-20 23:51:44 UTC (rev 13452)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FontUse4a.java 2025-04-20 23:58:42 UTC (rev 13453)
@@ -31,9 +31,9 @@
import org.foray.common.primitive.CharSequenceUtils;
import org.foray.common.primitive.UnicodeCharUtils;
import org.foray.font.config.RegisteredFont;
-import org.foray.font.format.ttf.TrueTypeFont;
-import org.foray.font.format.ttf.TtfTableGsub;
import org.foray.font.format.type1.Type1Font;
+import org.foray.font.ttf.TrueTypeFont;
+import org.foray.font.ttf.TtfTableGsub;
import org.foray.primitive.sequence.ByteArray;
import org.foray.primitive.sequence.IntArrayBuilder;
import org.foray.primitive.sequence.ShortArrayBuilder;
@@ -394,7 +394,7 @@
}
/**
- * Returns the encapsulated {@link org.foray.font.format.ttf.TrueTypeFont} instance, if one exists.
+ * Returns the encapsulated {@link org.foray.font.ttf.TrueTypeFont} instance, if one exists.
* @return The encapsulated TrueTypeFont, or null if this font is not a free-standing TrueType font.
*/
private TrueTypeFont getTrueTypeFont() {
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/FsTrueTypeFont.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/FsTrueTypeFont.java 2025-04-20 23:51:44 UTC (rev 13452)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FsTrueTypeFont.java 2025-04-20 23:58:42 UTC (rev 13453)
@@ -32,9 +32,9 @@
import org.foray.common.data.BoundingBoxShort;
import org.foray.common.data.BoundingBoxUtils;
import org.foray.font.config.RegisteredFontContent;
-import org.foray.font.format.ttf.TrueTypeContainer;
-import org.foray.font.format.ttf.TrueTypeFont;
-import org.foray.font.format.ttf.TtfSubSetFile;
+import org.foray.font.ttf.TrueTypeContainer;
+import org.foray.font.ttf.TrueTypeFont;
+import org.foray.font.ttf.TtfSubSetFile;
import org.axsl.font.Font;
import org.axsl.font.FontException;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/config/ConfigGenerator.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/config/ConfigGenerator.java 2025-04-20 23:51:44 UTC (rev 13452)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/config/ConfigGenerator.java 2025-04-20 23:58:42 UTC (rev 13453)
@@ -31,9 +31,9 @@
import org.foray.font.FontServer4a;
import org.foray.font.format.FontContent;
import org.foray.font.format.FontParser;
-import org.foray.font.format.ttf.TrueTypeContainer;
-import org.foray.font.format.ttf.TrueTypeFont;
import org.foray.font.format.type1.Type1Font;
+import org.foray.font.ttf.TrueTypeContainer;
+import org.foray.font.ttf.TrueTypeFont;
import org.axsl.font.FontException;
import org.axsl.value.FontStyle;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontContent.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontContent.java 2025-04-20 23:51:44 UTC (rev 13452)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/config/RegisteredFontContent.java 2025-04-20 23:58:42 UTC (rev 13453)
@@ -38,8 +38,8 @@
import org.foray.font.format.FontParser;
import org.foray.font.format.FontParserClient;
import org.foray.font.format.Panose4a;
-import org.foray.font.format.ttf.TtfRandomAccessInput;
import org.foray.font.format.type1.Type1MetricsParser;
+import org.foray.font.ttf.TtfRandomAccessInput;
import org.foray.primitive.sequence.ByteArray;
import org.axsl.font.Font;
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/format/FontParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/FontParser.java 2025-04-20 23:51:44 UTC (rev 13452)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/FontParser.java 2025-04-20 23:58:42 UTC (rev 13453)
@@ -28,13 +28,13 @@
package org.foray.font.format;
-import org.foray.font.format.ttf.TrueTypeCollection;
-import org.foray.font.format.ttf.TrueTypeSingle;
-import org.foray.font.format.ttf.TtfOffsetTable;
-import org.foray.font.format.ttf.TtfRandomAccessInput;
import org.foray.font.format.type1.Type1FontParser;
import org.foray.font.format.type1.Type1FontParserPfa;
import org.foray.font.format.type1.Type1FontParserPfb;
+import org.foray.font.ttf.TrueTypeCollection;
+import org.foray.font.ttf.TrueTypeSingle;
+import org.foray.font.ttf.TtfOffsetTable;
+import org.foray.font.ttf.TtfRandomAccessInput;
import org.axsl.font.Font;
import org.axsl.font.FontException;
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/AbstractOtfLayoutTable.java (from rev 13431, trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/AbstractOtfLayoutTable.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/AbstractOtfLayoutTable.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/AbstractOtfLayoutTable.java 2025-04-20 23:58:42 UTC (rev 13453)
@@ -0,0 +1,166 @@
+/*
+ * 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.HashMap;
+import java.util.Map;
+
+/**
+ * Abstract superclass for the OpenType layout tables.
+ */
+public abstract class AbstractOtfLayoutTable extends TtfTable {
+
+ /** Map of OpenType scripts for this table. The key is the script tag, and the value is the OtfScript instance for
+ * that tag. */
+ private Map<String, OtfScript> scriptMap;
+
+ /** Map of OpenType features for this table. The key is the feature tag, and the value is the OtfFeature instance
+ * for that tag. */
+ private Map<String, OtfFeature> featureMap;
+
+ /**
+ * Constructor.
+ * @param offsetTableRecord The offset table record that defines this table.
+ * @param scriptMap The script map for this table.
+ * @param featureMap The feature map for this table.
+ */
+ AbstractOtfLayoutTable(final TtfOffsetTableRecord offsetTableRecord, final Map<String, OtfScript> scriptMap,
+ final Map<String, OtfFeature> featureMap) {
+ super(offsetTableRecord);
+ this.scriptMap = scriptMap;
+ this.featureMap = featureMap;
+ }
+
+ /**
+ * Parses the script list.
+ * @param raInput The input from which the script list is being parsed.
+ * @param offset The offset in {@code raInput} for the start of the script list.
+ * @return The parsed map of scripts.
+ * @throws IOException For I/O errors during parsing.
+ */
+ protected static Map<String, OtfScript> parseScriptList(final RandomAccessInput raInput, final int offset)
+ throws IOException {
+ raInput.seek(offset);
+ final int scriptCount = raInput.readUnsignedShort();
+ final String[] scriptTableTags = new String[scriptCount];
+ final int[] scriptTableOffsets = new int[scriptCount];
+ for (int index = 0; index < scriptCount; index ++) {
+ scriptTableTags[index] = raInput.readStringASCII(OtfScript.TAG_SIZE);
+ scriptTableOffsets[index] = raInput.readUnsignedShort();
+ }
+
+ final Map<String, OtfScript> scriptMap = new HashMap<String, OtfScript>();
+ for (int index = 0; index < scriptCount; index ++) {
+ final OtfScript script = OtfScript.parse(raInput, offset + scriptTableOffsets[index]);
+ scriptMap.put(scriptTableTags[index], script);
+ }
+ return scriptMap;
+ }
+
+ /**
+ * Parses the feature list.
+ * @param raInput The input from which the feature list is being parsed.
+ * @param offset The offset in {@code raInput} for the start of the feature list.
+ * @return The parsed map of features.
+ * @throws IOException For I/O errors during parsing.
+ */
+ protected static Map<String, OtfFeature> parseFeatureList(final RandomAccessInput raInput, final int offset)
+ throws IOException {
+ raInput.seek(offset);
+ final int featureCount = raInput.readUnsignedShort();
+ final String[] featureTags = new String[featureCount];
+ final int[] featureOffsets = new int[featureCount];
+ for (int index = 0; index < featureCount; index ++) {
+ featureTags[index] = raInput.readStringASCII(OtfFeature.TAG_SIZE);
+ featureOffsets[index] = raInput.readUnsignedShort();
+ }
+ final Map<String, OtfFeature> featureMap = new HashMap<String, OtfFeature>();
+ for (int index = 0; index < featureCount; index ++) {
+ final OtfFeature feature = OtfFeature.parse(raInput, offset + featureOffsets[index]);
+ featureMap.put(featureTags[index], feature);
+ }
+ return featureMap;
+ }
+
+ /**
+ * Parses the feature variations.
+ * @param raInput The input from which the feature variations is being parsed.
+ * @param offset The offset in {@code raInput} for the start of the feature variations.
+ * @throws IOException For I/O errors during parsing.
+ */
+ protected static void parseFeatureVariations(final RandomAccessInput raInput, final int offset) throws IOException {
+ if (offset < 0) {
+ return;
+ }
+ }
+
+ /**
+ * Returns the script instance for a given tag.
+ * @param scriptTag The script tag to be retrieved.
+ * @return The script instance referenced by {@code scriptTag}, or null if that reference does not exist.
+ */
+ public OtfScript getScript(final String scriptTag) {
+ if (this.scriptMap == null) {
+ return null;
+ }
+ return this.scriptMap.get(scriptTag);
+ }
+
+ /**
+ * Returns the feature instance for a given tag.
+ * @param featureTag The feature tag to be retrieved.
+ * @return The feature instance referenced by {@code featureTag}, or null if that reference does not exist.
+ */
+ public OtfFeature getFeature(final String featureTag) {
+ if (this.featureMap == null) {
+ return null;
+ }
+ return this.featureMap.get(featureTag);
+ }
+
+ /**
+ * Package-visible method for testing.
+ * @return The script map.
+ */
+ Map<String, OtfScript> getScriptMap() {
+ return this.scriptMap;
+ }
+
+ /**
+ * Package-visible method for testing.
+ * @return The feature map.
+ */
+ Map<String, OtfFeature> getFeatureMap() {
+ return this.featureMap;
+ }
+
+}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfCoverage.java (from rev 13431, trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/OtfCoverage.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfCoverage.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfCoverage.java 2025-04-20 23:58:42 UTC (rev 13453)
@@ -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;
+
+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);
+
+}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfCoveragex01.java (from rev 13431, trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/OtfCoveragex01.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfCoveragex01.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfCoveragex01.java 2025-04-20 23:58:42 UTC (rev 13453)
@@ -0,0 +1,78 @@
+/*
+ * 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(TtfTable.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/OtfCoveragex02.java (from rev 13431, trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/OtfCoveragex02.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfCoveragex02.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfCoveragex02.java 2025-04-20 23:58:42 UTC (rev 13453)
@@ -0,0 +1,128 @@
+/*
+ * 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(TtfTable.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/OtfFeature.java (from rev 13431, trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/OtfFeature.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfFeature.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfFeature.java 2025-04-20 23:58:42 UTC (rev 13453)
@@ -0,0 +1,482 @@
+/*
+ * 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;
+
+/**
+ * An OpenType layout table feature.
+ */
+public class OtfFeature {
+
+ /**
+ * Enumeration of the various OTF feature tags.
+ */
+ public enum OtfFeatureTag {
+ /** The "aalt" tag. */
+ ACCESS_ALL_ALTERNATES("aalt"),
+
+ /** The "abvf" tag. */
+ ABOVE_BASE_FORMS("abvf"),
+
+ /** The "abvm" tag. */
+ ABOVE_BASE_MARK_POSITIONING("abvm"),
+
+ /** The "abvs" tag. */
+ ABOVE_BASE_SUBSTITUTIONS("abvs"),
+
+ /** The "afrc" tag. */
+ ALTERNATIVE_FRACTIONS("afrc"),
+
+ /** The "akhn" tag. */
+ AKHANDS("akhn"),
+
+ /** The "blwf" tag. */
+ BELOW_BASE_FORMS("blwf"),
+
+ /** The "blwm" tag. */
+ BELOW_BASE_MARK_POSITIONING("blwm"),
+
+ /** The "blws" tag. */
+ BELOW_BASE_SUBSTITUTIONS("blws"),
+
+ /** The "calt" tag. */
+ CONTEXTUAL_ALTERNATES("calt"),
+
+ /** The "case" tag. */
+ CASE_SENSITIVE_FORMS("case"),
+
+ /** The "ccmp" tag. */
+ GLYPH_COMPOSITION_DECOMPOSITION("ccmp"),
+
+ /** The "clig" tag. */
+ CONTEXTUAL_LIGATURES("clig"),
+
+ /** The "cpsp" tag. */
+ CAPITAL_SPACING("cpsp"),
+
+ /** The "cswh" tag. */
+ CONTEXTUAL_SWASH("cswh"),
+
+ /** The "curs" tag. */
+ CURSIVE_POSITIONING("curs"),
+
+ /** The "c2sc" tag. */
+ SMALL_CAPITALS_FROM_CAPITALS("c2sc"),
+
+ /** The "c2pc" tag. */
+ PETITE_CAPITALS_FROM_CAPITALS("c2pc"),
+
+ /** The "dist" tag. */
+ DISTANCES("dist"),
+
+ /** The "dlig" tag. */
+ DISCRETIONARY_LIGATURES("dlig"),
+
+ /** The "dnom" tag. */
+ DENOMINATORS("dnom"),
+
+ /** The "expt" tag. */
+ EXPERT_FORMS("expt"),
+
+ /** The "falt" tag. */
+ FINAL_GLYPH_ON_LINE_ALTERNATES("falt"),
+
+ /** The "fin2" tag. */
+ TERMINAL_FORMS_NO_2("fin2"),
+
+ /** The "fin3" tag. */
+ TERMINAL_FORMS_NO_3("fin3"),
+
+ /** The "fina" tag. */
+ TERMINAL_FORMS("fina"),
+
+ /** The "frac" tag. */
+ FRACTIONS("frac"),
+
+ /** The "fwid" tag. */
+ FULL_WIDTHS("fwid"),
+
+ /** The "half" tag. */
+ HALF_FORMS("half"),
+
+ /** The "haln" tag. */
+ HALANT_FORMS("haln"),
+
+ /** The "halt" tag. */
+ ALTERNATE_HALF_WIDTHS("halt"),
+
+ /** The "hist" tag. */
+ HISTORICAL_FORMS("hist"),
+
+ /** The "hkna" tag. */
+ HORIZONTAL_KANA_ALTERNATES("hkna"),
+
+ /** The "hlig" tag. */
+ HISTORICAL_LIGATURES("hlig"),
+
+ /** The "hngl" tag. */
+ HANGUL("hngl"),
+
+ /** The "hwid" tag. */
+ HALF_WIDTHS("hwid"),
+
+ /** The "init" tag. */
+ INITIAL_FORMS("init"),
+
+ /** The "isol" tag. */
+ ISOLATED_FORMS("isol"),
+
+ /** The "ital" tag. */
+ ITALICS("ital"),
+
+ /** The "jalt" tag. */
+ JUSTIFICATION_ALTERNATES("jalt"),
+
+ /** The "jp78" tag. */
+ JIS78_FORMS("jp78"),
+
+ /** The "jp83" tag. */
+ JIS83_FORMS("jp83"),
+
+ /** The "jp90" tag. */
+ JIS90_FORMS("jp90"),
+
+ /** The "kern" tag. */
+ KERNING("kern"),
+
+ /** The "lfbd" tag. */
+ LEFT_BOUNDS("lfbd"),
+
+ /** The "liga" tag. */
+ STANDARD_LIGATURES("liga"),
+
+ /** The "ljmo" tag. */
+ LEADING_JAMO_FORMS("ljmo"),
+
+ /** The "lnum" tag. */
+ LINING_FIGURES("lnum"),
+
+ /** The "locl" tag. */
+ LOCALIZED_FORMS("locl"),
+
+ /** The "mark" tag. */
+ MARK_POSITIONING("mark"),
+
+ /** The "med2" tag. */
+ MEDIAL_FORMS_NO_2("med2"),
+
+ /** The "medi" tag. */
+ MEDIAL_FORMS("medi"),
+
+ /** The "mgrk" tag. */
+ MATHEMATICAL_GREEK("mgrk"),
+
+ /** The "mkmk" tag. */
+ MARK_TO_MARK_POSITIONING("mkmk"),
+
+ /** The "mset" tag. */
+ MARK_POSITIONING_VIA_SUBSTITUTION("mset"),
+
+ /** The "nalt" tag. */
+ ALTERNATE_ANNOTATION_FORMS("nalt"),
+
+ /** The "nlck" tag. */
+ NLC_KANJI_FORMS("nlck"),
+
+ /** The "nukt" tag. */
+ NUKTA_FORMS("nukt"),
+
+ /** The "numr" tag. */
+ NUMERATORS("numr"),
+
+ /** The "onum" tag. */
+ OLDSTYLE_FIGURES("onum"),
+
+ /** The "opbd" tag. */
+ OPTICAL_BOUNDS("opbd"),
+
+ /** The "ordn" tag. */
+ ORDINALS("ordn"),
+
+ /** The "ornm" tag. */
+ ORNAMENTS("ornm"),
+
+ /** The "palt" tag. */
+ PROPORTIONAL_ALTERNATE_WIDTHS("palt"),
+
+ /** The "pcap" tag. */
+ PETITE_CAPITALS("pcap"),
+
+ /** The "pnum" tag. */
+ PROPORTIONAL_FIGURES("pnum"),
+
+ /** The "pref" tag. */
+ PRE_BASE_FORMS("pref"),
+
+ /** The "pres" tag. */
+ PRE_BASE_SUBSTITUTIONS("pres"),
+
+ /** The "pstf" tag. */
+ POST_BASE_FORMS("pstf"),
+
+ /** The "psts" tag. */
+ POST_BASE_SUBSTITUTIONS("psts"),
+
+ /** The "pwid" tag. */
+ PROPORTIONAL_WIDTHS("pwid"),
+
+ /** The "qwid" tag. */
+ QUARTER_WIDTHS("qwid"),
+
+ /** The "rand" tag. */
+ RANDOMIZE("rand"),
+
+ /** The "rlig" tag. */
+ REQUIRED_LIGATURES("rlig"),
+
+ /** The "rphf" tag. */
+ REPH_FORMS("rphf"),
+
+ /** The "rtbd" tag. */
+ RIGHT_BOUNDS("rtbd"),
+
+ /** The "rtla" tag. */
+ RIGHT_TO_LEFT_ALTERNATES("rtla"),
+
+ /** The "ruby" tag. */
+ RUBY_NOTATION_FORMS("ruby"),
+
+ /** The "salt" tag. */
+ STYLISTIC_ALTERNATES("salt"),
+
+ /** The "sinf" tag. */
+ SCIENTIFIC_INFERIORS("sinf"),
+
+ /** The "size" tag. */
+ OPTICAL_SIZE("size"),
+
+ /** The "smcp" tag. */
+ SMALL_CAPITALS("smcp"),
+
+ /** The "smpl" tag. */
+ SIMPLIFIED_FORMS("smpl"),
+
+ /** The "ss01" tag. */
+ STYLISTIC_SET_1("ss01"),
+
+ /** The "ss02" tag. */
+ STYLISTIC_SET_2("ss02"),
+
+ /** The "ss03" tag. */
+ STYLISTIC_SET_3("ss03"),
+
+ /** The "ss04" tag. */
+ STYLISTIC_SET_4("ss04"),
+
+ /** The "ss05" tag. */
+ STYLISTIC_SET_5("ss05"),
+
+ /** The "ss06" tag. */
+ STYLISTIC_SET_6("ss06"),
+
+ /** The "ss07" tag. */
+ STYLISTIC_SET_7("ss07"),
+
+ /** The "ss08" tag. */
+ STYLISTIC_SET_8("ss08"),
+
+ /** The "ss09" tag. */
+ STYLISTIC_SET_9("ss09"),
+
+ /** The "ss10" tag. */
+ STYLISTIC_SET_10("ss10"),
+
+ /** The "ss11" tag. */
+ STYLISTIC_SET_11("ss11"),
+
+ /** The "ss12" tag. */
+ STYLISTIC_SET_12("ss12"),
+
+ /** The "ss13" tag. */
+ STYLISTIC_SET_13("ss13"),
+
+ /** The "ss14" tag. */
+ STYLISTIC_SET_14("ss14"),
+
+ /** The "ss15" tag. */
+ STYLISTIC_SET_15("ss15"),
+
+ /** The "ss16" tag. */
+ STYLISTIC_SET_16("ss16"),
+
+ /** The "ss17" tag. */
+ STYLISTIC_SET_17("ss17"),
+
+ /** The "ss18" tag. */
+ STYLISTIC_SET_18("ss18"),
+
+ /** The "ss19" tag. */
+ STYLISTIC_SET_19("ss19"),
+
+ /** The "ss20" tag. */
+ STYLISTIC_SET_20("ss20"),
+
+ /** The "subs" tag. */
+ SUBSCRIPT("subs"),
+
+ /** The "sups" tag. */
+ SUPERSCRIPT("sups"),
+
+ /** The "swsh" tag. */
+ SWASH("swsh"),
+
+ /** The "titl" tag. */
+ TITLING("titl"),
+
+ /** The "tjmo" tag. */
+ TRAILING_JAMO_FORMS("tjmo"),
+
+ /** The "tnam" tag. */
+ TRADITIONAL_NAME_FORMS("tnam"),
+
+ /** The "tnum" tag. */
+ TABULAR_FIGURES("tnum"),
+
+ /** The "trad" tag. */
+ TRADITIONAL_FORMS("trad"),
+
+ /** The "twid" tag. */
+ THIRD_WIDTHS("twid"),
+
+ /** The "unic" tag. */
+ UNICASE("unic"),
+
+ /** The "valt" tag. */
+ ALTERNATE_VERTICAL_METRICS("valt"),
+
+ /** The "vatu" tag. */
+ VATTU_VARIANTS("vatu"),
+
+ /** The "vert" tag. */
+ VERTICAL_WRITING("vert"),
+
+ /** The "vhal" tag. */
+ ALTERNATE_VERTICAL_HALF_METRICS("vhal"),
+
+ /** The "vjmo" tag. */
+ VOWEL_JAMO_FORMS("vjmo"),
+
+ /** The "vkna" tag. */
+ VERTICAL_KANA_ALTERNATES("vkna"),
+
+ /** The "vkrn" tag. */
+ VERTICAL_KERNING("vkrn"),
+
+ /** The "vpal" tag. */
+ PROPORTIONAL_ALTERNATE_VERTICAL_METRICS("vpal"),
+
+ /** The "vrt2" tag. */
+ VERTICAL_ALTERNATES_AND_ROTATION("vrt2"),
+
+ /** The "zero" tag. */
+ SLASHED_ZERO("zero");
+
+ /** The text for this tag that is stored in the table. */
+ private String tagText;
+
+ /**
+ * Constructor.
+ * @param tagText The text for this tag.
+ */
+ OtfFeatureTag(final String tagText) {
+ this.tagText = tagText;
+ }
+
+ /**
+ * Returns the text for this tag.
+ * @return The text for this tag.
+ */
+ public String getTagText() {
+ return this.tagText;
+ }
+
+ }
+
+ /** The size, in bytes, of an OpenType Feature tag. */
+ public static final int TAG_SIZE = 4;
+
+ /** Array of lookup list indexes for this feature. */
+ private char[] lookupListIndexes;
+
+ /**
+ * Constructor.
+ */
+ public OtfFeature() {
+ }
+
+ /**
+ * Parses a feature.
+ * @param raInput The input from which the feature is being parsed.
+ * @param offset The offset in {@code raInput} for the start of the feature table.
+ * @return The parsed feature table instance.
+ * @throws IOException For I/O errors during parsing.
+ */
+ public static OtfFeature parse(final RandomAccessInput raInput, final int offset) throws IOException {
+ raInput.seek(offset);
+ final OtfFeature feature = new OtfFeature();
+ /*final int featureParamsOffset = */raInput.readUnsignedShort();
+ final int lookupCount = raInput.readUnsignedShort();
+ feature.lookupListIndexes = new char[lookupCount];
+ for (int index = 0; index < lookupCount; index ++) {
+ feature.lookupListIndexes[index] = raInput.readChar();
+ }
+ return feature;
+ }
+
+ /**
+ * Returns the number of lookup list indexes in this feature.
+ * @return The number of lookup list indexes in this feature.
+ */
+ public int lookupListIndexLength() {
+ return this.lookupListIndexes.length;
+ }
+
+ /**
+ * Returns a specified lookup list index.
+ * @param index The index into the lookup list indexes.
+ * @return The lookup list index at {@code index}.
+ */
+ public char lookupListIndexAt(final int index) {
+ return this.lookupListIndexes[index];
+ }
+
+}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLanguageSystem.java (from rev 13431, trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/OtfLanguageSystem.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLanguageSystem.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLanguageSystem.java 2025-04-20 23:58:42 UTC (rev 13453)
@@ -0,0 +1,93 @@
+/*
+ * 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;
+
+/**
+ * An OpenType Language System.
+ */
+public class OtfLanguageSystem {
+
+ /** The size, in bytes, of an OpenType Language System tag. */
+ public static final byte TAG_SIZE = 4;
+
+ /** Index of a required feature in this language system. If null, the value is 0xFFFF. */
+ private char reqFeatureIndex;
+
+ /** The (arbitarily ordered) array of indexes into the features list. */
+ private char[] featureIndexes;
+
+ /**
+ * Constructor.
+ */
+ public OtfLanguageSystem() {
+ }
+
+ /**
+ * Parses a language system.
+ * @param raInput The input from which the language system is being parsed.
+ * @param offset The offset in {@code raInput} for the start of the language system.
+ * @return The parsed language system instance.
+ * @throws IOException For I/O errors during parsing.
+ */
+ public static OtfLanguageSystem parse(final RandomAccessInput raInput, final int offset)
+ throws IOException {
+ raInput.seek(offset);
+ final OtfLanguageSystem langSys = new OtfLanguageSystem();
+ /* Skip the LookupOrder. */
+ raInput.skipBytes(TtfTable.OFFSET_BYTES);
+ langSys.reqFeatureIndex = raInput.readChar();
+ final int featureCount = raInput.readUnsignedShort();
+ langSys.featureIndexes = new char[featureCount];
+ for (int index = 0; index < featureCount; index ++) {
+ langSys.featureIndexes[index] = raInput.readChar();
+ }
+ return langSys;
+ }
+
+ /**
+ * Returns the index of a required feature in this language system. If null, the value is 0xFFFF.
+ * @return The index of a required feature, or 0xFFFF if null.
+ */
+ public char getRequiredFeatureIndex() {
+ return this.reqFeatureIndex;
+ }
+
+ /**
+ * Returns the (arbitarily ordered) array of indexes into the features list.
+ * @return The array of feature indexes for this language system.
+ */
+ public char[] getFeatureIndexes() {
+ return this.featureIndexes;
+ }
+
+}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsub.java (from rev 13431, trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/OtfLookupGsub.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsub.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsub.java 2025-04-20 23:58:42 UTC (rev 13453)
@@ -0,0 +1,241 @@
+/*
+ * 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;
+
+/**
+ * An OpenType lookup for the GSUB table.
+ */
+public class OtfLookupGsub {
+
+ /**
+ * Enumeration of possible LookupType values in a GSUB table.
+ */
+ public enum LookupType {
+
+ /** Replace one glyph with one glyph. */
+ SINGLE(1),
+
+ /** Replace one glyph with more than one glyph. */
+ MULTIPLE(2),
+
+ /** Replace one glyph with one of many glyphs. */
+ ALTERNATE(3),
+
+ /** Replace multiple glyphs with one glyph. */
+ LIGATURE(4),
+
+ /** Replace one or more glyphs in context. */
+ CONTEXT(5),
+
+ /** Replace one or more glyphs in chained context. */
+ CHAINING_CONTEXT(6),
+
+ /** Extension mechanism for other substitutions (i.e. this excludes the Extension type substitution itself). */
+ EXTENSION_SUBSTITUTION(7),
+
+ /** Applied in reverse order, replace single glyph in chaining context. */
+ REVERSE_CHAINING_CONTEXT_SINGLE(8);
+
+ /** The number this enumerated item is stored as in a font file. */
+ private byte value;
+
+ /**
+ * Constructor.
+ * @param value The number this enumerated item is stored as in a font file.
+ */
+ LookupType(final int value) {
+ this.value = (byte) value;
+ }
+
+ /**
+ * Finds the enumerated item from its value.
+ * @param value The value for which the enumerated item is needed.
+ * @return The enumerated item matching {@code value}, or null if it is not found.
+ */
+ public static LookupType fromValue(final int value) {
+ for (LookupType lookupType : values()) {
+ if (lookupType.value == value) {
+ return lookupType;
+ }
+ }
+ return null;
+ }
+ }
+
+ /** Constant identifying a format number. */
+ private static final byte FORMAT_1 = 1;
+
+ /** Constant identifying a format number. */
+ private static final byte FORMAT_2 = 2;
+
+ /** Constant identifying a format number. */
+ private static final byte FORMAT_3 = 3;
+
+ /** The lookup type for this lookup. */
+ private LookupType lookupType;
+
+ /** The lookup flag. */
+ private int lookupFlag;
+
+ /** The subtables. */
+ private OtfLookupGsubSubtable[] subtables;
+
+ /**
+ * Constructor.
+ */
+ public OtfLookupGsub() {
+ }
+
+ /**
+ * Parses a lookup.
+ * @param raInput The input from which the lookup is being parsed.
+ * @param offset The offset in {@code raInput} for the start of the lookup table.
+ * @return The parsed lookup table instance.
+ * @throws IOException For I/O errors during parsing.
+ */
+ public static OtfLookupGsub parse(final RandomAccessInput raInput, final int offset) throws IOException {
+ raInput.seek(offset);
+ final OtfLookupGsub lookup = new OtfLookupGsub();
+ final int lookupTypeInteger = raInput.readUnsignedShort();
+ lookup.lookupType = LookupType.fromValue(lookupTypeInteger);
+ lookup.lookupFlag = raInput.readUnsignedShort();
+ final int subTableCount = raInput.readUnsignedShort();
+ final int[] subTableOffsets = new int[subTableCount];
+ for (int index = 0; index < subTableCount; index ++) {
+ subTableOffsets[index] = raInput.readUnsignedShort();
+ }
+ /* TODO: The last item in the table is named "MarkFilteringSet" with a type of "unit16". Although this is
+ * probably a 16-bit type of some sort, we don't recognize it, and, for now, therefore skip parsing it. */
+
+ lookup.subtables = new OtfLookupGsubSubtable[subTableCount];
+ for (int index = 0; index < subTableCount; index ++) {
+ final OtfLookupGsubSubtable subtable =
+ parseSubtable(raInput, offset + subTableOffsets[index], lookup.lookupType);
+ lookup.subtables[index] = subtable;
+ }
+
+ return lookup;
+ }
+
+ /**
+ * Parses a subtable.
+ * @param raInput The input from which the subtable is being parsed.
+ * @param offset The offset in {@code raInput} for the start of the subtable.
+ * @param lookupType The lookup type being parsed.
+ * @return The parsed subtable instance.
+ * @throws IOException For I/O errors during parsing.
+ */
+ private static OtfLookupGsubSubtable parseSubtable(final RandomAccessInput raInput, final int offset,
+ final OtfLookupGsub.LookupType lookupType) throws IOException {
+ raInput.seek(offset);
+
+ final int formatId = raInput.readUnsignedShort();
+
+ switch (lookupType) {
+ case SINGLE: {
+ switch (formatId) {
+ case FORMAT_1: return OtfLookupGsubx01x01.parse(raInput, offset);
+ case FORMAT_2: return OtfLookupGsubx01x02.parse(raInput, offset);
+ default: throw new UnsupportedOperationException("Unrecognized GSUB lookup type 1: " + formatId);
+ }
+ }
+ case MULTIPLE:
+ switch (formatId) {
+ case FORMAT_1: return OtfLookupGsubx02x01.parse(raInput, offset);
+ default: throw new UnsupportedOperationException("Unrecognized GSUB lookup type 2: " + formatId);
+ }
+ case ALTERNATE:
+ switch (formatId) {
+ case FORMAT_1: return OtfLookupGsubx03x01.parse(raInput, offset);
+ default: throw new UnsupportedOperationException("Unrecognized GSUB lookup type 3: " + formatId);
+ }
+ case LIGATURE:
+ switch (formatId) {
+ case FORMAT_1: return OtfLookupGsubx04x01.parse(raInput, offset);
+ default: throw new UnsupportedOperationException("Unrecognized GSUB lookup type 4: " + formatId);
+ }
+ case CONTEXT:
+ switch (formatId) {
+ case FORMAT_1: return OtfLookupGsubx05x01.parse(raInput, offset);
+ case FORMAT_2: return OtfLookupGsubx05x02.parse(raInput, offset);
+ case FORMAT_3: return OtfLookupGsubx05x03.parse(raInput, offset);
+ default: throw new UnsupportedOperationException("Unrecognized GSUB lookup type 5: " + formatId);
+ }
+ case CHAINING_CONTEXT:
+ switch (formatId) {
+ case FORMAT_1: return OtfLookupGsubx06x01.parse(raInput, offset);
+ case FORMAT_2: return OtfLookupGsubx06x02.parse(raInput, offset);
+ case FORMAT_3: return OtfLookupGsubx06x03.parse(raInput, offset);
+ default: throw new UnsupportedOperationException("Unrecognized GSUB lookup type 6: " + formatId);
+ }
+ case EXTENSION_SUBSTITUTION:
+ switch (formatId) {
+ case FORMAT_1: return OtfLookupGsubx07x01.parse(raInput, offset);
+ default: throw new UnsupportedOperationException("Unrecognized GSUB lookup type 7: " + formatId);
+ }
+ case REVERSE_CHAINING_CONTEXT_SINGLE:
+ switch (formatId) {
+ case FORMAT_1: return OtfLookupGsubx08x01.parse(raInput, offset);
+ default: throw new UnsupportedOperationException("Unrecognized GSUB lookup type 8: " + formatId);
+ }
+ default: {
+ throw new UnsupportedOperationException("Unrecognized GSUB lookup type: " + lookupType);
+ }
+ }
+ }
+
+ /**
+ * Returns the lookup type.
+ * @return The lookupType.
+ */
+ protected LookupType getLookupType() {
+ return this.lookupType;
+ }
+
+ /**
+ * Returns the lookup flag.
+ * @return The lookupFlag.
+ */
+ protected int getLookupFlag() {
+ return this.lookupFlag;
+ }
+
+ /**
+ * Returns the subtables.
+ * @return The subtables.
+ */
+ protected OtfLookupGsubSubtable[] getSubtables() {
+ return this.subtables;
+ }
+
+}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubSubtable.java (from rev 13431, trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/OtfLookupGsubSubtable.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubSubtable.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubSubtable.java 2025-04-20 23:58:42 UTC (rev 13453)
@@ -0,0 +1,50 @@
+/*
+ * 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.primitive.sequence.IntArrayBuilder;
+
+import org.axsl.font.FontContext;
+
+/**
+ * Abstract superclass for all GSUB subtables.
+ */
+public abstract class OtfLookupGsubSubtable {
+
+ /**
+ * Process the substitution for this subtable.
+ * Looks through the possible substitution in this font, and for those that the client wants, converts the glyph
+ * indexes for those subsitutions.
+ * @param glyphIndexes The glyph indexes for which substitutions are being considered.
+ * @param fontContext The font context, such as ligatures and small-caps that should be used when computing the
+ * glyphs for this word.
+ */
+ abstract void makeSubstitutions(IntArrayBuilder glyphIndexes, FontContext fontContext);
+
+}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx01x01.java (from rev 13431, trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/OtfLookupGsubx01x01.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx01x01.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx01x01.java 2025-04-20 23:58:42 UTC (rev 13453)
@@ -0,0 +1,67 @@
+/*
+ * 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 org.foray.primitive.sequence.IntArrayBuilder;
+
+import org.axsl.font.FontContext;
+
+import java.io.IOException;
+
+/**
+ * A Single Substitution Format 1 GSUB Subtable.
+ */
+public class OtfLookupGsubx01x01 extends OtfLookupGsubSubtable {
+
+ /**
+ * Constructor.
+ */
+ public OtfLookupGsubx01x01() {
+ }
+
+ /**
+ * 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 OtfLookupGsubx01x01 parse(final RandomAccessInput raInput, final int offset) throws IOException {
+ raInput.seek(offset);
+ final OtfLookupGsubx01x01 subtable = new OtfLookupGsubx01x01();
+ return subtable;
+ }
+
+ @Override
+ void makeSubstitutions(final IntArrayBuilder glyphIndexes, final FontContext fontContext) {
+ /* TODO: Implement this. */
+ }
+
+}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx01x02.java (from rev 13431, trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/OtfLookupGsubx01x02.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/OtfLookupGsubx01x02.java ...
[truncated message content] |
|
From: <vic...@us...> - 2025-04-20 23:52:02
|
Revision: 13452
http://sourceforge.net/p/foray/code/13452
Author: victormote
Date: 2025-04-20 23:51:44 +0000 (Sun, 20 Apr 2025)
Log Message:
-----------
Rename parser files, for clarity.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TtfTableBase.java
trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TtfTableHead.java
trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TtfTableOs2.java
trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TtfTablePclt.java
Added Paths:
-----------
trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/BaseTableParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/HeadTableParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/Os2TableParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/PcltTableParser.java
Removed Paths:
-------------
trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/TtfTableBaseParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/TtfTableHeadParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/TtfTableOs2Parser.java
trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/TtfTablePcltParser.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TtfTableBase.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TtfTableBase.java 2025-04-20 21:10:48 UTC (rev 13451)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TtfTableBase.java 2025-04-20 23:51:44 UTC (rev 13452)
@@ -30,7 +30,7 @@
import org.foray.common.primitive.PrimitiveFerry;
import org.foray.font.FontParserConsumer;
-import org.foray.font.format.ttf.parse.TtfTableBaseParser;
+import org.foray.font.format.ttf.parse.BaseTableParser;
import java.io.IOException;
@@ -90,7 +90,7 @@
public static TtfTableBase parse(final TtfOffsetTableRecord dirEntry, final TtfRandomAccessInput input)
throws IOException {
final TtfTableBase table = new TtfTableBase(dirEntry);
- final TtfTableBaseParser parser = new TtfTableBaseParser();
+ final BaseTableParser parser = new BaseTableParser();
parser.parse(input, dirEntry.getOffset(), dirEntry.getLength(), table.new ParserConsumer(table));
return table;
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TtfTableHead.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TtfTableHead.java 2025-04-20 21:10:48 UTC (rev 13451)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TtfTableHead.java 2025-04-20 23:51:44 UTC (rev 13452)
@@ -32,7 +32,7 @@
import org.foray.common.data.BoundingBoxUtils;
import org.foray.common.primitive.PrimitiveFerry;
import org.foray.font.FontParserConsumer;
-import org.foray.font.format.ttf.parse.TtfTableHeadParser;
+import org.foray.font.format.ttf.parse.HeadTableParser;
import org.axsl.ps.BoundingBox;
@@ -118,7 +118,7 @@
public static TtfTableHead parse(final TtfOffsetTableRecord dirEntry, final TtfRandomAccessInput input)
throws IOException {
final TtfTableHead head = new TtfTableHead(dirEntry);
- final TtfTableHeadParser parser = new TtfTableHeadParser();
+ final HeadTableParser parser = new HeadTableParser();
parser.parse(input, dirEntry.getOffset(), dirEntry.getLength(), head.new ParserConsumer(head));
return head;
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TtfTableOs2.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TtfTableOs2.java 2025-04-20 21:10:48 UTC (rev 13451)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TtfTableOs2.java 2025-04-20 23:51:44 UTC (rev 13452)
@@ -31,7 +31,7 @@
import org.foray.common.primitive.PrimitiveFerry;
import org.foray.font.FontParserConsumer;
import org.foray.font.format.Panose4a;
-import org.foray.font.format.ttf.parse.TtfTableOs2Parser;
+import org.foray.font.format.ttf.parse.Os2TableParser;
import org.checkerframework.checker.signedness.qual.Unsigned;
@@ -126,7 +126,7 @@
public static TtfTableOs2 parse(final TtfOffsetTableRecord dirEntry, final TtfRandomAccessInput input)
throws IOException {
final TtfTableOs2 os2 = new TtfTableOs2(dirEntry);
- final TtfTableOs2Parser parser = new TtfTableOs2Parser();
+ final Os2TableParser parser = new Os2TableParser();
parser.parse(input, dirEntry.getOffset(), dirEntry.getLength(), os2.new ParserConsumer(os2));
return os2;
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TtfTablePclt.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TtfTablePclt.java 2025-04-20 21:10:48 UTC (rev 13451)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/TtfTablePclt.java 2025-04-20 23:51:44 UTC (rev 13452)
@@ -30,7 +30,7 @@
import org.foray.common.primitive.PrimitiveFerry;
import org.foray.font.FontParserConsumer;
-import org.foray.font.format.ttf.parse.TtfTablePcltParser;
+import org.foray.font.format.ttf.parse.PcltTableParser;
import java.io.IOException;
@@ -113,7 +113,7 @@
public static TtfTablePclt parse(final TtfOffsetTableRecord dirEntry, final TtfRandomAccessInput input)
throws IOException {
final TtfTablePclt pclt = new TtfTablePclt(dirEntry);
- final TtfTablePcltParser parser = new TtfTablePcltParser();
+ final PcltTableParser parser = new PcltTableParser();
parser.parse(input, dirEntry.getOffset(), dirEntry.getLength(), pclt.new ParserConsumer(pclt));
return pclt;
}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/BaseTableParser.java (from rev 13439, trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/TtfTableBaseParser.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/BaseTableParser.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/BaseTableParser.java 2025-04-20 23:51:44 UTC (rev 13452)
@@ -0,0 +1,69 @@
+/*
+ * 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.format.ttf.parse;
+
+import org.foray.common.primitive.PrimitiveFerry;
+import org.foray.font.FontParser;
+import org.foray.font.FontParserConsumer;
+import org.foray.font.format.ttf.TtfRandomAccessInput;
+
+import java.io.IOException;
+
+/**
+ * Parses a TTF BASE table.
+ * @see org.foray.font.format.ttf.TtfTableBase
+ */
+public class BaseTableParser extends FontParser {
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final int size,
+ final FontParserConsumer consumer) throws IOException {
+ final PrimitiveFerry ferry = new PrimitiveFerry();
+ input.seek(offset);
+
+ final int majorVersion = input.read_uint16(); // 2 bytes, total 2
+ consumer.primitiveField("majorVersion", ferry.setInt(majorVersion));
+ final int minorVersion = input.read_uint16(); // 2 bytes, total 4
+ consumer.primitiveField("minorVersion", ferry.setInt(minorVersion));
+
+
+ /* BASE Table Header, Version 1.0. */
+ final int horizAxisOffset = input.read_Offset16(); // 2 bytes, total 6
+ consumer.primitiveField("horizAxisOffset", ferry.setInt(horizAxisOffset));
+ final int vertAxisOffset = input.read_Offset16(); // 2 bytes, total 8
+ consumer.primitiveField("vertAxisOffset", ferry.setInt(vertAxisOffset));
+
+ /* BASE Table Header, Version 1.1. */
+ if (minorVersion > 0) {
+ final long itemVarStoreOffset = input.read_Offset32(); // 4 bytes, total 12
+ consumer.primitiveField("itemVarStoreOffset", ferry.setLong(itemVarStoreOffset));
+ }
+ }
+
+}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/HeadTableParser.java (from rev 13441, trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/TtfTableHeadParser.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/HeadTableParser.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/HeadTableParser.java 2025-04-20 23:51:44 UTC (rev 13452)
@@ -0,0 +1,82 @@
+/*
+ * 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.format.ttf.parse;
+
+import org.foray.common.primitive.PrimitiveFerry;
+import org.foray.font.FontParser;
+import org.foray.font.FontParserConsumer;
+import org.foray.font.format.ttf.TtfRandomAccessInput;
+
+import java.io.IOException;
+
+/**
+ * Parses a TTF HEAD table.
+ * @see org.foray.font.format.ttf.TtfTableHead
+ */
+public class HeadTableParser extends FontParser {
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final int size,
+ final FontParserConsumer consumer) throws IOException {
+ final PrimitiveFerry ferry = new PrimitiveFerry();
+ input.seek(offset);
+ final int majorVersion = input.read_uint16(); // 2 bytes, total 2
+ consumer.primitiveField("majorVersion", ferry.setInt(majorVersion));
+
+
+ /* Head Table, Version 1.0. */
+ consumer.primitiveField("minorVersion", ferry.setInt(input.read_uint16())); // 2 bytes, total 4
+ consumer.objectField("fontRevision", input.read_Fixed()); // 4 bytes, total 8
+ consumer.primitiveField("checksumAdjustment", ferry.setLong(input.read_uint32())); // 4 bytes, total 12
+ consumer.primitiveField("magicNumber", ferry.setLong(input.read_uint32())); // 4 bytes, total 16
+ consumer.primitiveField("flags", ferry.setInt(input.read_uint16())); // 2 bytes, total 18
+ consumer.primitiveField("unitsPerEm", ferry.setInt(input.read_uint16())); // 2 bytes, total 20
+ consumer.objectField("created", input.read_LONGDATETIME()); // 8 bytes, total 28
+ consumer.objectField("modifed", input.read_LONGDATETIME()); // 8 bytes, total 36
+
+ final short xMin = input.read_int16(); // 2 bytes, total 38
+ final short yMin = input.read_int16(); // 2 bytes, total 40
+ final short xMax = input.read_int16(); // 2 bytes, total 42
+ final short yMax = input.read_int16(); // 2 bytes, total 44
+ consumer.primitiveField("xMin", ferry.setShort(xMin));
+ consumer.primitiveField("yMin", ferry.setShort(yMin));
+ consumer.primitiveField("xMax", ferry.setShort(xMax));
+ consumer.primitiveField("yMax", ferry.setShort(yMax));
+ /* In case the consumer wants the four bounding box components already assembled. */
+ final short[] boundingBox = {xMin, yMin, xMax, yMax};
+ consumer.objectField("boundingBox", boundingBox);
+
+ consumer.primitiveField("macStyle", ferry.setInt(input.read_uint16())); // 2 bytes, total 46
+ consumer.primitiveField("lowestRecPPEM", ferry.setInt(input.read_uint16())); // 2 bytes, total 48
+ consumer.primitiveField("fontDirectionHint", ferry.setShort(input.read_int16())); // 2 bytes, total 50
+ consumer.primitiveField("indexToLocFormat", ferry.setShort(input.read_int16())); // 2 bytes, total 52
+ consumer.primitiveField("glyphDataFormat", ferry.setShort(input.read_int16())); // 2 bytes, total 54
+ }
+
+}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/Os2TableParser.java (from rev 13443, trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/TtfTableOs2Parser.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/Os2TableParser.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/Os2TableParser.java 2025-04-20 23:51:44 UTC (rev 13452)
@@ -0,0 +1,123 @@
+/*
+ * 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.format.ttf.parse;
+
+import org.foray.common.primitive.PrimitiveFerry;
+import org.foray.font.FontParser;
+import org.foray.font.FontParserConsumer;
+import org.foray.font.format.Panose4a;
+import org.foray.font.format.ttf.TtfRandomAccessInput;
+import org.foray.font.format.ttf.TtfTable;
+
+import org.checkerframework.checker.signedness.qual.Unsigned;
+
+import java.io.IOException;
+
+/**
+ * Parses a TTF OS/2 table.
+ * @see org.foray.font.format.ttf.TtfTableOs2
+ */
+public class Os2TableParser extends FontParser {
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final int size,
+ final FontParserConsumer consumer) throws IOException {
+ final PrimitiveFerry ferry = new PrimitiveFerry();
+ input.seek(offset);
+ final short version = input.read_uint16();
+ consumer.primitiveField("version", ferry.setShort(version)); // 2 bytes, total 2
+
+
+ /* OS/2 Table, Version 0. */
+ consumer.primitiveField("xAvgCharWidth", ferry.setShort(input.read_FWORD())); // 2 bytes, total 4
+ consumer.primitiveField("usWeightClass", ferry.setInt(input.read_uint16())); // 2 bytes, total 6
+ consumer.primitiveField("usWidthClass", ferry.setInt(input.read_uint16())); // 2 bytes, total 8
+ consumer.primitiveField("fsType", ferry.setInt(input.read_uint16())); // 2 bytes, total 10
+ consumer.primitiveField("ySubscriptXSize", ferry.setShort(input.read_FWORD())); // 2 bytes, total 12
+ consumer.primitiveField("ySubscriptYSize", ferry.setShort(input.read_FWORD())); // 2 bytes, total 14
+ consumer.primitiveField("ySubscriptXOffset", ferry.setShort(input.read_FWORD())); // 2 bytes, total 16
+ consumer.primitiveField("ySubscriptYOffset", ferry.setShort(input.read_FWORD())); // 2 bytes, total 18
+ consumer.primitiveField("ySuperscriptXSize", ferry.setShort(input.read_FWORD())); // 2 bytes, total 20
+ consumer.primitiveField("ySuperscriptYSize", ferry.setShort(input.read_FWORD())); // 2 bytes, total 22
+ consumer.primitiveField("ySuperscriptXOffset", ferry.setShort(input.read_FWORD())); // 2 bytes, total 24
+ consumer.primitiveField("ySuperscriptYOffset", ferry.setShort(input.read_FWORD())); // 2 bytes, total 26
+ consumer.primitiveField("yStrikeoutSize", ferry.setShort(input.read_FWORD())); // 2 bytes, total 28
+ consumer.primitiveField("yStrikeoutPosition", ferry.setShort(input.read_FWORD())); // 2 bytes, total 30
+ consumer.primitiveField("sFamilyClass", ferry.setShort(input.read_int16())); // 2 bytes, total 32
+
+ /* Read the Panose array. */
+ final @Unsigned byte[] panoseArray = new byte[Panose4a.Field.values().length]; // 10 bytes, total 42
+ for (int i = 0; i < panoseArray.length; i++) {
+ panoseArray[i] = input.read_uint8();
+ }
+ consumer.objectField("panose", panoseArray);
+
+ consumer.primitiveField("ulUnicodeRange1", ferry.setLong(input.read_uint32())); // 4 bytes, total 46
+ consumer.primitiveField("ulUnicodeRange2", ferry.setLong(input.read_uint32())); // 4 bytes, total 50
+ consumer.primitiveField("ulUnicodeRange3", ferry.setLong(input.read_uint32())); // 4 bytes, total 54
+ consumer.primitiveField("ulUnicodeRange4", ferry.setLong(input.read_uint32())); // 4 bytes, total 58
+ consumer.objectField("achVendID", input.read_Tag()); // 4 bytes, total 62
+ consumer.primitiveField("fsSelection", ferry.setInt(input.read_uint16())); // 2 bytes, total 64
+ consumer.primitiveField("usFirstCharIndex", ferry.setInt(input.read_uint16())); // 2 bytes, total 66
+ consumer.primitiveField("usLastCharIndex", ferry.setInt(input.read_uint16())); // 2 bytes, total 68
+ consumer.primitiveField("sTypoAscender", ferry.setShort(input.read_FWORD())); // 2 bytes, total 70
+ consumer.primitiveField("sTypoDescender", ferry.setShort(input.read_FWORD())); // 2 bytes, total 72
+ consumer.primitiveField("sTypoLineGap", ferry.setShort(input.read_FWORD())); // 2 bytes, total 74
+ consumer.primitiveField("usWinAscent", ferry.setInt(input.read_UFWORD())); // 2 bytes, total 76
+ consumer.primitiveField("usWinDescent", ferry.setInt(input.read_UFWORD())); // 2 bytes, total 78
+
+ if (version < TtfTable.MajorVersion.v1.getValue()) {
+ return;
+ }
+
+ /* OS/2 Table, Version 1. */
+ consumer.primitiveField("ulCodePageRange1", ferry.setLong(input.read_uint32())); // 4 bytes, total 82
+ consumer.primitiveField("ulCodePageRange2", ferry.setLong(input.read_uint32())); // 4 bytes, total 86
+
+ if (version < TtfTable.MajorVersion.v2.getValue()) {
+ return;
+ }
+
+ /* OS/2 Table, Version 2. Versions 3 & 4 are the same as Version 2. */
+ consumer.primitiveField("sxHeight", ferry.setShort(input.read_FWORD())); // 2 bytes, total 88
+ consumer.primitiveField("sCapHeight", ferry.setShort(input.read_FWORD())); // 2 bytes, total 90
+ consumer.primitiveField("usDefaultChar", ferry.setInt(input.read_uint16())); // 2 bytes, total 92
+ consumer.primitiveField("usBreakChar", ferry.setInt(input.read_uint16())); // 2 bytes, total 94
+ consumer.primitiveField("usMaxContext", ferry.setInt(input.read_uint16())); // 2 bytes, total 96
+
+ if (version < TtfTable.MajorVersion.v5.getValue()) {
+ return;
+ }
+
+ /* OS/2 Table, Version 5. */
+ consumer.primitiveField("usLowerOpticalPointSize", ferry.setInt(input.read_uint16())); // 2 bytes, total 98
+ consumer.primitiveField("usUpperOpticalPointSize", ferry.setInt(input.read_uint16())); // 2 bytes, total 100
+ }
+
+}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/PcltTableParser.java (from rev 13441, trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/TtfTablePcltParser.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/PcltTableParser.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/PcltTableParser.java 2025-04-20 23:51:44 UTC (rev 13452)
@@ -0,0 +1,75 @@
+/*
+ * 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.format.ttf.parse;
+
+import org.foray.common.primitive.PrimitiveFerry;
+import org.foray.font.FontParser;
+import org.foray.font.FontParserConsumer;
+import org.foray.font.format.ttf.TtfRandomAccessInput;
+import org.foray.font.format.ttf.TtfTablePclt;
+
+import java.io.IOException;
+
+/**
+ * Parses a TTF PCLT table.
+ * @see org.foray.font.format.ttf.TtfTablePclt
+ */
+public class PcltTableParser extends FontParser {
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final int size,
+ final FontParserConsumer consumer) throws IOException {
+ final PrimitiveFerry ferry = new PrimitiveFerry();
+ input.seek(offset);
+ final int majorVersion = input.read_uint16();
+ consumer.primitiveField("majorVersion", ferry.setInt(majorVersion)); // 2 bytes, total 2
+
+
+ /* PCLT Table, Version 1.0. */
+ consumer.primitiveField("minorVersion", ferry.setInt(input.read_uint16())); // 2 bytes, total 4
+ consumer.primitiveField("fontNumber", ferry.setLong(input.read_uint32())); // 4 bytes, total 8
+
+ consumer.primitiveField("pitch", ferry.setInt(input.read_uint16())); // 2 bytes, total 10
+ consumer.primitiveField("xHeight", ferry.setInt(input.read_uint16())); // 2 bytes, total 12
+ consumer.primitiveField("style", ferry.setInt(input.read_uint16())); // 2 bytes, total 14
+ consumer.primitiveField("typeFamily", ferry.setInt(input.read_uint16())); // 2 bytes, total 16
+ consumer.primitiveField("capHeight", ferry.setInt(input.read_uint16())); // 2 bytes, total 18
+ consumer.primitiveField("symbolSet", ferry.setInt(input.read_uint16())); // 2 bytes, total 20
+ consumer.objectField("typeface", input.readStringASCII(TtfTablePclt.TYPEFACE_CHARS));
+ // 16 bytes, total 36
+ consumer.objectField("characterComplement", input.readStringASCII(TtfTablePclt.CHARACTER_COMPLEMENT_CHARS));
+ // 8 bytes, total 44
+ consumer.objectField("fileName", input.readStringASCII(TtfTablePclt.FILE_NAME_CHARS));
+ // 6 bytes, total 50
+ consumer.primitiveField("strokeWeight", ferry.setByte(input.read_int8())); // 1 bytes, total 51
+ consumer.primitiveField("widthType", ferry.setByte(input.read_int8())); // 1 bytes, total 52
+ consumer.primitiveField("serifStyle", ferry.setShort(input.read_uint8())); // 1 bytes, total 53
+ }
+
+}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/TtfTableBaseParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/TtfTableBaseParser.java 2025-04-20 21:10:48 UTC (rev 13451)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/TtfTableBaseParser.java 2025-04-20 23:51:44 UTC (rev 13452)
@@ -1,69 +0,0 @@
-/*
- * 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.format.ttf.parse;
-
-import org.foray.common.primitive.PrimitiveFerry;
-import org.foray.font.FontParser;
-import org.foray.font.FontParserConsumer;
-import org.foray.font.format.ttf.TtfRandomAccessInput;
-
-import java.io.IOException;
-
-/**
- * Parses a TTF BASE table.
- * @see org.foray.font.format.ttf.TtfTableBase
- */
-public class TtfTableBaseParser extends FontParser {
-
- @Override
- public void parse(final TtfRandomAccessInput input, final int offset, final int size,
- final FontParserConsumer consumer) throws IOException {
- final PrimitiveFerry ferry = new PrimitiveFerry();
- input.seek(offset);
-
- final int majorVersion = input.read_uint16(); // 2 bytes, total 2
- consumer.primitiveField("majorVersion", ferry.setInt(majorVersion));
- final int minorVersion = input.read_uint16(); // 2 bytes, total 4
- consumer.primitiveField("minorVersion", ferry.setInt(minorVersion));
-
-
- /* BASE Table Header, Version 1.0. */
- final int horizAxisOffset = input.read_Offset16(); // 2 bytes, total 6
- consumer.primitiveField("horizAxisOffset", ferry.setInt(horizAxisOffset));
- final int vertAxisOffset = input.read_Offset16(); // 2 bytes, total 8
- consumer.primitiveField("vertAxisOffset", ferry.setInt(vertAxisOffset));
-
- /* BASE Table Header, Version 1.1. */
- if (minorVersion > 0) {
- final long itemVarStoreOffset = input.read_Offset32(); // 4 bytes, total 12
- consumer.primitiveField("itemVarStoreOffset", ferry.setLong(itemVarStoreOffset));
- }
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/TtfTableHeadParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/TtfTableHeadParser.java 2025-04-20 21:10:48 UTC (rev 13451)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/TtfTableHeadParser.java 2025-04-20 23:51:44 UTC (rev 13452)
@@ -1,82 +0,0 @@
-/*
- * 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.format.ttf.parse;
-
-import org.foray.common.primitive.PrimitiveFerry;
-import org.foray.font.FontParser;
-import org.foray.font.FontParserConsumer;
-import org.foray.font.format.ttf.TtfRandomAccessInput;
-
-import java.io.IOException;
-
-/**
- * Parses a TTF HEAD table.
- * @see org.foray.font.format.ttf.TtfTableHead
- */
-public class TtfTableHeadParser extends FontParser {
-
- @Override
- public void parse(final TtfRandomAccessInput input, final int offset, final int size,
- final FontParserConsumer consumer) throws IOException {
- final PrimitiveFerry ferry = new PrimitiveFerry();
- input.seek(offset);
- final int majorVersion = input.read_uint16(); // 2 bytes, total 2
- consumer.primitiveField("majorVersion", ferry.setInt(majorVersion));
-
-
- /* Head Table, Version 1.0. */
- consumer.primitiveField("minorVersion", ferry.setInt(input.read_uint16())); // 2 bytes, total 4
- consumer.objectField("fontRevision", input.read_Fixed()); // 4 bytes, total 8
- consumer.primitiveField("checksumAdjustment", ferry.setLong(input.read_uint32())); // 4 bytes, total 12
- consumer.primitiveField("magicNumber", ferry.setLong(input.read_uint32())); // 4 bytes, total 16
- consumer.primitiveField("flags", ferry.setInt(input.read_uint16())); // 2 bytes, total 18
- consumer.primitiveField("unitsPerEm", ferry.setInt(input.read_uint16())); // 2 bytes, total 20
- consumer.objectField("created", input.read_LONGDATETIME()); // 8 bytes, total 28
- consumer.objectField("modifed", input.read_LONGDATETIME()); // 8 bytes, total 36
-
- final short xMin = input.read_int16(); // 2 bytes, total 38
- final short yMin = input.read_int16(); // 2 bytes, total 40
- final short xMax = input.read_int16(); // 2 bytes, total 42
- final short yMax = input.read_int16(); // 2 bytes, total 44
- consumer.primitiveField("xMin", ferry.setShort(xMin));
- consumer.primitiveField("yMin", ferry.setShort(yMin));
- consumer.primitiveField("xMax", ferry.setShort(xMax));
- consumer.primitiveField("yMax", ferry.setShort(yMax));
- /* In case the consumer wants the four bounding box components already assembled. */
- final short[] boundingBox = {xMin, yMin, xMax, yMax};
- consumer.objectField("boundingBox", boundingBox);
-
- consumer.primitiveField("macStyle", ferry.setInt(input.read_uint16())); // 2 bytes, total 46
- consumer.primitiveField("lowestRecPPEM", ferry.setInt(input.read_uint16())); // 2 bytes, total 48
- consumer.primitiveField("fontDirectionHint", ferry.setShort(input.read_int16())); // 2 bytes, total 50
- consumer.primitiveField("indexToLocFormat", ferry.setShort(input.read_int16())); // 2 bytes, total 52
- consumer.primitiveField("glyphDataFormat", ferry.setShort(input.read_int16())); // 2 bytes, total 54
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/TtfTableOs2Parser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/TtfTableOs2Parser.java 2025-04-20 21:10:48 UTC (rev 13451)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/TtfTableOs2Parser.java 2025-04-20 23:51:44 UTC (rev 13452)
@@ -1,123 +0,0 @@
-/*
- * 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.format.ttf.parse;
-
-import org.foray.common.primitive.PrimitiveFerry;
-import org.foray.font.FontParser;
-import org.foray.font.FontParserConsumer;
-import org.foray.font.format.Panose4a;
-import org.foray.font.format.ttf.TtfRandomAccessInput;
-import org.foray.font.format.ttf.TtfTable;
-
-import org.checkerframework.checker.signedness.qual.Unsigned;
-
-import java.io.IOException;
-
-/**
- * Parses a TTF OS/2 table.
- * @see org.foray.font.format.ttf.TtfTableOs2
- */
-public class TtfTableOs2Parser extends FontParser {
-
- @Override
- public void parse(final TtfRandomAccessInput input, final int offset, final int size,
- final FontParserConsumer consumer) throws IOException {
- final PrimitiveFerry ferry = new PrimitiveFerry();
- input.seek(offset);
- final short version = input.read_uint16();
- consumer.primitiveField("version", ferry.setShort(version)); // 2 bytes, total 2
-
-
- /* OS/2 Table, Version 0. */
- consumer.primitiveField("xAvgCharWidth", ferry.setShort(input.read_FWORD())); // 2 bytes, total 4
- consumer.primitiveField("usWeightClass", ferry.setInt(input.read_uint16())); // 2 bytes, total 6
- consumer.primitiveField("usWidthClass", ferry.setInt(input.read_uint16())); // 2 bytes, total 8
- consumer.primitiveField("fsType", ferry.setInt(input.read_uint16())); // 2 bytes, total 10
- consumer.primitiveField("ySubscriptXSize", ferry.setShort(input.read_FWORD())); // 2 bytes, total 12
- consumer.primitiveField("ySubscriptYSize", ferry.setShort(input.read_FWORD())); // 2 bytes, total 14
- consumer.primitiveField("ySubscriptXOffset", ferry.setShort(input.read_FWORD())); // 2 bytes, total 16
- consumer.primitiveField("ySubscriptYOffset", ferry.setShort(input.read_FWORD())); // 2 bytes, total 18
- consumer.primitiveField("ySuperscriptXSize", ferry.setShort(input.read_FWORD())); // 2 bytes, total 20
- consumer.primitiveField("ySuperscriptYSize", ferry.setShort(input.read_FWORD())); // 2 bytes, total 22
- consumer.primitiveField("ySuperscriptXOffset", ferry.setShort(input.read_FWORD())); // 2 bytes, total 24
- consumer.primitiveField("ySuperscriptYOffset", ferry.setShort(input.read_FWORD())); // 2 bytes, total 26
- consumer.primitiveField("yStrikeoutSize", ferry.setShort(input.read_FWORD())); // 2 bytes, total 28
- consumer.primitiveField("yStrikeoutPosition", ferry.setShort(input.read_FWORD())); // 2 bytes, total 30
- consumer.primitiveField("sFamilyClass", ferry.setShort(input.read_int16())); // 2 bytes, total 32
-
- /* Read the Panose array. */
- final @Unsigned byte[] panoseArray = new byte[Panose4a.Field.values().length]; // 10 bytes, total 42
- for (int i = 0; i < panoseArray.length; i++) {
- panoseArray[i] = input.read_uint8();
- }
- consumer.objectField("panose", panoseArray);
-
- consumer.primitiveField("ulUnicodeRange1", ferry.setLong(input.read_uint32())); // 4 bytes, total 46
- consumer.primitiveField("ulUnicodeRange2", ferry.setLong(input.read_uint32())); // 4 bytes, total 50
- consumer.primitiveField("ulUnicodeRange3", ferry.setLong(input.read_uint32())); // 4 bytes, total 54
- consumer.primitiveField("ulUnicodeRange4", ferry.setLong(input.read_uint32())); // 4 bytes, total 58
- consumer.objectField("achVendID", input.read_Tag()); // 4 bytes, total 62
- consumer.primitiveField("fsSelection", ferry.setInt(input.read_uint16())); // 2 bytes, total 64
- consumer.primitiveField("usFirstCharIndex", ferry.setInt(input.read_uint16())); // 2 bytes, total 66
- consumer.primitiveField("usLastCharIndex", ferry.setInt(input.read_uint16())); // 2 bytes, total 68
- consumer.primitiveField("sTypoAscender", ferry.setShort(input.read_FWORD())); // 2 bytes, total 70
- consumer.primitiveField("sTypoDescender", ferry.setShort(input.read_FWORD())); // 2 bytes, total 72
- consumer.primitiveField("sTypoLineGap", ferry.setShort(input.read_FWORD())); // 2 bytes, total 74
- consumer.primitiveField("usWinAscent", ferry.setInt(input.read_UFWORD())); // 2 bytes, total 76
- consumer.primitiveField("usWinDescent", ferry.setInt(input.read_UFWORD())); // 2 bytes, total 78
-
- if (version < TtfTable.MajorVersion.v1.getValue()) {
- return;
- }
-
- /* OS/2 Table, Version 1. */
- consumer.primitiveField("ulCodePageRange1", ferry.setLong(input.read_uint32())); // 4 bytes, total 82
- consumer.primitiveField("ulCodePageRange2", ferry.setLong(input.read_uint32())); // 4 bytes, total 86
-
- if (version < TtfTable.MajorVersion.v2.getValue()) {
- return;
- }
-
- /* OS/2 Table, Version 2. Versions 3 & 4 are the same as Version 2. */
- consumer.primitiveField("sxHeight", ferry.setShort(input.read_FWORD())); // 2 bytes, total 88
- consumer.primitiveField("sCapHeight", ferry.setShort(input.read_FWORD())); // 2 bytes, total 90
- consumer.primitiveField("usDefaultChar", ferry.setInt(input.read_uint16())); // 2 bytes, total 92
- consumer.primitiveField("usBreakChar", ferry.setInt(input.read_uint16())); // 2 bytes, total 94
- consumer.primitiveField("usMaxContext", ferry.setInt(input.read_uint16())); // 2 bytes, total 96
-
- if (version < TtfTable.MajorVersion.v5.getValue()) {
- return;
- }
-
- /* OS/2 Table, Version 5. */
- consumer.primitiveField("usLowerOpticalPointSize", ferry.setInt(input.read_uint16())); // 2 bytes, total 98
- consumer.primitiveField("usUpperOpticalPointSize", ferry.setInt(input.read_uint16())); // 2 bytes, total 100
- }
-
-}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/TtfTablePcltParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/TtfTablePcltParser.java 2025-04-20 21:10:48 UTC (rev 13451)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/format/ttf/parse/TtfTablePcltParser.java 2025-04-20 23:51:44 UTC (rev 13452)
@@ -1,75 +0,0 @@
-/*
- * 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.format.ttf.parse;
-
-import org.foray.common.primitive.PrimitiveFerry;
-import org.foray.font.FontParser;
-import org.foray.font.FontParserConsumer;
-import org.foray.font.format.ttf.TtfRandomAccessInput;
-import org.foray.font.format.ttf.TtfTablePclt;
-
-import java.io.IOException;
-
-/**
- * Parses a TTF PCLT table.
- * @see org.foray.font.format.ttf.TtfTablePclt
- */
-public class TtfTablePcltParser extends FontParser {
-
- @Override
- public void parse(final TtfRandomAccessInput input, final int offset, final int size,
- final FontParserConsumer consumer) throws IOException {
- final PrimitiveFerry ferry = new PrimitiveFerry();
- input.seek(offset);
- final int majorVersion = input.read_uint16();
- consumer.primitiveField("majorVersion", ferry.setInt(majorVersion)); // 2 bytes, total 2
-
-
- /* PCLT Table, Version 1.0. */
- consumer.primitiveField("minorVersion", ferry.setInt(input.read_uint16())); // 2 bytes, total 4
- consumer.primitiveField("fontNumber", ferry.setLong(input.read_uint32())); // 4 bytes, total 8
-
- consumer.primitiveField("pitch", ferry.setInt(input.read_uint16())); // 2 bytes, total 10
- consumer.primitiveField("xHeight", ferry.setInt(input.read_uint16())); // 2 bytes, total 12
- consumer.primitiveField("style", ferry.setInt(input.read_uint16())); // 2 bytes, total 14
- consumer.primitiveField("typeFamily", ferry.setInt(input.read_uint16())); // 2 bytes, total 16
- consumer.primitiveField("capHeight", ferry.setInt(input.read_uint16())); // 2 bytes, total 18
- consumer.primitiveField("symbolSet", ferry.setInt(input.read_uint16())); // 2 bytes, total 20
- consumer.objectField("typeface", input.readStringASCII(TtfTablePclt.TYPEFACE_CHARS));
- // 16 bytes, total 36
- consumer.objectField("characterComplement", input.readStringASCII(TtfTablePclt.CHARACTER_COMPLEMENT_CHARS));
- // 8 bytes, total 44
- consumer.objectField("fileName", input.readStringASCII(TtfTablePclt.FILE_NAME_CHARS));
- // 6 bytes, total 50
- consumer.primitiveField("strokeWeight", ferry.setByte(input.read_int8())); // 1 bytes, total 51
- consumer.primitiveField("widthType", ferry.setByte(input.read_int8())); // 1 bytes, total 52
- consumer.primitiveField("serifStyle", ferry.setShort(input.read_uint8())); // 1 bytes, total 53
- }
-
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|