aboutsummaryrefslogtreecommitdiffstats
path: root/src/codegen/code-point-mapping.xsl
diff options
context:
space:
mode:
authorManuel Mall <manuel@apache.org>2006-12-22 09:16:18 +0000
committerManuel Mall <manuel@apache.org>2006-12-22 09:16:18 +0000
commitc78f7767b3686e851ede4c41d6747fcecc539e83 (patch)
treeb5b0de4af7b90930883ee8055f0681a65b1df7c4 /src/codegen/code-point-mapping.xsl
parent3c0a84fd754d2a0b981ea1f0d06ae3046d36da4d (diff)
downloadxmlgraphics-fop-c78f7767b3686e851ede4c41d6747fcecc539e83.tar.gz
xmlgraphics-fop-c78f7767b3686e851ede4c41d6747fcecc539e83.zip
Added (limited) support for Unicode UAX#14 compliant line breaking. Thanks to Joerg Pietschman who supplied the core code for the Unicode line breaking algorithm
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@489585 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/codegen/code-point-mapping.xsl')
-rw-r--r--src/codegen/code-point-mapping.xsl120
1 files changed, 0 insertions, 120 deletions
diff --git a/src/codegen/code-point-mapping.xsl b/src/codegen/code-point-mapping.xsl
deleted file mode 100644
index 7d0d6cd71..000000000
--- a/src/codegen/code-point-mapping.xsl
+++ /dev/null
@@ -1,120 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You 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.
--->
-<!-- $Id$ -->
-<xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
- <xsl:output method="text"/>
- <xsl:variable name='glyphlists'
- select="document('glyphlist.xml')/glyphlist-set"/>
-
- <xsl:template match="encoding-set">
-package org.apache.fop.fonts;
-
-import java.util.Map;
-import java.util.Collections;
-
-public class CodePointMapping {
- private char[] latin1Map;
- private char[] characters;
- private char[] codepoints;
- private CodePointMapping(int [] table) {
- int nonLatin1 = 0;
- latin1Map = new char[256];
- 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;
- }
- characters = new char[nonLatin1];
- codepoints = new char[nonLatin1];
- int top = 0;
- for(int i = 0; i &lt; table.length; i += 2) {
- char c = (char) table[i+1];
- if(c >= 256) {
- ++top;
- for(int j = top - 1; j >= 0; --j) {
- if(j > 0 &amp;&amp; characters[j-1] >= c) {
- characters[j] = characters[j-1];
- codepoints[j] = codepoints[j-1];
- } else {
- characters[j] = c;
- codepoints[j] = (char) table[i];
- break;
- }
- }
- }
- }
- }
- public final char mapChar(char c) {
- if(c &lt; 256) {
- return latin1Map[c];
- } else {
- int bot = 0, top = characters.length - 1;
- while(top >= bot) {
- int mid = (bot + top) / 2;
- char mc = characters[mid];
-
- if(c == mc)
- return codepoints[mid];
- else if(c &lt; mc)
- top = mid - 1;
- else
- bot = mid + 1;
- }
- return 0;
- }
- }
-
- 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) {
- return mapping;
- } <xsl:apply-templates mode="get"/>
- else {
- return null;
- }
- }
-<xsl:apply-templates mode="table"/>
-}
- </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);
- return mapping;
- }
- </xsl:template>
-
- <xsl:template match="encoding" mode="table">
- <xsl:variable name="glyphlist-name" select="@glyphlist"/>
- <xsl:variable name="glyphlist"
- select="$glyphlists/glyphlist[@id=$glyphlist-name]"/>
- private static final int[] enc<xsl:value-of select="@id"/>
- = {<xsl:for-each select="glyph">
- <xsl:variable name="codepoint" select="@codepoint"/>
- <xsl:variable name="name" select="@name"/><xsl:for-each select="$glyphlist/glyph[@name=$name]">
- 0x<xsl:value-of select="$codepoint"/>, 0x<xsl:value-of select="@codepoint"/>, // <xsl:value-of select="$name"/>
-</xsl:for-each></xsl:for-each>
- };
- </xsl:template>
-</xsl:stylesheet>