*/ it = blockConfig.keySet().iterator(); it.hasNext();) {
+ String blockName = (String)it.next();
+ Character.UnicodeBlock block;
+ try {
+ block = Character.UnicodeBlock.forName(blockName);
+ } catch (IllegalArgumentException e) {
+ //The calling code should handle explicitly handle bad configuration
+ throw new Exception("Unicode block name '"+blockName+"' not recognised");
+ }
+ Double scaleFactor = (Double)blockConfig.get(blockName);
+ map.put(block, scaleFactor);
+ }
+
+ return map;
+ }
+
+
+
+ /**
+ * {@inheritDoc}
+ */
+
+ public int getWidth(int character, CharacterSet charSet) {
+
+ //Does character hava a fallback?
+ Double scaleFactor = (Double)charMap.get(Integer.valueOf(character));
+ if (scaleFactor != null) {
+ return (int)(charSet.getEmSpaceIncrement() * scaleFactor.doubleValue());
+ }
+
+ //Does the character's unicode block have a fallback?
+ Character.UnicodeBlock block = Character.UnicodeBlock.of(character);
+ if (block != null) {
+ scaleFactor = (Double)blockMap.get(block);
+ if (scaleFactor != null) {
+ return (int)(charSet.getEmSpaceIncrement() * scaleFactor.doubleValue());
+ }
+ } else {
+ throw new IllegalArgumentException("" + character + " is an illegal codepoint");
+ }
+
+ return charSet.getSpaceIncrement();
+ }
+
+
+
+}
Property changes on: src/java/org/apache/fop/afp/fonts/MetricFallbackStrategy.java
___________________________________________________________________
Added: svn:eol-style
+ native
Index: src/java/org/apache/fop/afp/fonts/DefaultMetricFallbackStrategy.java
===================================================================
--- src/java/org/apache/fop/afp/fonts/DefaultMetricFallbackStrategy.java (revision 0)
+++ src/java/org/apache/fop/afp/fonts/DefaultMetricFallbackStrategy.java (revision 0)
@@ -0,0 +1,70 @@
+/*
+ * 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:$ */
+
+package org.apache.fop.afp.fonts;
+
+import java.util.Set;
+
+/**
+ * A default implementation
+ */
+public class DefaultMetricFallbackStrategy implements IMetricFallbackStrategy {
+
+
+ private static final Set IDEOGRAPHIC = new java.util.HashSet();
+ static {
+ IDEOGRAPHIC.add(Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS);
+ //IDEOGRAPHIC.add(Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT); //Java 1.5
+ IDEOGRAPHIC.add(Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS);
+ IDEOGRAPHIC.add(Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A);
+ //IDEOGRAPHIC.add(Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B); //Java 1.1
+ }
+
+
+ /**
+ * Default constructor. Should be instantiated by FallbackStrategyFactory.
+ */
+ protected DefaultMetricFallbackStrategy() { }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getWidth(int character, CharacterSet charSet) {
+
+ //Is this character an ideograph?
+ boolean isIdeographic = false;
+ Character.UnicodeBlock charBlock = Character.UnicodeBlock.of(character);
+ if (charBlock == null) {
+ isIdeographic = false;
+ } else if (IDEOGRAPHIC.contains(charBlock)) {
+ isIdeographic = true;
+ } else { //default
+ isIdeographic = false;
+ }
+
+ if (isIdeographic) {
+ return charSet.getEmSpaceIncrement();
+ } else {
+ return charSet.getSpaceIncrement();
+ }
+ }
+
+
+}
Property changes on: src/java/org/apache/fop/afp/fonts/DefaultMetricFallbackStrategy.java
___________________________________________________________________
Added: svn:eol-style
+ native
Index: src/documentation/content/xdocs/trunk/output.xml
===================================================================
--- src/documentation/content/xdocs/trunk/output.xml (revision 908040)
+++ src/documentation/content/xdocs/trunk/output.xml (working copy)
@@ -555,7 +555,7 @@
IBM CID-keyed (Type 0) fonts
FOP built-in Base14 fonts
- A typical raster font configuration looks like:
+ A typical raster font configuration looks like: