[FOray-commit] SF.net SVN: foray:[11902] trunk/foray/foray-ps/src/main/java/org/foray/ps
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2021-02-09 01:03:10
|
Revision: 11902
http://sourceforge.net/p/foray/code/11902
Author: victormote
Date: 2021-02-09 01:03:02 +0000 (Tue, 09 Feb 2021)
Log Message:
-----------
Rename classes for consistency.
Modified Paths:
--------------
trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java
Added Paths:
-----------
trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap00Ttf4a.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap04Ttf4a.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap04TtfEntry4a.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap12Ttf4a.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap12TtfEntry4a.java
Removed Paths:
-------------
trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap4a.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap4a04.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap4a04Entry.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap4a12.java
trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap4a12Entry.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 2021-02-08 23:30:03 UTC (rev 11901)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/PsServer4a.java 2021-02-09 01:03:02 UTC (rev 11902)
@@ -31,8 +31,8 @@
import org.foray.common.sequence.IntArrayBuilder;
import org.foray.ps.encode.CharSet4a;
import org.foray.ps.encode.CharSetParser;
-import org.foray.ps.encode.Cmap4a04;
-import org.foray.ps.encode.Cmap4a12;
+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;
@@ -302,12 +302,12 @@
@Override
public Cmap04Ttf makeCmap04(final String name, final int expectedEntries) {
- return new Cmap4a04(name, expectedEntries);
+ return new Cmap04Ttf4a(name, expectedEntries);
}
@Override
public Cmap12Ttf makeCmap12(final String name, final int expectedEntries) {
- return new Cmap4a12(name, expectedEntries);
+ return new Cmap12Ttf4a(name, expectedEntries);
}
}
Copied: trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap00Ttf4a.java (from rev 11898, trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap4a.java)
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap00Ttf4a.java (rev 0)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap00Ttf4a.java 2021-02-09 01:03:02 UTC (rev 11902)
@@ -0,0 +1,46 @@
+/*
+ * 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;
+ }
+
+}
Copied: trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap04Ttf4a.java (from rev 11901, trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap4a04.java)
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap04Ttf4a.java (rev 0)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap04Ttf4a.java 2021-02-09 01:03:02 UTC (rev 11902)
@@ -0,0 +1,157 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.ps.encode;
+
+import org.axsl.ps.Cmap04Ttf;
+
+/**
+ * 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 {
+
+ /** 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;
+ }
+
+ @Override
+ public void addEntry(final int unicodeStart, final int unicodeEnd, final char glyphStartIndex) {
+ final Cmap04TtfEntry4a newEntry = new Cmap04TtfEntry4a(unicodeStart, unicodeEnd,
+ glyphStartIndex);
+ addEntry(newEntry);
+ }
+
+ @Override
+ 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;
+ }
+
+}
Copied: trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap04TtfEntry4a.java (from rev 11898, trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap4a04Entry.java)
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap04TtfEntry4a.java (rev 0)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap04TtfEntry4a.java 2021-02-09 01:03:02 UTC (rev 11902)
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2004 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.ps.encode;
+
+/**
+ * Contains one entry from a TrueType Cmap4a subtable, format 4, which handles
+ * 16-bit Unicode codepoint ranges.
+ */
+public class Cmap04TtfEntry4a {
+
+ /** The first Unicode codepoint in this entry. */
+ private int unicodeStart;
+
+ /** The last Unicode codepoint 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 iff 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;
+ }
+
+}
Copied: trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap12Ttf4a.java (from rev 11901, trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap4a12.java)
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap12Ttf4a.java (rev 0)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap12Ttf4a.java 2021-02-09 01:03:02 UTC (rev 11902)
@@ -0,0 +1,152 @@
+/*
+ * 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.Cmap12Ttf;
+
+/**
+ * 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 {
+
+ /** 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;
+ }
+
+ @Override
+ 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;
+ }
+
+}
Copied: trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap12TtfEntry4a.java (from rev 11880, trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap4a12Entry.java)
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap12TtfEntry4a.java (rev 0)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap12TtfEntry4a.java 2021-02-09 01:03:02 UTC (rev 11902)
@@ -0,0 +1,117 @@
+/*
+ * 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 codepoint ranges.
+ */
+public class Cmap12TtfEntry4a {
+
+ /** The first Unicode codepoint in this entry. */
+ private int unicodeStart;
+
+ /** The last Unicode codepoint 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 iff 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;
+ }
+
+}
Deleted: trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap4a.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap4a.java 2021-02-08 23:30:03 UTC (rev 11901)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap4a.java 2021-02-09 01:03:02 UTC (rev 11902)
@@ -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 Cmap4a implements Cmap {
-
- /** Constant needed for serialization. */
- public static final long serialVersionUID = -6516855352094857929L;
-
- @Override
- public boolean canEncode(final int codePoint) {
- return this.encode(codePoint) > -1;
- }
-
-}
Deleted: trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap4a04.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap4a04.java 2021-02-08 23:30:03 UTC (rev 11901)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap4a04.java 2021-02-09 01:03:02 UTC (rev 11902)
@@ -1,157 +0,0 @@
-/*
- * Copyright 2004 The FOray Project.
- * http://www.foray.org
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This work is in part derived from the following work(s), used with the
- * permission of the licensor:
- * Apache FOP, licensed by the Apache Software Foundation
- *
- */
-
-/*
- * $LastChangedRevision$
- * $LastChangedDate$
- * $LastChangedBy$
- */
-
-package org.foray.ps.encode;
-
-import org.axsl.ps.Cmap04Ttf;
-
-/**
- * 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 Cmap4a04 extends Cmap4a implements Cmap04Ttf {
-
- /** Constant needed for serialization. */
- public static final long serialVersionUID = 985957847129472354L;
-
- /** The name of this encoding. */
- private String name;
-
- /** The array of entries. */
- private Cmap4a04Entry[] 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 Cmap4a04(final String name, final int expectedEntries) {
- this.name = name;
- this.entries = new Cmap4a04Entry[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 Cmap4a04Entry entry) {
- this.lastEntryAdded++;
- if (this.lastEntryAdded >= this.entries.length) {
- // Fails silently.
- return;
- }
- this.entries[this.lastEntryAdded] = entry;
- }
-
- @Override
- public void addEntry(final int unicodeStart, final int unicodeEnd, final char glyphStartIndex) {
- final Cmap4a04Entry newEntry = new Cmap4a04Entry(unicodeStart, unicodeEnd,
- glyphStartIndex);
- addEntry(newEntry);
- }
-
- @Override
- public void addEntry(final int unicodeStart, final int unicodeEnd, final CharSequence glyphIndexes) {
- final Cmap4a04Entry newEntry = new Cmap4a04Entry(unicodeStart, unicodeEnd, glyphIndexes);
- addEntry(newEntry);
- }
-
- @Override
- public int encode(final int c) {
- final Cmap4a04Entry 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 Cmap4a04Entry 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;
- }
-
-}
Deleted: trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap4a04Entry.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap4a04Entry.java 2021-02-08 23:30:03 UTC (rev 11901)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap4a04Entry.java 2021-02-09 01:03:02 UTC (rev 11902)
@@ -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 codepoint ranges.
- */
-public class Cmap4a04Entry {
-
- /** The first Unicode codepoint in this entry. */
- private int unicodeStart;
-
- /** The last Unicode codepoint 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 Cmap4a04Entry(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 Cmap4a04Entry(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 iff 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/src/main/java/org/foray/ps/encode/Cmap4a12.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap4a12.java 2021-02-08 23:30:03 UTC (rev 11901)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap4a12.java 2021-02-09 01:03:02 UTC (rev 11902)
@@ -1,152 +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.Cmap12Ttf;
-
-/**
- * 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 Cmap4a12 extends Cmap4a implements Cmap12Ttf {
-
- /** Constant needed for serialization. */
- public static final long serialVersionUID = -606154911100219394L;
-
- /** The name of this encoding. */
- private String name;
-
- /** The array of entries. */
- private Cmap4a12Entry[] 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 Cmap4a12(final String name, final int expectedEntries) {
- this.name = name;
- this.entries = new Cmap4a12Entry[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 Cmap4a12Entry entry) {
- this.lastEntryAdded++;
- if (this.lastEntryAdded >= this.entries.length) {
- // Fails silently.
- return;
- }
- this.entries[this.lastEntryAdded] = entry;
- }
-
- @Override
- public void addEntry(final int unicodeStart, final int unicodeEnd,
- final int glyphStartIndex) {
- final Cmap4a12Entry newEntry = new Cmap4a12Entry(unicodeStart, unicodeEnd,
- glyphStartIndex);
- addEntry(newEntry);
- }
-
- @Override
- public int encode(final int codePoint) {
- final Cmap4a12Entry 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 Cmap4a12Entry 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;
- }
-
-}
Deleted: trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap4a12Entry.java
===================================================================
--- trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap4a12Entry.java 2021-02-08 23:30:03 UTC (rev 11901)
+++ trunk/foray/foray-ps/src/main/java/org/foray/ps/encode/Cmap4a12Entry.java 2021-02-09 01:03:02 UTC (rev 11902)
@@ -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 codepoint ranges.
- */
-public class Cmap4a12Entry {
-
- /** The first Unicode codepoint in this entry. */
- private int unicodeStart;
-
- /** The last Unicode codepoint 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 Cmap4a12Entry(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 iff 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.
|