aboutsummaryrefslogtreecommitdiffstats
path: root/src/codegen/fonts
diff options
context:
space:
mode:
Diffstat (limited to 'src/codegen/fonts')
-rw-r--r--src/codegen/fonts/code-point-mapping.xsl44
-rw-r--r--src/codegen/fonts/encodings.xml18
2 files changed, 49 insertions, 13 deletions
diff --git a/src/codegen/fonts/code-point-mapping.xsl b/src/codegen/fonts/code-point-mapping.xsl
index 53636505d..80b62dd17 100644
--- a/src/codegen/fonts/code-point-mapping.xsl
+++ b/src/codegen/fonts/code-point-mapping.xsl
@@ -40,23 +40,37 @@
package org.apache.fop.fonts;
+import java.util.Arrays;
import java.util.Map;
import java.util.Collections;
+import org.apache.fop.util.CharUtilities;
+
public class CodePointMapping {
+
+<xsl:apply-templates mode="constant"/>
+
+ private String name;
private char[] latin1Map;
private char[] characters;
private char[] codepoints;
+ private char[] unicodeMap; //code point to Unicode char
- private CodePointMapping(int [] table) {
+ public CodePointMapping(String name, int[] table) {
+ this.name = name;
int nonLatin1 = 0;
latin1Map = new char[256];
+ unicodeMap = new char[256];
+ Arrays.fill(unicodeMap, CharUtilities.NOT_A_CHARACTER);
for (int i = 0; i &lt; table.length; i += 2) {
if (table[i + 1] &lt; 256) {
latin1Map[table[i + 1]] = (char) table[i];
} else {
++nonLatin1;
}
+ if (unicodeMap[table[i]] == CharUtilities.NOT_A_CHARACTER) {
+ unicodeMap[table[i]] = (char)table[i + 1];
+ }
}
characters = new char[nonLatin1];
codepoints = new char[nonLatin1];
@@ -79,6 +93,10 @@ public class CodePointMapping {
}
}
+ public String getName() {
+ return this.name;
+ }
+
public final char mapChar(char c) {
if (c &lt; 256) {
return latin1Map[c];
@@ -100,10 +118,26 @@ public class CodePointMapping {
}
}
+ public final char getUnicodeForIndex(int idx) {
+ return this.unicodeMap[idx];
+ }
+
+ public final char[] getUnicodeCharMap() {
+ char[] copy = new char[this.unicodeMap.length];
+ System.arraycopy(this.unicodeMap, 0, copy, 0, this.unicodeMap.length);
+ return copy;
+ }
+
+ /** {@inheritDoc} */
+ public String toString() {
+ return getName();
+ }
+
private static Map mappings;
static {
mappings = Collections.synchronizedMap(new java.util.HashMap());
}
+
public static CodePointMapping getMapping(String encoding) {
CodePointMapping mapping = (CodePointMapping) mappings.get(encoding);
if (mapping != null) {
@@ -119,10 +153,12 @@ public class CodePointMapping {
}
</xsl:template>
+ <xsl:template match="encoding" mode="constant"> public static final String <xsl:value-of select="@constant"/> = "<xsl:value-of select="@id"/>";</xsl:template>
+
<xsl:template match="encoding" mode="get">
- else if (encoding.equals("<xsl:value-of select="@id"/>")) {
- mapping = new CodePointMapping(enc<xsl:value-of select="@id"/>);
- mappings.put("<xsl:value-of select="@id"/>", mapping);
+ else if (encoding.equals(<xsl:value-of select="@constant"/>)) {
+ mapping = new CodePointMapping(<xsl:value-of select="@constant"/>, enc<xsl:value-of select="@id"/>);
+ mappings.put(<xsl:value-of select="@constant"/>, mapping);
return mapping;
}
</xsl:template>
diff --git a/src/codegen/fonts/encodings.xml b/src/codegen/fonts/encodings.xml
index 1f8497ee3..d7855000e 100644
--- a/src/codegen/fonts/encodings.xml
+++ b/src/codegen/fonts/encodings.xml
@@ -19,12 +19,12 @@
<!DOCTYPE encoding-set [
<!ELEMENT encoding-set (encoding+)>
<!ELEMENT encoding (glyph+)>
- <!ATTLIST encoding id ID #REQUIRED glyphlist CDATA "AGL">
+ <!ATTLIST encoding id ID #REQUIRED constant CDATA #REQUIRED glyphlist CDATA "AGL">
<!ELEMENT glyph EMPTY>
<!ATTLIST glyph codepoint CDATA #REQUIRED name CDATA #REQUIRED>
]>
<encoding-set>
- <encoding id='StandardEncoding' glyphlist='AGL'>
+ <encoding id='StandardEncoding' constant="STANDARD_ENCODING" glyphlist='AGL'>
<glyph codepoint='20' name='space'/>
<glyph codepoint='21' name='exclam'/>
<glyph codepoint='22' name='quotedbl'/>
@@ -175,7 +175,7 @@
<glyph codepoint='fa' name='oe'/>
<glyph codepoint='fb' name='germandbls'/>
</encoding>
- <encoding id='ISOLatin1Encoding' glyphlist='AGL'>
+ <encoding id='ISOLatin1Encoding' constant="ISOLATIN1_ENCODING" glyphlist='AGL'>
<glyph codepoint='20' name='space'/>
<glyph codepoint='21' name='exclam'/>
<glyph codepoint='22' name='quotedbl'/>
@@ -377,7 +377,7 @@
<glyph codepoint='fe' name='thorn'/>
<glyph codepoint='ff' name='ydieresis'/>
</encoding>
- <encoding id='CEEncoding' glyphlist='AGL'>
+ <encoding id='CEEncoding' constant="CE_ENCODING" glyphlist='AGL'>
<glyph codepoint='20' name='space'/>
<glyph codepoint='21' name='exclam'/>
<glyph codepoint='22' name='quotedbl'/>
@@ -594,7 +594,7 @@
<glyph codepoint='fe' name='tcommaaccent'/>
<glyph codepoint='ff' name='dotaccent'/>
</encoding>
- <encoding id='MacRomanEncoding' glyphlist='AGL'>
+ <encoding id='MacRomanEncoding' constant="MAC_ROMAN_ENCODING" glyphlist='AGL'>
<glyph codepoint='20' name='space'/>
<glyph codepoint='21' name='exclam'/>
<glyph codepoint='22' name='quotedbl'/>
@@ -803,7 +803,7 @@
<glyph codepoint='b4' name='yen'/>
<glyph codepoint='7a' name='z'/>
</encoding>
- <encoding id='WinAnsiEncoding' glyphlist='AGL'>
+ <encoding id='WinAnsiEncoding' constant="WIN_ANSI_ENCODING" glyphlist='AGL'>
<glyph codepoint='20' name='space'/>
<glyph codepoint='21' name='exclam'/>
<glyph codepoint='22' name='quotedbl'/>
@@ -1021,7 +1021,7 @@
<glyph codepoint='fe' name='thorn'/>
<glyph codepoint='ff' name='ydieresis'/>
</encoding>
- <encoding id='PDFDocEncoding' glyphlist='AGL'>
+ <encoding id='PDFDocEncoding' constant="PDF_DOC_ENCODING" glyphlist='AGL'>
<glyph codepoint='18' name='breve'/>
<glyph codepoint='19' name='caron'/>
<glyph codepoint='1a' name='circumflex'/>
@@ -1252,7 +1252,7 @@
<glyph codepoint='fe' name='thorn'/>
<glyph codepoint='ff' name='ydieresis'/>
</encoding>
- <encoding id='SymbolEncoding' glyphlist='AGL'>
+ <encoding id='SymbolEncoding' constant="SYMBOL_ENCODING" glyphlist='AGL'>
<glyph codepoint='20' name='space'/>
<glyph codepoint='21' name='exclam'/>
<glyph codepoint='22' name='universal'/>
@@ -1443,7 +1443,7 @@
<glyph codepoint='fd' name='bracerightmid'/>
<glyph codepoint='fe' name='bracerightbt'/>
</encoding>
- <encoding id='ZapfDingbatsEncoding' glyphlist='ZGL'>
+ <encoding id='ZapfDingbatsEncoding' constant="ZAPF_DINGBATS_ENCODING" glyphlist='ZGL'>
<glyph codepoint='20' name='space'/>
<glyph codepoint='21' name='a1'/>
<glyph codepoint='22' name='a2'/>