foray-commit Mailing List for FOray (Page 15)
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-27 12:35:21
|
Revision: 13528
http://sourceforge.net/p/foray/code/13528
Author: victormote
Date: 2025-04-27 12:35:03 +0000 (Sun, 27 Apr 2025)
Log Message:
-----------
Improvements to Cmap04.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java
Added Paths:
-----------
trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/Cmap04TableTests.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java 2025-04-27 10:38:57 UTC (rev 13527)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java 2025-04-27 12:35:03 UTC (rev 13528)
@@ -30,6 +30,8 @@
import org.axsl.ps.Encoding;
+import org.checkerframework.checker.signedness.qual.Unsigned;
+
/**
* Class containing a set of 16-bit Unicode ranges that sequentially map to the same-sized range of glyph indexes.
* The contents are analogous to a Format 4 TrueType Font cmap table (from which this class derives its name).
@@ -43,19 +45,18 @@
public class Entry {
/** The first Unicode code point in this entry. */
- private int unicodeStart;
+ private @Unsigned short unicodeStart;
/** The last Unicode code point in this entry.*/
- private int unicodeEnd;
+ private @Unsigned short unicodeEnd;
/** The starting glyph index for this entry. This index points to the glyph
* representing {@link #unicodeStart}. */
- private char glyphStartIndex;
+ private @Unsigned short glyphStartIndex;
/** The list of non-contiguous entries, if any, for this entry.
* For contiguous entries, this will be null.
- * For non-contiguous entries, this array contains the glyph Indexes for the
- * range of Unicode characters. */
+ * For non-contiguous entries, this array contains the glyph Indexes for the range of Unicode characters. */
private CharSequence glyphIndexes;
/**
@@ -66,7 +67,8 @@
* @param glyphStartIndex The starting glyph index mapped by this mapping.
* This is the encoded value for {@code unicodeStart}.
*/
- public Entry(final int unicodeStart, final int unicodeEnd, final char glyphStartIndex) {
+ public Entry(final @Unsigned short unicodeStart, final @Unsigned short unicodeEnd,
+ final @Unsigned short glyphStartIndex) {
this.unicodeStart = unicodeStart;
this.unicodeEnd = unicodeEnd;
this.glyphStartIndex = glyphStartIndex;
@@ -80,7 +82,8 @@
* @param glyphIndexes The array of encoded glyph indexes corresponding to
* the range {@code unicodeStart} through {@code unicodeEnd}.
*/
- public Entry(final int unicodeStart, final int unicodeEnd, final CharSequence glyphIndexes) {
+ public Entry(final @Unsigned short unicodeStart, final @Unsigned short unicodeEnd,
+ final CharSequence glyphIndexes) {
this.unicodeStart = unicodeStart;
this.unicodeEnd = unicodeEnd;
this.glyphIndexes = glyphIndexes;
@@ -160,18 +163,16 @@
/** The array of entries. */
private Entry[] entries;
- /** Counter to the last entry added. */
+ /** Index to the last entry added. */
private int lastEntryAdded = -1;
/**
* Constructor.
- * @param name The name of this encoding.
* @param expectedEntries The number of expected entries in this encoding.
* Setting this to the correct value will result in more efficient
* processing.
*/
- public Cmap04Table(final String name, final int expectedEntries) {
- this.name = name;
+ public Cmap04Table(final int expectedEntries) {
this.entries = new Entry[expectedEntries];
}
@@ -200,9 +201,10 @@
* @param glyphStartIndex The starting glyph index for this map.
* This index is the encoded value for {@code unicodeStart}.
*/
- public void addEntry(final int unicodeStart, final int unicodeEnd, final char glyphStartIndex) {
- final Entry newEntry = new Entry(unicodeStart, unicodeEnd,
- glyphStartIndex);
+ public void addEntry(final @Unsigned int unicodeStart, final @Unsigned int unicodeEnd,
+ final @Unsigned int glyphStartIndex) {
+ final Entry newEntry = new Entry((@Unsigned short) unicodeStart, (@Unsigned short) unicodeEnd,
+ (@Unsigned short) glyphStartIndex);
addEntry(newEntry);
}
@@ -213,8 +215,8 @@
* @param glyphIndexes The array of glyph indexes corresponding to the range {@code unicodeStart} through
* {@code unicodeEnd}.
*/
- public void addEntry(final int unicodeStart, final int unicodeEnd, final CharSequence glyphIndexes) {
- final Entry newEntry = new Entry(unicodeStart, unicodeEnd, glyphIndexes);
+ public void addEntry(final int unicodeStart, final @Unsigned int unicodeEnd, final CharSequence glyphIndexes) {
+ final Entry newEntry = new Entry((@Unsigned short) unicodeStart, (@Unsigned short) unicodeEnd, glyphIndexes);
addEntry(newEntry);
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java 2025-04-27 10:38:57 UTC (rev 13527)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java 2025-04-27 12:35:03 UTC (rev 13528)
@@ -30,9 +30,12 @@
import org.foray.common.RandomAccessInput;
import org.foray.font.ttf.RoTable;
+import org.foray.fontParse.ttf.TtfRandomAccessInput;
import org.axsl.ps.Encoding;
+import org.checkerframework.checker.signedness.qual.Unsigned;
+
import java.io.IOException;
/**
@@ -80,7 +83,7 @@
* @return The parsed instance.
* @throws IOException For I/O Error.
*/
- public static CmapTable parse(final RandomAccessInput input, final int offset, final int length,
+ public static CmapTable parse(final TtfRandomAccessInput input, final int offset, final int length,
final String fontPostScriptName) throws IOException {
input.seek(offset);
final CmapTable cmap = new CmapTable();
@@ -138,7 +141,7 @@
* @return The parsed Cmap4a instance.
* @throws IOException For I/O Error.
*/
- private static Encoding parseCMap(final RandomAccessInput input, final int tableOffset,
+ private static Encoding parseCMap(final TtfRandomAccessInput input, final int tableOffset,
final long offsetToParse, final String fontPostScriptName) throws IOException {
input.seek(tableOffset + offsetToParse);
final int formatHigh = input.readUnsignedShort();
@@ -168,7 +171,7 @@
* @return The parsed Cmap4a format 4 table.
* @throws IOException For I/O Error.
*/
- private static Cmap04Table parseCMap04(final RandomAccessInput raInput, final String fontPostScriptName)
+ private static Cmap04Table parseCMap04(final TtfRandomAccessInput raInput, final String fontPostScriptName)
throws IOException {
/* Format and Length have already been read. */
/* Skip version */
@@ -181,13 +184,13 @@
/* Skip rangeShift. */
raInput.skipBytes(RoTable.USHORT_BYTES);
- final int[] endCount = new int[segCountX2 / 2];
+ final @Unsigned short[] endCount = new @Unsigned short[segCountX2 / 2];
final int[] startCount = new int[segCountX2 / 2];
final int deltas[] = new int[segCountX2 / 2];
final int rangeOffset[] = new int[segCountX2 / 2];
for (int i = 0; i < (segCountX2 / 2); i++) {
- endCount[i] = (char) raInput.readUnsignedShort();
+ endCount[i] = raInput.read_uint16();
}
/* Skip reservedPad. */
@@ -208,13 +211,12 @@
final int glyphIdArrayOffset = (int) raInput.getOffset();
// Parse the table entries and build a CMap4 from them.
- final String encodingName = "internal-" + fontPostScriptName;
- final Cmap04Table cmap04 = new Cmap04Table(encodingName, segCountX2 / 2);
+ final Cmap04Table cmap04 = new Cmap04Table(segCountX2 / 2);
for (int i = 0; i < startCount.length; i++) {
if (rangeOffset[i] == 0) {
cmap04.addEntry(startCount[i],
endCount[i],
- (char) (startCount[i] + deltas[i]));
+ (short) (startCount[i] + deltas[i]));
} else {
final char[] computedIndexes = new char[endCount[i]
- startCount[i] + 1];
Added: trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/Cmap04TableTests.java
===================================================================
--- trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/Cmap04TableTests.java (rev 0)
+++ trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/Cmap04TableTests.java 2025-04-27 12:35:03 UTC (rev 13528)
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+package org.foray.font.ttf.table;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests of {@link Cmap04Table}.
+ */
+public class Cmap04TableTests {
+
+ /**
+ * Test of creating and using a Type 04 Cmap table.
+ * Since we neither need to create nor use the optimization fields, we ignore them for these tests.
+ * All we care about is whether we can accurately encode & decode.
+ */
+ @Test
+ @Disabled
+ public void test01() {
+ final Cmap04Table out = new Cmap04Table(5);
+ /* Add some contiguous segments. */
+ out.addEntry(20, 30, (short) 100);
+ out.addEntry(120, 130, (short) 200);
+
+ /* Add some non-contiguous segments. */
+ out.addEntry(220, 230, "abc");
+ out.addEntry(320, 330, "xyz");
+ out.addEntry(Character.MAX_VALUE, Character.MAX_VALUE, (short) 0);
+
+ assertFalse(out.canEncode(1));
+ assertTrue(out.canEncode(225));
+
+ assertEquals(401, out.encode(321));
+ assertEquals(321, out.decode(401));
+ }
+
+}
Property changes on: trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/Cmap04TableTests.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-27 10:39:15
|
Revision: 13527
http://sourceforge.net/p/foray/code/13527
Author: victormote
Date: 2025-04-27 10:38:57 +0000 (Sun, 27 Apr 2025)
Log Message:
-----------
Rename variables to match TTF/OTF doc.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Table.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Table.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Table.java 2025-04-27 10:33:30 UTC (rev 13526)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Table.java 2025-04-27 10:38:57 UTC (rev 13527)
@@ -45,17 +45,16 @@
private String name;
/** The first Unicode code point in this entry. */
- private @Unsigned int[] unicodeStart;
+ private @Unsigned int[] startCharCode;
/** The last Unicode code point in this entry.*/
- private @Unsigned int[] unicodeEnd;
+ private @Unsigned int[] endCharCode;
/** The starting glyph index for this entry. This index points to the glyph
- * representing {@link #unicodeStart}. */
- private @Unsigned int[] glyphStartIndex;
+ * representing {@link #startCharCode}. */
+ private @Unsigned int[] startGlyphID;
-
- /** Counter to the last entry added. */
+ /** Index to the last entry added. */
private int lastEntryAdded = -1;
/**
@@ -67,9 +66,9 @@
*/
public Cmap12Table(final String name, final int expectedEntries) {
this.name = name;
- this.unicodeStart = new @Unsigned int[expectedEntries];
- this.unicodeEnd = new @Unsigned int[expectedEntries];
- this.glyphStartIndex = new @Unsigned int[expectedEntries];
+ this.startCharCode = new @Unsigned int[expectedEntries];
+ this.endCharCode = new @Unsigned int[expectedEntries];
+ this.startGlyphID = new @Unsigned int[expectedEntries];
}
@Override
@@ -86,17 +85,17 @@
*/
public void addEntry(final int unicodeStart, final int unicodeEnd, final int glyphStartIndex) {
this.lastEntryAdded ++;
- this.unicodeStart[this.lastEntryAdded] = unicodeStart;
- this.unicodeEnd[this.lastEntryAdded] = unicodeEnd;
- this.glyphStartIndex[this.lastEntryAdded] = glyphStartIndex;
+ this.startCharCode[this.lastEntryAdded] = unicodeStart;
+ this.endCharCode[this.lastEntryAdded] = unicodeEnd;
+ this.startGlyphID[this.lastEntryAdded] = glyphStartIndex;
}
@Override
public int encode(final int codePoint) {
- for (int index = 0; index < this.unicodeStart.length; index ++) {
- if (codePoint >= this.unicodeStart[index]
- && codePoint <= this.unicodeEnd[index]) {
- return codePoint - this.unicodeStart[index] + this.glyphStartIndex[index];
+ for (int index = 0; index < this.startCharCode.length; index ++) {
+ if (codePoint >= this.startCharCode[index]
+ && codePoint <= this.endCharCode[index]) {
+ return codePoint - this.startCharCode[index] + this.startGlyphID[index];
}
}
return -1;
@@ -104,10 +103,10 @@
@Override
public int decode(final int glyphIndex) {
- for (int index = 0; index < this.unicodeStart.length; index++) {
- final int provisionalCodePoint = glyphIndex - this.glyphStartIndex[index] + this.unicodeStart[index];
- if (provisionalCodePoint >= this.unicodeStart[index]
- && provisionalCodePoint <= this.unicodeEnd[index]) {
+ for (int index = 0; index < this.startCharCode.length; index++) {
+ final int provisionalCodePoint = glyphIndex - this.startGlyphID[index] + this.startCharCode[index];
+ if (provisionalCodePoint >= this.startCharCode[index]
+ && provisionalCodePoint <= this.endCharCode[index]) {
return provisionalCodePoint;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-27 10:33:48
|
Revision: 13526
http://sourceforge.net/p/foray/code/13526
Author: victormote
Date: 2025-04-27 10:33:30 +0000 (Sun, 27 Apr 2025)
Log Message:
-----------
Flatten inner class into parallel arrays.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Table.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Table.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Table.java 2025-04-27 09:56:26 UTC (rev 13525)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Table.java 2025-04-27 10:33:30 UTC (rev 13526)
@@ -30,6 +30,8 @@
import org.axsl.ps.Encoding;
+import org.checkerframework.checker.signedness.qual.Unsigned;
+
/**
* Class containing a set of 32-bit Unicode ranges that sequentially map to the same-sized range of glyph indexes.
* The contents are analogous to a Format 12 TrueType Font cmap table (from which this class derives its name).
@@ -36,97 +38,6 @@
*/
public class Cmap12Table implements Encoding {
- /**
- * Contains one entry from a TrueType Cmap4a subtable, Format 12, which handles
- * 32-bit Unicode code point ranges.
- */
- public class Entry {
-
- /** The first Unicode code point in this entry. */
- private int unicodeStart;
-
- /** The last Unicode code point in this entry.*/
- private int unicodeEnd;
-
- /** The starting glyph index for this entry. This index points to the glyph
- * representing {@link #unicodeStart}. */
- private int glyphStartIndex;
-
- /**
- * Constructor.
- * @param unicodeStart The starting Unicode code point covered by this
- * mapping.
- * @param unicodeEnd The ending Unicode code point covered by this mapping.
- * @param glyphStartIndex The starting glyph index mapped by this mapping.
- * This is the encoded value for {@code unicodeStart}.
- */
- public Entry(final int unicodeStart, final int unicodeEnd,
- final int glyphStartIndex) {
- this.unicodeStart = unicodeStart;
- this.unicodeEnd = unicodeEnd;
- this.glyphStartIndex = glyphStartIndex;
- }
-
- /**
- * Compute the glyphEndIndex that is implied from the raw data.
- * @return The last glyphIndex that is addressed by this entry, i.e. the
- * glyph index that corresponds to unicodeEnd.
- */
- public int getGlyphEndIndex() {
- return this.glyphStartIndex + this.unicodeEnd - this.unicodeStart;
- }
-
- /**
- * Indicates whether this entry can encode a given character.
- * @param codePoint The Unicode code point to be tested.
- * @return True if and only if this entry has encoding information for
- * {@code codePoint}.
- */
- public boolean containsChar(final int codePoint) {
- if (codePoint < this.unicodeStart) {
- return false;
- }
- if (codePoint > this.unicodeEnd) {
- return false;
- }
- return true;
- }
-
- /**
- * Encodes a given character.
- * @param codePoint The Unicode code point to be encoded.
- * @return The glyph index corresponding to {@code codePoint}, or zero
- * if this entry does not know how to encode it.
- */
- public int encodeCharacter(final int codePoint) {
- if (! containsChar(codePoint)) {
- return 0;
- }
- return codePoint - this.unicodeStart + this.glyphStartIndex;
- }
-
- /**
- * Decodes a given glyphIndex.
- * @param glyphIndex The glyph index to be decoded.
- * @return The Unicode code point corresponding to {@code glyphIndex},
- * or {@link Character#MAX_VALUE} if this entry does not know how to decode
- * it.
- */
- public int decodeCharacter(final int glyphIndex) {
- final int provisionalCodePoint = glyphIndex - this.glyphStartIndex + this.unicodeStart;
- if (provisionalCodePoint >= this.unicodeStart
- && provisionalCodePoint <= this.unicodeEnd) {
- return provisionalCodePoint;
- }
- return Character.MAX_VALUE;
- }
-
- }
-
-
-
-
-
/** Constant needed for serialization. */
public static final long serialVersionUID = -606154911100219394L;
@@ -133,9 +44,17 @@
/** The name of this encoding. */
private String name;
- /** The array of entries. */
- private Entry[] entries;
+ /** The first Unicode code point in this entry. */
+ private @Unsigned int[] unicodeStart;
+ /** The last Unicode code point in this entry.*/
+ private @Unsigned int[] unicodeEnd;
+
+ /** The starting glyph index for this entry. This index points to the glyph
+ * representing {@link #unicodeStart}. */
+ private @Unsigned int[] glyphStartIndex;
+
+
/** Counter to the last entry added. */
private int lastEntryAdded = -1;
@@ -148,7 +67,9 @@
*/
public Cmap12Table(final String name, final int expectedEntries) {
this.name = name;
- this.entries = new Entry[expectedEntries];
+ this.unicodeStart = new @Unsigned int[expectedEntries];
+ this.unicodeEnd = new @Unsigned int[expectedEntries];
+ this.glyphStartIndex = new @Unsigned int[expectedEntries];
}
@Override
@@ -158,60 +79,36 @@
/**
* Add a new entry to this map.
- * @param entry The entry to be added.
- */
- public void addEntry(final Entry entry) {
- this.lastEntryAdded++;
- if (this.lastEntryAdded >= this.entries.length) {
- // Fails silently.
- return;
- }
- this.entries[this.lastEntryAdded] = entry;
- }
-
- /**
- * Add a new entry to this map.
* @param unicodeStart The starting Unicode code point for this map.
* @param unicodeEnd The ending Unicode code point for this map.
* @param glyphStartIndex The starting glyph index for this map.
* This index is the encoded value for {@code unicodeStart}.
*/
- public void addEntry(final int unicodeStart, final int unicodeEnd,
- final int glyphStartIndex) {
- final Entry newEntry = new Entry(unicodeStart, unicodeEnd,
- glyphStartIndex);
- addEntry(newEntry);
+ public void addEntry(final int unicodeStart, final int unicodeEnd, final int glyphStartIndex) {
+ this.lastEntryAdded ++;
+ this.unicodeStart[this.lastEntryAdded] = unicodeStart;
+ this.unicodeEnd[this.lastEntryAdded] = unicodeEnd;
+ this.glyphStartIndex[this.lastEntryAdded] = glyphStartIndex;
}
@Override
public int encode(final int codePoint) {
- final Entry entry = entryForChar(codePoint);
- if (entry == null) {
- return -1;
- }
- return entry.encodeCharacter(codePoint);
- }
-
- /**
- * Find the entry for a given character.
- * @param codePoint The Unicode code point for which an entry is sought.
- * @return The entry, or null if none is defined for {@code codePoint}.
- */
- private Entry entryForChar(final int codePoint) {
- for (int i = 0; i < this.entries.length; i++) {
- if (this.entries[i].containsChar(codePoint)) {
- return this.entries[i];
+ for (int index = 0; index < this.unicodeStart.length; index ++) {
+ if (codePoint >= this.unicodeStart[index]
+ && codePoint <= this.unicodeEnd[index]) {
+ return codePoint - this.unicodeStart[index] + this.glyphStartIndex[index];
}
}
- return null;
+ return -1;
}
@Override
- public int decode(final int glyphIndexInput) {
- for (int i = 0; i < this.entries.length; i++) {
- final int codePoint = this.entries[i].decodeCharacter(glyphIndexInput);
- if (codePoint != Character.MAX_VALUE) {
- return codePoint;
+ public int decode(final int glyphIndex) {
+ for (int index = 0; index < this.unicodeStart.length; index++) {
+ final int provisionalCodePoint = glyphIndex - this.glyphStartIndex[index] + this.unicodeStart[index];
+ if (provisionalCodePoint >= this.unicodeStart[index]
+ && provisionalCodePoint <= this.unicodeEnd[index]) {
+ return provisionalCodePoint;
}
}
return -1;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-27 09:56:46
|
Revision: 13525
http://sourceforge.net/p/foray/code/13525
Author: victormote
Date: 2025-04-27 09:56:26 +0000 (Sun, 27 Apr 2025)
Log Message:
-----------
Add Cmap12 test and fix decode method.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Table.java
Added Paths:
-----------
trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/Cmap12TableTests.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Table.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Table.java 2025-04-27 00:29:53 UTC (rev 13524)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Table.java 2025-04-27 09:56:26 UTC (rev 13525)
@@ -113,11 +113,10 @@
* it.
*/
public int decodeCharacter(final int glyphIndex) {
- final int codePoint = glyphIndex - this.glyphStartIndex
- + this.unicodeStart;
- if (glyphIndex >= this.glyphStartIndex
- && codePoint <= this.unicodeStart) {
- return codePoint;
+ final int provisionalCodePoint = glyphIndex - this.glyphStartIndex + this.unicodeStart;
+ if (provisionalCodePoint >= this.unicodeStart
+ && provisionalCodePoint <= this.unicodeEnd) {
+ return provisionalCodePoint;
}
return Character.MAX_VALUE;
}
Added: trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/Cmap12TableTests.java
===================================================================
--- trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/Cmap12TableTests.java (rev 0)
+++ trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/Cmap12TableTests.java 2025-04-27 09:56:26 UTC (rev 13525)
@@ -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.table;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests of {@link Cmap12Table}.
+ */
+public class Cmap12TableTests {
+
+ /**
+ * Test of creating and using a Type 12 Cmap table.
+ */
+ @Test
+ public void test01() {
+ final Cmap12Table out = new Cmap12Table("test", 5);
+ out.addEntry(20, 30, 100);
+ out.addEntry(120, 130, 200);
+ out.addEntry(220, 230, 300);
+ out.addEntry(320, 330, 400);
+ out.addEntry(420, 430, 500);
+
+ assertFalse(out.canEncode(1));
+ assertTrue(out.canEncode(225));
+
+ assertEquals(401, out.encode(321));
+ assertEquals(321, out.decode(401));
+ }
+
+}
Property changes on: trunk/foray/foray-font/src/test/java/org/foray/font/ttf/table/Cmap12TableTests.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-27 00:30:10
|
Revision: 13524
http://sourceforge.net/p/foray/code/13524
Author: victormote
Date: 2025-04-27 00:29:53 +0000 (Sun, 27 Apr 2025)
Log Message:
-----------
Clean up naming of Cmap classes.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java
Added Paths:
-----------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Table.java
Removed Paths:
-------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Ttf4a.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Ttf4a.java
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java (from rev 13523, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Ttf4a.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java 2025-04-27 00:29:53 UTC (rev 13524)
@@ -0,0 +1,289 @@
+/*
+ * 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.Encoding;
+
+/**
+ * Class containing a set of 16-bit Unicode ranges that sequentially map to the same-sized range of glyph indexes.
+ * The contents are analogous to a Format 4 TrueType Font cmap table (from which this class derives its name).
+ */
+public class Cmap04Table implements Encoding {
+
+ /**
+ * Contains one entry from a TrueType Cmap4a subtable, format 4, which handles
+ * 16-bit Unicode code point ranges.
+ */
+ public class Entry {
+
+ /** The first Unicode code point in this entry. */
+ private int unicodeStart;
+
+ /** The last Unicode code point in this entry.*/
+ private int unicodeEnd;
+
+ /** The starting glyph index for this entry. This index points to the glyph
+ * representing {@link #unicodeStart}. */
+ private char glyphStartIndex;
+
+ /** The list of non-contiguous entries, if any, for this entry.
+ * For contiguous entries, this will be null.
+ * For non-contiguous entries, this array contains the glyph Indexes for the
+ * range of Unicode characters. */
+ private CharSequence glyphIndexes;
+
+ /**
+ * Constructor for contiguous entries.
+ * @param unicodeStart The starting Unicode code point covered by this
+ * mapping.
+ * @param unicodeEnd The ending Unicode code point covered by this mapping.
+ * @param glyphStartIndex The starting glyph index mapped by this mapping.
+ * This is the encoded value for {@code unicodeStart}.
+ */
+ public Entry(final int unicodeStart, final int unicodeEnd, final char glyphStartIndex) {
+ this.unicodeStart = unicodeStart;
+ this.unicodeEnd = unicodeEnd;
+ this.glyphStartIndex = glyphStartIndex;
+ }
+
+ /**
+ * Constructor for non-contiguous entries.
+ * @param unicodeStart The starting Unicode code point covered by this
+ * mapping.
+ * @param unicodeEnd The ending Unicode code point covered by this mapping.
+ * @param glyphIndexes The array of encoded glyph indexes corresponding to
+ * the range {@code unicodeStart} through {@code unicodeEnd}.
+ */
+ public Entry(final int unicodeStart, final int unicodeEnd, final CharSequence glyphIndexes) {
+ this.unicodeStart = unicodeStart;
+ this.unicodeEnd = unicodeEnd;
+ this.glyphIndexes = glyphIndexes;
+ }
+
+ /**
+ * Compute the glyphEndIndex that is implied from the raw data.
+ * @return The last glyphIndex that is addressed by this entry, i.e. the
+ * glyph index that corresponds to unicodeEnd.
+ */
+ public char getGlyphEndIndex() {
+ return (char) (this.glyphStartIndex + this.unicodeEnd
+ - this.unicodeStart);
+ }
+
+ /**
+ * Indicates whether this entry can encode a given character.
+ * @param c The character to be tested.
+ * @return True if and only if this entry has encoding information for {@code c}.
+ */
+ public boolean containsChar(final int c) {
+ return (c >= this.unicodeStart) && (c <= this.unicodeEnd);
+ }
+
+ /**
+ * Encodes a given character.
+ * @param c The character to be encoded.
+ * @return The glyph index corresponding to {@code c}, or -1 if this entry does not know how to encode it.
+ */
+ public int encodeCharacter(final int c) {
+ if (! containsChar(c)) {
+ return -1;
+ }
+ if (this.glyphIndexes == null) {
+ return (char) (c - this.unicodeStart + this.glyphStartIndex);
+ }
+ return this.glyphIndexes.charAt(c - this.unicodeStart);
+ }
+
+ /**
+ * Decodes a given glyphIndex.
+ * @param glyphIndex The glyph index to be decoded.
+ * @return The Unicode code point corresponding to {@code glyphIndex}, or -1 if this entry does not know how to
+ * decode it.
+ */
+ public int decodeCharacter(final int glyphIndex) {
+ if (this.glyphIndexes == null) {
+ final char codePoint = (char) (glyphIndex - this.glyphStartIndex + this.unicodeStart);
+ if (glyphIndex >= this.glyphStartIndex
+ && codePoint <= this.unicodeStart) {
+ return codePoint;
+ }
+ return -1;
+ }
+ for (int i = 0; i < this.glyphIndexes.length(); i++) {
+ if (this.glyphIndexes.charAt(i) == glyphIndex) {
+ return this.unicodeStart + i;
+ }
+ }
+ return -1;
+ }
+
+ }
+
+
+
+
+
+
+
+ /** Constant needed for serialization. */
+ public static final long serialVersionUID = 985957847129472354L;
+
+ /** The name of this encoding. */
+ private String name;
+
+ /** The array of entries. */
+ private Entry[] entries;
+
+ /** Counter to the last entry added. */
+ private int lastEntryAdded = -1;
+
+ /**
+ * Constructor.
+ * @param name The name of this encoding.
+ * @param expectedEntries The number of expected entries in this encoding.
+ * Setting this to the correct value will result in more efficient
+ * processing.
+ */
+ public Cmap04Table(final String name, final int expectedEntries) {
+ this.name = name;
+ this.entries = new Entry[expectedEntries];
+ }
+
+ @Override
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * Add a new entry to this map.
+ * @param entry The entry to be added.
+ */
+ public void addEntry(final Entry entry) {
+ this.lastEntryAdded++;
+ if (this.lastEntryAdded >= this.entries.length) {
+ // Fails silently.
+ return;
+ }
+ this.entries[this.lastEntryAdded] = entry;
+ }
+
+ /**
+ * Add a new entry to this map for contiguous values.
+ * @param unicodeStart The starting Unicode code point for this map.
+ * @param unicodeEnd The ending Unicode code point for this map.
+ * @param glyphStartIndex The starting glyph index for this map.
+ * This index is the encoded value for {@code unicodeStart}.
+ */
+ public void addEntry(final int unicodeStart, final int unicodeEnd, final char glyphStartIndex) {
+ final Entry newEntry = new Entry(unicodeStart, unicodeEnd,
+ glyphStartIndex);
+ addEntry(newEntry);
+ }
+
+ /**
+ * Add a new entry to this map for non-contiguous values.
+ * @param unicodeStart The starting Unicode code point for this map.
+ * @param unicodeEnd The ending Unicode code point for this map.
+ * @param glyphIndexes The array of glyph indexes corresponding to the range {@code unicodeStart} through
+ * {@code unicodeEnd}.
+ */
+ public void addEntry(final int unicodeStart, final int unicodeEnd, final CharSequence glyphIndexes) {
+ final Entry newEntry = new Entry(unicodeStart, unicodeEnd, glyphIndexes);
+ addEntry(newEntry);
+ }
+
+ @Override
+ public int encode(final int c) {
+ final Entry entry = entryForChar((char) c);
+ if (entry == null) {
+ return -1;
+ }
+ return entry.encodeCharacter((char) c);
+ }
+
+ /**
+ * Find the entry for a given character.
+ * @param c The character for which an entry is sought.
+ * @return The entry, or null if none is defined for {@code c}.
+ */
+ private Entry entryForChar(final char c) {
+ for (int i = 0; i < this.entries.length; i++) {
+ if (this.entries[i].containsChar(c)) {
+ return this.entries[i];
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public int decode(final int glyphIndexInput) {
+ for (int i = 0; i < this.entries.length; i++) {
+ final int codePoint = this.entries[i].decodeCharacter(glyphIndexInput);
+ if (codePoint > -1) {
+ return codePoint;
+ }
+ }
+ return -1;
+ }
+
+ @Override
+ public String asPostScript(final org.axsl.ps.Encoding baseEncoding) {
+ return null;
+ }
+
+ @Override
+ public int getFirstIndex() {
+ return -1;
+ }
+
+ @Override
+ public int getLastIndex() {
+ return -1;
+ }
+
+ @Override
+ public boolean isBuiltInPs() {
+ /* TODO Make this class abstract and make a subclass that handled custom instances, so that we can keep the
+ * prebuilt instances separate, and return different values here. */
+ return false;
+ }
+
+ @Override
+ public boolean isBuiltInPdf() {
+ /* TODO Make this class abstract and make a subclass that handled custom instances, so that we can keep the
+ * prebuilt instances separate, and return different values here. */
+ return false;
+ }
+
+ @Override
+ public boolean canEncode(final int codePoint) {
+ return this.encode(codePoint) > -1;
+ }
+
+}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Ttf4a.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Ttf4a.java 2025-04-27 00:02:24 UTC (rev 13523)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Ttf4a.java 2025-04-27 00:29:53 UTC (rev 13524)
@@ -1,289 +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.axsl.ps.Encoding;
-
-/**
- * Class containing a set of 16-bit Unicode ranges that sequentially map to the same-sized range of glyph indexes.
- * The contents are analogous to a Format 4 TrueType Font cmap table (from which this class derives its name).
- */
-public class Cmap04Ttf4a implements Encoding {
-
- /**
- * Contains one entry from a TrueType Cmap4a subtable, format 4, which handles
- * 16-bit Unicode code point ranges.
- */
- public class Entry {
-
- /** The first Unicode code point in this entry. */
- private int unicodeStart;
-
- /** The last Unicode code point in this entry.*/
- private int unicodeEnd;
-
- /** The starting glyph index for this entry. This index points to the glyph
- * representing {@link #unicodeStart}. */
- private char glyphStartIndex;
-
- /** The list of non-contiguous entries, if any, for this entry.
- * For contiguous entries, this will be null.
- * For non-contiguous entries, this array contains the glyph Indexes for the
- * range of Unicode characters. */
- private CharSequence glyphIndexes;
-
- /**
- * Constructor for contiguous entries.
- * @param unicodeStart The starting Unicode code point covered by this
- * mapping.
- * @param unicodeEnd The ending Unicode code point covered by this mapping.
- * @param glyphStartIndex The starting glyph index mapped by this mapping.
- * This is the encoded value for {@code unicodeStart}.
- */
- public Entry(final int unicodeStart, final int unicodeEnd, final char glyphStartIndex) {
- this.unicodeStart = unicodeStart;
- this.unicodeEnd = unicodeEnd;
- this.glyphStartIndex = glyphStartIndex;
- }
-
- /**
- * Constructor for non-contiguous entries.
- * @param unicodeStart The starting Unicode code point covered by this
- * mapping.
- * @param unicodeEnd The ending Unicode code point covered by this mapping.
- * @param glyphIndexes The array of encoded glyph indexes corresponding to
- * the range {@code unicodeStart} through {@code unicodeEnd}.
- */
- public Entry(final int unicodeStart, final int unicodeEnd, final CharSequence glyphIndexes) {
- this.unicodeStart = unicodeStart;
- this.unicodeEnd = unicodeEnd;
- this.glyphIndexes = glyphIndexes;
- }
-
- /**
- * Compute the glyphEndIndex that is implied from the raw data.
- * @return The last glyphIndex that is addressed by this entry, i.e. the
- * glyph index that corresponds to unicodeEnd.
- */
- public char getGlyphEndIndex() {
- return (char) (this.glyphStartIndex + this.unicodeEnd
- - this.unicodeStart);
- }
-
- /**
- * Indicates whether this entry can encode a given character.
- * @param c The character to be tested.
- * @return True if and only if this entry has encoding information for {@code c}.
- */
- public boolean containsChar(final int c) {
- return (c >= this.unicodeStart) && (c <= this.unicodeEnd);
- }
-
- /**
- * Encodes a given character.
- * @param c The character to be encoded.
- * @return The glyph index corresponding to {@code c}, or -1 if this entry does not know how to encode it.
- */
- public int encodeCharacter(final int c) {
- if (! containsChar(c)) {
- return -1;
- }
- if (this.glyphIndexes == null) {
- return (char) (c - this.unicodeStart + this.glyphStartIndex);
- }
- return this.glyphIndexes.charAt(c - this.unicodeStart);
- }
-
- /**
- * Decodes a given glyphIndex.
- * @param glyphIndex The glyph index to be decoded.
- * @return The Unicode code point corresponding to {@code glyphIndex}, or -1 if this entry does not know how to
- * decode it.
- */
- public int decodeCharacter(final int glyphIndex) {
- if (this.glyphIndexes == null) {
- final char codePoint = (char) (glyphIndex - this.glyphStartIndex + this.unicodeStart);
- if (glyphIndex >= this.glyphStartIndex
- && codePoint <= this.unicodeStart) {
- return codePoint;
- }
- return -1;
- }
- for (int i = 0; i < this.glyphIndexes.length(); i++) {
- if (this.glyphIndexes.charAt(i) == glyphIndex) {
- return this.unicodeStart + i;
- }
- }
- return -1;
- }
-
- }
-
-
-
-
-
-
-
- /** Constant needed for serialization. */
- public static final long serialVersionUID = 985957847129472354L;
-
- /** The name of this encoding. */
- private String name;
-
- /** The array of entries. */
- private Entry[] entries;
-
- /** Counter to the last entry added. */
- private int lastEntryAdded = -1;
-
- /**
- * Constructor.
- * @param name The name of this encoding.
- * @param expectedEntries The number of expected entries in this encoding.
- * Setting this to the correct value will result in more efficient
- * processing.
- */
- public Cmap04Ttf4a(final String name, final int expectedEntries) {
- this.name = name;
- this.entries = new Entry[expectedEntries];
- }
-
- @Override
- public String getName() {
- return this.name;
- }
-
- /**
- * Add a new entry to this map.
- * @param entry The entry to be added.
- */
- public void addEntry(final Entry entry) {
- this.lastEntryAdded++;
- if (this.lastEntryAdded >= this.entries.length) {
- // Fails silently.
- return;
- }
- this.entries[this.lastEntryAdded] = entry;
- }
-
- /**
- * Add a new entry to this map for contiguous values.
- * @param unicodeStart The starting Unicode code point for this map.
- * @param unicodeEnd The ending Unicode code point for this map.
- * @param glyphStartIndex The starting glyph index for this map.
- * This index is the encoded value for {@code unicodeStart}.
- */
- public void addEntry(final int unicodeStart, final int unicodeEnd, final char glyphStartIndex) {
- final Entry newEntry = new Entry(unicodeStart, unicodeEnd,
- glyphStartIndex);
- addEntry(newEntry);
- }
-
- /**
- * Add a new entry to this map for non-contiguous values.
- * @param unicodeStart The starting Unicode code point for this map.
- * @param unicodeEnd The ending Unicode code point for this map.
- * @param glyphIndexes The array of glyph indexes corresponding to the range {@code unicodeStart} through
- * {@code unicodeEnd}.
- */
- public void addEntry(final int unicodeStart, final int unicodeEnd, final CharSequence glyphIndexes) {
- final Entry newEntry = new Entry(unicodeStart, unicodeEnd, glyphIndexes);
- addEntry(newEntry);
- }
-
- @Override
- public int encode(final int c) {
- final Entry entry = entryForChar((char) c);
- if (entry == null) {
- return -1;
- }
- return entry.encodeCharacter((char) c);
- }
-
- /**
- * Find the entry for a given character.
- * @param c The character for which an entry is sought.
- * @return The entry, or null if none is defined for {@code c}.
- */
- private Entry entryForChar(final char c) {
- for (int i = 0; i < this.entries.length; i++) {
- if (this.entries[i].containsChar(c)) {
- return this.entries[i];
- }
- }
- return null;
- }
-
- @Override
- public int decode(final int glyphIndexInput) {
- for (int i = 0; i < this.entries.length; i++) {
- final int codePoint = this.entries[i].decodeCharacter(glyphIndexInput);
- if (codePoint > -1) {
- return codePoint;
- }
- }
- return -1;
- }
-
- @Override
- public String asPostScript(final org.axsl.ps.Encoding baseEncoding) {
- return null;
- }
-
- @Override
- public int getFirstIndex() {
- return -1;
- }
-
- @Override
- public int getLastIndex() {
- return -1;
- }
-
- @Override
- public boolean isBuiltInPs() {
- /* TODO Make this class abstract and make a subclass that handled custom instances, so that we can keep the
- * prebuilt instances separate, and return different values here. */
- return false;
- }
-
- @Override
- public boolean isBuiltInPdf() {
- /* TODO Make this class abstract and make a subclass that handled custom instances, so that we can keep the
- * prebuilt instances separate, and return different values here. */
- return false;
- }
-
- @Override
- public boolean canEncode(final int codePoint) {
- return this.encode(codePoint) > -1;
- }
-
-}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Table.java (from rev 13523, trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Ttf4a.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Table.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Table.java 2025-04-27 00:29:53 UTC (rev 13524)
@@ -0,0 +1,255 @@
+/*
+ * 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.axsl.ps.Encoding;
+
+/**
+ * Class containing a set of 32-bit Unicode ranges that sequentially map to the same-sized range of glyph indexes.
+ * The contents are analogous to a Format 12 TrueType Font cmap table (from which this class derives its name).
+ */
+public class Cmap12Table implements Encoding {
+
+ /**
+ * Contains one entry from a TrueType Cmap4a subtable, Format 12, which handles
+ * 32-bit Unicode code point ranges.
+ */
+ public class Entry {
+
+ /** The first Unicode code point in this entry. */
+ private int unicodeStart;
+
+ /** The last Unicode code point in this entry.*/
+ private int unicodeEnd;
+
+ /** The starting glyph index for this entry. This index points to the glyph
+ * representing {@link #unicodeStart}. */
+ private int glyphStartIndex;
+
+ /**
+ * Constructor.
+ * @param unicodeStart The starting Unicode code point covered by this
+ * mapping.
+ * @param unicodeEnd The ending Unicode code point covered by this mapping.
+ * @param glyphStartIndex The starting glyph index mapped by this mapping.
+ * This is the encoded value for {@code unicodeStart}.
+ */
+ public Entry(final int unicodeStart, final int unicodeEnd,
+ final int glyphStartIndex) {
+ this.unicodeStart = unicodeStart;
+ this.unicodeEnd = unicodeEnd;
+ this.glyphStartIndex = glyphStartIndex;
+ }
+
+ /**
+ * Compute the glyphEndIndex that is implied from the raw data.
+ * @return The last glyphIndex that is addressed by this entry, i.e. the
+ * glyph index that corresponds to unicodeEnd.
+ */
+ public int getGlyphEndIndex() {
+ return this.glyphStartIndex + this.unicodeEnd - this.unicodeStart;
+ }
+
+ /**
+ * Indicates whether this entry can encode a given character.
+ * @param codePoint The Unicode code point to be tested.
+ * @return True if and only if this entry has encoding information for
+ * {@code codePoint}.
+ */
+ public boolean containsChar(final int codePoint) {
+ if (codePoint < this.unicodeStart) {
+ return false;
+ }
+ if (codePoint > this.unicodeEnd) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Encodes a given character.
+ * @param codePoint The Unicode code point to be encoded.
+ * @return The glyph index corresponding to {@code codePoint}, or zero
+ * if this entry does not know how to encode it.
+ */
+ public int encodeCharacter(final int codePoint) {
+ if (! containsChar(codePoint)) {
+ return 0;
+ }
+ return codePoint - this.unicodeStart + this.glyphStartIndex;
+ }
+
+ /**
+ * Decodes a given glyphIndex.
+ * @param glyphIndex The glyph index to be decoded.
+ * @return The Unicode code point corresponding to {@code glyphIndex},
+ * or {@link Character#MAX_VALUE} if this entry does not know how to decode
+ * it.
+ */
+ public int decodeCharacter(final int glyphIndex) {
+ final int codePoint = glyphIndex - this.glyphStartIndex
+ + this.unicodeStart;
+ if (glyphIndex >= this.glyphStartIndex
+ && codePoint <= this.unicodeStart) {
+ return codePoint;
+ }
+ return Character.MAX_VALUE;
+ }
+
+ }
+
+
+
+
+
+ /** Constant needed for serialization. */
+ public static final long serialVersionUID = -606154911100219394L;
+
+ /** The name of this encoding. */
+ private String name;
+
+ /** The array of entries. */
+ private Entry[] entries;
+
+ /** Counter to the last entry added. */
+ private int lastEntryAdded = -1;
+
+ /**
+ * Constructor.
+ * @param name The name of this encoding.
+ * @param expectedEntries The number of expected entries in this encoding.
+ * Setting this to the correct value will result in more efficient
+ * processing.
+ */
+ public Cmap12Table(final String name, final int expectedEntries) {
+ this.name = name;
+ this.entries = new Entry[expectedEntries];
+ }
+
+ @Override
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * Add a new entry to this map.
+ * @param entry The entry to be added.
+ */
+ public void addEntry(final Entry entry) {
+ this.lastEntryAdded++;
+ if (this.lastEntryAdded >= this.entries.length) {
+ // Fails silently.
+ return;
+ }
+ this.entries[this.lastEntryAdded] = entry;
+ }
+
+ /**
+ * Add a new entry to this map.
+ * @param unicodeStart The starting Unicode code point for this map.
+ * @param unicodeEnd The ending Unicode code point for this map.
+ * @param glyphStartIndex The starting glyph index for this map.
+ * This index is the encoded value for {@code unicodeStart}.
+ */
+ public void addEntry(final int unicodeStart, final int unicodeEnd,
+ final int glyphStartIndex) {
+ final Entry newEntry = new Entry(unicodeStart, unicodeEnd,
+ glyphStartIndex);
+ addEntry(newEntry);
+ }
+
+ @Override
+ public int encode(final int codePoint) {
+ final Entry entry = entryForChar(codePoint);
+ if (entry == null) {
+ return -1;
+ }
+ return entry.encodeCharacter(codePoint);
+ }
+
+ /**
+ * Find the entry for a given character.
+ * @param codePoint The Unicode code point for which an entry is sought.
+ * @return The entry, or null if none is defined for {@code codePoint}.
+ */
+ private Entry entryForChar(final int codePoint) {
+ for (int i = 0; i < this.entries.length; i++) {
+ if (this.entries[i].containsChar(codePoint)) {
+ return this.entries[i];
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public int decode(final int glyphIndexInput) {
+ for (int i = 0; i < this.entries.length; i++) {
+ final int codePoint = this.entries[i].decodeCharacter(glyphIndexInput);
+ if (codePoint != Character.MAX_VALUE) {
+ return codePoint;
+ }
+ }
+ return -1;
+ }
+
+ @Override
+ public String asPostScript(final org.axsl.ps.Encoding baseEncoding) {
+ return null;
+ }
+
+ @Override
+ public int getFirstIndex() {
+ return -1;
+ }
+
+ @Override
+ public int getLastIndex() {
+ return -1;
+ }
+
+ @Override
+ public boolean isBuiltInPs() {
+ /* TODO Make this class abstract and make a subclass that handled custom instances, so that we can keep the
+ * prebuilt instances separate, and return different values here. */
+ return false;
+ }
+
+ @Override
+ public boolean isBuiltInPdf() {
+ /* TODO Make this class abstract and make a subclass that handled custom instances, so that we can keep the
+ * prebuilt instances separate, and return different values here. */
+ return false;
+ }
+
+ @Override
+ public boolean canEncode(final int codePoint) {
+ return this.encode(codePoint) > -1;
+ }
+
+}
Deleted: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Ttf4a.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Ttf4a.java 2025-04-27 00:02:24 UTC (rev 13523)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Ttf4a.java 2025-04-27 00:29:53 UTC (rev 13524)
@@ -1,255 +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.table;
-
-import org.axsl.ps.Encoding;
-
-/**
- * Class containing a set of 32-bit Unicode ranges that sequentially map to the same-sized range of glyph indexes.
- * The contents are analogous to a Format 12 TrueType Font cmap table (from which this class derives its name).
- */
-public class Cmap12Ttf4a implements Encoding {
-
- /**
- * Contains one entry from a TrueType Cmap4a subtable, Format 12, which handles
- * 32-bit Unicode code point ranges.
- */
- public class Entry {
-
- /** The first Unicode code point in this entry. */
- private int unicodeStart;
-
- /** The last Unicode code point in this entry.*/
- private int unicodeEnd;
-
- /** The starting glyph index for this entry. This index points to the glyph
- * representing {@link #unicodeStart}. */
- private int glyphStartIndex;
-
- /**
- * Constructor.
- * @param unicodeStart The starting Unicode code point covered by this
- * mapping.
- * @param unicodeEnd The ending Unicode code point covered by this mapping.
- * @param glyphStartIndex The starting glyph index mapped by this mapping.
- * This is the encoded value for {@code unicodeStart}.
- */
- public Entry(final int unicodeStart, final int unicodeEnd,
- final int glyphStartIndex) {
- this.unicodeStart = unicodeStart;
- this.unicodeEnd = unicodeEnd;
- this.glyphStartIndex = glyphStartIndex;
- }
-
- /**
- * Compute the glyphEndIndex that is implied from the raw data.
- * @return The last glyphIndex that is addressed by this entry, i.e. the
- * glyph index that corresponds to unicodeEnd.
- */
- public int getGlyphEndIndex() {
- return this.glyphStartIndex + this.unicodeEnd - this.unicodeStart;
- }
-
- /**
- * Indicates whether this entry can encode a given character.
- * @param codePoint The Unicode code point to be tested.
- * @return True if and only if this entry has encoding information for
- * {@code codePoint}.
- */
- public boolean containsChar(final int codePoint) {
- if (codePoint < this.unicodeStart) {
- return false;
- }
- if (codePoint > this.unicodeEnd) {
- return false;
- }
- return true;
- }
-
- /**
- * Encodes a given character.
- * @param codePoint The Unicode code point to be encoded.
- * @return The glyph index corresponding to {@code codePoint}, or zero
- * if this entry does not know how to encode it.
- */
- public int encodeCharacter(final int codePoint) {
- if (! containsChar(codePoint)) {
- return 0;
- }
- return codePoint - this.unicodeStart + this.glyphStartIndex;
- }
-
- /**
- * Decodes a given glyphIndex.
- * @param glyphIndex The glyph index to be decoded.
- * @return The Unicode code point corresponding to {@code glyphIndex},
- * or {@link Character#MAX_VALUE} if this entry does not know how to decode
- * it.
- */
- public int decodeCharacter(final int glyphIndex) {
- final int codePoint = glyphIndex - this.glyphStartIndex
- + this.unicodeStart;
- if (glyphIndex >= this.glyphStartIndex
- && codePoint <= this.unicodeStart) {
- return codePoint;
- }
- return Character.MAX_VALUE;
- }
-
- }
-
-
-
-
-
- /** Constant needed for serialization. */
- public static final long serialVersionUID = -606154911100219394L;
-
- /** The name of this encoding. */
- private String name;
-
- /** The array of entries. */
- private Entry[] entries;
-
- /** Counter to the last entry added. */
- private int lastEntryAdded = -1;
-
- /**
- * Constructor.
- * @param name The name of this encoding.
- * @param expectedEntries The number of expected entries in this encoding.
- * Setting this to the correct value will result in more efficient
- * processing.
- */
- public Cmap12Ttf4a(final String name, final int expectedEntries) {
- this.name = name;
- this.entries = new Entry[expectedEntries];
- }
-
- @Override
- public String getName() {
- return this.name;
- }
-
- /**
- * Add a new entry to this map.
- * @param entry The entry to be added.
- */
- public void addEntry(final Entry entry) {
- this.lastEntryAdded++;
- if (this.lastEntryAdded >= this.entries.length) {
- // Fails silently.
- return;
- }
- this.entries[this.lastEntryAdded] = entry;
- }
-
- /**
- * Add a new entry to this map.
- * @param unicodeStart The starting Unicode code point for this map.
- * @param unicodeEnd The ending Unicode code point for this map.
- * @param glyphStartIndex The starting glyph index for this map.
- * This index is the encoded value for {@code unicodeStart}.
- */
- public void addEntry(final int unicodeStart, final int unicodeEnd,
- final int glyphStartIndex) {
- final Entry newEntry = new Entry(unicodeStart, unicodeEnd,
- glyphStartIndex);
- addEntry(newEntry);
- }
-
- @Override
- public int encode(final int codePoint) {
- final Entry entry = entryForChar(codePoint);
- if (entry == null) {
- return -1;
- }
- return entry.encodeCharacter(codePoint);
- }
-
- /**
- * Find the entry for a given character.
- * @param codePoint The Unicode code point for which an entry is sought.
- * @return The entry, or null if none is defined for {@code codePoint}.
- */
- private Entry entryForChar(final int codePoint) {
- for (int i = 0; i < this.entries.length; i++) {
- if (this.entries[i].containsChar(codePoint)) {
- return this.entries[i];
- }
- }
- return null;
- }
-
- @Override
- public int decode(final int glyphIndexInput) {
- for (int i = 0; i < this.entries.length; i++) {
- final int codePoint = this.entries[i].decodeCharacter(glyphIndexInput);
- if (codePoint != Character.MAX_VALUE) {
- return codePoint;
- }
- }
- return -1;
- }
-
- @Override
- public String asPostScript(final org.axsl.ps.Encoding baseEncoding) {
- return null;
- }
-
- @Override
- public int getFirstIndex() {
- return -1;
- }
-
- @Override
- public int getLastIndex() {
- return -1;
- }
-
- @Override
- public boolean isBuiltInPs() {
- /* TODO Make this class abstract and make a subclass that handled custom instances, so that we can keep the
- * prebuilt instances separate, and return different values here. */
- return false;
- }
-
- @Override
- public boolean isBuiltInPdf() {
- /* TODO Make this class abstract and make a subclass that handled custom instances, so that we can keep the
- * prebuilt instances separate, and return different values here. */
- return false;
- }
-
- @Override
- public boolean canEncode(final int codePoint) {
- return this.encode(codePoint) > -1;
- }
-
-}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java 2025-04-27 00:02:24 UTC (rev 13523)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java 2025-04-27 00:29:53 UTC (rev 13524)
@@ -168,7 +168,7 @@
* @return The parsed Cmap4a format 4 table.
* @throws IOException For I/O Error.
*/
- private static Cmap04Ttf4a parseCMap04(final RandomAccessInput raInput, final String fontPostScriptName)
+ private static Cmap04Table parseCMap04(final RandomAccessInput raInput, final String fontPostScriptName)
throws IOException {
/* Format and Length have already been read. */
/* Skip version */
@@ -209,7 +209,7 @@
// Parse the table entries and build a CMap4 from them.
final String encodingName = "internal-" + fontPostScriptName;
- final Cmap04Ttf4a cmap04 = new Cmap04Ttf4a(encodingName, segCountX2 / 2);
+ final Cmap04Table cmap04 = new Cmap04Table(encodingName, segCountX2 / 2);
for (int i = 0; i < startCount.length; i++) {
if (rangeOffset[i] == 0) {
cmap04.addEntry(startCount[i],
@@ -245,7 +245,7 @@
* @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 Cmap12Ttf4a parseCMap12(final RandomAccessInput raInput, final String fontPostScriptName)
+ private static Cmap12Table parseCMap12(final RandomAccessInput raInput, final String fontPostScriptName)
throws IOException {
/* Format and Length have already been read. */
/* Skip language. */
@@ -253,7 +253,7 @@
final int nGroups = (int) raInput.readUnsignedInt();
final String encodingName = "internal-" + fontPostScriptName;
- final Cmap12Ttf4a cmap12 = new Cmap12Ttf4a(encodingName, nGroups);
+ final Cmap12Table cmap12 = new Cmap12Table(encodingName, nGroups);
for (int i = 0; i < nGroups; i++) {
final int startCharCode = (int) raInput.readUnsignedInt();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-27 00:02:42
|
Revision: 13523
http://sourceforge.net/p/foray/code/13523
Author: victormote
Date: 2025-04-27 00:02:24 +0000 (Sun, 27 Apr 2025)
Log Message:
-----------
Move Cmap Entry classes to inner classes.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Ttf4a.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Ttf4a.java
Removed Paths:
-------------
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap04TtfEntry4a.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap12TtfEntry4a.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Ttf4a.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Ttf4a.java 2025-04-26 23:50:06 UTC (rev 13522)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Ttf4a.java 2025-04-27 00:02:24 UTC (rev 13523)
@@ -28,8 +28,6 @@
package org.foray.font.ttf.table;
-import org.foray.ps.encode.Cmap04TtfEntry4a;
-
import org.axsl.ps.Encoding;
/**
@@ -38,6 +36,121 @@
*/
public class Cmap04Ttf4a implements Encoding {
+ /**
+ * Contains one entry from a TrueType Cmap4a subtable, format 4, which handles
+ * 16-bit Unicode code point ranges.
+ */
+ public class Entry {
+
+ /** The first Unicode code point in this entry. */
+ private int unicodeStart;
+
+ /** The last Unicode code point in this entry.*/
+ private int unicodeEnd;
+
+ /** The starting glyph index for this entry. This index points to the glyph
+ * representing {@link #unicodeStart}. */
+ private char glyphStartIndex;
+
+ /** The list of non-contiguous entries, if any, for this entry.
+ * For contiguous entries, this will be null.
+ * For non-contiguous entries, this array contains the glyph Indexes for the
+ * range of Unicode characters. */
+ private CharSequence glyphIndexes;
+
+ /**
+ * Constructor for contiguous entries.
+ * @param unicodeStart The starting Unicode code point covered by this
+ * mapping.
+ * @param unicodeEnd The ending Unicode code point covered by this mapping.
+ * @param glyphStartIndex The starting glyph index mapped by this mapping.
+ * This is the encoded value for {@code unicodeStart}.
+ */
+ public Entry(final int unicodeStart, final int unicodeEnd, final char glyphStartIndex) {
+ this.unicodeStart = unicodeStart;
+ this.unicodeEnd = unicodeEnd;
+ this.glyphStartIndex = glyphStartIndex;
+ }
+
+ /**
+ * Constructor for non-contiguous entries.
+ * @param unicodeStart The starting Unicode code point covered by this
+ * mapping.
+ * @param unicodeEnd The ending Unicode code point covered by this mapping.
+ * @param glyphIndexes The array of encoded glyph indexes corresponding to
+ * the range {@code unicodeStart} through {@code unicodeEnd}.
+ */
+ public Entry(final int unicodeStart, final int unicodeEnd, final CharSequence glyphIndexes) {
+ this.unicodeStart = unicodeStart;
+ this.unicodeEnd = unicodeEnd;
+ this.glyphIndexes = glyphIndexes;
+ }
+
+ /**
+ * Compute the glyphEndIndex that is implied from the raw data.
+ * @return The last glyphIndex that is addressed by this entry, i.e. the
+ * glyph index that corresponds to unicodeEnd.
+ */
+ public char getGlyphEndIndex() {
+ return (char) (this.glyphStartIndex + this.unicodeEnd
+ - this.unicodeStart);
+ }
+
+ /**
+ * Indicates whether this entry can encode a given character.
+ * @param c The character to be tested.
+ * @return True if and only if this entry has encoding information for {@code c}.
+ */
+ public boolean containsChar(final int c) {
+ return (c >= this.unicodeStart) && (c <= this.unicodeEnd);
+ }
+
+ /**
+ * Encodes a given character.
+ * @param c The character to be encoded.
+ * @return The glyph index corresponding to {@code c}, or -1 if this entry does not know how to encode it.
+ */
+ public int encodeCharacter(final int c) {
+ if (! containsChar(c)) {
+ return -1;
+ }
+ if (this.glyphIndexes == null) {
+ return (char) (c - this.unicodeStart + this.glyphStartIndex);
+ }
+ return this.glyphIndexes.charAt(c - this.unicodeStart);
+ }
+
+ /**
+ * Decodes a given glyphIndex.
+ * @param glyphIndex The glyph index to be decoded.
+ * @return The Unicode code point corresponding to {@code glyphIndex}, or -1 if this entry does not know how to
+ * decode it.
+ */
+ public int decodeCharacter(final int glyphIndex) {
+ if (this.glyphIndexes == null) {
+ final char codePoint = (char) (glyphIndex - this.glyphStartIndex + this.unicodeStart);
+ if (glyphIndex >= this.glyphStartIndex
+ && codePoint <= this.unicodeStart) {
+ return codePoint;
+ }
+ return -1;
+ }
+ for (int i = 0; i < this.glyphIndexes.length(); i++) {
+ if (this.glyphIndexes.charAt(i) == glyphIndex) {
+ return this.unicodeStart + i;
+ }
+ }
+ return -1;
+ }
+
+ }
+
+
+
+
+
+
+
/** Constant needed for serialization. */
public static final long serialVersionUID = 985957847129472354L;
@@ -45,7 +158,7 @@
private String name;
/** The array of entries. */
- private Cmap04TtfEntry4a[] entries;
+ private Entry[] entries;
/** Counter to the last entry added. */
private int lastEntryAdded = -1;
@@ -59,7 +172,7 @@
*/
public Cmap04Ttf4a(final String name, final int expectedEntries) {
this.name = name;
- this.entries = new Cmap04TtfEntry4a[expectedEntries];
+ this.entries = new Entry[expectedEntries];
}
@Override
@@ -71,7 +184,7 @@
* Add a new entry to this map.
* @param entry The entry to be added.
*/
- public void addEntry(final Cmap04TtfEntry4a entry) {
+ public void addEntry(final Entry entry) {
this.lastEntryAdded++;
if (this.lastEntryAdded >= this.entries.length) {
// Fails silently.
@@ -88,7 +201,7 @@
* This index is the encoded value for {@code unicodeStart}.
*/
public void addEntry(final int unicodeStart, final int unicodeEnd, final char glyphStartIndex) {
- final Cmap04TtfEntry4a newEntry = new Cmap04TtfEntry4a(unicodeStart, unicodeEnd,
+ final Entry newEntry = new Entry(unicodeStart, unicodeEnd,
glyphStartIndex);
addEntry(newEntry);
}
@@ -101,13 +214,13 @@
* {@code unicodeEnd}.
*/
public void addEntry(final int unicodeStart, final int unicodeEnd, final CharSequence glyphIndexes) {
- final Cmap04TtfEntry4a newEntry = new Cmap04TtfEntry4a(unicodeStart, unicodeEnd, glyphIndexes);
+ final Entry newEntry = new Entry(unicodeStart, unicodeEnd, glyphIndexes);
addEntry(newEntry);
}
@Override
public int encode(final int c) {
- final Cmap04TtfEntry4a entry = entryForChar((char) c);
+ final Entry entry = entryForChar((char) c);
if (entry == null) {
return -1;
}
@@ -119,7 +232,7 @@
* @param c The character for which an entry is sought.
* @return The entry, or null if none is defined for {@code c}.
*/
- private Cmap04TtfEntry4a entryForChar(final char c) {
+ private Entry entryForChar(final char c) {
for (int i = 0; i < this.entries.length; i++) {
if (this.entries[i].containsChar(c)) {
return this.entries[i];
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Ttf4a.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Ttf4a.java 2025-04-26 23:50:06 UTC (rev 13522)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Ttf4a.java 2025-04-27 00:02:24 UTC (rev 13523)
@@ -28,8 +28,6 @@
package org.foray.font.ttf.table;
-import org.foray.ps.encode.Cmap12TtfEntry4a;
-
import org.axsl.ps.Encoding;
/**
@@ -38,6 +36,98 @@
*/
public class Cmap12Ttf4a implements Encoding {
+ /**
+ * Contains one entry from a TrueType Cmap4a subtable, Format 12, which handles
+ * 32-bit Unicode code point ranges.
+ */
+ public class Entry {
+
+ /** The first Unicode code point in this entry. */
+ private int unicodeStart;
+
+ /** The last Unicode code point in this entry.*/
+ private int unicodeEnd;
+
+ /** The starting glyph index for this entry. This index points to the glyph
+ * representing {@link #unicodeStart}. */
+ private int glyphStartIndex;
+
+ /**
+ * Constructor.
+ * @param unicodeStart The starting Unicode code point covered by this
+ * mapping.
+ * @param unicodeEnd The ending Unicode code point covered by this mapping.
+ * @param glyphStartIndex The starting glyph index mapped by this mapping.
+ * This is the encoded value for {@code unicodeStart}.
+ */
+ public Entry(final int unicodeStart, final int unicodeEnd,
+ final int glyphStartIndex) {
+ this.unicodeStart = unicodeStart;
+ this.unicodeEnd = unicodeEnd;
+ this.glyphStartIndex = glyphStartIndex;
+ }
+
+ /**
+ * Compute the glyphEndIndex that is implied from the raw data.
+ * @return The last glyphIndex that is addressed by this entry, i.e. the
+ * glyph index that corresponds to unicodeEnd.
+ */
+ public int getGlyphEndIndex() {
+ return this.glyphStartIndex + this.unicodeEnd - this.unicodeStart;
+ }
+
+ /**
+ * Indicates whether this entry can encode a given character.
+ * @param codePoint The Unicode code point to be tested.
+ * @return True if and only if this entry has encoding information for
+ * {@code codePoint}.
+ */
+ public boolean containsChar(final int codePoint) {
+ if (codePoint < this.unicodeStart) {
+ return false;
+ }
+ if (codePoint > this.unicodeEnd) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Encodes a given character.
+ * @param codePoint The Unicode code point to be encoded.
+ * @return The glyph index corresponding to {@code codePoint}, or zero
+ * if this entry does not know how to encode it.
+ */
+ public int encodeCharacter(final int codePoint) {
+ if (! containsChar(codePoint)) {
+ return 0;
+ }
+ return codePoint - this.unicodeStart + this.glyphStartIndex;
+ }
+
+ /**
+ * Decodes a given glyphIndex.
+ * @param glyphIndex The glyph index to be decoded.
+ * @return The Unicode code point corresponding to {@code glyphIndex},
+ * or {@link Character#MAX_VALUE} if this entry does not know how to decode
+ * it.
+ */
+ public int decodeCharacter(final int glyphIndex) {
+ final int codePoint = glyphIndex - this.glyphStartIndex
+ + this.unicodeStart;
+ if (glyphIndex >= this.glyphStartIndex
+ && codePoint <= this.unicodeStart) {
+ return codePoint;
+ }
+ return Character.MAX_VALUE;
+ }
+
+ }
+
+
+
+
+
/** Constant needed for serialization. */
public static final long serialVersionUID = -606154911100219394L;
@@ -45,7 +135,7 @@
private String name;
/** The array of entries. */
- private Cmap12TtfEntry4a[] entries;
+ private Entry[] entries;
/** Counter to the last entry added. */
private int lastEntryAdded = -1;
@@ -59,7 +149,7 @@
*/
public Cmap12Ttf4a(final String name, final int expectedEntries) {
this.name = name;
- this.entries = new Cmap12TtfEntry4a[expectedEntries];
+ this.entries = new Entry[expectedEntries];
}
@Override
@@ -71,7 +161,7 @@
* Add a new entry to this map.
* @param entry The entry to be added.
*/
- public void addEntry(final Cmap12TtfEntry4a entry) {
+ public void addEntry(final Entry entry) {
this.lastEntryAdded++;
if (this.lastEntryAdded >= this.entries.length) {
// Fails silently.
@@ -89,7 +179,7 @@
*/
public void addEntry(final int unicodeStart, final int unicodeEnd,
final int glyphStartIndex) {
- final Cmap12TtfEntry4a newEntry = new Cmap12TtfEntry4a(unicodeStart, unicodeEnd,
+ final Entry newEntry = new Entry(unicodeStart, unicodeEnd,
glyphStartIndex);
addEntry(newEntry);
}
@@ -96,7 +186,7 @@
@Override
public int encode(final int codePoint) {
- final Cmap12TtfEntry4a entry = entryForChar(codePoint);
+ final Entry entry = entryForChar(codePoint);
if (entry == null) {
return -1;
}
@@ -108,7 +198,7 @@
* @param codePoint The Unicode code point for which an entry is sought.
* @return The entry, or null if none is defined for {@code codePoint}.
*/
- private Cmap12TtfEntry4a entryForChar(final int codePoint) {
+ private Entry entryForChar(final int codePoint) {
for (int i = 0; i < this.entries.length; i++) {
if (this.entries[i].containsChar(codePoint)) {
return this.entries[i];
Deleted: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap04TtfEntry4a.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap04TtfEntry4a.java 2025-04-26 23:50:06 UTC (rev 13522)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap04TtfEntry4a.java 2025-04-27 00:02:24 UTC (rev 13523)
@@ -1,138 +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.ps.encode;
-
-/**
- * Contains one entry from a TrueType Cmap4a subtable, format 4, which handles
- * 16-bit Unicode code point ranges.
- */
-public class Cmap04TtfEntry4a {
-
- /** The first Unicode code point in this entry. */
- private int unicodeStart;
-
- /** The last Unicode code point in this entry.*/
- private int unicodeEnd;
-
- /** The starting glyph index for this entry. This index points to the glyph
- * representing {@link #unicodeStart}. */
- private char glyphStartIndex;
-
- /** The list of non-contiguous entries, if any, for this entry.
- * For contiguous entries, this will be null.
- * For non-contiguous entries, this array contains the glyph Indexes for the
- * range of Unicode characters. */
- private CharSequence glyphIndexes;
-
- /**
- * Constructor for contiguous entries.
- * @param unicodeStart The starting Unicode code point covered by this
- * mapping.
- * @param unicodeEnd The ending Unicode code point covered by this mapping.
- * @param glyphStartIndex The starting glyph index mapped by this mapping.
- * This is the encoded value for {@code unicodeStart}.
- */
- public Cmap04TtfEntry4a(final int unicodeStart, final int unicodeEnd, final char glyphStartIndex) {
- this.unicodeStart = unicodeStart;
- this.unicodeEnd = unicodeEnd;
- this.glyphStartIndex = glyphStartIndex;
- }
-
- /**
- * Constructor for non-contiguous entries.
- * @param unicodeStart The starting Unicode code point covered by this
- * mapping.
- * @param unicodeEnd The ending Unicode code point covered by this mapping.
- * @param glyphIndexes The array of encoded glyph indexes corresponding to
- * the range {@code unicodeStart} through {@code unicodeEnd}.
- */
- public Cmap04TtfEntry4a(final int unicodeStart, final int unicodeEnd, final CharSequence glyphIndexes) {
- this.unicodeStart = unicodeStart;
- this.unicodeEnd = unicodeEnd;
- this.glyphIndexes = glyphIndexes;
- }
-
- /**
- * Compute the glyphEndIndex that is implied from the raw data.
- * @return The last glyphIndex that is addressed by this entry, i.e. the
- * glyph index that corresponds to unicodeEnd.
- */
- public char getGlyphEndIndex() {
- return (char) (this.glyphStartIndex + this.unicodeEnd
- - this.unicodeStart);
- }
-
- /**
- * Indicates whether this entry can encode a given character.
- * @param c The character to be tested.
- * @return True if and only if this entry has encoding information for {@code c}.
- */
- public boolean containsChar(final int c) {
- return (c >= this.unicodeStart) && (c <= this.unicodeEnd);
- }
-
- /**
- * Encodes a given character.
- * @param c The character to be encoded.
- * @return The glyph index corresponding to {@code c}, or -1 if this entry does not know how to encode it.
- */
- public int encodeCharacter(final int c) {
- if (! containsChar(c)) {
- return -1;
- }
- if (this.glyphIndexes == null) {
- return (char) (c - this.unicodeStart + this.glyphStartIndex);
- }
- return this.glyphIndexes.charAt(c - this.unicodeStart);
- }
-
- /**
- * Decodes a given glyphIndex.
- * @param glyphIndex The glyph index to be decoded.
- * @return The Unicode code point corresponding to {@code glyphIndex}, or -1 if this entry does not know how to
- * decode it.
- */
- public int decodeCharacter(final int glyphIndex) {
- if (this.glyphIndexes == null) {
- final char codePoint = (char) (glyphIndex - this.glyphStartIndex + this.unicodeStart);
- if (glyphIndex >= this.glyphStartIndex
- && codePoint <= this.unicodeStart) {
- return codePoint;
- }
- return -1;
- }
- for (int i = 0; i < this.glyphIndexes.length(); i++) {
- if (this.glyphIndexes.charAt(i) == glyphIndex) {
- return this.unicodeStart + i;
- }
- }
- return -1;
- }
-
-}
Deleted: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap12TtfEntry4a.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap12TtfEntry4a.java 2025-04-26 23:50:06 UTC (rev 13522)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap12TtfEntry4a.java 2025-04-27 00:02:24 UTC (rev 13523)
@@ -1,117 +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.ps.encode;
-
-/**
- * Contains one entry from a TrueType Cmap4a subtable, Format 12, which handles
- * 32-bit Unicode code point ranges.
- */
-public class Cmap12TtfEntry4a {
-
- /** The first Unicode code point in this entry. */
- private int unicodeStart;
-
- /** The last Unicode code point in this entry.*/
- private int unicodeEnd;
-
- /** The starting glyph index for this entry. This index points to the glyph
- * representing {@link #unicodeStart}. */
- private int glyphStartIndex;
-
- /**
- * Constructor.
- * @param unicodeStart The starting Unicode code point covered by this
- * mapping.
- * @param unicodeEnd The ending Unicode code point covered by this mapping.
- * @param glyphStartIndex The starting glyph index mapped by this mapping.
- * This is the encoded value for {@code unicodeStart}.
- */
- public Cmap12TtfEntry4a(final int unicodeStart, final int unicodeEnd,
- final int glyphStartIndex) {
- this.unicodeStart = unicodeStart;
- this.unicodeEnd = unicodeEnd;
- this.glyphStartIndex = glyphStartIndex;
- }
-
- /**
- * Compute the glyphEndIndex that is implied from the raw data.
- * @return The last glyphIndex that is addressed by this entry, i.e. the
- * glyph index that corresponds to unicodeEnd.
- */
- public int getGlyphEndIndex() {
- return this.glyphStartIndex + this.unicodeEnd - this.unicodeStart;
- }
-
- /**
- * Indicates whether this entry can encode a given character.
- * @param codePoint The Unicode code point to be tested.
- * @return True if and only if this entry has encoding information for
- * {@code codePoint}.
- */
- public boolean containsChar(final int codePoint) {
- if (codePoint < this.unicodeStart) {
- return false;
- }
- if (codePoint > this.unicodeEnd) {
- return false;
- }
- return true;
- }
-
- /**
- * Encodes a given character.
- * @param codePoint The Unicode code point to be encoded.
- * @return The glyph index corresponding to {@code codePoint}, or zero
- * if this entry does not know how to encode it.
- */
- public int encodeCharacter(final int codePoint) {
- if (! containsChar(codePoint)) {
- return 0;
- }
- return codePoint - this.unicodeStart + this.glyphStartIndex;
- }
-
- /**
- * Decodes a given glyphIndex.
- * @param glyphIndex The glyph index to be decoded.
- * @return The Unicode code point corresponding to {@code glyphIndex},
- * or {@link Character#MAX_VALUE} if this entry does not know how to decode
- * it.
- */
- public int decodeCharacter(final int glyphIndex) {
- final int codePoint = glyphIndex - this.glyphStartIndex
- + this.unicodeStart;
- if (glyphIndex >= this.glyphStartIndex
- && codePoint <= this.unicodeStart) {
- return codePoint;
- }
- return Character.MAX_VALUE;
- }
-
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-26 23:50:24
|
Revision: 13522
http://sourceforge.net/p/foray/code/13522
Author: victormote
Date: 2025-04-26 23:50:06 +0000 (Sat, 26 Apr 2025)
Log Message:
-----------
Move Cmap classes from PostScript to Font project.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java
Added Paths:
-----------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Ttf4a.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Ttf4a.java
Removed Paths:
-------------
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap04Ttf4a.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap12Ttf4a.java
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Ttf4a.java (from rev 13513, trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap04Ttf4a.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Ttf4a.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Ttf4a.java 2025-04-26 23:50:06 UTC (rev 13522)
@@ -0,0 +1,176 @@
+/*
+ * 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.ps.encode.Cmap04TtfEntry4a;
+
+import org.axsl.ps.Encoding;
+
+/**
+ * Class containing a set of 16-bit Unicode ranges that sequentially map to the same-sized range of glyph indexes.
+ * The contents are analogous to a Format 4 TrueType Font cmap table (from which this class derives its name).
+ */
+public class Cmap04Ttf4a implements Encoding {
+
+ /** Constant needed for serialization. */
+ public static final long serialVersionUID = 985957847129472354L;
+
+ /** The name of this encoding. */
+ private String name;
+
+ /** The array of entries. */
+ private Cmap04TtfEntry4a[] entries;
+
+ /** Counter to the last entry added. */
+ private int lastEntryAdded = -1;
+
+ /**
+ * Constructor.
+ * @param name The name of this encoding.
+ * @param expectedEntries The number of expected entries in this encoding.
+ * Setting this to the correct value will result in more efficient
+ * processing.
+ */
+ public Cmap04Ttf4a(final String name, final int expectedEntries) {
+ this.name = name;
+ this.entries = new Cmap04TtfEntry4a[expectedEntries];
+ }
+
+ @Override
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * Add a new entry to this map.
+ * @param entry The entry to be added.
+ */
+ public void addEntry(final Cmap04TtfEntry4a entry) {
+ this.lastEntryAdded++;
+ if (this.lastEntryAdded >= this.entries.length) {
+ // Fails silently.
+ return;
+ }
+ this.entries[this.lastEntryAdded] = entry;
+ }
+
+ /**
+ * Add a new entry to this map for contiguous values.
+ * @param unicodeStart The starting Unicode code point for this map.
+ * @param unicodeEnd The ending Unicode code point for this map.
+ * @param glyphStartIndex The starting glyph index for this map.
+ * This index is the encoded value for {@code unicodeStart}.
+ */
+ public void addEntry(final int unicodeStart, final int unicodeEnd, final char glyphStartIndex) {
+ final Cmap04TtfEntry4a newEntry = new Cmap04TtfEntry4a(unicodeStart, unicodeEnd,
+ glyphStartIndex);
+ addEntry(newEntry);
+ }
+
+ /**
+ * Add a new entry to this map for non-contiguous values.
+ * @param unicodeStart The starting Unicode code point for this map.
+ * @param unicodeEnd The ending Unicode code point for this map.
+ * @param glyphIndexes The array of glyph indexes corresponding to the range {@code unicodeStart} through
+ * {@code unicodeEnd}.
+ */
+ public void addEntry(final int unicodeStart, final int unicodeEnd, final CharSequence glyphIndexes) {
+ final Cmap04TtfEntry4a newEntry = new Cmap04TtfEntry4a(unicodeStart, unicodeEnd, glyphIndexes);
+ addEntry(newEntry);
+ }
+
+ @Override
+ public int encode(final int c) {
+ final Cmap04TtfEntry4a entry = entryForChar((char) c);
+ if (entry == null) {
+ return -1;
+ }
+ return entry.encodeCharacter((char) c);
+ }
+
+ /**
+ * Find the entry for a given character.
+ * @param c The character for which an entry is sought.
+ * @return The entry, or null if none is defined for {@code c}.
+ */
+ private Cmap04TtfEntry4a entryForChar(final char c) {
+ for (int i = 0; i < this.entries.length; i++) {
+ if (this.entries[i].containsChar(c)) {
+ return this.entries[i];
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public int decode(final int glyphIndexInput) {
+ for (int i = 0; i < this.entries.length; i++) {
+ final int codePoint = this.entries[i].decodeCharacter(glyphIndexInput);
+ if (codePoint > -1) {
+ return codePoint;
+ }
+ }
+ return -1;
+ }
+
+ @Override
+ public String asPostScript(final org.axsl.ps.Encoding baseEncoding) {
+ return null;
+ }
+
+ @Override
+ public int getFirstIndex() {
+ return -1;
+ }
+
+ @Override
+ public int getLastIndex() {
+ return -1;
+ }
+
+ @Override
+ public boolean isBuiltInPs() {
+ /* TODO Make this class abstract and make a subclass that handled custom instances, so that we can keep the
+ * prebuilt instances separate, and return different values here. */
+ return false;
+ }
+
+ @Override
+ public boolean isBuiltInPdf() {
+ /* TODO Make this class abstract and make a subclass that handled custom instances, so that we can keep the
+ * prebuilt instances separate, and return different values here. */
+ return false;
+ }
+
+ @Override
+ public boolean canEncode(final int codePoint) {
+ return this.encode(codePoint) > -1;
+ }
+
+}
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Ttf4a.java (from rev 13513, trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap12Ttf4a.java)
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Ttf4a.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap12Ttf4a.java 2025-04-26 23:50:06 UTC (rev 13522)
@@ -0,0 +1,165 @@
+/*
+ * 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.ps.encode.Cmap12TtfEntry4a;
+
+import org.axsl.ps.Encoding;
+
+/**
+ * Class containing a set of 32-bit Unicode ranges that sequentially map to the same-sized range of glyph indexes.
+ * The contents are analogous to a Format 12 TrueType Font cmap table (from which this class derives its name).
+ */
+public class Cmap12Ttf4a implements Encoding {
+
+ /** Constant needed for serialization. */
+ public static final long serialVersionUID = -606154911100219394L;
+
+ /** The name of this encoding. */
+ private String name;
+
+ /** The array of entries. */
+ private Cmap12TtfEntry4a[] entries;
+
+ /** Counter to the last entry added. */
+ private int lastEntryAdded = -1;
+
+ /**
+ * Constructor.
+ * @param name The name of this encoding.
+ * @param expectedEntries The number of expected entries in this encoding.
+ * Setting this to the correct value will result in more efficient
+ * processing.
+ */
+ public Cmap12Ttf4a(final String name, final int expectedEntries) {
+ this.name = name;
+ this.entries = new Cmap12TtfEntry4a[expectedEntries];
+ }
+
+ @Override
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * Add a new entry to this map.
+ * @param entry The entry to be added.
+ */
+ public void addEntry(final Cmap12TtfEntry4a entry) {
+ this.lastEntryAdded++;
+ if (this.lastEntryAdded >= this.entries.length) {
+ // Fails silently.
+ return;
+ }
+ this.entries[this.lastEntryAdded] = entry;
+ }
+
+ /**
+ * Add a new entry to this map.
+ * @param unicodeStart The starting Unicode code point for this map.
+ * @param unicodeEnd The ending Unicode code point for this map.
+ * @param glyphStartIndex The starting glyph index for this map.
+ * This index is the encoded value for {@code unicodeStart}.
+ */
+ public void addEntry(final int unicodeStart, final int unicodeEnd,
+ final int glyphStartIndex) {
+ final Cmap12TtfEntry4a newEntry = new Cmap12TtfEntry4a(unicodeStart, unicodeEnd,
+ glyphStartIndex);
+ addEntry(newEntry);
+ }
+
+ @Override
+ public int encode(final int codePoint) {
+ final Cmap12TtfEntry4a entry = entryForChar(codePoint);
+ if (entry == null) {
+ return -1;
+ }
+ return entry.encodeCharacter(codePoint);
+ }
+
+ /**
+ * Find the entry for a given character.
+ * @param codePoint The Unicode code point for which an entry is sought.
+ * @return The entry, or null if none is defined for {@code codePoint}.
+ */
+ private Cmap12TtfEntry4a entryForChar(final int codePoint) {
+ for (int i = 0; i < this.entries.length; i++) {
+ if (this.entries[i].containsChar(codePoint)) {
+ return this.entries[i];
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public int decode(final int glyphIndexInput) {
+ for (int i = 0; i < this.entries.length; i++) {
+ final int codePoint = this.entries[i].decodeCharacter(glyphIndexInput);
+ if (codePoint != Character.MAX_VALUE) {
+ return codePoint;
+ }
+ }
+ return -1;
+ }
+
+ @Override
+ public String asPostScript(final org.axsl.ps.Encoding baseEncoding) {
+ return null;
+ }
+
+ @Override
+ public int getFirstIndex() {
+ return -1;
+ }
+
+ @Override
+ public int getLastIndex() {
+ return -1;
+ }
+
+ @Override
+ public boolean isBuiltInPs() {
+ /* TODO Make this class abstract and make a subclass that handled custom instances, so that we can keep the
+ * prebuilt instances separate, and return different values here. */
+ return false;
+ }
+
+ @Override
+ public boolean isBuiltInPdf() {
+ /* TODO Make this class abstract and make a subclass that handled custom instances, so that we can keep the
+ * prebuilt instances separate, and return different values here. */
+ return false;
+ }
+
+ @Override
+ public boolean canEncode(final int codePoint) {
+ return this.encode(codePoint) > -1;
+ }
+
+}
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-26 23:34:06 UTC (rev 13521)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java 2025-04-26 23:50:06 UTC (rev 13522)
@@ -30,8 +30,6 @@
import org.foray.common.RandomAccessInput;
import org.foray.font.ttf.RoTable;
-import org.foray.ps.encode.Cmap04Ttf4a;
-import org.foray.ps.encode.Cmap12Ttf4a;
import org.axsl.ps.Encoding;
Deleted: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap04Ttf4a.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap04Ttf4a.java 2025-04-26 23:34:06 UTC (rev 13521)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap04Ttf4a.java 2025-04-26 23:50:06 UTC (rev 13522)
@@ -1,174 +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.ps.encode;
-
-import org.axsl.ps.Encoding;
-
-/**
- * Class containing a set of 16-bit Unicode ranges that sequentially map to the same-sized range of glyph indexes.
- * The contents are analogous to a Format 4 TrueType Font cmap table (from which this class derives its name).
- */
-public class Cmap04Ttf4a implements Encoding {
-
- /** Constant needed for serialization. */
- public static final long serialVersionUID = 985957847129472354L;
-
- /** The name of this encoding. */
- private String name;
-
- /** The array of entries. */
- private Cmap04TtfEntry4a[] entries;
-
- /** Counter to the last entry added. */
- private int lastEntryAdded = -1;
-
- /**
- * Constructor.
- * @param name The name of this encoding.
- * @param expectedEntries The number of expected entries in this encoding.
- * Setting this to the correct value will result in more efficient
- * processing.
- */
- public Cmap04Ttf4a(final String name, final int expectedEntries) {
- this.name = name;
- this.entries = new Cmap04TtfEntry4a[expectedEntries];
- }
-
- @Override
- public String getName() {
- return this.name;
- }
-
- /**
- * Add a new entry to this map.
- * @param entry The entry to be added.
- */
- public void addEntry(final Cmap04TtfEntry4a entry) {
- this.lastEntryAdded++;
- if (this.lastEntryAdded >= this.entries.length) {
- // Fails silently.
- return;
- }
- this.entries[this.lastEntryAdded] = entry;
- }
-
- /**
- * Add a new entry to this map for contiguous values.
- * @param unicodeStart The starting Unicode code point for this map.
- * @param unicodeEnd The ending Unicode code point for this map.
- * @param glyphStartIndex The starting glyph index for this map.
- * This index is the encoded value for {@code unicodeStart}.
- */
- public void addEntry(final int unicodeStart, final int unicodeEnd, final char glyphStartIndex) {
- final Cmap04TtfEntry4a newEntry = new Cmap04TtfEntry4a(unicodeStart, unicodeEnd,
- glyphStartIndex);
- addEntry(newEntry);
- }
-
- /**
- * Add a new entry to this map for non-contiguous values.
- * @param unicodeStart The starting Unicode code point for this map.
- * @param unicodeEnd The ending Unicode code point for this map.
- * @param glyphIndexes The array of glyph indexes corresponding to the range {@code unicodeStart} through
- * {@code unicodeEnd}.
- */
- public void addEntry(final int unicodeStart, final int unicodeEnd, final CharSequence glyphIndexes) {
- final Cmap04TtfEntry4a newEntry = new Cmap04TtfEntry4a(unicodeStart, unicodeEnd, glyphIndexes);
- addEntry(newEntry);
- }
-
- @Override
- public int encode(final int c) {
- final Cmap04TtfEntry4a entry = entryForChar((char) c);
- if (entry == null) {
- return -1;
- }
- return entry.encodeCharacter((char) c);
- }
-
- /**
- * Find the entry for a given character.
- * @param c The character for which an entry is sought.
- * @return The entry, or null if none is defined for {@code c}.
- */
- private Cmap04TtfEntry4a entryForChar(final char c) {
- for (int i = 0; i < this.entries.length; i++) {
- if (this.entries[i].containsChar(c)) {
- return this.entries[i];
- }
- }
- return null;
- }
-
- @Override
- public int decode(final int glyphIndexInput) {
- for (int i = 0; i < this.entries.length; i++) {
- final int codePoint = this.entries[i].decodeCharacter(glyphIndexInput);
- if (codePoint > -1) {
- return codePoint;
- }
- }
- return -1;
- }
-
- @Override
- public String asPostScript(final org.axsl.ps.Encoding baseEncoding) {
- return null;
- }
-
- @Override
- public int getFirstIndex() {
- return -1;
- }
-
- @Override
- public int getLastIndex() {
- return -1;
- }
-
- @Override
- public boolean isBuiltInPs() {
- /* TODO Make this class abstract and make a subclass that handled custom instances, so that we can keep the
- * prebuilt instances separate, and return different values here. */
- return false;
- }
-
- @Override
- public boolean isBuiltInPdf() {
- /* TODO Make this class abstract and make a subclass that handled custom instances, so that we can keep the
- * prebuilt instances separate, and return different values here. */
- return false;
- }
-
- @Override
- public boolean canEncode(final int codePoint) {
- return this.encode(codePoint) > -1;
- }
-
-}
Deleted: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap12Ttf4a.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap12Ttf4a.java 2025-04-26 23:34:06 UTC (rev 13521)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap12Ttf4a.java 2025-04-26 23:50:06 UTC (rev 13522)
@@ -1,163 +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.ps.encode;
-
-import org.axsl.ps.Encoding;
-
-/**
- * Class containing a set of 32-bit Unicode ranges that sequentially map to the same-sized range of glyph indexes.
- * The contents are analogous to a Format 12 TrueType Font cmap table (from which this class derives its name).
- */
-public class Cmap12Ttf4a implements Encoding {
-
- /** Constant needed for serialization. */
- public static final long serialVersionUID = -606154911100219394L;
-
- /** The name of this encoding. */
- private String name;
-
- /** The array of entries. */
- private Cmap12TtfEntry4a[] entries;
-
- /** Counter to the last entry added. */
- private int lastEntryAdded = -1;
-
- /**
- * Constructor.
- * @param name The name of this encoding.
- * @param expectedEntries The number of expected entries in this encoding.
- * Setting this to the correct value will result in more efficient
- * processing.
- */
- public Cmap12Ttf4a(final String name, final int expectedEntries) {
- this.name = name;
- this.entries = new Cmap12TtfEntry4a[expectedEntries];
- }
-
- @Override
- public String getName() {
- return this.name;
- }
-
- /**
- * Add a new entry to this map.
- * @param entry The entry to be added.
- */
- public void addEntry(final Cmap12TtfEntry4a entry) {
- this.lastEntryAdded++;
- if (this.lastEntryAdded >= this.entries.length) {
- // Fails silently.
- return;
- }
- this.entries[this.lastEntryAdded] = entry;
- }
-
- /**
- * Add a new entry to this map.
- * @param unicodeStart The starting Unicode code point for this map.
- * @param unicodeEnd The ending Unicode code point for this map.
- * @param glyphStartIndex The starting glyph index for this map.
- * This index is the encoded value for {@code unicodeStart}.
- */
- public void addEntry(final int unicodeStart, final int unicodeEnd,
- final int glyphStartIndex) {
- final Cmap12TtfEntry4a newEntry = new Cmap12TtfEntry4a(unicodeStart, unicodeEnd,
- glyphStartIndex);
- addEntry(newEntry);
- }
-
- @Override
- public int encode(final int codePoint) {
- final Cmap12TtfEntry4a entry = entryForChar(codePoint);
- if (entry == null) {
- return -1;
- }
- return entry.encodeCharacter(codePoint);
- }
-
- /**
- * Find the entry for a given character.
- * @param codePoint The Unicode code point for which an entry is sought.
- * @return The entry, or null if none is defined for {@code codePoint}.
- */
- private Cmap12TtfEntry4a entryForChar(final int codePoint) {
- for (int i = 0; i < this.entries.length; i++) {
- if (this.entries[i].containsChar(codePoint)) {
- return this.entries[i];
- }
- }
- return null;
- }
-
- @Override
- public int decode(final int glyphIndexInput) {
- for (int i = 0; i < this.entries.length; i++) {
- final int codePoint = this.entries[i].decodeCharacter(glyphIndexInput);
- if (codePoint != Character.MAX_VALUE) {
- return codePoint;
- }
- }
- return -1;
- }
-
- @Override
- public String asPostScript(final org.axsl.ps.Encoding baseEncoding) {
- return null;
- }
-
- @Override
- public int getFirstIndex() {
- return -1;
- }
-
- @Override
- public int getLastIndex() {
- return -1;
- }
-
- @Override
- public boolean isBuiltInPs() {
- /* TODO Make this class abstract and make a subclass that handled custom instances, so that we can keep the
- * prebuilt instances separate, and return different values here. */
- return false;
- }
-
- @Override
- public boolean isBuiltInPdf() {
- /* TODO Make this class abstract and make a subclass that handled custom instances, so that we can keep the
- * prebuilt instances separate, and return different values here. */
- return false;
- }
-
- @Override
- public boolean canEncode(final int codePoint) {
- return this.encode(codePoint) > -1;
- }
-
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-26 23:34:23
|
Revision: 13521
http://sourceforge.net/p/foray/code/13521
Author: victormote
Date: 2025-04-26 23:34:06 +0000 (Sat, 26 Apr 2025)
Log Message:
-----------
Remove unused and unneeded methods.
Modified Paths:
--------------
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java 2025-04-26 17:36:21 UTC (rev 13520)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java 2025-04-26 23:34:06 UTC (rev 13521)
@@ -31,8 +31,6 @@
import org.foray.primitive.sequence.IntArrayBuilder;
import org.foray.ps.encode.CharSet4a;
import org.foray.ps.encode.CharSetParser;
-import org.foray.ps.encode.Cmap04Ttf4a;
-import org.foray.ps.encode.Cmap12Ttf4a;
import org.foray.ps.filter.Ascii85DecodeFilter;
import org.foray.ps.filter.Ascii85EncodeFilter;
import org.foray.ps.filter.AsciiHexDecodeFilter;
@@ -170,26 +168,4 @@
return charSet;
}
- /**
- * Creates a new Cmap04 with a given name and expected size.
- * @param name The name of this encoding.
- * @param expectedEntries The number of expected entries in this encoding.
- * Setting this to the correct value gives the implementation an opportunity for more efficient processing.
- * @return The newly-created implementation-specific Cmap04 instance.
- */
- public Cmap04Ttf4a createCmap04(final String name, final int expectedEntries) {
- return new Cmap04Ttf4a(name, expectedEntries);
- }
-
- /**
- * Creates a new Cmap12 with a given name and expected size.
- * @param name The name of this encoding.
- * @param expectedEntries The number of expected entries in this encoding.
- * Setting this to the correct value gives the implementation an opportunity for more efficient processing.
- * @return The newly-created implementation-specific Cmap12 instance.
- */
- public Cmap12Ttf4a createCmap12(final String name, final int expectedEntries) {
- return new Cmap12Ttf4a(name, expectedEntries);
- }
-
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-26 17:36:41
|
Revision: 13520
http://sourceforge.net/p/foray/code/13520
Author: victormote
Date: 2025-04-26 17:36:21 +0000 (Sat, 26 Apr 2025)
Log Message:
-----------
Conform to aXSL change: Rename interface for clarity.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ConsumerFont4a.java
trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java
trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.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/type1/Type1Metrics.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-pdf/src/main/java/org/foray/pdf/text/PdfEncoding4a.java
trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFont4a.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInterpreter4a.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/filter/EncodingVectorInputStream.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Encoding4aLatinExtra.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingCe.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingCustom.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingExpert.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingExpertSubset.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingIsoLatin1.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingMacExpert.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingMacRoman.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingMacStandard.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingPdfDoc.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingStandard.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingSymbol.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingVector4a.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingWinAnsi.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingZapfDingbats.java
trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ConsumerFont4a.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ConsumerFont4a.java 2025-04-26 15:15:58 UTC (rev 13519)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ConsumerFont4a.java 2025-04-26 17:36:21 UTC (rev 13520)
@@ -32,7 +32,7 @@
import org.foray.ps.encode.EncodingVector4a;
import org.axsl.ps.Encoding;
-import org.axsl.ps.PsEncoding;
+import org.axsl.ps.EncodingVector;
import java.util.ArrayList;
import java.util.List;
@@ -266,28 +266,28 @@
/* Cmap encodings should be able to handle any character in the font's character set. */
- if (! (internalEncoding instanceof PsEncoding)) {
+ if (! (internalEncoding instanceof EncodingVector)) {
return internalEncoding;
}
/* Cast checked above. */
- final PsEncoding internalEncodingVector = (PsEncoding) internalEncoding;
+ final EncodingVector internalEncodingVector = (EncodingVector) internalEncoding;
/* The specialized encodings cover their entire character set. */
- if (internalEncodingVector.getPredefinedType() == PsEncoding.Predefined.SYMBOL
- || internalEncodingVector.getPredefinedType() == PsEncoding.Predefined.ZAPF_DINGBATS) {
+ if (internalEncodingVector.getPredefinedType() == EncodingVector.Predefined.SYMBOL
+ || internalEncodingVector.getPredefinedType() == EncodingVector.Predefined.ZAPF_DINGBATS) {
return internalEncoding;
}
- if (internalEncodingVector.getPredefinedType() == PsEncoding.Predefined.STANDARD) {
+ if (internalEncodingVector.getPredefinedType() == EncodingVector.Predefined.STANDARD) {
/* Try WinAnsiEncoding. */
- trialEncoding = EncodingVector4a.getPredefinedEncoding(PsEncoding.Predefined.WIN_ANSI);
+ trialEncoding = EncodingVector4a.getPredefinedEncoding(EncodingVector.Predefined.WIN_ANSI);
if (trialEncoding.canEncode(codePoint)) {
return trialEncoding;
}
/* Try the Central European encoding. */
- trialEncoding = EncodingVector4a.getPredefinedEncoding(PsEncoding.Predefined.CE);
+ trialEncoding = EncodingVector4a.getPredefinedEncoding(EncodingVector.Predefined.CE);
if (trialEncoding.canEncode(codePoint)) {
return trialEncoding;
}
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-26 15:15:58 UTC (rev 13519)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java 2025-04-26 17:36:21 UTC (rev 13520)
@@ -44,7 +44,7 @@
import org.axsl.font.Font;
import org.axsl.font.FontException;
import org.axsl.ps.BoundingBox;
-import org.axsl.ps.PsEncoding;
+import org.axsl.ps.EncodingVector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -142,11 +142,11 @@
/* If not already set, set the Encoding. */
if (this.getInternalEncoding() == null) {
final String encodingName = this.metricsFile.getEncoding();
- PsEncoding encoding = null;
- final PsEncoding.Predefined predefined = PsEncoding.Predefined.findByName(encodingName);
+ EncodingVector encoding = null;
+ final EncodingVector.Predefined predefined = EncodingVector.Predefined.findByName(encodingName);
if (encodingName.equals("StandardEncoding")
|| encodingName.equals("AdobeStandardEncoding")) {
- encoding = EncodingVector4a.getPredefinedEncoding(PsEncoding.Predefined.WIN_ANSI);
+ encoding = EncodingVector4a.getPredefinedEncoding(EncodingVector.Predefined.WIN_ANSI);
} else {
if (predefined != null) {
encoding = EncodingVector4a.getPredefinedEncoding(predefined);
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java 2025-04-26 15:15:58 UTC (rev 13519)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java 2025-04-26 17:36:21 UTC (rev 13520)
@@ -40,8 +40,8 @@
import org.axsl.font.Font;
import org.axsl.font.FontException;
+import org.axsl.ps.EncodingVector;
import org.axsl.ps.GlyphList;
-import org.axsl.ps.PsEncoding;
import org.axsl.ps.PsException;
import org.axsl.value.FontStretch;
import org.axsl.value.FontStyle;
@@ -188,7 +188,7 @@
/** A map of all of the encodings that have already been parsed.
* The key to the map is a String containing the name of the encoding. The value is the Encoding instance.
*/
- private Map<String, PsEncoding> encodingsMap = new HashMap<String, PsEncoding>();
+ private Map<String, EncodingVector> encodingsMap = new HashMap<String, EncodingVector>();
/**
* Constructor.
@@ -441,7 +441,7 @@
final FontStretch stretch = FontStretch.parseFo(stretchString);
// final float simulateOblique = Float.parseFloat(simulateObliqueString);
// final String simulateBackslant = attributes.getValue("simulate-backslant");
- final PsEncoding encoding = encodingString == null ? null :
+ final EncodingVector encoding = encodingString == null ? null :
EncodingVector4a.getPredefinedEncoding(encodingString);
final String[] simulateStretch = new String[RegisteredFont.QTY_SIMULATED_STRETCH];
@@ -669,7 +669,7 @@
errorMessage("Attribute \"name\" required for element \"encoding\".");
return;
}
- PsEncoding encoding = EncodingVector4a.getPredefinedEncoding(name);
+ EncodingVector encoding = EncodingVector4a.getPredefinedEncoding(name);
if (encoding != null) {
errorMessage("Encoding already defined: " + name);
return;
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-26 15:15:58 UTC (rev 13519)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PostTable.java 2025-04-26 17:36:21 UTC (rev 13520)
@@ -34,7 +34,7 @@
import org.foray.fontParse.ttfHandler.PostTableHandler;
import org.foray.ps.encode.EncodingVector4a;
-import org.axsl.ps.PsEncoding;
+import org.axsl.ps.EncodingVector;
import org.axsl.ps.PsServer;
import java.math.BigDecimal;
@@ -163,8 +163,8 @@
* @return The PostScript name for {@code glyphIndex}.
*/
public String getPostScriptName(final PsServer psServer, final char glyphIndex) {
- final PsEncoding macOrdering = EncodingVector4a.getPredefinedEncoding(
- PsEncoding.Predefined.STANDARD_MACINTOSH_ORDERING);
+ final EncodingVector macOrdering = EncodingVector4a.getPredefinedEncoding(
+ EncodingVector.Predefined.STANDARD_MACINTOSH_ORDERING);
final int codePoint = macOrdering.decode(glyphIndex);
switch (this.majorVersion) {
case 1:
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1Metrics.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1Metrics.java 2025-04-26 15:15:58 UTC (rev 13519)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1Metrics.java 2025-04-26 17:36:21 UTC (rev 13520)
@@ -37,7 +37,7 @@
import org.axsl.primitive.sequence.ShortSequence;
import org.axsl.ps.BoundingBox;
import org.axsl.ps.CharSet;
-import org.axsl.ps.PsEncoding;
+import org.axsl.ps.EncodingVector;
import java.io.Serializable;
@@ -199,7 +199,7 @@
* first character is at index 5, an index that is not included in the
* EncodingScheme listed, "AdobeStandardEncoding".</p>
*/
- private PsEncoding internalEncoding;
+ private EncodingVector internalEncoding;
/** The characters set used by this font. */
private CharSet charSet;
@@ -543,7 +543,7 @@
* Sets the encoding vector.
* @param internalEncoding The encoding vector.
*/
- public void setInternalEncoding(final PsEncoding internalEncoding) {
+ public void setInternalEncoding(final EncodingVector internalEncoding) {
this.internalEncoding = internalEncoding;
}
@@ -551,7 +551,7 @@
* Returns the internal encoding vector for this font.
* @return The internal encoding vector for this font.
*/
- public PsEncoding getInternalEncoding() {
+ public EncodingVector getInternalEncoding() {
return this.internalEncoding;
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1MetricsParserAfm.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1MetricsParserAfm.java 2025-04-26 15:15:58 UTC (rev 13519)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1MetricsParserAfm.java 2025-04-26 17:36:21 UTC (rev 13520)
@@ -41,8 +41,8 @@
import org.axsl.font.FontException;
import org.axsl.ps.BoundingBox;
import org.axsl.ps.CharSet;
+import org.axsl.ps.EncodingVector;
import org.axsl.ps.GlyphList;
-import org.axsl.ps.PsEncoding;
import org.axsl.ps.PsServer;
import org.axsl.value.FontWeight;
@@ -1514,7 +1514,7 @@
* @param psServer The PostScript server.
* @return The internal encoding for this font.
*/
- private PsEncoding findInternalEncoding(final PsServer psServer) {
+ private EncodingVector findInternalEncoding(final PsServer psServer) {
// Truncate the arrays to the right size.
if (this.internalCodePointCount < Type1MetricsParserAfm.MAX_CODE_POINTS) {
this.internalCodePoints.trimToSize();
@@ -1521,18 +1521,18 @@
this.internalCodePointIndexes.trimToSize();
}
/* Create a tentative EncodingVector instance. */
- final PsEncoding newEncoding = EncodingVector4a.createEncodingVector(
+ final EncodingVector newEncoding = EncodingVector4a.createEncodingVector(
"internal-" + this.metrics.getPostscriptName(), this.internalCodePoints, this.internalCodePointIndexes);
/* Is this a predefined encoding? */
- PsEncoding predefinedEncoding = null;
+ EncodingVector predefinedEncoding = null;
if (this.metrics.getPostscriptName().equals("ZapfDingbats")) {
- predefinedEncoding = EncodingVector4a.getPredefinedEncoding(PsEncoding.Predefined.ZAPF_DINGBATS);
+ predefinedEncoding = EncodingVector4a.getPredefinedEncoding(EncodingVector.Predefined.ZAPF_DINGBATS);
if (newEncoding.isSubsetOf(predefinedEncoding)) {
return predefinedEncoding;
}
}
if (this.metrics.getPostscriptName().equals("Symbol")) {
- predefinedEncoding = EncodingVector4a.getPredefinedEncoding(PsEncoding.Predefined.SYMBOL);
+ predefinedEncoding = EncodingVector4a.getPredefinedEncoding(EncodingVector.Predefined.SYMBOL);
if (newEncoding.isSubsetOf(predefinedEncoding)) {
return predefinedEncoding;
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1MetricsParserPfm.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1MetricsParserPfm.java 2025-04-26 15:15:58 UTC (rev 13519)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1MetricsParserPfm.java 2025-04-26 17:36:21 UTC (rev 13520)
@@ -36,7 +36,7 @@
import org.axsl.constants.PrimitiveConstants;
import org.axsl.ps.CharSet;
-import org.axsl.ps.PsEncoding;
+import org.axsl.ps.EncodingVector;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@@ -112,7 +112,8 @@
parseHeader();
switch (this.metrics.getCharSetID()) {
case 0: {
- this.metrics.setInternalEncoding(EncodingVector4a.getPredefinedEncoding(PsEncoding.Predefined.WIN_ANSI));
+ this.metrics.setInternalEncoding(
+ EncodingVector4a.getPredefinedEncoding(EncodingVector.Predefined.WIN_ANSI));
this.metrics.setCharSet(CharSet4a.getRegisteredCharSet(CharSet.Predefined.WINDOWS_ANSI));
break;
}
@@ -336,7 +337,7 @@
* @throws IOException For I/O Error.
*/
private void loadExtentTable() throws IOException {
- final PsEncoding internalEncoding = this.metrics.getInternalEncoding();
+ final EncodingVector internalEncoding = this.metrics.getInternalEncoding();
if (internalEncoding == null) {
return;
}
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfEncoding4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfEncoding4a.java 2025-04-26 15:15:58 UTC (rev 13519)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfEncoding4a.java 2025-04-26 17:36:21 UTC (rev 13520)
@@ -34,7 +34,7 @@
import org.axsl.primitive.sequence.ByteSequencePlus;
import org.axsl.ps.Encoding;
-import org.axsl.ps.PsEncoding;
+import org.axsl.ps.EncodingVector;
/**
* Class representing an /Encoding object.
@@ -67,7 +67,7 @@
* @return The name of the underlying encoding.
*/
public String getName() {
- if (this.encoding instanceof PsEncoding) {
+ if (this.encoding instanceof EncodingVector) {
return this.encoding.getName();
}
return "Identity-H";
@@ -78,7 +78,7 @@
if (this.encoding.isBuiltInPdf()) {
return "/" + this.getName();
}
- if (! (this.encoding instanceof PsEncoding)) {
+ if (! (this.encoding instanceof EncodingVector)) {
return "/" + this.getName();
}
return super.pdfReference(doc);
Modified: trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFont4a.java
===================================================================
--- trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFont4a.java 2025-04-26 15:15:58 UTC (rev 13519)
+++ trunk/foray/foray-pdf/src/main/java/org/foray/pdf/text/PdfFont4a.java 2025-04-26 17:36:21 UTC (rev 13520)
@@ -43,7 +43,7 @@
import org.axsl.primitive.sequence.ByteSequencePlus;
import org.axsl.primitive.sequence.ShortSequence;
import org.axsl.ps.Encoding;
-import org.axsl.ps.PsEncoding;
+import org.axsl.ps.EncodingVector;
/**
* A /Font object in PDF.
@@ -287,7 +287,7 @@
if (this.pdfEncoding == null) {
return;
}
- if (getEncoding() instanceof PsEncoding
+ if (getEncoding() instanceof EncodingVector
&& (getEncoding()
== getFont().getInternalEncoding())) {
/* If using the font's internal encoding, no need to write it. */
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInterpreter4a.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInterpreter4a.java 2025-04-26 15:15:58 UTC (rev 13519)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInterpreter4a.java 2025-04-26 17:36:21 UTC (rev 13520)
@@ -32,7 +32,7 @@
import org.foray.ps.readonly.ReadOnlySystemDict;
import org.axsl.constants.PrimitiveConstants;
-import org.axsl.ps.PsEncoding;
+import org.axsl.ps.EncodingVector;
import org.axsl.ps.PsInput;
import java.io.IOException;
@@ -249,7 +249,7 @@
systemDictToUse.setPSInterpreter(this);
// Add the Standard Encoding to the System Dictionary.
PsName name = new PsName("StandardEncoding", false, false);
- PsEncoding encoding = EncodingVector4a.getPredefinedEncoding(name.getValue());
+ EncodingVector encoding = EncodingVector4a.getPredefinedEncoding(name.getValue());
PsArray array = new PsArray(encoding.getGlyphNames().toArray(), false);
systemDictToUse.addItem(this, name, array);
// Add the ISO Latin 1 Encoding to the System Dictionary.
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/filter/EncodingVectorInputStream.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/filter/EncodingVectorInputStream.java 2025-04-26 15:15:58 UTC (rev 13519)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/filter/EncodingVectorInputStream.java 2025-04-26 17:36:21 UTC (rev 13520)
@@ -31,7 +31,7 @@
import org.foray.common.primitive.UnicodeCharUtils;
import org.foray.ps.encode.EncodingVector4a;
-import org.axsl.ps.PsEncoding;
+import org.axsl.ps.EncodingVector;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
@@ -62,7 +62,7 @@
public class EncodingVectorInputStream extends FilterInputStream {
/** The encoding which should be used to decode the underlying input stream. */
- private PsEncoding encoding;
+ private EncodingVector encoding;
/**
* Constructor.
@@ -70,7 +70,7 @@
* This stream is assumed to contain single-byte characters, encoded with {@code encoding}.
* @param encoding The encoding in which {@code inputStream} is assumed to be encoded.
*/
- public EncodingVectorInputStream(final InputStream inputStream, final PsEncoding encoding) {
+ public EncodingVectorInputStream(final InputStream inputStream, final EncodingVector encoding) {
super(inputStream);
this.encoding = encoding;
}
@@ -159,7 +159,7 @@
System.exit(1);
}
- final PsEncoding encoding = EncodingVector4a.getPredefinedEncoding(encodingString);
+ final EncodingVector encoding = EncodingVector4a.getPredefinedEncoding(encodingString);
final EncodingVectorInputStream inputFilter = new EncodingVectorInputStream(inputStream, encoding);
try {
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Encoding4aLatinExtra.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Encoding4aLatinExtra.java 2025-04-26 15:15:58 UTC (rev 13519)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Encoding4aLatinExtra.java 2025-04-26 17:36:21 UTC (rev 13520)
@@ -31,7 +31,7 @@
import org.foray.primitive.sequence.IntArray;
-import org.axsl.ps.PsEncoding;
+import org.axsl.ps.EncodingVector;
import java.io.Serializable;
@@ -306,7 +306,7 @@
}
@Override
- public PsEncoding.Predefined getPredefinedType() {
+ public EncodingVector.Predefined getPredefinedType() {
return null;
}
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingCe.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingCe.java 2025-04-26 15:15:58 UTC (rev 13519)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingCe.java 2025-04-26 17:36:21 UTC (rev 13520)
@@ -31,7 +31,7 @@
import org.foray.primitive.sequence.IntArray;
-import org.axsl.ps.PsEncoding;
+import org.axsl.ps.EncodingVector;
import java.io.Serializable;
@@ -944,7 +944,7 @@
* {@link #getInstance()}.
*/
private EncodingCe() {
- super(PsEncoding.Predefined.CE.getName(),
+ super(EncodingVector.Predefined.CE.getName(),
GlyphList4a.standardSourceGlyphLists(),
new IntArray(EncodingCe.CODE_POINTS),
new IntArray(EncodingCe.CODE_POINT_INDEXES));
@@ -979,8 +979,8 @@
}
@Override
- public PsEncoding.Predefined getPredefinedType() {
- return PsEncoding.Predefined.CE;
+ public EncodingVector.Predefined getPredefinedType() {
+ return EncodingVector.Predefined.CE;
}
@Override
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingCustom.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingCustom.java 2025-04-26 15:15:58 UTC (rev 13519)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingCustom.java 2025-04-26 17:36:21 UTC (rev 13520)
@@ -30,8 +30,8 @@
import org.axsl.primitive.sequence.IntSequence;
+import org.axsl.ps.EncodingVector;
import org.axsl.ps.GlyphList;
-import org.axsl.ps.PsEncoding;
import java.util.List;
@@ -66,7 +66,7 @@
}
@Override
- public PsEncoding.Predefined getPredefinedType() {
+ public EncodingVector.Predefined getPredefinedType() {
return null;
}
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingExpert.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingExpert.java 2025-04-26 15:15:58 UTC (rev 13519)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingExpert.java 2025-04-26 17:36:21 UTC (rev 13520)
@@ -31,7 +31,7 @@
import org.foray.primitive.sequence.IntArray;
-import org.axsl.ps.PsEncoding;
+import org.axsl.ps.EncodingVector;
import java.io.Serializable;
@@ -740,7 +740,7 @@
* {@link #getInstance()}.
*/
private EncodingExpert() {
- super(PsEncoding.Predefined.EXPERT.getName(),
+ super(EncodingVector.Predefined.EXPERT.getName(),
GlyphList4a.standardSourceGlyphLists(),
new IntArray(EncodingExpert.CODE_POINTS),
new IntArray(EncodingExpert.CODE_POINT_INDEXES));
@@ -772,8 +772,8 @@
}
@Override
- public PsEncoding.Predefined getPredefinedType() {
- return PsEncoding.Predefined.EXPERT;
+ public EncodingVector.Predefined getPredefinedType() {
+ return EncodingVector.Predefined.EXPERT;
}
@Override
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingExpertSubset.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingExpertSubset.java 2025-04-26 15:15:58 UTC (rev 13519)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingExpertSubset.java 2025-04-26 17:36:21 UTC (rev 13520)
@@ -31,7 +31,7 @@
import org.foray.primitive.sequence.IntArray;
-import org.axsl.ps.PsEncoding;
+import org.axsl.ps.EncodingVector;
import java.io.Serializable;
@@ -425,7 +425,7 @@
* {@link #getInstance()}.
*/
private EncodingExpertSubset() {
- super(PsEncoding.Predefined.EXPERT_SUBSET.getName(),
+ super(EncodingVector.Predefined.EXPERT_SUBSET.getName(),
GlyphList4a.standardSourceGlyphLists(),
new IntArray(EncodingExpertSubset.CODE_POINTS),
new IntArray(EncodingExpertSubset.CODE_POINT_INDEXES));
@@ -457,8 +457,8 @@
}
@Override
- public PsEncoding.Predefined getPredefinedType() {
- return PsEncoding.Predefined.EXPERT_SUBSET;
+ public EncodingVector.Predefined getPredefinedType() {
+ return EncodingVector.Predefined.EXPERT_SUBSET;
}
@Override
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingIsoLatin1.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingIsoLatin1.java 2025-04-26 15:15:58 UTC (rev 13519)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingIsoLatin1.java 2025-04-26 17:36:21 UTC (rev 13520)
@@ -31,7 +31,7 @@
import org.foray.primitive.sequence.IntArray;
-import org.axsl.ps.PsEncoding;
+import org.axsl.ps.EncodingVector;
import java.io.Serializable;
@@ -881,7 +881,7 @@
* {@link #getInstance()}.
*/
private EncodingIsoLatin1() {
- super(PsEncoding.Predefined.ISO_LATIN_1.getName(),
+ super(EncodingVector.Predefined.ISO_LATIN_1.getName(),
GlyphList4a.standardSourceGlyphLists(),
new IntArray(EncodingIsoLatin1.CODE_POINTS),
new IntArray(EncodingIsoLatin1.CODE_POINT_INDEXES));
@@ -913,8 +913,8 @@
}
@Override
- public PsEncoding.Predefined getPredefinedType() {
- return PsEncoding.Predefined.ISO_LATIN_1;
+ public EncodingVector.Predefined getPredefinedType() {
+ return EncodingVector.Predefined.ISO_LATIN_1;
}
@Override
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingMacExpert.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingMacExpert.java 2025-04-26 15:15:58 UTC (rev 13519)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingMacExpert.java 2025-04-26 17:36:21 UTC (rev 13520)
@@ -31,7 +31,7 @@
import org.foray.primitive.sequence.IntArray;
-import org.axsl.ps.PsEncoding;
+import org.axsl.ps.EncodingVector;
import java.io.Serializable;
@@ -743,7 +743,7 @@
* {@link #getInstance()}.
*/
private EncodingMacExpert() {
- super(PsEncoding.Predefined.MAC_EXPERT.getName(),
+ super(EncodingVector.Predefined.MAC_EXPERT.getName(),
GlyphList4a.standardSourceGlyphLists(),
new IntArray(EncodingMacExpert.CODE_POINTS),
new IntArray(EncodingMacExpert.CODE_POINT_INDEXES));
@@ -778,8 +778,8 @@
}
@Override
- public PsEncoding.Predefined getPredefinedType() {
- return PsEncoding.Predefined.MAC_EXPERT;
+ public EncodingVector.Predefined getPredefinedType() {
+ return EncodingVector.Predefined.MAC_EXPERT;
}
@Override
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingMacRoman.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingMacRoman.java 2025-04-26 15:15:58 UTC (rev 13519)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingMacRoman.java 2025-04-26 17:36:21 UTC (rev 13520)
@@ -31,7 +31,7 @@
import org.foray.primitive.sequence.IntArray;
-import org.axsl.ps.PsEncoding;
+import org.axsl.ps.EncodingVector;
import java.io.Serializable;
@@ -909,7 +909,7 @@
* {@link #getInstance()}.
*/
private EncodingMacRoman() {
- super(PsEncoding.Predefined.MAC_ROMAN.getName(),
+ super(EncodingVector.Predefined.MAC_ROMAN.getName(),
GlyphList4a.standardSourceGlyphLists(),
new IntArray(EncodingMacRoman.CODE_POINTS),
new IntArray(EncodingMacRoman.CODE_POINT_INDEXES));
@@ -941,8 +941,8 @@
}
@Override
- public PsEncoding.Predefined getPredefinedType() {
- return PsEncoding.Predefined.MAC_ROMAN;
+ public EncodingVector.Predefined getPredefinedType() {
+ return EncodingVector.Predefined.MAC_ROMAN;
}
@Override
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingMacStandard.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingMacStandard.java 2025-04-26 15:15:58 UTC (rev 13519)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingMacStandard.java 2025-04-26 17:36:21 UTC (rev 13520)
@@ -31,7 +31,7 @@
import org.foray.primitive.sequence.IntArray;
-import org.axsl.ps.PsEncoding;
+import org.axsl.ps.EncodingVector;
import java.io.Serializable;
@@ -1118,7 +1118,7 @@
* {@link #getInstance()}.
*/
private EncodingMacStandard() {
- super(PsEncoding.Predefined.STANDARD_MACINTOSH_ORDERING.getName(),
+ super(EncodingVector.Predefined.STANDARD_MACINTOSH_ORDERING.getName(),
GlyphList4a.standardSourceGlyphLists(),
new IntArray(EncodingMacStandard.CODE_POINTS),
new IntArray(EncodingMacStandard.CODE_POINT_INDEXES));
@@ -1150,8 +1150,8 @@
}
@Override
- public PsEncoding.Predefined getPredefinedType() {
- return PsEncoding.Predefined.STANDARD_MACINTOSH_ORDERING;
+ public EncodingVector.Predefined getPredefinedType() {
+ return EncodingVector.Predefined.STANDARD_MACINTOSH_ORDERING;
}
@Override
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingPdfDoc.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingPdfDoc.java 2025-04-26 15:15:58 UTC (rev 13519)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingPdfDoc.java 2025-04-26 17:36:21 UTC (rev 13520)
@@ -31,7 +31,7 @@
import org.foray.primitive.sequence.IntArray;
-import org.axsl.ps.PsEncoding;
+import org.axsl.ps.EncodingVector;
import java.io.Serializable;
@@ -997,7 +997,7 @@
* {@link #getInstance()}.
*/
private EncodingPdfDoc() {
- super(PsEncoding.Predefined.PDF_DOC.getName(),
+ super(EncodingVector.Predefined.PDF_DOC.getName(),
GlyphList4a.standardSourceGlyphLists(),
new IntArray(EncodingPdfDoc.CODE_POINTS),
new IntArray(EncodingPdfDoc.CODE_POINT_INDEXES));
@@ -1015,7 +1015,7 @@
}
@Override
- public org.axsl.ps.PsEncoding bestBaseEncodingPdf() {
+ public EncodingVector bestBaseEncodingPdf() {
return EncodingWinAnsi.getInstance();
}
@@ -1034,8 +1034,8 @@
}
@Override
- public PsEncoding.Predefined getPredefinedType() {
- return PsEncoding.Predefined.PDF_DOC;
+ public EncodingVector.Predefined getPredefinedType() {
+ return EncodingVector.Predefined.PDF_DOC;
}
@Override
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingStandard.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingStandard.java 2025-04-26 15:15:58 UTC (rev 13519)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingStandard.java 2025-04-26 17:36:21 UTC (rev 13520)
@@ -31,7 +31,7 @@
import org.foray.primitive.sequence.IntArray;
-import org.axsl.ps.PsEncoding;
+import org.axsl.ps.EncodingVector;
import java.io.Serializable;
@@ -692,7 +692,7 @@
* {@link #getInstance()}.
*/
private EncodingStandard() {
- super(PsEncoding.Predefined.STANDARD.getName(),
+ super(EncodingVector.Predefined.STANDARD.getName(),
GlyphList4a.standardSourceGlyphLists(),
new IntArray(EncodingStandard.CODE_POINTS),
new IntArray(EncodingStandard.CODE_POINT_INDEXES));
@@ -736,8 +736,8 @@
}
@Override
- public PsEncoding.Predefined getPredefinedType() {
- return PsEncoding.Predefined.STANDARD;
+ public EncodingVector.Predefined getPredefinedType() {
+ return EncodingVector.Predefined.STANDARD;
}
}
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingSymbol.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingSymbol.java 2025-04-26 15:15:58 UTC (rev 13519)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingSymbol.java 2025-04-26 17:36:21 UTC (rev 13520)
@@ -31,7 +31,7 @@
import org.foray.primitive.sequence.IntArray;
-import org.axsl.ps.PsEncoding;
+import org.axsl.ps.EncodingVector;
import java.io.Serializable;
@@ -845,7 +845,7 @@
* {@link #getInstance()}.
*/
private EncodingSymbol() {
- super(PsEncoding.Predefined.SYMBOL.getName(),
+ super(EncodingVector.Predefined.SYMBOL.getName(),
GlyphList4a.standardSourceGlyphLists(),
new IntArray(EncodingSymbol.CODE_POINTS),
new IntArray(EncodingSymbol.CODE_POINT_INDEXES));
@@ -877,8 +877,8 @@
}
@Override
- public PsEncoding.Predefined getPredefinedType() {
- return PsEncoding.Predefined.SYMBOL;
+ public EncodingVector.Predefined getPredefinedType() {
+ return EncodingVector.Predefined.SYMBOL;
}
@Override
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingVector4a.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingVector4a.java 2025-04-26 15:15:58 UTC (rev 13519)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingVector4a.java 2025-04-26 17:36:21 UTC (rev 13520)
@@ -35,8 +35,8 @@
import org.axsl.primitive.sequence.IntSequence;
import org.axsl.primitive.sequence.IntSequenceMutable;
+import org.axsl.ps.EncodingVector;
import org.axsl.ps.GlyphList;
-import org.axsl.ps.PsEncoding;
import org.axsl.ps.PsException;
import java.io.IOException;
@@ -48,9 +48,15 @@
import java.util.List;
/**
- * Abstract superclass for implementations of {@link PsEncoding}.
+ * <p>Abstract superclass for implementations of {@link PsEncoding}.</p>
+ *
+ * <p>Two parallel arrays are used to make this process efficient.
+ * The first is a an array of all Unicode code points supported in the Encoding.
+ * This array is sorted for fast searching.
+ * The second array provides the encoded index for the Unicode code point in the first array.</p>
+
*/
-public abstract class EncodingVector4a implements PsEncoding, Serializable {
+public abstract class EncodingVector4a implements EncodingVector, Serializable {
/** The name of the undefined glyph. */
public static final String NOTDEF = ".notdef";
@@ -314,7 +320,7 @@
}
@Override
- public org.axsl.ps.PsEncoding bestBaseEncodingPdf() {
+ public EncodingVector bestBaseEncodingPdf() {
/* Predefined encodings do not need to be written at all. */
if (this.isBuiltInPdf()) {
return null;
@@ -326,7 +332,7 @@
}
@Override
- public boolean isSubsetOf(final PsEncoding otherVector) {
+ public boolean isSubsetOf(final EncodingVector otherVector) {
for (int i = 0; i < this.codePoints.length(); i++) {
final int thisEncodedValue = this.encode(this.codePoints.charAt(i));
final int otherEncodedValue = otherVector.encode(this.codePoints.charAt(i));
@@ -472,9 +478,9 @@
* @return The predefined encoding if it can be found or created, or null otherwise.
* @see #getPredefinedEncoding(PsEncoding.Predefined)
*/
- public static PsEncoding getPredefinedEncoding(final String name) {
- final PsEncoding.Predefined predefined = PsEncoding.Predefined.findByName(name);
- PsEncoding encoding = getPredefinedEncoding(predefined);
+ public static EncodingVector getPredefinedEncoding(final String name) {
+ final EncodingVector.Predefined predefined = EncodingVector.Predefined.findByName(name);
+ EncodingVector encoding = getPredefinedEncoding(predefined);
if (name.equals("FOrayLatinExtraEncoding")) {
encoding = Encoding4aLatinExtra.getInstance();
@@ -496,7 +502,7 @@
* @return The predefined encoding if it can be found or created, or null otherwise.
* @see #getPredefinedEncoding(String)
*/
- public static PsEncoding getPredefinedEncoding(final PsEncoding.Predefined predefinedVector) {
+ public static EncodingVector4a getPredefinedEncoding(final EncodingVector.Predefined predefinedVector) {
if (predefinedVector == null) {
return null;
}
@@ -552,7 +558,7 @@
* @return The newly-created implementation-specific EncodingVector instance.
* @see "https://docs.microsoft.com/en-us/typography/opentype/spec/maxp"
*/
- public static PsEncoding createEncodingVector(final String name, final IntSequence codePoints,
+ public static EncodingCustom createEncodingVector(final String name, final IntSequence codePoints,
final IntSequence codePointIndexes) {
return new EncodingCustom(name, null, codePoints, codePointIndexes);
}
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingWinAnsi.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingWinAnsi.java 2025-04-26 15:15:58 UTC (rev 13519)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingWinAnsi.java 2025-04-26 17:36:21 UTC (rev 13520)
@@ -31,7 +31,7 @@
import org.foray.primitive.sequence.IntArray;
-import org.axsl.ps.PsEncoding;
+import org.axsl.ps.EncodingVector;
import java.io.Serializable;
@@ -952,7 +952,7 @@
* {@link #getInstance()}.
*/
private EncodingWinAnsi() {
- super(PsEncoding.Predefined.WIN_ANSI.getName(),
+ super(EncodingVector.Predefined.WIN_ANSI.getName(),
GlyphList4a.standardSourceGlyphLists(),
new IntArray(EncodingWinAnsi.CODE_POINTS),
new IntArray(EncodingWinAnsi.CODE_POINT_INDEXES));
@@ -999,8 +999,8 @@
}
@Override
- public PsEncoding.Predefined getPredefinedType() {
- return PsEncoding.Predefined.WIN_ANSI;
+ public EncodingVector.Predefined getPredefinedType() {
+ return EncodingVector.Predefined.WIN_ANSI;
}
@Override
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingZapfDingbats.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingZapfDingbats.java 2025-04-26 15:15:58 UTC (rev 13519)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingZapfDingbats.java 2025-04-26 17:36:21 UTC (rev 13520)
@@ -31,8 +31,8 @@
import org.foray.primitive.sequence.IntArray;
+import org.axsl.ps.EncodingVector;
import org.axsl.ps.GlyphList;
-import org.axsl.ps.PsEncoding;
import java.io.Serializable;
import java.util.ArrayList;
@@ -908,7 +908,7 @@
* {@link #getInstance()}.
*/
private EncodingZapfDingbats() {
- super(PsEncoding.Predefined.ZAPF_DINGBATS.getName(),
+ super(EncodingVector.Predefined.ZAPF_DINGBATS.getName(),
EncodingZapfDingbats.GLYPH_LISTS_USED,
new IntArray(EncodingZapfDingbats.CODE_POINTS),
new IntArray(EncodingZapfDingbats.CODE_POINT_INDEXES));
@@ -943,8 +943,8 @@
}
@Override
- public PsEncoding.Predefined getPredefinedType() {
- return PsEncoding.Predefined.ZAPF_DINGBATS;
+ public EncodingVector.Predefined getPredefinedType() {
+ return EncodingVector.Predefined.ZAPF_DINGBATS;
}
@Override
Modified: trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java
===================================================================
--- trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java 2025-04-26 15:15:58 UTC (rev 13519)
+++ trunk/foray/foray-render/src/main/java/org/foray/render/ps/PsRenderer.java 2025-04-26 17:36:21 UTC (rev 13520)
@@ -67,7 +67,7 @@
import org.axsl.primitive.sequence.IntSequence;
import org.axsl.ps.BoundingBox;
import org.axsl.ps.Encoding;
-import org.axsl.ps.PsEncoding;
+import org.axsl.ps.EncodingVector;
import org.axsl.ps.PsFilterType;
import org.axsl.ps.PsServer;
import org.axsl.value.RuleStyle;
@@ -352,7 +352,7 @@
for (int i = 0; i < fontUses.size(); i++) {
final FontUse fontUse = fontUses.get(i);
/* For now, we don't know how to process TrueType fonts. */
- if (! (fontUse.getEncoding() instanceof PsEncoding)) {
+ if (! (fontUse.getEncoding() instanceof EncodingVector)) {
continue;
}
final Font font = fontUse.getFont();
@@ -373,7 +373,7 @@
for (int i = 0; i < fontUses.size(); i++) {
final FontUse fontUse = fontUses.get(0);
/* For now, we don't know how to process TrueType fonts. */
- if (! (fontUse.getEncoding() instanceof PsEncoding)) {
+ if (! (fontUse.getEncoding() instanceof EncodingVector)) {
continue;
}
final PsFont psFont = getPSFont(fontUse);
@@ -384,8 +384,7 @@
write("%%EndResource");
/* Get a List of all EncodingVectors used. */
- final List<PsEncoding> encodingsUsed
- = new ArrayList<PsEncoding>();
+ final List<EncodingVector> encodingsUsed = new ArrayList<EncodingVector>();
for (int i = 0; i < fontUses.size(); i++) {
final FontUse fontUse = fontUses.get(i);
final Encoding encoding = fontUse.getEncoding();
@@ -396,7 +395,7 @@
if (encoding == font.getInternalEncoding()) {
continue;
}
- if (encoding instanceof PsEncoding) {
+ if (encoding instanceof EncodingVector) {
boolean encodingFound = false;
for (int j = 0; j < encodingsUsed.size() && ! encodingFound;
j++) {
@@ -405,7 +404,7 @@
}
}
if (! encodingFound) {
- encodingsUsed.add((PsEncoding) encoding);
+ encodingsUsed.add((EncodingVector) encoding);
}
}
}
@@ -412,7 +411,7 @@
/* Except PostScript-native encodings, write each encoding vector. */
for (int i = 0; i < encodingsUsed.size(); i++) {
- final PsEncoding vector = encodingsUsed.get(i);
+ final EncodingVector vector = encodingsUsed.get(i);
if (! vector.isBuiltInPs()) {
writeRaw(vector.asPostScript(null));
}
@@ -422,12 +421,12 @@
for (int i = 0; i < fontUses.size(); i++) {
final FontUse fontUse = fontUses.get(i);
final Font font = fontUse.getFont();
- PsEncoding vector = null;
- if (! (fontUse.getEncoding() instanceof PsEncoding)) {
+ EncodingVector vector = null;
+ if (! (fontUse.getEncoding() instanceof EncodingVector)) {
/* For now, we don't know how to handle TrueType fonts here. */
continue;
}
- vector = (PsEncoding) fontUse.getEncoding();
+ vector = (EncodingVector) fontUse.getEncoding();
if (vector == font.getInternalEncoding()) {
/* If using font's internal encoding, don't re-encode. */
continue;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-26 15:16:20
|
Revision: 13519
http://sourceforge.net/p/foray/code/13519
Author: victormote
Date: 2025-04-26 15:15:58 +0000 (Sat, 26 Apr 2025)
Log Message:
-----------
Conform to aXSL change: Remove no-longer-needed methods.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java
trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1MetricsParserAfm.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/CharSet4a.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingVector4a.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java 2025-04-26 14:43:46 UTC (rev 13518)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java 2025-04-26 15:15:58 UTC (rev 13519)
@@ -716,7 +716,7 @@
glyphList.add(token);
}
try {
- encoding = this.fontServer.getPsServer().parseEncodingVector(name, input, columnNumber, radix, glyphList);
+ encoding = EncodingVector4a.parseEncodingVector(name, input, columnNumber, radix, glyphList);
this.encodingsMap.put(name, encoding);
} catch (final IOException e) {
errorMessage("Error parsing Encoding Vector \"" + name + "\": " + e.getMessage());
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1MetricsParserAfm.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1MetricsParserAfm.java 2025-04-26 14:43:46 UTC (rev 13518)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1MetricsParserAfm.java 2025-04-26 15:15:58 UTC (rev 13519)
@@ -1098,7 +1098,7 @@
}
}
}
- this.metrics.setCharSet(psServer.createCharSet(this.metrics.getPostscriptName(),
+ this.metrics.setCharSet(CharSet4a.createCharSet(this.metrics.getPostscriptName(),
new IntArrayBuilder().append(this.codePoints)));
}
@@ -1521,8 +1521,8 @@
this.internalCodePointIndexes.trimToSize();
}
/* Create a tentative EncodingVector instance. */
- final PsEncoding newEncoding = psServer.createEncodingVector("internal-" + this.metrics.getPostscriptName(),
- this.internalCodePoints, this.internalCodePointIndexes);
+ final PsEncoding newEncoding = EncodingVector4a.createEncodingVector(
+ "internal-" + this.metrics.getPostscriptName(), this.internalCodePoints, this.internalCodePointIndexes);
/* Is this a predefined encoding? */
PsEncoding predefinedEncoding = null;
if (this.metrics.getPostscriptName().equals("ZapfDingbats")) {
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java 2025-04-26 14:43:46 UTC (rev 13518)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java 2025-04-26 15:15:58 UTC (rev 13519)
@@ -33,9 +33,6 @@
import org.foray.ps.encode.CharSetParser;
import org.foray.ps.encode.Cmap04Ttf4a;
import org.foray.ps.encode.Cmap12Ttf4a;
-import org.foray.ps.encode.EncodingCustom;
-import org.foray.ps.encode.EncodingParser;
-import org.foray.ps.encode.EncodingVector4a;
import org.foray.ps.filter.Ascii85DecodeFilter;
import org.foray.ps.filter.Ascii85EncodeFilter;
import org.foray.ps.filter.AsciiHexDecodeFilter;
@@ -53,10 +50,7 @@
import org.foray.ps.pdf.PdfSystemDict;
import org.foray.ps.readonly.ReadOnlySystemDict;
-import org.axsl.primitive.sequence.IntSequence;
-import org.axsl.primitive.sequence.IntSequenceMutable;
import org.axsl.ps.CharSet;
-import org.axsl.ps.PsEncoding;
import org.axsl.ps.PsException;
import org.axsl.ps.PsFilterType;
import org.axsl.ps.PsInput;
@@ -67,7 +61,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.util.List;
/**
* Implementation of {@link PsServer} for FOray.
@@ -162,28 +155,6 @@
}
}
- @Override
- public PsEncoding createEncodingVector(final String name, final IntSequence codePoints,
- final IntSequence codePointIndexes) {
- return new EncodingCustom(name, null, codePoints, codePointIndexes);
- }
-
- @Override
- public EncodingVector4a parseEncodingVector(final String name, final InputStream inputStream, final int columnNum,
- final int radix, final List<String> glyphLists) throws IOException, PsException {
- final EncodingParser parser = new EncodingParser(inputStream, columnNum, radix, glyphLists);
- parser.parseList();
- final EncodingVector4a encodingVector = new EncodingCustom(name, parser.getGlyphListsToCheck(),
- parser.getCodePoints(), parser.getCodePointIndexes());
- return encodingVector;
- }
-
- @Override
- public CharSet createCharSet(final String name, final IntSequence characterSet) {
- final IntSequenceMutable mutable = IntArrayBuilder.fromIntSequence(characterSet);
- return new CharSet4a(name, mutable);
- }
-
/**
* Parse a character set from an input stream.
* @param name The name of the character set to be parsed.
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/CharSet4a.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/CharSet4a.java 2025-04-26 14:43:46 UTC (rev 13518)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/CharSet4a.java 2025-04-26 15:15:58 UTC (rev 13519)
@@ -30,7 +30,9 @@
import org.foray.primitive.sequence.CharArray;
import org.foray.primitive.sequence.IntArray;
+import org.foray.primitive.sequence.IntArrayBuilder;
+import org.axsl.primitive.sequence.IntSequence;
import org.axsl.primitive.sequence.IntSequenceMutable;
import org.axsl.ps.CharSet;
@@ -165,6 +167,17 @@
}
/**
+ * Creates a new CharSet.
+ * @param name The name of this character set.
+ * @param characterSet The array containing the code points in the new character set.
+ * @return The newly-created implementation-specific CharSet instance.
+ */
+ public static CharSet4a createCharSet(final String name, final IntSequence characterSet) {
+ final IntSequenceMutable mutable = IntArrayBuilder.fromIntSequence(characterSet);
+ return new CharSet4a(name, mutable);
+ }
+
+ /**
* Returns the size, in characters, of this character set.
* @return The size of this character set.
*/
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingVector4a.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingVector4a.java 2025-04-26 14:43:46 UTC (rev 13518)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingVector4a.java 2025-04-26 15:15:58 UTC (rev 13519)
@@ -37,8 +37,10 @@
import org.axsl.primitive.sequence.IntSequenceMutable;
import org.axsl.ps.GlyphList;
import org.axsl.ps.PsEncoding;
+import org.axsl.ps.PsException;
import java.io.IOException;
+import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
@@ -539,4 +541,43 @@
return null;
}
+ /**
+ * Creates a new EncodingVector instance and registers it for later use.
+ * @param name The name of this encoding.
+ * @param codePoints The sequence of Unicode code points supported by this encoding.
+ * @param codePointIndexes The sequence of encoded indexes that is parallel to {@code codePoints}.
+ * codePointIndexes[n] should contain the encoded index that corresponds to the Unicode code point at codePoints[n].
+ * The number of glyphs in a font appears to be constrained to 16 bits, but this parameter allows for 32 bits,
+ * allowing for other uses of an encoding and future changes to font capabilities.
+ * @return The newly-created implementation-specific EncodingVector instance.
+ * @see "https://docs.microsoft.com/en-us/typography/opentype/spec/maxp"
+ */
+ public static PsEncoding createEncodingVector(final String name, final IntSequence codePoints,
+ final IntSequence codePointIndexes) {
+ return new EncodingCustom(name, null, codePoints, codePointIndexes);
+ }
+
+ /**
+ * Parse an encoding vector from an input stream.
+ * @param name The name of the encoding vector to be parsed.
+ * @param inputStream The input stream containing the raw encoding vector information.
+ * @param columnNum The column number in the input file that should be read to get the encoded value for this
+ * encoding.
+ * Column number 1 is the first field after the glyph name, that is, field 2.
+ * @param radix The radix of the numbering system (10 for decimal, 8 for octal, etc.).
+ * @param glyphLists A space-separated list of glyph lists to be consulted when mapping glyph names to Unicode code
+ * points.
+ * @return The parsed encoding vector.
+ * @throws IOException For errors opening or reading the input stream.
+ * @throws PsException For errors parsing the encoding vector.
+ */
+ public static EncodingVector4a parseEncodingVector(final String name, final InputStream inputStream,
+ final int columnNum, final int radix, final List<String> glyphLists) throws IOException, PsException {
+ final EncodingParser parser = new EncodingParser(inputStream, columnNum, radix, glyphLists);
+ parser.parseList();
+ final EncodingVector4a encodingVector = new EncodingCustom(name, parser.getGlyphListsToCheck(),
+ parser.getCodePoints(), parser.getCodePointIndexes());
+ return encodingVector;
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-26 14:44:04
|
Revision: 13518
http://sourceforge.net/p/foray/code/13518
Author: victormote
Date: 2025-04-26 14:43:46 +0000 (Sat, 26 Apr 2025)
Log Message:
-----------
Conform to aXSL change: Remove no-longer-needed methods.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ConsumerFont4a.java
trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java
trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.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/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-ps/src/main/java/org/foray/ps/PsInterpreter4a.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/filter/EncodingVectorInputStream.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingVector4a.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ConsumerFont4a.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ConsumerFont4a.java 2025-04-26 14:03:52 UTC (rev 13517)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ConsumerFont4a.java 2025-04-26 14:43:46 UTC (rev 13518)
@@ -29,10 +29,10 @@
package org.foray.font;
import org.foray.font.config.RegisteredFont;
+import org.foray.ps.encode.EncodingVector4a;
import org.axsl.ps.Encoding;
import org.axsl.ps.PsEncoding;
-import org.axsl.ps.PsServer;
import java.util.ArrayList;
import java.util.List;
@@ -281,14 +281,13 @@
}
if (internalEncodingVector.getPredefinedType() == PsEncoding.Predefined.STANDARD) {
- final PsServer psServer = this.getFontConsumer().getFontServer().getPsServer();
/* Try WinAnsiEncoding. */
- trialEncoding = psServer.getPredefinedEncoding(PsEncoding.Predefined.WIN_ANSI);
+ trialEncoding = EncodingVector4a.getPredefinedEncoding(PsEncoding.Predefined.WIN_ANSI);
if (trialEncoding.canEncode(codePoint)) {
return trialEncoding;
}
/* Try the Central European encoding. */
- trialEncoding = psServer.getPredefinedEncoding(PsEncoding.Predefined.CE);
+ trialEncoding = EncodingVector4a.getPredefinedEncoding(PsEncoding.Predefined.CE);
if (trialEncoding.canEncode(codePoint)) {
return trialEncoding;
}
@@ -295,7 +294,7 @@
/* Try the FOray catch-all encoding. */
/* TODO: Move this encoding from the PS package to the Fonts package so that we don't have to address it
* by name. */
- trialEncoding = psServer.getPredefinedEncoding("FOrayLatinExtraEncoding");
+ trialEncoding = EncodingVector4a.getPredefinedEncoding("FOrayLatinExtraEncoding");
if (trialEncoding != null
&& trialEncoding.canEncode(codePoint)) {
return trialEncoding;
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-26 14:03:52 UTC (rev 13517)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/FsType1Font.java 2025-04-26 14:43:46 UTC (rev 13518)
@@ -38,6 +38,7 @@
import org.foray.font.type1.Type1FontParserPfb;
import org.foray.font.type1.Type1Metrics;
import org.foray.font.type1.Type1MetricsParser;
+import org.foray.ps.encode.EncodingVector4a;
import org.axsl.constants.TypographicConstants;
import org.axsl.font.Font;
@@ -44,7 +45,6 @@
import org.axsl.font.FontException;
import org.axsl.ps.BoundingBox;
import org.axsl.ps.PsEncoding;
-import org.axsl.ps.PsServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -143,14 +143,13 @@
if (this.getInternalEncoding() == null) {
final String encodingName = this.metricsFile.getEncoding();
PsEncoding encoding = null;
- final PsServer psServer = this.getRegisteredFontContent().getFontServer().getPsServer();
final PsEncoding.Predefined predefined = PsEncoding.Predefined.findByName(encodingName);
if (encodingName.equals("StandardEncoding")
|| encodingName.equals("AdobeStandardEncoding")) {
- encoding = psServer.getPredefinedEncoding(PsEncoding.Predefined.WIN_ANSI);
+ encoding = EncodingVector4a.getPredefinedEncoding(PsEncoding.Predefined.WIN_ANSI);
} else {
if (predefined != null) {
- encoding = psServer.getPredefinedEncoding(predefined);
+ encoding = EncodingVector4a.getPredefinedEncoding(predefined);
}
}
this.setInternalEncoding(encoding);
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java 2025-04-26 14:03:52 UTC (rev 13517)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java 2025-04-26 14:43:46 UTC (rev 13518)
@@ -32,6 +32,7 @@
import org.foray.common.url.UrlFactory;
import org.foray.font.FontServer4a;
import org.foray.primitive.StringUtils;
+import org.foray.ps.encode.EncodingVector4a;
import org.foray.ps.encode.GlyphList4a;
import org.foray.ps.encode.GlyphListParser;
import org.foray.xml.SaxLocation;
@@ -441,7 +442,7 @@
// final float simulateOblique = Float.parseFloat(simulateObliqueString);
// final String simulateBackslant = attributes.getValue("simulate-backslant");
final PsEncoding encoding = encodingString == null ? null :
- this.fontServer.getPsServer().getPredefinedEncoding(encodingString);
+ EncodingVector4a.getPredefinedEncoding(encodingString);
final String[] simulateStretch = new String[RegisteredFont.QTY_SIMULATED_STRETCH];
simulateStretch[RegisteredFont.SIMULATE_ULTRA_CONDENSED_INDEX]
@@ -668,7 +669,7 @@
errorMessage("Attribute \"name\" required for element \"encoding\".");
return;
}
- PsEncoding encoding = this.fontServer.getPsServer().getPredefinedEncoding(name);
+ PsEncoding encoding = EncodingVector4a.getPredefinedEncoding(name);
if (encoding != null) {
errorMessage("Encoding already defined: " + name);
return;
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-26 14:03:52 UTC (rev 13517)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/PostTable.java 2025-04-26 14:43:46 UTC (rev 13518)
@@ -32,6 +32,7 @@
import org.foray.font.ttf.RoTable;
import org.foray.fontParse.ttf.PostTableParser;
import org.foray.fontParse.ttfHandler.PostTableHandler;
+import org.foray.ps.encode.EncodingVector4a;
import org.axsl.ps.PsEncoding;
import org.axsl.ps.PsServer;
@@ -162,7 +163,7 @@
* @return The PostScript name for {@code glyphIndex}.
*/
public String getPostScriptName(final PsServer psServer, final char glyphIndex) {
- final PsEncoding macOrdering = psServer.getPredefinedEncoding(
+ final PsEncoding macOrdering = EncodingVector4a.getPredefinedEncoding(
PsEncoding.Predefined.STANDARD_MACINTOSH_ORDERING);
final int codePoint = macOrdering.decode(glyphIndex);
switch (this.majorVersion) {
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1MetricsParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1MetricsParser.java 2025-04-26 14:03:52 UTC (rev 13517)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1MetricsParser.java 2025-04-26 14:43:46 UTC (rev 13518)
@@ -103,7 +103,7 @@
public Type1Metrics parse() throws IOException, FontException {
switch (this.metricsFormat) {
case PFM: {
- final Type1MetricsParserPfm parser = new Type1MetricsParserPfm(this.fontServer, this.randomInput);
+ final Type1MetricsParserPfm parser = new Type1MetricsParserPfm(this.randomInput);
final Type1Metrics metrics = parser.parse();
return metrics;
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1MetricsParserAfm.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1MetricsParserAfm.java 2025-04-26 14:03:52 UTC (rev 13517)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1MetricsParserAfm.java 2025-04-26 14:43:46 UTC (rev 13518)
@@ -34,6 +34,8 @@
import org.foray.font.format.Kerning;
import org.foray.primitive.sequence.IntArrayBuilder;
import org.foray.primitive.sequence.ShortArrayBuilder;
+import org.foray.ps.encode.CharSet4a;
+import org.foray.ps.encode.EncodingVector4a;
import org.foray.ps.encode.GlyphList4a;
import org.axsl.font.FontException;
@@ -1042,7 +1044,7 @@
this.metrics.setCharSet(null);
if (this.charSetString != null) {
/* See if this one is already registered. */
- this.metrics.setCharSet(psServer.getPredefinedCharSet(this.charSetString));
+ this.metrics.setCharSet(CharSet4a.getRegisteredCharSet(this.charSetString));
}
if (this.metrics.getCharSet() == null) {
this.codePoints = new int[this.qtyCharMetricsExpected];
@@ -1524,18 +1526,18 @@
/* Is this a predefined encoding? */
PsEncoding predefinedEncoding = null;
if (this.metrics.getPostscriptName().equals("ZapfDingbats")) {
- predefinedEncoding = psServer.getPredefinedEncoding(PsEncoding.Predefined.ZAPF_DINGBATS);
+ predefinedEncoding = EncodingVector4a.getPredefinedEncoding(PsEncoding.Predefined.ZAPF_DINGBATS);
if (newEncoding.isSubsetOf(predefinedEncoding)) {
return predefinedEncoding;
}
}
if (this.metrics.getPostscriptName().equals("Symbol")) {
- predefinedEncoding = psServer.getPredefinedEncoding(PsEncoding.Predefined.SYMBOL);
+ predefinedEncoding = EncodingVector4a.getPredefinedEncoding(PsEncoding.Predefined.SYMBOL);
if (newEncoding.isSubsetOf(predefinedEncoding)) {
return predefinedEncoding;
}
}
- predefinedEncoding = psServer.getPredefinedEncoding(this.metrics.getEncoding());
+ predefinedEncoding = EncodingVector4a.getPredefinedEncoding(this.metrics.getEncoding());
if (newEncoding.isSubsetOf(predefinedEncoding)) {
return predefinedEncoding;
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1MetricsParserPfm.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1MetricsParserPfm.java 2025-04-26 14:03:52 UTC (rev 13517)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1MetricsParserPfm.java 2025-04-26 14:43:46 UTC (rev 13518)
@@ -29,14 +29,14 @@
package org.foray.font.type1;
import org.foray.common.RandomAccessInput;
-import org.foray.font.FontServer4a;
import org.foray.font.format.Kerning;
import org.foray.primitive.sequence.ShortArrayBuilder;
+import org.foray.ps.encode.CharSet4a;
+import org.foray.ps.encode.EncodingVector4a;
import org.axsl.constants.PrimitiveConstants;
import org.axsl.ps.CharSet;
import org.axsl.ps.PsEncoding;
-import org.axsl.ps.PsServer;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@@ -88,9 +88,6 @@
/** The last character index in this font, as parsed. */
private char dfLastChar = 0;
- /** The font server. */
- private FontServer4a fontServer;
-
/** The raw metric content bytes. */
private RandomAccessInput input;
@@ -99,11 +96,9 @@
/**
* Constructor.
- * @param fontServer The font server.
* @param input The raw metric content bytes.
*/
- public Type1MetricsParserPfm(final FontServer4a fontServer, final RandomAccessInput input) {
- this.fontServer = fontServer;
+ public Type1MetricsParserPfm(final RandomAccessInput input) {
this.input = input;
this.metrics = new Type1Metrics(Type1Metrics.Format.PFM);
}
@@ -117,9 +112,8 @@
parseHeader();
switch (this.metrics.getCharSetID()) {
case 0: {
- final PsServer psServer = this.fontServer.getPsServer();
- this.metrics.setInternalEncoding(psServer.getPredefinedEncoding(PsEncoding.Predefined.WIN_ANSI));
- this.metrics.setCharSet(psServer.getPredefinedCharSet(CharSet.Predefined.WINDOWS_ANSI));
+ this.metrics.setInternalEncoding(EncodingVector4a.getPredefinedEncoding(PsEncoding.Predefined.WIN_ANSI));
+ this.metrics.setCharSet(CharSet4a.getRegisteredCharSet(CharSet.Predefined.WINDOWS_ANSI));
break;
}
default: {
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInterpreter4a.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInterpreter4a.java 2025-04-26 14:03:52 UTC (rev 13517)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsInterpreter4a.java 2025-04-26 14:43:46 UTC (rev 13518)
@@ -28,6 +28,7 @@
package org.foray.ps;
+import org.foray.ps.encode.EncodingVector4a;
import org.foray.ps.readonly.ReadOnlySystemDict;
import org.axsl.constants.PrimitiveConstants;
@@ -246,15 +247,14 @@
}
// Register this as the parent of the System Dictionary
systemDictToUse.setPSInterpreter(this);
- final PsServer4a psServer = new PsServer4a();
// Add the Standard Encoding to the System Dictionary.
PsName name = new PsName("StandardEncoding", false, false);
- PsEncoding encoding = psServer.getPredefinedEncoding(name.getValue());
+ PsEncoding encoding = EncodingVector4a.getPredefinedEncoding(name.getValue());
PsArray array = new PsArray(encoding.getGlyphNames().toArray(), false);
systemDictToUse.addItem(this, name, array);
// Add the ISO Latin 1 Encoding to the System Dictionary.
name = new PsName("ISOLatin1Encoding", false, false);
- encoding = psServer.getPredefinedEncoding(name.getValue());
+ encoding = EncodingVector4a.getPredefinedEncoding(name.getValue());
array = new PsArray(encoding.getGlyphNames().toArray(), false);
systemDictToUse.addItem(this, name, array);
// Add the System Dictionary to the dictionary stack.
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java 2025-04-26 14:03:52 UTC (rev 13517)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java 2025-04-26 14:43:46 UTC (rev 13518)
@@ -33,22 +33,9 @@
import org.foray.ps.encode.CharSetParser;
import org.foray.ps.encode.Cmap04Ttf4a;
import org.foray.ps.encode.Cmap12Ttf4a;
-import org.foray.ps.encode.Encoding4aLatinExtra;
-import org.foray.ps.encode.EncodingCe;
import org.foray.ps.encode.EncodingCustom;
-import org.foray.ps.encode.EncodingExpert;
-import org.foray.ps.encode.EncodingExpertSubset;
-import org.foray.ps.encode.EncodingIsoLatin1;
-import org.foray.ps.encode.EncodingMacExpert;
-import org.foray.ps.encode.EncodingMacRoman;
-import org.foray.ps.encode.EncodingMacStandard;
import org.foray.ps.encode.EncodingParser;
-import org.foray.ps.encode.EncodingPdfDoc;
-import org.foray.ps.encode.EncodingStandard;
-import org.foray.ps.encode.EncodingSymbol;
import org.foray.ps.encode.EncodingVector4a;
-import org.foray.ps.encode.EncodingWinAnsi;
-import org.foray.ps.encode.EncodingZapfDingbats;
import org.foray.ps.filter.Ascii85DecodeFilter;
import org.foray.ps.filter.Ascii85EncodeFilter;
import org.foray.ps.filter.AsciiHexDecodeFilter;
@@ -176,71 +163,6 @@
}
@Override
- public PsEncoding getPredefinedEncoding(final String name) {
- final PsEncoding.Predefined predefined = PsEncoding.Predefined.findByName(name);
- PsEncoding encoding = getPredefinedEncoding(predefined);
-
- if (name.equals("FOrayLatinExtraEncoding")) {
- encoding = Encoding4aLatinExtra.getInstance();
- } else if (name.equals("InternalEncoding")) {
- /* The statement below is a bit redundant, but is included to
- * document the fact that "InternalEncoding" is reserved to
- * indicate that the Font's internal encoding should be used. */
- encoding = null;
- }
- if (encoding == null) {
- return null;
- }
- return encoding;
- }
-
- @Override
- public PsEncoding getPredefinedEncoding(final PsEncoding.Predefined predefinedVector) {
- if (predefinedVector == null) {
- return null;
- }
- switch (predefinedVector) {
- case STANDARD: {
- return EncodingStandard.getInstance();
- }
- case ISO_LATIN_1: {
- return EncodingIsoLatin1.getInstance();
- }
- case WIN_ANSI: {
- return EncodingWinAnsi.getInstance();
- }
- case SYMBOL: {
- return EncodingSymbol.getInstance();
- }
- case ZAPF_DINGBATS: {
- return EncodingZapfDingbats.getInstance();
- }
- case CE: {
- return EncodingCe.getInstance();
- }
- case MAC_ROMAN: {
- return EncodingMacRoman.getInstance();
- }
- case PDF_DOC: {
- return EncodingPdfDoc.getInstance();
- }
- case MAC_EXPERT: {
- return EncodingMacExpert.getInstance();
- }
- case EXPERT: {
- return EncodingExpert.getInstance();
- }
- case EXPERT_SUBSET: {
- return EncodingExpertSubset.getInstance();
- }
- case STANDARD_MACINTOSH_ORDERING: {
- return EncodingMacStandard.getInstance();
- }
- }
- return null;
- }
-
- @Override
public PsEncoding createEncodingVector(final String name, final IntSequence codePoints,
final IntSequence codePointIndexes) {
return new EncodingCustom(name, null, codePoints, codePointIndexes);
@@ -257,16 +179,6 @@
}
@Override
- public CharSet getPredefinedCharSet(final String name) {
- return CharSet4a.getRegisteredCharSet(name);
- }
-
- @Override
- public CharSet getPredefinedCharSet(final CharSet.Predefined predefined) {
- return CharSet4a.getRegisteredCharSet(predefined);
- }
-
- @Override
public CharSet createCharSet(final String name, final IntSequence characterSet) {
final IntSequenceMutable mutable = IntArrayBuilder.fromIntSequence(characterSet);
return new CharSet4a(name, mutable);
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/filter/EncodingVectorInputStream.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/filter/EncodingVectorInputStream.java 2025-04-26 14:03:52 UTC (rev 13517)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/filter/EncodingVectorInputStream.java 2025-04-26 14:43:46 UTC (rev 13518)
@@ -29,7 +29,7 @@
package org.foray.ps.filter;
import org.foray.common.primitive.UnicodeCharUtils;
-import org.foray.ps.PsServer4a;
+import org.foray.ps.encode.EncodingVector4a;
import org.axsl.ps.PsEncoding;
@@ -159,8 +159,7 @@
System.exit(1);
}
- final PsServer4a psServer = new PsServer4a();
- final PsEncoding encoding = psServer.getPredefinedEncoding(encodingString);
+ final PsEncoding encoding = EncodingVector4a.getPredefinedEncoding(encodingString);
final EncodingVectorInputStream inputFilter = new EncodingVectorInputStream(inputStream, encoding);
try {
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingVector4a.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingVector4a.java 2025-04-26 14:03:52 UTC (rev 13517)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/EncodingVector4a.java 2025-04-26 14:43:46 UTC (rev 13518)
@@ -464,4 +464,79 @@
return "[" + this.name + "]";
}
+ /**
+ * Returns one of the predefined encodings.
+ * @param name The name of the predefined encoding to be returned.
+ * @return The predefined encoding if it can be found or created, or null otherwise.
+ * @see #getPredefinedEncoding(PsEncoding.Predefined)
+ */
+ public static PsEncoding getPredefinedEncoding(final String name) {
+ final PsEncoding.Predefined predefined = PsEncoding.Predefined.findByName(name);
+ PsEncoding encoding = getPredefinedEncoding(predefined);
+
+ if (name.equals("FOrayLatinExtraEncoding")) {
+ encoding = Encoding4aLatinExtra.getInstance();
+ } else if (name.equals("InternalEncoding")) {
+ /* The statement below is a bit redundant, but is included to
+ * document the fact that "InternalEncoding" is reserved to
+ * indicate that the Font's internal encoding should be used. */
+ encoding = null;
+ }
+ if (encoding == null) {
+ return null;
+ }
+ return encoding;
+ }
+
+ /**
+ * Returns one of the predefined encodings.
+ * @param predefinedVector The predefined encoding to be returned.
+ * @return The predefined encoding if it can be found or created, or null otherwise.
+ * @see #getPredefinedEncoding(String)
+ */
+ public static PsEncoding getPredefinedEncoding(final PsEncoding.Predefined predefinedVector) {
+ if (predefinedVector == null) {
+ return null;
+ }
+ switch (predefinedVector) {
+ case STANDARD: {
+ return EncodingStandard.getInstance();
+ }
+ case ISO_LATIN_1: {
+ return EncodingIsoLatin1.getInstance();
+ }
+ case WIN_ANSI: {
+ return EncodingWinAnsi.getInstance();
+ }
+ case SYMBOL: {
+ return EncodingSymbol.getInstance();
+ }
+ case ZAPF_DINGBATS: {
+ return EncodingZapfDingbats.getInstance();
+ }
+ case CE: {
+ return EncodingCe.getInstance();
+ }
+ case MAC_ROMAN: {
+ return EncodingMacRoman.getInstance();
+ }
+ case PDF_DOC: {
+ return EncodingPdfDoc.getInstance();
+ }
+ case MAC_EXPERT: {
+ return EncodingMacExpert.getInstance();
+ }
+ case EXPERT: {
+ return EncodingExpert.getInstance();
+ }
+ case EXPERT_SUBSET: {
+ return EncodingExpertSubset.getInstance();
+ }
+ case STANDARD_MACINTOSH_ORDERING: {
+ return EncodingMacStandard.getInstance();
+ }
+ }
+ return null;
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-26 14:04:11
|
Revision: 13517
http://sourceforge.net/p/foray/code/13517
Author: victormote
Date: 2025-04-26 14:03:52 +0000 (Sat, 26 Apr 2025)
Log Message:
-----------
Conform to aXSL change: Remove no-longer-needed method.
Modified Paths:
--------------
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java 2025-04-26 13:43:15 UTC (rev 13516)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java 2025-04-26 14:03:52 UTC (rev 13517)
@@ -272,7 +272,14 @@
return new CharSet4a(name, mutable);
}
- @Override
+ /**
+ * Parse a character set from an input stream.
+ * @param name The name of the character set to be parsed.
+ * @param inputStream The input stream containing the raw character set information.
+ * @return The parsed character set.
+ * @throws IOException For errors opening or reading the input stream.
+ * @throws PsException For errors parsing the character set.
+ */
public CharSet parseCharSet(final String name, final InputStream inputStream) throws IOException, PsException {
final CharSetParser parser = new CharSetParser(inputStream);
parser.parseList();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-26 13:43:33
|
Revision: 13516
http://sourceforge.net/p/foray/code/13516
Author: victormote
Date: 2025-04-26 13:43:15 +0000 (Sat, 26 Apr 2025)
Log Message:
-----------
Conform to aXSL change: Remove no-longer-needed method.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1MetricsParserAfm.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1MetricsParserAfm.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1MetricsParserAfm.java 2025-04-26 13:41:23 UTC (rev 13515)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/type1/Type1MetricsParserAfm.java 2025-04-26 13:43:15 UTC (rev 13516)
@@ -34,6 +34,7 @@
import org.foray.font.format.Kerning;
import org.foray.primitive.sequence.IntArrayBuilder;
import org.foray.primitive.sequence.ShortArrayBuilder;
+import org.foray.ps.encode.GlyphList4a;
import org.axsl.font.FontException;
import org.axsl.ps.BoundingBox;
@@ -1486,10 +1487,10 @@
* @return The Unicode code point that corresponds to glyphName.
*/
private int getCodePointForGlyphName(final PsServer psServer, final String glyphName) {
- GlyphList gl = psServer.getPredefinedGlyphList(GlyphList.Predefined.AGL);
+ GlyphList gl = GlyphList4a.getGlyphList(GlyphList.Predefined.AGL);
int theChar = gl.mapGlyphNameToCodePoint(glyphName);
if (theChar < 0) {
- gl = psServer.getPredefinedGlyphList(GlyphList.Predefined.ZAPF_DINGBATS);
+ gl = GlyphList4a.getGlyphList(GlyphList.Predefined.ZAPF_DINGBATS);
theChar = gl.mapGlyphNameToCodePoint(glyphName);
}
return theChar;
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java 2025-04-26 13:41:23 UTC (rev 13515)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java 2025-04-26 13:43:15 UTC (rev 13516)
@@ -49,7 +49,6 @@
import org.foray.ps.encode.EncodingVector4a;
import org.foray.ps.encode.EncodingWinAnsi;
import org.foray.ps.encode.EncodingZapfDingbats;
-import org.foray.ps.encode.GlyphList4a;
import org.foray.ps.filter.Ascii85DecodeFilter;
import org.foray.ps.filter.Ascii85EncodeFilter;
import org.foray.ps.filter.AsciiHexDecodeFilter;
@@ -70,7 +69,6 @@
import org.axsl.primitive.sequence.IntSequence;
import org.axsl.primitive.sequence.IntSequenceMutable;
import org.axsl.ps.CharSet;
-import org.axsl.ps.GlyphList;
import org.axsl.ps.PsEncoding;
import org.axsl.ps.PsException;
import org.axsl.ps.PsFilterType;
@@ -282,11 +280,6 @@
return charSet;
}
- @Override
- public GlyphList getPredefinedGlyphList(final GlyphList.Predefined predefined) {
- return GlyphList4a.getGlyphList(predefined);
- }
-
/**
* Creates a new Cmap04 with a given name and expected size.
* @param name The name of this encoding.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-26 13:41:40
|
Revision: 13515
http://sourceforge.net/p/foray/code/13515
Author: victormote
Date: 2025-04-26 13:41:23 +0000 (Sat, 26 Apr 2025)
Log Message:
-----------
Add Eclipse launch config for normal FOray build.
Added Paths:
-----------
trunk/foray/foray-00-dev/ide/eclipse/launch-configurations/foray-gradle-clean-test-distZip.launch
Added: trunk/foray/foray-00-dev/ide/eclipse/launch-configurations/foray-gradle-clean-test-distZip.launch
===================================================================
--- trunk/foray/foray-00-dev/ide/eclipse/launch-configurations/foray-gradle-clean-test-distZip.launch (rev 0)
+++ trunk/foray/foray-00-dev/ide/eclipse/launch-configurations/foray-gradle-clean-test-distZip.launch 2025-04-26 13:41:23 UTC (rev 13515)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.buildship.core.launch.runconfiguration">
+ <listAttribute key="arguments"/>
+ <booleanAttribute key="build_scans_enabled" value="false"/>
+ <stringAttribute key="gradle_distribution" value="GRADLE_DISTRIBUTION(WRAPPER)"/>
+ <stringAttribute key="gradle_user_home" value=""/>
+ <stringAttribute key="java_home" value=""/>
+ <listAttribute key="jvm_arguments"/>
+ <booleanAttribute key="offline_mode" value="false"/>
+ <booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/>
+ <booleanAttribute key="override_workspace_settings" value="false"/>
+ <booleanAttribute key="show_console_view" value="true"/>
+ <booleanAttribute key="show_execution_view" value="true"/>
+ <listAttribute key="tasks">
+ <listEntry value="clean"/>
+ <listEntry value="test"/>
+ <listEntry value="distZip"/>
+ </listAttribute>
+ <stringAttribute key="working_dir" value="${workspace_loc:/foray}"/>
+</launchConfiguration>
Property changes on: trunk/foray/foray-00-dev/ide/eclipse/launch-configurations/foray-gradle-clean-test-distZip.launch
___________________________________________________________________
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-26 13:16:03
|
Revision: 13514
http://sourceforge.net/p/foray/code/13514
Author: victormote
Date: 2025-04-26 13:15:46 +0000 (Sat, 26 Apr 2025)
Log Message:
-----------
Conform to aXSL change: Remove no-longer-needed method.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java 2025-04-26 12:22:58 UTC (rev 13513)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/config/FontConfigParser.java 2025-04-26 13:15:46 UTC (rev 13514)
@@ -32,6 +32,8 @@
import org.foray.common.url.UrlFactory;
import org.foray.font.FontServer4a;
import org.foray.primitive.StringUtils;
+import org.foray.ps.encode.GlyphList4a;
+import org.foray.ps.encode.GlyphListParser;
import org.foray.xml.SaxLocation;
import org.foray.xml.SaxParser4a;
@@ -754,7 +756,10 @@
return;
}
try {
- final GlyphList glyphList = this.fontServer.getPsServer().parseGlyphList(name, input);
+ final GlyphListParser parser = new GlyphListParser(input);
+ parser.parseList();
+ final GlyphList4a glyphList = new GlyphList4a(name, parser.getGlyphNames(),
+ parser.getCodePointsForGlyphNames(), parser.getCodePoints(), parser.getGlyphNameIndex());
this.glyphListMap.put(name, glyphList);
} catch (final IOException e) {
errorMessage("Error parsing \"" + file + "\": " + e.getMessage());
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java 2025-04-26 12:22:58 UTC (rev 13513)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java 2025-04-26 13:15:46 UTC (rev 13514)
@@ -50,7 +50,6 @@
import org.foray.ps.encode.EncodingWinAnsi;
import org.foray.ps.encode.EncodingZapfDingbats;
import org.foray.ps.encode.GlyphList4a;
-import org.foray.ps.encode.GlyphListParser;
import org.foray.ps.filter.Ascii85DecodeFilter;
import org.foray.ps.filter.Ascii85EncodeFilter;
import org.foray.ps.filter.AsciiHexDecodeFilter;
@@ -288,16 +287,6 @@
return GlyphList4a.getGlyphList(predefined);
}
- @Override
- public GlyphList4a parseGlyphList(final String name, final InputStream inputStream) throws IOException,
- PsException {
- final GlyphListParser parser = new GlyphListParser(inputStream);
- parser.parseList();
- final GlyphList4a glyphList = new GlyphList4a(name, parser.getGlyphNames(), parser.getCodePointsForGlyphNames(),
- parser.getCodePoints(), parser.getGlyphNameIndex());
- return glyphList;
- }
-
/**
* Creates a new Cmap04 with a given name and expected size.
* @param name The name of this encoding.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-26 12:23:16
|
Revision: 13513
http://sourceforge.net/p/foray/code/13513
Author: victormote
Date: 2025-04-26 12:22:58 +0000 (Sat, 26 Apr 2025)
Log Message:
-----------
Conform to aXSL change: Remove no-longer-needed interface.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap04Ttf4a.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap12Ttf4a.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-26 12:05:22 UTC (rev 13512)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-04-26 12:22:58 UTC (rev 13513)
@@ -84,7 +84,7 @@
import org.axsl.font.Font;
import org.axsl.primitive.sequence.ShortSequence;
import org.axsl.ps.BoundingBox;
-import org.axsl.ps.Cmap;
+import org.axsl.ps.Encoding;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -851,7 +851,7 @@
* Returns the "To Unicode" Cmap4a for this font.
* @return The "To Unicode" Cmap4a for this font, or null if there is none.
*/
- public Cmap getUnicodeCMap() {
+ public Encoding getUnicodeCMap() {
return this.cmapTable.getUnicodeCMap();
}
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-26 12:05:22 UTC (rev 13512)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java 2025-04-26 12:22:58 UTC (rev 13513)
@@ -33,7 +33,7 @@
import org.foray.ps.encode.Cmap04Ttf4a;
import org.foray.ps.encode.Cmap12Ttf4a;
-import org.axsl.ps.Cmap;
+import org.axsl.ps.Encoding;
import java.io.IOException;
@@ -70,7 +70,7 @@
protected static final int ENCODING_UCS_4 = 10;
/** The Cmap4a instance that was parsed from this table. */
- private Cmap unicodeCMap;
+ private Encoding unicodeCMap;
/**
* Parse the cmap table.
@@ -140,7 +140,7 @@
* @return The parsed Cmap4a instance.
* @throws IOException For I/O Error.
*/
- private static Cmap parseCMap(final RandomAccessInput input, final int tableOffset,
+ private static Encoding parseCMap(final RandomAccessInput input, final int tableOffset,
final long offsetToParse, final String fontPostScriptName) throws IOException {
input.seek(tableOffset + offsetToParse);
final int formatHigh = input.readUnsignedShort();
@@ -270,7 +270,7 @@
* Returns the Unicode Cmap4a instance parsed from this table.
* @return The Unicode Cmap4a instance parsed from this table.
*/
- public Cmap getUnicodeCMap() {
+ public Encoding getUnicodeCMap() {
return this.unicodeCMap;
}
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap04Ttf4a.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap04Ttf4a.java 2025-04-26 12:05:22 UTC (rev 13512)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap04Ttf4a.java 2025-04-26 12:22:58 UTC (rev 13513)
@@ -28,13 +28,13 @@
package org.foray.ps.encode;
-import org.axsl.ps.Cmap;
+import org.axsl.ps.Encoding;
/**
* Class containing a set of 16-bit Unicode ranges that sequentially map to the same-sized range of glyph indexes.
* The contents are analogous to a Format 4 TrueType Font cmap table (from which this class derives its name).
*/
-public class Cmap04Ttf4a implements Cmap {
+public class Cmap04Ttf4a implements Encoding {
/** Constant needed for serialization. */
public static final long serialVersionUID = 985957847129472354L;
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap12Ttf4a.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap12Ttf4a.java 2025-04-26 12:05:22 UTC (rev 13512)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap12Ttf4a.java 2025-04-26 12:22:58 UTC (rev 13513)
@@ -28,13 +28,13 @@
package org.foray.ps.encode;
-import org.axsl.ps.Cmap;
+import org.axsl.ps.Encoding;
/**
* Class containing a set of 32-bit Unicode ranges that sequentially map to the same-sized range of glyph indexes.
* The contents are analogous to a Format 12 TrueType Font cmap table (from which this class derives its name).
*/
-public class Cmap12Ttf4a implements Cmap {
+public class Cmap12Ttf4a implements Encoding {
/** Constant needed for serialization. */
public static final long serialVersionUID = -606154911100219394L;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-26 12:05:40
|
Revision: 13512
http://sourceforge.net/p/foray/code/13512
Author: victormote
Date: 2025-04-26 12:05:22 +0000 (Sat, 26 Apr 2025)
Log Message:
-----------
Conform to aXSL change: Remove no-longer-needed interfaces.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap04Ttf4a.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap12Ttf4a.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java 2025-04-26 11:12:30 UTC (rev 13511)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/CmapTable.java 2025-04-26 12:05:22 UTC (rev 13512)
@@ -34,8 +34,6 @@
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;
@@ -172,7 +170,7 @@
* @return The parsed Cmap4a format 4 table.
* @throws IOException For I/O Error.
*/
- private static Cmap04Ttf parseCMap04(final RandomAccessInput raInput, final String fontPostScriptName)
+ private static Cmap04Ttf4a parseCMap04(final RandomAccessInput raInput, final String fontPostScriptName)
throws IOException {
/* Format and Length have already been read. */
/* Skip version */
@@ -213,7 +211,7 @@
// Parse the table entries and build a CMap4 from them.
final String encodingName = "internal-" + fontPostScriptName;
- final Cmap04Ttf cmap04 = new Cmap04Ttf4a(encodingName, segCountX2 / 2);
+ final Cmap04Ttf4a cmap04 = new Cmap04Ttf4a(encodingName, segCountX2 / 2);
for (int i = 0; i < startCount.length; i++) {
if (rangeOffset[i] == 0) {
cmap04.addEntry(startCount[i],
@@ -249,7 +247,7 @@
* @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)
+ private static Cmap12Ttf4a parseCMap12(final RandomAccessInput raInput, final String fontPostScriptName)
throws IOException {
/* Format and Length have already been read. */
/* Skip language. */
@@ -257,7 +255,7 @@
final int nGroups = (int) raInput.readUnsignedInt();
final String encodingName = "internal-" + fontPostScriptName;
- final Cmap12Ttf cmap12 = new Cmap12Ttf4a(encodingName, nGroups);
+ final Cmap12Ttf4a cmap12 = new Cmap12Ttf4a(encodingName, nGroups);
for (int i = 0; i < nGroups; i++) {
final int startCharCode = (int) raInput.readUnsignedInt();
Modified: trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java 2025-04-26 11:12:30 UTC (rev 13511)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java 2025-04-26 12:05:22 UTC (rev 13512)
@@ -71,8 +71,6 @@
import org.axsl.primitive.sequence.IntSequence;
import org.axsl.primitive.sequence.IntSequenceMutable;
import org.axsl.ps.CharSet;
-import org.axsl.ps.Cmap04Ttf;
-import org.axsl.ps.Cmap12Ttf;
import org.axsl.ps.GlyphList;
import org.axsl.ps.PsEncoding;
import org.axsl.ps.PsException;
@@ -300,13 +298,25 @@
return glyphList;
}
- @Override
- public Cmap04Ttf createCmap04(final String name, final int expectedEntries) {
+ /**
+ * Creates a new Cmap04 with a given name and expected size.
+ * @param name The name of this encoding.
+ * @param expectedEntries The number of expected entries in this encoding.
+ * Setting this to the correct value gives the implementation an opportunity for more efficient processing.
+ * @return The newly-created implementation-specific Cmap04 instance.
+ */
+ public Cmap04Ttf4a createCmap04(final String name, final int expectedEntries) {
return new Cmap04Ttf4a(name, expectedEntries);
}
- @Override
- public Cmap12Ttf createCmap12(final String name, final int expectedEntries) {
+ /**
+ * Creates a new Cmap12 with a given name and expected size.
+ * @param name The name of this encoding.
+ * @param expectedEntries The number of expected entries in this encoding.
+ * Setting this to the correct value gives the implementation an opportunity for more efficient processing.
+ * @return The newly-created implementation-specific Cmap12 instance.
+ */
+ public Cmap12Ttf4a createCmap12(final String name, final int expectedEntries) {
return new Cmap12Ttf4a(name, expectedEntries);
}
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap04Ttf4a.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap04Ttf4a.java 2025-04-26 11:12:30 UTC (rev 13511)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap04Ttf4a.java 2025-04-26 12:05:22 UTC (rev 13512)
@@ -28,13 +28,13 @@
package org.foray.ps.encode;
-import org.axsl.ps.Cmap04Ttf;
+import org.axsl.ps.Cmap;
/**
* Class containing a set of 16-bit Unicode ranges that sequentially map to the same-sized range of glyph indexes.
* The contents are analogous to a Format 4 TrueType Font cmap table (from which this class derives its name).
*/
-public class Cmap04Ttf4a implements Cmap04Ttf {
+public class Cmap04Ttf4a implements Cmap {
/** Constant needed for serialization. */
public static final long serialVersionUID = 985957847129472354L;
@@ -78,7 +78,13 @@
this.entries[this.lastEntryAdded] = entry;
}
- @Override
+ /**
+ * Add a new entry to this map for contiguous values.
+ * @param unicodeStart The starting Unicode code point for this map.
+ * @param unicodeEnd The ending Unicode code point for this map.
+ * @param glyphStartIndex The starting glyph index for this map.
+ * This index is the encoded value for {@code unicodeStart}.
+ */
public void addEntry(final int unicodeStart, final int unicodeEnd, final char glyphStartIndex) {
final Cmap04TtfEntry4a newEntry = new Cmap04TtfEntry4a(unicodeStart, unicodeEnd,
glyphStartIndex);
@@ -85,7 +91,13 @@
addEntry(newEntry);
}
- @Override
+ /**
+ * Add a new entry to this map for non-contiguous values.
+ * @param unicodeStart The starting Unicode code point for this map.
+ * @param unicodeEnd The ending Unicode code point for this map.
+ * @param glyphIndexes The array of glyph indexes corresponding to the range {@code unicodeStart} through
+ * {@code unicodeEnd}.
+ */
public void addEntry(final int unicodeStart, final int unicodeEnd, final CharSequence glyphIndexes) {
final Cmap04TtfEntry4a newEntry = new Cmap04TtfEntry4a(unicodeStart, unicodeEnd, glyphIndexes);
addEntry(newEntry);
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap12Ttf4a.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap12Ttf4a.java 2025-04-26 11:12:30 UTC (rev 13511)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap12Ttf4a.java 2025-04-26 12:05:22 UTC (rev 13512)
@@ -28,13 +28,13 @@
package org.foray.ps.encode;
-import org.axsl.ps.Cmap12Ttf;
+import org.axsl.ps.Cmap;
/**
* Class containing a set of 32-bit Unicode ranges that sequentially map to the same-sized range of glyph indexes.
* The contents are analogous to a Format 12 TrueType Font cmap table (from which this class derives its name).
*/
-public class Cmap12Ttf4a implements Cmap12Ttf {
+public class Cmap12Ttf4a implements Cmap {
/** Constant needed for serialization. */
public static final long serialVersionUID = -606154911100219394L;
@@ -78,7 +78,13 @@
this.entries[this.lastEntryAdded] = entry;
}
- @Override
+ /**
+ * Add a new entry to this map.
+ * @param unicodeStart The starting Unicode code point for this map.
+ * @param unicodeEnd The ending Unicode code point for this map.
+ * @param glyphStartIndex The starting glyph index for this map.
+ * This index is the encoded value for {@code unicodeStart}.
+ */
public void addEntry(final int unicodeStart, final int unicodeEnd,
final int glyphStartIndex) {
final Cmap12TtfEntry4a newEntry = new Cmap12TtfEntry4a(unicodeStart, unicodeEnd,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-26 11:12:47
|
Revision: 13511
http://sourceforge.net/p/foray/code/13511
Author: victormote
Date: 2025-04-26 11:12:30 +0000 (Sat, 26 Apr 2025)
Log Message:
-----------
Remove abstract class not adding much value.
Modified Paths:
--------------
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap04Ttf4a.java
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap12Ttf4a.java
Removed Paths:
-------------
trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap00Ttf4a.java
Deleted: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap00Ttf4a.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap00Ttf4a.java 2025-04-26 10:08:56 UTC (rev 13510)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap00Ttf4a.java 2025-04-26 11:12:30 UTC (rev 13511)
@@ -1,46 +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.ps.encode;
-
-import org.axsl.ps.Cmap;
-
-/**
- * Abstract superclass for all Cmap4a Tables.
- */
-public abstract class Cmap00Ttf4a implements Cmap {
-
- /** Constant needed for serialization. */
- public static final long serialVersionUID = -6516855352094857929L;
-
- @Override
- public boolean canEncode(final int codePoint) {
- return this.encode(codePoint) > -1;
- }
-
-}
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap04Ttf4a.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap04Ttf4a.java 2025-04-26 10:08:56 UTC (rev 13510)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap04Ttf4a.java 2025-04-26 11:12:30 UTC (rev 13511)
@@ -34,7 +34,7 @@
* Class containing a set of 16-bit Unicode ranges that sequentially map to the same-sized range of glyph indexes.
* The contents are analogous to a Format 4 TrueType Font cmap table (from which this class derives its name).
*/
-public class Cmap04Ttf4a extends Cmap00Ttf4a implements Cmap04Ttf {
+public class Cmap04Ttf4a implements Cmap04Ttf {
/** Constant needed for serialization. */
public static final long serialVersionUID = 985957847129472354L;
@@ -154,4 +154,9 @@
return false;
}
+ @Override
+ public boolean canEncode(final int codePoint) {
+ return this.encode(codePoint) > -1;
+ }
+
}
Modified: trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap12Ttf4a.java
===================================================================
--- trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap12Ttf4a.java 2025-04-26 10:08:56 UTC (rev 13510)
+++ trunk/foray/foray-ps-data/src/main/java/org/foray/ps/encode/Cmap12Ttf4a.java 2025-04-26 11:12:30 UTC (rev 13511)
@@ -34,7 +34,7 @@
* Class containing a set of 32-bit Unicode ranges that sequentially map to the same-sized range of glyph indexes.
* The contents are analogous to a Format 12 TrueType Font cmap table (from which this class derives its name).
*/
-public class Cmap12Ttf4a extends Cmap00Ttf4a implements Cmap12Ttf {
+public class Cmap12Ttf4a implements Cmap12Ttf {
/** Constant needed for serialization. */
public static final long serialVersionUID = -606154911100219394L;
@@ -149,4 +149,9 @@
return false;
}
+ @Override
+ public boolean canEncode(final int codePoint) {
+ return this.encode(codePoint) > -1;
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-26 10:09:21
|
Revision: 13510
http://sourceforge.net/p/foray/code/13510
Author: victormote
Date: 2025-04-26 10:08:56 +0000 (Sat, 26 Apr 2025)
Log Message:
-----------
Move Hhea table to new parsing scheme.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HheaTable.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/TtfRandomAccessInput.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Os2TableHandler.java
Added Paths:
-----------
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/HheaTableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/HheaTableHandler.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-26 09:16:16 UTC (rev 13509)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-04-26 10:08:56 UTC (rev 13510)
@@ -62,6 +62,7 @@
import org.foray.fontParse.TableParser;
import org.foray.fontParse.ttf.BaseTableParser;
import org.foray.fontParse.ttf.HeadTableParser;
+import org.foray.fontParse.ttf.HheaTableParser;
import org.foray.fontParse.ttf.MaxpTableParser;
import org.foray.fontParse.ttf.NameTableParser;
import org.foray.fontParse.ttf.Os2TableParser;
@@ -70,6 +71,7 @@
import org.foray.fontParse.ttf.TtfRandomAccessInput;
import org.foray.fontParse.ttfHandler.BaseTableHandler;
import org.foray.fontParse.ttfHandler.HeadTableHandler;
+import org.foray.fontParse.ttfHandler.HheaTableHandler;
import org.foray.fontParse.ttfHandler.MaxpTableHandler;
import org.foray.fontParse.ttfHandler.NameTableHandler;
import org.foray.fontParse.ttfHandler.Os2TableHandler;
@@ -238,7 +240,12 @@
/* Read the Horizontal Header before the Horizontal Metrics. */
dirEntry = ttfTableDir.getTableDirectoryEntry("hhea");
- font.hheaTable = HheaTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength());
+ {
+ final ParserKit<HheaTable, HheaTableHandler> parseKit = HheaTable.createContentHandler();
+ final HheaTableParser parser = new HheaTableParser();
+ parser.parse(raInput, dirEntry.getOffset(), parseKit.getHandler());
+ font.hheaTable = parseKit.getTable();
+ }
/* After this point, the order may not matter. */
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-26 09:16:16 UTC (rev 13509)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HheaTable.java 2025-04-26 10:08:56 UTC (rev 13510)
@@ -28,10 +28,11 @@
package org.foray.font.ttf.table;
-import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.ParserKit;
import org.foray.font.ttf.RoTable;
+import org.foray.fontParse.ttfHandler.HheaTableHandler;
-import java.io.IOException;
+import org.checkerframework.checker.signedness.qual.Unsigned;
/**
* Class representing a TTF "hhea" (horizontal header) table.
@@ -38,62 +39,65 @@
*/
public class HheaTable extends RoTable {
+ /**
+ * The handler of events from the parser.
+ */
+ private final class ContentHandler implements HheaTableHandler {
+
+ /** The table instance being created. */
+ private HheaTable table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final HheaTable table) {
+ this.table = table;
+ }
+
+ @Override
+ public void ascender(final short value) {
+ this.table.ascender = value;
+ }
+
+ @Override
+ public void descender(final short value) {
+ this.table.descender = value;
+ }
+
+ @Override
+ public void numberOfHMetrics(final short value) {
+ this.table.numberOfHMetrics = value;
+ }
+
+ }
+
+
+
+
+
+
+
/** Typographic ascent. */
- private int ascender = 0;
+ private short ascender;
/** Typographic descent. */
- private int descender = 0;
+ private short descender;
/**
* 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;
+ private @Unsigned short numberOfHMetrics;
/**
- * Parse the table.
- * @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 HheaTable parse(final RandomAccessInput input, final int offset, final int length)
- throws IOException {
- input.seek(offset);
- final HheaTable hhea = new HheaTable();
- /* Skip the table version number. */
- input.skipBytes(RoTable.FIXED_BYTES);
- hhea.ascender = input.readShort();
- hhea.descender = input.readShort();
- /* Skip the lineGap. */
- input.skipBytes(RoTable.FWORD_BYTES);
- /* Skip the advanceWidthMax*/
- input.skipBytes(RoTable.UFWORD_BYTES);
- /* Skip the minLeftSideBearing*/
- input.skipBytes(RoTable.FWORD_BYTES);
- /* Skip the minRightSideBearing*/
- input.skipBytes(RoTable.FWORD_BYTES);
- /* Skip the xMaxExtent*/
- input.skipBytes(RoTable.FWORD_BYTES);
- /* Skip the caretSlopeRise*/
- input.skipBytes(RoTable.SHORT_BYTES);
- /* Skip the caretSlopeRun*/
- input.skipBytes(RoTable.SHORT_BYTES);
- /* Skip this reserved area. */
- input.skipBytes(RoTable.SHORT_BYTES);
- /* Skip this reserved area. */
- input.skipBytes(RoTable.SHORT_BYTES);
- /* Skip this reserved area. */
- input.skipBytes(RoTable.SHORT_BYTES);
- /* Skip this reserved area. */
- input.skipBytes(RoTable.SHORT_BYTES);
- /* Skip this reserved area. */
- input.skipBytes(RoTable.SHORT_BYTES);
- /* Skip the metricDataFormat. */
- input.skipBytes(RoTable.SHORT_BYTES);
- hhea.numberOfHMetrics = input.readUnsignedShort();
- return hhea;
+ public static ParserKit<HheaTable, HheaTableHandler> createContentHandler() {
+ final HheaTable table = new HheaTable();
+ final HheaTableHandler handler = table.new ContentHandler(table);
+ return new ParserKit<HheaTable, HheaTableHandler>(table, handler);
}
/**
@@ -114,8 +118,7 @@
/**
* 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).
+ * 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() {
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/HheaTableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/HheaTableParser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/HheaTableParser.java 2025-04-26 10:08:56 UTC (rev 13510)
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.HheaTableHandler;
+
+import java.io.IOException;
+
+/**
+ * Parses a TTF Hhea table.
+ */
+public class HheaTableParser extends TableParser<HheaTableHandler> {
+
+ /** The number of Panose fields. */
+ public static final byte QTY_PANOSE_FIELDS = 10;
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final HheaTableHandler handler)
+ throws IOException {
+ input.seek(offset);
+
+ /* Hhea Table, Version 1.0. */
+ handler.majorVersion(input.read_uint16()); // 2 bytes, total 2
+ handler.minorVersion(input.read_uint16()); // 2 bytes, total 4
+
+ handler.ascender(input.read_FWORD()); // 2 bytes, total 6
+ handler.descender(input.read_FWORD()); // 2 bytes, total 8
+ handler.lineGap(input.read_FWORD()); // 2 bytes, total 10
+ handler.advanceWidthMax(input.read_UFWORD()); // 2 bytes, total 12
+ handler.minLeftSideBearing(input.read_FWORD()); // 2 bytes, total 14
+ handler.minRightSideBearing(input.read_FWORD()); // 2 bytes, total 16
+ handler.xMaxExtent(input.read_FWORD()); // 2 bytes, total 18
+ handler.caretSlopeRise(input.read_int16()); // 2 bytes, total 20
+ handler.caretSlopeRun(input.read_int16()); // 2 bytes, total 22
+ handler.caretOffset(input.read_int16()); // 2 bytes, total 24
+
+ /* Skip fields reserved for future use. */
+ input.seek(TtfType.int16.getQtyBytes()); // 2 bytes, total 26
+ input.seek(TtfType.int16.getQtyBytes()); // 2 bytes, total 28
+ input.seek(TtfType.int16.getQtyBytes()); // 2 bytes, total 30
+ input.seek(TtfType.int16.getQtyBytes()); // 2 bytes, total 32
+
+ handler.metricDataFormat(input.read_int16()); // 2 bytes, total 34
+ handler.numberOfHMetrics(input.read_uint16()); // 2 bytes, total 36
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/HheaTableParser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/TtfRandomAccessInput.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/TtfRandomAccessInput.java 2025-04-26 09:16:16 UTC (rev 13509)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/TtfRandomAccessInput.java 2025-04-26 10:08:56 UTC (rev 13510)
@@ -77,7 +77,7 @@
/**
- * Parses a TrueType "uint8" field (1 byte).
+ * Parses a TrueType "uint8" field (1 byte, unsigned).
* @return The parsed value.
* @throws IOException For I/O Error.
*/
@@ -86,7 +86,7 @@
}
/**
- * Parses a TrueType "int8" field (1 byte).
+ * Parses a TrueType "int8" field (1 byte, signed).
* @return The parsed value.
* @throws IOException For I/O Error.
*/
@@ -95,7 +95,7 @@
}
/**
- * Parses a TrueType "uint16" field (2 bytes).
+ * Parses a TrueType "uint16" field (2 bytes, unsigned).
* @return The parsed value.
* @throws IOException For I/O Error.
*/
@@ -104,7 +104,7 @@
}
/**
- * Parses a TrueType "int16" field (2 bytes).
+ * Parses a TrueType "int16" field (2 bytes, signed).
* @return The parsed value.
* @throws IOException For I/O Error.
*/
@@ -113,7 +113,7 @@
}
/**
- * Parses a TrueType "uint24" field (3 bytes).
+ * Parses a TrueType "uint24" field (3 bytes, unsigned).
* @return The parsed value.
* @throws IOException For I/O Error.
*/
@@ -123,7 +123,7 @@
}
/**
- * Parses a TrueType "uint32" field (4 bytes).
+ * Parses a TrueType "uint32" field (4 bytes, unsigned).
* @return The parsed value.
* @throws IOException For I/O Error.
*/
@@ -132,7 +132,7 @@
}
/**
- * Parses a TrueType "int32" field (4 bytes).
+ * Parses a TrueType "int32" field (4 bytes, signed).
* @return The parsed value.
* @throws IOException For I/O Error.
*/
@@ -156,7 +156,7 @@
}
/**
- * Parses a TrueType "FWORD" field (2 bytes).
+ * Parses a TrueType "FWORD" field (2 bytes, signed).
* @return The parsed value.
* @throws IOException For I/O Error.
*/
@@ -165,7 +165,7 @@
}
/**
- * Parses a TrueType "UFWORD" field (2 bytes).
+ * Parses a TrueType "UFWORD" field (2 bytes, unsigned).
* @return The parsed value.
* @throws IOException For I/O Error.
*/
@@ -184,7 +184,7 @@
}
/**
- * Parses a TrueType "LONGDATETIME" field (4 bytes).
+ * Parses a TrueType "LONGDATETIME" field (4 bytes, unsigned).
* @return The parsed value.
* @throws IOException For I/O Error.
*/
@@ -193,7 +193,7 @@
}
/**
- * Parses a TrueType "Tag" field (4 bytes).
+ * Parses a TrueType "Tag" field (4 bytes, chars).
* @return The parsed value.
* @throws IOException For I/O Error.
*/
@@ -202,7 +202,7 @@
}
/**
- * Parses a TrueType "Offset8" field (1 byte).
+ * Parses a TrueType "Offset8" field (1 byte, unsigned).
* @return The parsed value.
* @throws IOException For I/O Error.
*/
@@ -211,7 +211,7 @@
}
/**
- * Parses a TrueType "Offset16" field (2 bytes).
+ * Parses a TrueType "Offset16" field (2 bytes, unsigned).
* @return The parsed value.
* @throws IOException For I/O Error.
*/
@@ -220,7 +220,7 @@
}
/**
- * Parses a TrueType "Offset24" field (3 bytes).
+ * Parses a TrueType "Offset24" field (3 bytes, unsigned).
* @return The parsed value.
* @throws IOException For I/O Error.
*/
@@ -229,7 +229,7 @@
}
/**
- * Parses a TrueType "Offset32" field (4 bytes).
+ * Parses a TrueType "Offset32" field (4 bytes, unsigned).
* @return The parsed value.
* @throws IOException For I/O Error.
*/
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/HheaTableHandler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/HheaTableHandler.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/HheaTableHandler.java 2025-04-26 10:08:56 UTC (rev 13510)
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttfHandler;
+
+import org.foray.fontParse.FontContentHandler;
+import org.foray.fontParse.ttf.HheaTableParser;
+
+import org.checkerframework.checker.signedness.qual.Unsigned;
+
+/**
+ * Implementations catch and handle the output from {@link HheaTableParser}.
+ */
+public interface HheaTableHandler extends FontContentHandler {
+
+ /* Hhea Table, Version 1.0. */
+ default void majorVersion(@Unsigned short value) { return; }
+ default void minorVersion(@Unsigned short value) { return; }
+
+ default void ascender(short value) { return; }
+ default void descender(short value) { return; }
+ default void lineGap(short value) { return; }
+ default void advanceWidthMax(@Unsigned short value) { return; }
+ default void minLeftSideBearing(short value) { return; }
+ default void minRightSideBearing(short value) { return; }
+ default void xMaxExtent(short value) { return; }
+ default void caretSlopeRise(short value) { return; }
+ default void caretSlopeRun(short value) { return; }
+ default void caretOffset(short value) { return; }
+
+ default void metricDataFormat(short value) { return; }
+ default void numberOfHMetrics(@Unsigned short value) { return; }
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/HheaTableHandler.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Os2TableHandler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Os2TableHandler.java 2025-04-26 09:16:16 UTC (rev 13509)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/Os2TableHandler.java 2025-04-26 10:08:56 UTC (rev 13510)
@@ -36,7 +36,7 @@
*/
public interface Os2TableHandler extends FontContentHandler {
- default void version(short version) { return; }
+ default void version(short value) { return; }
/* OS/2 Table, Version 0. */
default void xAvgCharWidth(short value) { return; }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-26 09:16:40
|
Revision: 13509
http://sourceforge.net/p/foray/code/13509
Author: victormote
Date: 2025-04-26 09:16:16 +0000 (Sat, 26 Apr 2025)
Log Message:
-----------
Move Maxp table to new parsing scheme.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/ParserKit.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/MaxpTable.java
Added Paths:
-----------
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/MaxpTableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/MaxpTableHandler.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/ParserKit.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/ParserKit.java 2025-04-26 08:25:39 UTC (rev 13508)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/ParserKit.java 2025-04-26 09:16:16 UTC (rev 13509)
@@ -33,6 +33,9 @@
/**
* Wrapper for a table being created and the related handler that is being used to create it.
* Keeping them together allows the table and handler to be created and used more flexibly.
+ * The FOray philosophy of font parsing separates the parsing from the use of the parsed data.
+ * The "Table" classes know about the parsers, but the parsers do not know about the "Table" classes.
+ * This parser kit allows those two concepts to be paired up properly.
* @param <T> The class of the table instance being created.
* @param <H> The class of the parser handler that is being used to create the table.
*/
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-26 08:25:39 UTC (rev 13508)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-04-26 09:16:16 UTC (rev 13509)
@@ -62,6 +62,7 @@
import org.foray.fontParse.TableParser;
import org.foray.fontParse.ttf.BaseTableParser;
import org.foray.fontParse.ttf.HeadTableParser;
+import org.foray.fontParse.ttf.MaxpTableParser;
import org.foray.fontParse.ttf.NameTableParser;
import org.foray.fontParse.ttf.Os2TableParser;
import org.foray.fontParse.ttf.PcltTableParser;
@@ -69,6 +70,7 @@
import org.foray.fontParse.ttf.TtfRandomAccessInput;
import org.foray.fontParse.ttfHandler.BaseTableHandler;
import org.foray.fontParse.ttfHandler.HeadTableHandler;
+import org.foray.fontParse.ttfHandler.MaxpTableHandler;
import org.foray.fontParse.ttfHandler.NameTableHandler;
import org.foray.fontParse.ttfHandler.Os2TableHandler;
import org.foray.fontParse.ttfHandler.PcltTableHandler;
@@ -212,8 +214,14 @@
/* Then the Maximum Profile, so general sizes are known. */
dirEntry = ttfTableDir.getTableDirectoryEntry("maxp");
- font.maxpTable = MaxpTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength());
+ {
+ final ParserKit<MaxpTable, MaxpTableHandler> contentHandler = MaxpTable.createContentHandler();
+ final TableParser<MaxpTableHandler> parser = new MaxpTableParser();
+ parser.parse(raInput, dirEntry.getOffset(), contentHandler.getHandler());
+ font.maxpTable = contentHandler.getTable();
+ }
+
/* The NAME table needs to be read before the CMAP. */
dirEntry = ttfTableDir.getTableDirectoryEntry("name");
{
@@ -221,7 +229,6 @@
final NameTableParser parser = new NameTableParser();
parser.parse(raInput, dirEntry.getOffset(), parseKit.getHandler());
font.nameTable = parseKit.getTable();
-
}
/* Then the CMAP, so that glyph indexes can be computed. */
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-26 08:25:39 UTC (rev 13508)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/MaxpTable.java 2025-04-26 09:16:16 UTC (rev 13509)
@@ -28,10 +28,11 @@
package org.foray.font.ttf.table;
-import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.ParserKit;
import org.foray.font.ttf.RoTable;
+import org.foray.fontParse.ttfHandler.MaxpTableHandler;
-import java.io.IOException;
+import org.checkerframework.checker.signedness.qual.Unsigned;
/**
* Class representing a TTF "maxp" (maximum profile) table.
@@ -38,25 +39,44 @@
*/
public class MaxpTable extends RoTable {
+ /**
+ * The handler of events from the parser.
+ */
+ private final class ContentHandler implements MaxpTableHandler {
+
+ /** The table instance being created. */
+ private MaxpTable table;
+
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final MaxpTable table) {
+ this.table = table;
+ }
+
+ @Override
+ public void numGlyphs(final @Unsigned short value) {
+ this.table.numGlyphs = value;
+ }
+ }
+
+
+
+
+
+
/** The number of glyphs in the font. */
private int numGlyphs;
/**
- * Reads the number of glyphs from the "maxp" table.
- * @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 MaxpTable parse(final RandomAccessInput input, final int offset, final int length)
- throws IOException {
- input.seek(offset);
- final MaxpTable maxp = new MaxpTable();
- /* Skip Table version number. */
- input.skipBytes(RoTable.FIXED_BYTES);
- maxp.numGlyphs = input.readUnsignedShort();
- return maxp;
+ public static ParserKit<MaxpTable, MaxpTableHandler> createContentHandler() {
+ final MaxpTable table = new MaxpTable();
+ final MaxpTableHandler handler = table.new ContentHandler(table);
+ return new ParserKit<MaxpTable, MaxpTableHandler>(table, handler);
}
/**
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/MaxpTableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/MaxpTableParser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/MaxpTableParser.java 2025-04-26 09:16:16 UTC (rev 13509)
@@ -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.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.MaxpTableHandler;
+
+import org.checkerframework.checker.signedness.qual.Unsigned;
+
+import java.io.IOException;
+
+/**
+ * Parses a TTF OS/2 table.
+ */
+public class MaxpTableParser extends TableParser<MaxpTableHandler> {
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final MaxpTableHandler handler)
+ throws IOException {
+ input.seek(offset);
+
+ /* Maxp Table, Version 0.5 */
+ final @Unsigned short majorVersion = input.read_uint16(); // 2 bytes, total 2
+ handler.majorVersion(majorVersion);
+ final @Unsigned short minorVersion = input.read_uint16();
+ handler.minorVersion(minorVersion); // 2 bytes, total 4
+ handler.numGlyphs(input.read_uint16()); // 2 bytes, total 6
+
+ if (majorVersion < 1) {
+ return;
+ }
+
+ /* Maxp Table, Version 1.0 */
+ handler.maxPoints(input.read_uint16()); // 2 bytes, total 8
+ handler.maxContours(input.read_uint16()); // 2 bytes, total 10
+ handler.maxCompositePoints(input.read_uint16()); // 2 bytes, total 12
+ handler.maxCompositeContours(input.read_uint16()); // 2 bytes, total 14
+ handler.maxZones(input.read_uint16()); // 2 bytes, total 16
+ handler.maxTwilightPoints(input.read_uint16()); // 2 bytes, total 18
+ handler.maxStorage(input.read_uint16()); // 2 bytes, total 20
+ handler.maxFunctionDefs(input.read_uint16()); // 2 bytes, total 22
+ handler.maxInstructionDefs(input.read_uint16()); // 2 bytes, total 24
+ handler.maxStackElements(input.read_uint16()); // 2 bytes, total 26
+ handler.maxSizeOfInstructions(input.read_uint16()); // 2 bytes, total 28
+ handler.maxComponentElements(input.read_uint16()); // 2 bytes, total 30
+ handler.maxComponentDepth(input.read_uint16()); // 2 bytes, total 32
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/MaxpTableParser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/MaxpTableHandler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/MaxpTableHandler.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/MaxpTableHandler.java 2025-04-26 09:16:16 UTC (rev 13509)
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttfHandler;
+
+import org.foray.fontParse.FontContentHandler;
+import org.foray.fontParse.ttf.MaxpTableParser;
+
+import org.checkerframework.checker.signedness.qual.Unsigned;
+
+/**
+ * Implementations catch and handle the output from {@link MaxpTableParser}.
+ */
+public interface MaxpTableHandler extends FontContentHandler {
+
+ default void majorVersion(@Unsigned short version) { return; }
+ default void minorVersion(@Unsigned short version) { return; }
+ default void numGlyphs(@Unsigned short version) { return; }
+
+ default void maxPoints(@Unsigned short version) { return; }
+ default void maxContours(@Unsigned short version) { return; }
+ default void maxCompositePoints(@Unsigned short version) { return; }
+ default void maxCompositeContours(@Unsigned short version) { return; }
+ default void maxZones(@Unsigned short version) { return; }
+ default void maxTwilightPoints(@Unsigned short version) { return; }
+ default void maxStorage(@Unsigned short version) { return; }
+ default void maxFunctionDefs(@Unsigned short version) { return; }
+ default void maxInstructionDefs(@Unsigned short version) { return; }
+ default void maxStackElements(@Unsigned short version) { return; }
+ default void maxSizeOfInstructions(@Unsigned short version) { return; }
+ default void maxComponentElements(@Unsigned short version) { return; }
+ default void maxComponentDepth(@Unsigned short version) { return; }
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/MaxpTableHandler.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-26 08:25:56
|
Revision: 13508
http://sourceforge.net/p/foray/code/13508
Author: victormote
Date: 2025-04-26 08:25:39 +0000 (Sat, 26 Apr 2025)
Log Message:
-----------
Rename mis-named class.
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/HmtxTable.java
Removed Paths:
-------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HtmxTable.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-25 23:40:35 UTC (rev 13507)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-04-26 08:25:39 UTC (rev 13508)
@@ -45,7 +45,7 @@
import org.foray.font.ttf.table.GsubTable;
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.HmtxTable;
import org.foray.font.ttf.table.JstfTable;
import org.foray.font.ttf.table.KernTable;
import org.foray.font.ttf.table.LocaTable;
@@ -108,7 +108,7 @@
private HheaTable hheaTable = null;
/** The (required) "hmtx" table instance. */
- private HtmxTable hmtxTable = null;
+ private HmtxTable hmtxTable = null;
/** The (required) "maxp" table instance. */
private MaxpTable maxpTable = null;
@@ -238,7 +238,7 @@
dirEntry = ttfTableDir.getTableDirectoryEntry("hmtx");
final int numberOfGlyphs = font.maxpTable.getNumberOfGlyphs();
final int numberOfHMetrics = font.hheaTable.getNumberOfHMetrics();
- font.hmtxTable = HtmxTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength(), numberOfGlyphs,
+ font.hmtxTable = HmtxTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength(), numberOfGlyphs,
numberOfHMetrics);
dirEntry = ttfTableDir.getTableDirectoryEntry("post");
@@ -400,7 +400,7 @@
* Returns the "hmtx" table.
* @return The "hmtx" table.
*/
- public HtmxTable getHmtxTable() {
+ public HmtxTable getHmtxTable() {
return this.hmtxTable;
}
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-25 23:40:35 UTC (rev 13507)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TtfSubSetFile.java 2025-04-26 08:25:39 UTC (rev 13508)
@@ -33,7 +33,7 @@
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.HmtxTable;
import org.foray.font.ttf.table.MtxEntry;
import org.axsl.constants.PrimitiveConstants;
@@ -461,7 +461,7 @@
final byte[] byteArray = createTableByteArray(arraySize);
int cumulativeSize = 0;
- final HtmxTable hmtx = this.ttfFont.getHmtxTable();
+ final HmtxTable 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);
@@ -507,7 +507,7 @@
private int computeGlyphLength(final int origGlyphIndex)
throws IOException {
int nextOffset = 0;
- final HtmxTable hmtx = this.ttfFont.getHmtxTable();
+ final HmtxTable hmtx = this.ttfFont.getHmtxTable();
if (origGlyphIndex >= (hmtx.numMtxEntries() - 1)) {
nextOffset = (int) this.ttfFont.getLocaTable().lastOffset();
} else {
@@ -537,7 +537,7 @@
final int entrySize = widthSize + lsbSize;
final int arraySize = this.subset.numGlyphsUsed() * entrySize;
final byte[] byteArray = createTableByteArray(arraySize);
- final HtmxTable hmtx = this.ttfFont.getHmtxTable();
+ final HmtxTable hmtx = this.ttfFont.getHmtxTable();
for (int i = 0; i < this.subset.numGlyphsUsed(); i ++) {
final int originalIndex = this.subset.decodeSubsetIndex(i);
final MtxEntry metricEntry = hmtx.getMtxEntry(originalIndex);
@@ -561,7 +561,7 @@
final List<Integer> ret = new ArrayList<Integer>();
ret.add(glyphIdx);
int offset = glyphOffset;
- final HtmxTable hmtxTable = this.ttfFont.getHmtxTable();
+ final HmtxTable hmtxTable = this.ttfFont.getHmtxTable();
final MtxEntry mtxEntry = hmtxTable.getMtxEntry(glyphIdx.intValue());
offset += (int) mtxEntry.getOffset();
offset += GlyfTable.HEADER_SIZE;
@@ -653,7 +653,7 @@
final Map<Integer, Integer> usedCompositeGlyphs
= new HashMap<Integer, Integer>();
boolean stillCheckingForCompositeGlyphs = true;
- final HtmxTable hmtx = this.ttfFont.getHmtxTable();
+ final HmtxTable hmtx = this.ttfFont.getHmtxTable();
while (stillCheckingForCompositeGlyphs) {
boolean anyGlyphsAdded = false;
for (int i = 0; i < this.subset.numGlyphsUsed(); i++) {
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-25 23:40:35 UTC (rev 13507)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/GlyfTable.java 2025-04-26 08:25:39 UTC (rev 13508)
@@ -86,7 +86,7 @@
* @throws IOException For I/O Error.
*/
public static GlyfTable parse(final RandomAccessInput input, final int offset, final int length,
- final int numberOfGlyphs, final HtmxTable hmtx) throws IOException {
+ final int numberOfGlyphs, final HmtxTable hmtx) throws IOException {
input.seek(offset);
final GlyfTable glyf = new GlyfTable();
final MtxEntry firstMetric = hmtx.getMtxEntry(0);
Copied: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HmtxTable.java (from rev 13486, 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/HmtxTable.java (rev 0)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HmtxTable.java 2025-04-26 08:25:39 UTC (rev 13508)
@@ -0,0 +1,109 @@
+/*
+ * 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.RoTable;
+
+import java.io.IOException;
+
+/**
+ * Class representing a TTF "hmtx" (horizontal metrics) table.
+ */
+public class HmtxTable extends RoTable {
+
+ /** The metrics entries for this table. */
+ private MtxEntry[] metrics;
+
+ /**
+ * 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 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.
+ * This information is derived from the "hhea" table.
+ * @return The parsed instance.
+ * @throws IOException For I/O Error.
+ */
+ public static HmtxTable parse(final RandomAccessInput input, final int offset, final int length,
+ final int numberOfGlyphs, final int numberOfHMetrics) throws IOException {
+ input.seek(offset);
+ final HmtxTable hmtx = new HmtxTable();
+ 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(input.readUnsignedShort());
+ hmtx.metrics[i].setLeftSideBearing(input.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(input.readShort());
+ }
+ }
+ 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;
+ }
+
+}
Deleted: 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-25 23:40:35 UTC (rev 13507)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/HtmxTable.java 2025-04-26 08:25:39 UTC (rev 13508)
@@ -1,109 +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.RandomAccessInput;
-import org.foray.font.ttf.RoTable;
-
-import java.io.IOException;
-
-/**
- * Class representing a TTF "hmtx" (horizontal metrics) table.
- */
-public class HtmxTable extends RoTable {
-
- /** The metrics entries for this table. */
- private MtxEntry[] metrics;
-
- /**
- * 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 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.
- * This information is derived from the "hhea" table.
- * @return The parsed instance.
- * @throws IOException For I/O Error.
- */
- 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];
-
- for (int i = 0; i < metricsSize; i++) {
- hmtx.metrics[i] = new MtxEntry();
- }
- for (int i = 0; i < numberOfHMetrics; i++) {
- hmtx.metrics[i].setWidth(input.readUnsignedShort());
- hmtx.metrics[i].setLeftSideBearing(input.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(input.readShort());
- }
- }
- 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-25 23:40:35 UTC (rev 13507)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/LocaTable.java 2025-04-26 08:25:39 UTC (rev 13508)
@@ -57,7 +57,7 @@
* @throws IOException For I/O Error.
*/
public static LocaTable parse(final RandomAccessInput input, final int offset, final int length,
- final boolean isLongFormat, final int numberOfGlyphs, final HtmxTable hmtx) throws IOException {
+ final boolean isLongFormat, final int numberOfGlyphs, final HmtxTable hmtx) throws IOException {
input.seek(offset);
final LocaTable loca = new LocaTable();
for (int i = 0; i < numberOfGlyphs; i++) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-25 23:40:53
|
Revision: 13507
http://sourceforge.net/p/foray/code/13507
Author: victormote
Date: 2025-04-25 23:40:35 +0000 (Fri, 25 Apr 2025)
Log Message:
-----------
Move parsing of TTF "name" table to foray-font-parse project. Reworked logic from a parse-in-place scheme to a parse-into-instance scheme.
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
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/BaseAxisTableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/BaseCoordTableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/BaseMinMaxTableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/BaseScriptTableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/BaseTableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/HeadTableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Os2TableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/PcltTableParser.java
Added Paths:
-----------
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/NameTableParser.java
trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/NameTableHandler.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-25 23:39:41 UTC (rev 13506)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeCollection.java 2025-04-25 23:40:35 UTC (rev 13507)
@@ -32,6 +32,9 @@
import org.foray.common.RandomAccessInput;
import org.foray.font.format.FontParser;
import org.foray.font.ttf.table.NameTable;
+import org.foray.fontParse.ttf.NameTableParser;
+import org.foray.fontParse.ttf.TtfRandomAccessInput;
+import org.foray.fontParse.ttfHandler.NameTableHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -53,7 +56,7 @@
private TtfOffsetTable[] tableDirectories;
/** TODO: Remove this. */
- private RandomAccessInput raInput;
+ private TtfRandomAccessInput raInput;
/**
* Constructor.
@@ -106,8 +109,11 @@
// Get the "name" table
final TtfOffsetTableRecord tableDirEntry
= tableDir.getTableDirectoryEntry("name");
- final NameTable nameTable = NameTable.parse(this.raInput, tableDirEntry.getOffset(),
- tableDirEntry.getLength());
+ final ParserKit<NameTable, NameTableHandler> parseKit = NameTable.createContentHandler();
+ final NameTableParser parser = new NameTableParser();
+ parser.parse(this.raInput, tableDirEntry.getOffset(), parseKit.getHandler());
+
+ final NameTable nameTable = parseKit.getTable();
fontNames[i] = nameTable.getFullName();
}
return fontNames;
@@ -124,8 +130,17 @@
final TtfOffsetTableRecord tableDirEntry
= tableDir.getTableDirectoryEntry("name");
this.getReader().getRandomInput().seek(tableDirEntry.getOffset());
- final NameTable nameTable = NameTable.parse(this.raInput, tableDirEntry.getOffset(),
- tableDirEntry.getLength());
+
+ final ParserKit<NameTable, NameTableHandler> parseKit = NameTable.createContentHandler();
+ final NameTableParser parser = new NameTableParser();
+ parser.parse(this.raInput, tableDirEntry.getOffset(), parseKit.getHandler());
+
+ final NameTable nameTable = parseKit.getTable();
+
+
+
+// final NameTable nameTable = NameTable.parse(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-25 23:39:41 UTC (rev 13506)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/TrueTypeFont.java 2025-04-25 23:40:35 UTC (rev 13507)
@@ -62,6 +62,7 @@
import org.foray.fontParse.TableParser;
import org.foray.fontParse.ttf.BaseTableParser;
import org.foray.fontParse.ttf.HeadTableParser;
+import org.foray.fontParse.ttf.NameTableParser;
import org.foray.fontParse.ttf.Os2TableParser;
import org.foray.fontParse.ttf.PcltTableParser;
import org.foray.fontParse.ttf.PostTableParser;
@@ -68,6 +69,7 @@
import org.foray.fontParse.ttf.TtfRandomAccessInput;
import org.foray.fontParse.ttfHandler.BaseTableHandler;
import org.foray.fontParse.ttfHandler.HeadTableHandler;
+import org.foray.fontParse.ttfHandler.NameTableHandler;
import org.foray.fontParse.ttfHandler.Os2TableHandler;
import org.foray.fontParse.ttfHandler.PcltTableHandler;
import org.foray.fontParse.ttfHandler.PostTableHandler;
@@ -214,8 +216,14 @@
/* The NAME table needs to be read before the CMAP. */
dirEntry = ttfTableDir.getTableDirectoryEntry("name");
- font.nameTable = NameTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength());
+ {
+ final ParserKit<NameTable, NameTableHandler> parseKit = NameTable.createContentHandler();
+ final NameTableParser parser = new NameTableParser();
+ parser.parse(raInput, dirEntry.getOffset(), parseKit.getHandler());
+ font.nameTable = parseKit.getTable();
+ }
+
/* Then the CMAP, so that glyph indexes can be computed. */
dirEntry = ttfTableDir.getTableDirectoryEntry("cmap");
font.cmapTable = CmapTable.parse(raInput, dirEntry.getOffset(), dirEntry.getLength(),
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-25 23:39:41 UTC (rev 13506)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/NameTable.java 2025-04-25 23:40:35 UTC (rev 13507)
@@ -28,13 +28,12 @@
package org.foray.font.ttf.table;
-import org.foray.common.RandomAccessInput;
+import org.foray.font.ttf.ParserKit;
import org.foray.font.ttf.RoTable;
-import org.foray.primitive.StringUtils;
+import org.foray.fontParse.ttf.NameTableParser;
+import org.foray.fontParse.ttfHandler.NameTableHandler;
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
+import org.checkerframework.checker.signedness.qual.Unsigned;
/**
* Class representing a TTF "name" (naming) table.
@@ -41,480 +40,161 @@
*/
public class NameTable extends RoTable {
- /** Constant documented in the TTF "name" table doc as indicating the
- * Macintosh platform. */
- public static final byte PLATFORM_MACINTOSH = 1;
+ /**
+ * The handler of events from the parser.
+ */
+ private final class ContentHandler implements NameTableHandler {
- /** Constant documented in the TTF "name" table doc as indicating the
- * Microsoft platform. */
- public static final byte PLATFORM_MICROSOFT = 3;
+ /** The table instance being created. */
+ private NameTable table;
- /** 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;
+ /** The index of the name record or language tag record being parsed. */
+ private int currentIndex;
- /** 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;
+ /**
+ * Constructor.
+ * @param table The table instance being created.
+ */
+ private ContentHandler(final NameTable table) {
+ this.table = table;
+ }
- /** 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;
+ @Override
+ public void count(final @Unsigned short value) {
+ this.currentIndex = 0;
+ this.table.platformIdArray = new short[value];
+ this.table.encodingIdArray = new short[value];
+ this.table.languageIdArray = new short[value];
+ this.table.nameIdArray = new short[value];
+ this.table.nameArray = new String[value];
+ }
- /** 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;
+ @Override
+ public void platformId(final @Unsigned short value) {
+ this.table.platformIdArray[this.currentIndex] = value;
+ }
- /** 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;
+ @Override
+ public void encodingId(final @Unsigned short value) {
+ this.table.encodingIdArray[this.currentIndex] = value;
+ }
- /** Constant documented in the TTF "name" table doc as indicating the name
- * id for "Copyright notice". */
- public static final byte NAME_COPYRIGHT = 0;
+ @Override
+ public void languageId(final @Unsigned short value) {
+ this.table.languageIdArray[this.currentIndex] = value;
+ }
- /** 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;
+ @Override
+ public void nameId(final @Unsigned short value) {
+ this.table.nameIdArray[this.currentIndex] = value;
+ }
- /** 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;
+ @Override
+ public void name(final String value) {
+ this.table.nameArray[this.currentIndex] = value;
+ this.currentIndex ++;
+ }
- /** 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[] {
- NameTable.NAME_COPYRIGHT,
- NameTable.NAME_FONT_FAMILY,
- NameTable.NAME_FONT_SUBFAMILY,
- NameTable.NAME_FULL_FONT_NAME,
- NameTable.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.
+ * 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;
+ private @Unsigned short[] platformIdArray;
/**
- * Array containing the second of four items that compreise the "key" to
- * the name table.
+ * Array containing the second of four items that comprise the "key" to the name table.
* @see #platformArray
* @see #languageArray
* @see #nameArray
*/
- private int[] encodingArray;
+ private @Unsigned short[] encodingIdArray;
/**
- * Array containing the third of four items that compreise the "key" to
- * the name table.
+ * Array containing the third of four items that comprise the "key" to the name table.
* @see #platformArray
* @see #encodingArray
* @see #nameArray
*/
- private int[] languageArray;
+ private @Unsigned short[] languageIdArray;
/**
- * Array containing the fourth of four items that compreise the "key" to
- * the name table.
+ * Array containing the fourth of four items that comprise the "key" to the name table.
* @see #platformArray
* @see #encodingArray
* @see #languageArray
*/
- private int[] nameArray;
+ private @Unsigned short[] nameIdArray;
/**
- * Reads the "name" 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.
+ * Array containing the String names, which are located by referring to the four-part key.
+ * @see #platformIdArray
+ * @see #encodingIdArray
+ * @see #languageIdArray
+ * @see #nameIdArray
*/
- 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();
- name.offsetToStrings = raInput.readUnsignedShort();
+ private String[] nameArray;
- /* 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(raInput, offset, 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, offset,
- NameTable.PLATFORM_MICROSOFT,
- NameTable.ENCODING_MICROSOFT_UGL,
- NameTable.LANGUAGE_MICROSOFT_ENGLISH_AMERICAN);
- findForKeySet(name, raInput, offset,
- NameTable.PLATFORM_MICROSOFT,
- NameTable.ENCODING_MICROSOFT_UNDEFINED,
- NameTable.LANGUAGE_MICROSOFT_ENGLISH_AMERICAN);
- /* Now try 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, offset);
- 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 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.
+ * Creates a table instance and a content handler for that instance.
+ * @return A new content handler.
*/
- 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;
- }
- final int nameRecordNumber = name.findNameRecord(platformID, encodingID,
- languageID, NameTable.NAMES_TO_TEST[i]);
- parseNameRecord(name, raInput, tableOffset, nameRecordNumber);
- }
+ public static ParserKit<NameTable, NameTableHandler> createContentHandler() {
+ final NameTable table = new NameTable();
+ final NameTableHandler handler = table.new ContentHandler(table);
+ return new ParserKit<NameTable, NameTableHandler>(table, handler);
}
- /**
- * 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.
- * @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, final int tableOffset)
- throws IOException {
- for (int i = 1; i <= name.numNameRecords && ! name.allStringsFound(); i++) {
- parseNameRecord(name, raInput, tableOffset, i);
- }
- }
/**
- * 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.
+ * Find a name record from its key elements.
+ * instance variables if they are found. Enter a -1 for any parameters for
+ * which any value should be accepted.
+ * @param platformId The platform ID portion of the key. Enter -1 to match any value.
+ * @param encodingId The encoding ID portion of the key. Enter -1 to match any value.
+ * @param languageId The language ID portion of the key. Enter -1 to match any value.
+ * @param nameId The name ID portion of the key. Enter -1 to match any value.
+ * @return The name matching the key elements, or null if none is found.
*/
- 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, tableOffset, nameRecordNum);
- if (name.platformArray[arrayIndex] != NameTable.PLATFORM_MACINTOSH
- && name.platformArray[arrayIndex]
- != NameTable.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 NameTable name, final int nameID, final String updateString) {
- if (nameRecorded(name, nameID)) {
- return;
- }
- switch (nameID) {
- case NameTable.NAME_COPYRIGHT:
- name.copyrightNotice = updateString;
- break;
- case NameTable.NAME_FONT_FAMILY:
- name.familyName = updateString;
- break;
- case NameTable.NAME_FONT_SUBFAMILY:
- name.subFamilyName = updateString;
- break;
- case NameTable.NAME_FULL_FONT_NAME:
- name.fullName = updateString;
- break;
- case NameTable.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 NameTable name, final int nameID) {
- switch (nameID) {
- case NameTable.NAME_COPYRIGHT:
- if (name.copyrightNotice.equals(StringUtils.EMPTY_STRING)) {
- return false;
- }
- break;
- case NameTable.NAME_FONT_FAMILY:
- if (name.familyName.equals(StringUtils.EMPTY_STRING)) {
- return false;
- }
- break;
- case NameTable.NAME_FONT_SUBFAMILY:
- if (name.subFamilyName.equals(StringUtils.EMPTY_STRING)) {
- return false;
- }
- break;
- case NameTable.NAME_FULL_FONT_NAME:
- if (name.fullName.equals(StringUtils.EMPTY_STRING)) {
- return false;
- }
- break;
- case NameTable.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 NameTable 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 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 RandomAccessInput raInput, final int tableOffset, final int nameRecordNum)
- throws IOException {
- /* Start at the beginning of the table. */
- long offsetOfThisNameRecord = tableOffset;
- /* Skip the bytes before name records. */
- /* Skip the Format selector. */
- offsetOfThisNameRecord += RoTable.USHORT_BYTES;
- /* Skip the Number of NameRecords that follow. */
- offsetOfThisNameRecord += RoTable.USHORT_BYTES;
- /* Skip the Offset to start of string storage. */
- offsetOfThisNameRecord += RoTable.USHORT_BYTES;
- /* Skip 12 bytes for each name record that precedes the one sought. */
- offsetOfThisNameRecord += (nameRecordNum - 1)
- * NameTable.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 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 tableOffset,
- final int nameRecordNum) throws IOException {
- final int arrayIndex = nameRecordNum - 1;
- seekNameRecord(raInput, tableOffset, nameRecordNum);
- /* Skip the Platform ID. */
- raInput.skipBytes(RoTable.USHORT_BYTES);
- /* Skip the Platform-specific encoding ID. */
- raInput.skipBytes(RoTable.USHORT_BYTES);
- /* Skip the Language ID. */
- raInput.skipBytes(RoTable.USHORT_BYTES);
- /* Skip the Name ID. */
- 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). */
- final int stringOffset = raInput.readUnsignedShort();
- final Charset charset = getStringEncoding(
- name.platformArray[arrayIndex], name.encodingArray[arrayIndex],
- name.languageArray[arrayIndex]);
- final long stringOffsetInFile
- = 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;
- }
-
- /**
- * 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 == NameTable.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) {
+ private String getName(final int platformId, final int encodingId, final int languageId, final int nameId) {
+ for (int index = 0; index < this.platformIdArray.length; index ++) {
+ if (platformId > -1
+ && platformId != platformIdArray[index]) {
continue;
}
- if (encodingID > -1 && this.encodingArray[i] != encodingID) {
+ if (encodingId > -1
+ && encodingId != encodingIdArray[index]) {
continue;
}
- if (languageID > -1 && this.languageArray[i] != languageID) {
+ if (languageId > -1
+ && languageId != languageIdArray[index]) {
continue;
}
- if (nameID > -1 && this.nameArray[i] != nameID) {
+ if (nameId > -1
+ && nameId != nameIdArray[index]) {
continue;
}
- return i + 1;
+ return this.nameArray[index];
}
- return -1;
+ return null;
}
/**
- * 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;
- }
-
- /**
* Returns the postscript name of this font.
* @return The postscript name.
*/
public String getPostscriptName() {
- return this.postscriptName;
+ return this.getName(-1, -1, -1, NameTableParser.NAME_POSTSCRIPT_NAME);
}
/**
@@ -522,7 +202,7 @@
* @return The copyright notice.
*/
public String getCopyrightNotice() {
- return this.copyrightNotice;
+ return this.getName(-1, -1, -1, NameTableParser.NAME_COPYRIGHT);
}
/**
@@ -530,7 +210,7 @@
* @return The family name.
*/
public String getFamilyName() {
- return this.familyName;
+ return this.getName(-1, -1, -1, NameTableParser.NAME_FONT_FAMILY);
}
/**
@@ -538,7 +218,7 @@
* @return The full name.
*/
public String getFullName() {
- return this.fullName;
+ return this.getName(-1, -1, -1, NameTableParser.NAME_FULL_FONT_NAME);
}
/**
@@ -546,7 +226,7 @@
* @return The sub-family name.
*/
public String getSubFamilyName() {
- return this.subFamilyName;
+ return this.getName(-1, -1, -1, NameTableParser.NAME_FONT_SUBFAMILY);
}
}
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/BaseAxisTableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/BaseAxisTableParser.java 2025-04-25 23:39:41 UTC (rev 13506)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/BaseAxisTableParser.java 2025-04-25 23:40:35 UTC (rev 13507)
@@ -36,7 +36,6 @@
/**
* Parses a TTF BASE table.
- * @see org.foray.font.ttf.table.BaseTable
*/
public class BaseAxisTableParser extends TableParser<BaseAxisTableHandler> {
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/BaseCoordTableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/BaseCoordTableParser.java 2025-04-25 23:39:41 UTC (rev 13506)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/BaseCoordTableParser.java 2025-04-25 23:40:35 UTC (rev 13507)
@@ -35,7 +35,6 @@
/**
* Parses a TTF BASE table, Coord Subtable.
- * @see org.foray.font.ttf.table.BaseCoordTable
*/
public class BaseCoordTableParser extends TableParser<BaseCoordTableHandler> {
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/BaseMinMaxTableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/BaseMinMaxTableParser.java 2025-04-25 23:39:41 UTC (rev 13506)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/BaseMinMaxTableParser.java 2025-04-25 23:40:35 UTC (rev 13507)
@@ -36,7 +36,6 @@
/**
* Parses a TTF BASE table, MinMax subtable.
- * @see org.foray.font.ttf.table.BaseMinMaxTable
*/
public class BaseMinMaxTableParser extends TableParser<BaseMinMaxTableHandler> {
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/BaseScriptTableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/BaseScriptTableParser.java 2025-04-25 23:39:41 UTC (rev 13506)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/BaseScriptTableParser.java 2025-04-25 23:40:35 UTC (rev 13507)
@@ -37,7 +37,6 @@
/**
* Parses a TTF BASE table, Script Subtable.
- * @see org.foray.font.ttf.table.BaseScriptTable
*/
public class BaseScriptTableParser extends TableParser<BaseScriptTableHandler> {
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/BaseTableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/BaseTableParser.java 2025-04-25 23:39:41 UTC (rev 13506)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/BaseTableParser.java 2025-04-25 23:40:35 UTC (rev 13507)
@@ -36,7 +36,6 @@
/**
* Parses a TTF BASE table.
- * @see org.foray.font.ttf.table.BaseTable
*/
public class BaseTableParser extends TableParser<BaseTableHandler> {
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/HeadTableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/HeadTableParser.java 2025-04-25 23:39:41 UTC (rev 13506)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/HeadTableParser.java 2025-04-25 23:40:35 UTC (rev 13507)
@@ -35,7 +35,6 @@
/**
* Parses a TTF HEAD table.
- * @see org.foray.font.ttf.table.HeadTable
*/
public class HeadTableParser extends TableParser<HeadTableHandler> {
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/NameTableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/NameTableParser.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/NameTableParser.java 2025-04-25 23:40:35 UTC (rev 13507)
@@ -0,0 +1,189 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttf;
+
+import org.foray.fontParse.TableParser;
+import org.foray.fontParse.ttfHandler.NameTableHandler;
+
+import org.checkerframework.checker.signedness.qual.Unsigned;
+
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+
+/**
+ * Parses a TTF "name" table.
+ */
+public class NameTableParser extends TableParser<NameTableHandler> {
+
+ /** 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;
+
+ @Override
+ public void parse(final TtfRandomAccessInput input, final int offset, final NameTableHandler handler)
+ throws IOException {
+ input.seek(offset);
+
+ final @Unsigned short version = input.read_uint16();
+ handler.version(version);
+ final @Unsigned short count = input.read_uint16();
+ handler.count(count);
+ final @Unsigned short storageOffset = input.read_Offset16();
+ handler.storageOffset(storageOffset);
+
+ /* Populate the key arrays. */
+ for (int index = 1; index <= count; index ++) {
+ final @Unsigned short platformId = input.read_uint16();
+ handler.platformId(platformId);
+ final @Unsigned short encodingId = input.read_uint16();
+ handler.encodingId(encodingId);
+ final @Unsigned short languageId = input.read_uint16();
+ handler.languageId(languageId);
+ handler.nameId(input.read_uint16());
+ final short nameRecordByteLength = input.read_uint16();
+ handler.nameRecordByteLength(nameRecordByteLength);
+ final short stringRelativeOffset = input.read_uint16();
+ handler.stringOffset(stringRelativeOffset);
+
+ final long bookmark = input.getOffset();
+ final long stringAbsoluteOffset = offset + storageOffset + stringRelativeOffset;
+ input.seek(stringAbsoluteOffset);
+ final Charset charset = getStringEncoding(platformId, encodingId, languageId);
+ final String name = input.readString(nameRecordByteLength, charset);
+ handler.name(name);
+ input.seek(bookmark);
+ }
+
+
+
+
+
+ /* Version 1. */
+ if (version > 0) {
+ final @Unsigned short langTagCount = input.read_uint16();
+ handler.langTagCount(langTagCount);
+
+ for (int index = 0; index < langTagCount; index ++) {
+ final @Unsigned short langTagRecordLength = input.read_uint16();
+ handler.langTagRecordLength(langTagRecordLength);
+ final @Unsigned short langTagRecordOffset = input.read_uint16();
+ handler.langTagRecordOffset(langTagRecordOffset);
+
+ final long bookmark = input.getOffset();
+ final long stringAbsoluteOffset = offset + storageOffset + langTagRecordOffset;
+ input.seek(stringAbsoluteOffset);
+ final String name = input.readString(langTagRecordLength, StandardCharsets.UTF_16BE);
+ handler.name(name);
+ input.seek(bookmark);
+ }
+ }
+ }
+
+ /**
+ * 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 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 == NameTableParser.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;
+ }
+
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/NameTableParser.java
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Rev
\ No newline at end of property
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Os2TableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Os2TableParser.java 2025-04-25 23:39:41 UTC (rev 13506)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/Os2TableParser.java 2025-04-25 23:40:35 UTC (rev 13507)
@@ -38,7 +38,6 @@
/**
* Parses a TTF OS/2 table.
- * @see org.foray.font.ttf.table.Os2Table
*/
public class Os2TableParser extends TableParser<Os2TableHandler> {
Modified: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/PcltTableParser.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/PcltTableParser.java 2025-04-25 23:39:41 UTC (rev 13506)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttf/PcltTableParser.java 2025-04-25 23:40:35 UTC (rev 13507)
@@ -35,7 +35,6 @@
/**
* Parses a TTF PCLT table.
- * @see org.foray.font.ttf.table.PcltTable
*/
public class PcltTableParser extends TableParser<PcltTableHandler> {
Added: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/NameTableHandler.java
===================================================================
--- trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/NameTableHandler.java (rev 0)
+++ trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/NameTableHandler.java 2025-04-25 23:40:35 UTC (rev 13507)
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2025 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.fontParse.ttfHandler;
+
+import org.foray.fontParse.FontContentHandler;
+import org.foray.fontParse.ttf.NameTableParser;
+
+import org.checkerframework.checker.signedness.qual.Unsigned;
+
+/**
+ * Implementations catch and handle the output from {@link NameTableParser}.
+ */
+public interface NameTableHandler extends FontContentHandler {
+
+ default void version(@Unsigned short value) { return; }
+ default void count(@Unsigned short value) { return; }
+ default void storageOffset(@Unsigned short value) { return; }
+
+ /* Name record. */
+ default void platformId(@Unsigned short value) { return; }
+ default void encodingId(@Unsigned short value) { return; }
+ default void languageId(@Unsigned short value) { return; }
+ default void nameId(@Unsigned short value) { return; }
+ default void nameRecordByteLength(@Unsigned short value) { return; }
+ default void stringOffset(@Unsigned short value) { return; }
+ default void name(String value) { return; }
+
+ default void langTagCount(@Unsigned short value) { return; }
+
+ /* LangTagRecord. */
+ default void langTagRecordLength(@Unsigned short value) { return; }
+ default void langTagRecordOffset(@Unsigned short value) { return; }
+ default void langTag(String value) { return; }
+}
Property changes on: trunk/foray/foray-font-parse/src/main/java/org/foray/fontParse/ttfHandler/NameTableHandler.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-25 23:39:57
|
Revision: 13506
http://sourceforge.net/p/foray/code/13506
Author: victormote
Date: 2025-04-25 23:39:41 +0000 (Fri, 25 Apr 2025)
Log Message:
-----------
Another fix to WritingSystem logic.
Modified Paths:
--------------
trunk/foray/foray-common/src/main/java/org/foray/common/i18n/WritingSystem4a.java
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/i18n/WritingSystem4a.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/i18n/WritingSystem4a.java 2025-04-25 23:15:48 UTC (rev 13505)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/i18n/WritingSystem4a.java 2025-04-25 23:39:41 UTC (rev 13506)
@@ -148,10 +148,17 @@
}
final Country4a countryToUse = country == null ? Country4a.NOT_SPECIFIED : country;
- Script4a scriptToUse = script == null ? language.getDefaultScript(countryToUse) : script;
- scriptToUse = script == Script4a.UNDETERMINED ? language.getDefaultScript(countryToUse) : script;
- scriptToUse = scriptToUse == null ? Script4a.UNDETERMINED : scriptToUse;
+ Script4a scriptToUse = script;
+ if (scriptToUse == null
+ || scriptToUse == Script4a.UNDETERMINED) {
+ scriptToUse = language.getDefaultScript(countryToUse);
+ }
+ /* If it is still null, set it to undefined. */
+ if (scriptToUse == null) {
+ scriptToUse = Script4a.UNDETERMINED;
+ }
+
Map<Language4a, Map<Country4a, WritingSystem4a>> scriptMap = REGISTRATION_MAP.get(scriptToUse);
if (scriptMap == null) {
scriptMap = new HashMap<Language4a, Map<Country4a, WritingSystem4a>>();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-25 23:16:06
|
Revision: 13505
http://sourceforge.net/p/foray/code/13505
Author: victormote
Date: 2025-04-25 23:15:48 +0000 (Fri, 25 Apr 2025)
Log Message:
-----------
Another fix to WritingSystem logic.
Modified Paths:
--------------
trunk/foray/foray-common/src/main/java/org/foray/common/i18n/WritingSystem4a.java
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/i18n/WritingSystem4a.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/i18n/WritingSystem4a.java 2025-04-25 12:22:05 UTC (rev 13504)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/i18n/WritingSystem4a.java 2025-04-25 23:15:48 UTC (rev 13505)
@@ -150,6 +150,7 @@
final Country4a countryToUse = country == null ? Country4a.NOT_SPECIFIED : country;
Script4a scriptToUse = script == null ? language.getDefaultScript(countryToUse) : script;
scriptToUse = script == Script4a.UNDETERMINED ? language.getDefaultScript(countryToUse) : script;
+ scriptToUse = scriptToUse == null ? Script4a.UNDETERMINED : scriptToUse;
Map<Language4a, Map<Country4a, WritingSystem4a>> scriptMap = REGISTRATION_MAP.get(scriptToUse);
if (scriptMap == null) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2025-04-25 12:22:22
|
Revision: 13504
http://sourceforge.net/p/foray/code/13504
Author: victormote
Date: 2025-04-25 12:22:05 +0000 (Fri, 25 Apr 2025)
Log Message:
-----------
Fix bug in WritingSystem computation.
Modified Paths:
--------------
trunk/foray/foray-common/src/main/java/org/foray/common/i18n/WritingSystem4a.java
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/i18n/WritingSystem4a.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/i18n/WritingSystem4a.java 2025-04-25 02:38:56 UTC (rev 13503)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/i18n/WritingSystem4a.java 2025-04-25 12:22:05 UTC (rev 13504)
@@ -149,7 +149,7 @@
final Country4a countryToUse = country == null ? Country4a.NOT_SPECIFIED : country;
Script4a scriptToUse = script == null ? language.getDefaultScript(countryToUse) : script;
- scriptToUse = scriptToUse == null ? Script4a.UNDETERMINED : scriptToUse;
+ scriptToUse = script == Script4a.UNDETERMINED ? language.getDefaultScript(countryToUse) : script;
Map<Language4a, Map<Country4a, WritingSystem4a>> scriptMap = REGISTRATION_MAP.get(scriptToUse);
if (scriptMap == null) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|