You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by cb...@apache.org on 2005/08/15 15:23:41 UTC
svn commit: r232810 - in /xmlgraphics/fop/trunk:
src/java/org/apache/fop/fonts/ src/java/org/apache/fop/render/xml/
test/layoutengine/testcases/
Author: cbowditch
Date: Mon Aug 15 06:23:27 2005
New Revision: 232810
URL: http://svn.apache.org/viewcvs?rev=232810&view=rev
Log:
ref to bugzilla 36180
Submitted by: Manuel Mall <mm.at.arcus.com.au>
Added:
xmlgraphics/fop/trunk/test/layoutengine/testcases/font-family.xml (with props)
xmlgraphics/fop/trunk/test/layoutengine/testcases/font-style.xml (with props)
xmlgraphics/fop/trunk/test/layoutengine/testcases/font-weight.xml (with props)
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontInfo.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRenderer.java
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontInfo.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontInfo.java?rev=232810&r1=232809&r2=232810&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontInfo.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontInfo.java Mon Aug 15 06:23:27 2005
@@ -18,9 +18,13 @@
package org.apache.fop.fonts;
-// Java
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
import java.util.Map;
+
/**
* The FontInfo for the layout and rendering of a fo document.
* This stores the list of available fonts that are setup by
@@ -226,6 +230,61 @@
usedFonts.put(fontName, fonts.get(fontName));
return (FontMetrics)fonts.get(fontName);
}
+
+ /**
+ * Returns the first triplet matching the given font name.
+ * As there may be multiple triplets matching the font name
+ * the result set is sorted first to guarantee consistent results.
+ * @param fontName The font name we are looking for
+ * @return The first triplet for the given font name
+ */
+ private String getTripletFor(String fontName) {
+ List foundTriplets = new ArrayList();
+ for (Iterator iter = triplets.entrySet().iterator(); iter.hasNext(); ) {
+ Map.Entry tripletEntry = (Map.Entry) iter.next();
+ if (fontName.equals(((String)tripletEntry.getValue()))) {
+ foundTriplets.add(tripletEntry.getKey());
+ }
+ }
+ if (foundTriplets.size() > 0) {
+ Collections.sort(foundTriplets);
+ return (String)foundTriplets.get(0);
+ }
+ return null;
+ }
+
+ /**
+ * Returns the font style for a particular font.
+ * There may be multiple font styles matching this font. Only the first
+ * found is returned. Searching is done on a sorted list to guarantee consistent
+ * results.
+ * @param fontName internal key
+ * @return font style
+ */
+ public String getFontStyleFor(String fontName) {
+ String triplet = getTripletFor(fontName);
+ if (triplet != null) {
+ return triplet.substring(triplet.indexOf(',') + 1, triplet.lastIndexOf(','));
+ }
+ return "";
+ }
+
+ /**
+ * Returns the font weight for a particular font.
+ * There may be multiple font weights matching this font. Only the first
+ * found is returned. Searching is done on a sorted list to guarantee consistent
+ * results.
+ * @param fontName internal key
+ * @return font weight
+ */
+ public String getFontWeightFor(String fontName) {
+ String triplet = getTripletFor(fontName);
+ if (triplet != null) {
+ return triplet.substring(triplet.lastIndexOf(',') + 1);
+ }
+ return "";
+ }
+
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRenderer.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRenderer.java?rev=232810&r1=232809&r2=232810&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRenderer.java Mon Aug 15 06:23:27 2005
@@ -37,7 +37,7 @@
import org.xml.sax.helpers.AttributesImpl;
// FOP
-import org.apache.fop.render.AbstractRenderer;
+import org.apache.fop.render.PrintRenderer;
import org.apache.fop.render.RendererContext;
import org.apache.fop.render.XMLHandler;
import org.apache.fop.apps.FOUserAgent;
@@ -68,6 +68,7 @@
import org.apache.fop.area.inline.TextArea;
import org.apache.fop.fonts.FontSetup;
import org.apache.fop.fonts.FontInfo;
+import org.apache.fop.fonts.FontMetrics;
/**
* Renderer that renders areas to XML for debugging purposes.
@@ -76,7 +77,7 @@
* The output can be used to build a new area tree (@see AreaTreeBuilder)
* which can be rendered to any renderer.
*/
-public class XMLRenderer extends AbstractRenderer {
+public class XMLRenderer extends PrintRenderer {
/** XML MIME type */
public static final String XML_MIME_TYPE = "application/x-fop-areatree";
@@ -130,15 +131,6 @@
this.handler = handler;
}
- /**
- * set up the font info
- *
- * @param fontInfo the font info object to set up
- */
- public void setupFontInfo(FontInfo fontInfo) {
- FontSetup.setup(fontInfo, null);
- }
-
private boolean isCoarseXml() {
return ((Boolean)
userAgent.getRendererOptions().get("fineDetail")).booleanValue();
@@ -272,6 +264,11 @@
}
String value = traitEntry.getValue().toString();
addAttribute(name, value);
+ if ("font-family".equals(name)) {
+ addAttribute("font-name", fontInfo.getMetricsFor(value).getFontName());
+ addAttribute("font-style", fontInfo.getFontStyleFor(value));
+ addAttribute("font-weight", fontInfo.getFontWeightFor(value));
+ }
}
}
}
Added: xmlgraphics/fop/trunk/test/layoutengine/testcases/font-family.xml
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/test/layoutengine/testcases/font-family.xml?rev=232810&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/test/layoutengine/testcases/font-family.xml (added)
+++ xmlgraphics/fop/trunk/test/layoutengine/testcases/font-family.xml Mon Aug 15 06:23:27 2005
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2005 The Apache Software Foundation
+
+ 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.
+-->
+<!-- $Id$ -->
+<testcase>
+ <info>
+ <p>
+ This test checks the generic font families.
+ </p>
+ </info>
+ <fo>
+ <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
+ <fo:layout-master-set>
+ <fo:simple-page-master master-name="normal" page-width="210mm" page-height="297mm">
+ <fo:region-body/>
+ </fo:simple-page-master>
+ </fo:layout-master-set>
+ <fo:page-sequence master-reference="normal" white-space-collapse="true">
+ <fo:flow flow-name="xsl-region-body">
+ <fo:block>font-family not given</fo:block>
+ <fo:block font-family="serif">font-family="serif"</fo:block>
+ <fo:block font-family="sans-serif">font-family="sans-serif"</fo:block>
+ <fo:block font-family="cursive">font-family="cursive"</fo:block>
+ <fo:block font-family="fantasy">font-family="fantasy"</fo:block>
+ <fo:block font-family="monospace">font-family="monospace"</fo:block>
+ </fo:flow>
+ </fo:page-sequence>
+ </fo:root>
+ </fo>
+ <checks>
+ <eval expected="Helvetica" xpath="//flow/block[1]/lineArea/text/@font-name"/>
+ <eval expected="Times-Roman" xpath="//flow/block[2]/lineArea/text/@font-name"/>
+ <eval expected="Helvetica" xpath="//flow/block[3]/lineArea/text/@font-name"/>
+ <eval expected="Times-Roman" xpath="//flow/block[4]/lineArea/text/@font-name"/>
+ <eval expected="Times-Roman" xpath="//flow/block[5]/lineArea/text/@font-name"/>
+ <eval expected="Courier" xpath="//flow/block[6]/lineArea/text/@font-name"/>
+ </checks>
+</testcase>
Propchange: xmlgraphics/fop/trunk/test/layoutengine/testcases/font-family.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/test/layoutengine/testcases/font-family.xml
------------------------------------------------------------------------------
svn:keywords = Id
Added: xmlgraphics/fop/trunk/test/layoutengine/testcases/font-style.xml
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/test/layoutengine/testcases/font-style.xml?rev=232810&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/test/layoutengine/testcases/font-style.xml (added)
+++ xmlgraphics/fop/trunk/test/layoutengine/testcases/font-style.xml Mon Aug 15 06:23:27 2005
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2005 The Apache Software Foundation
+
+ 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.
+-->
+<!-- $Id$ -->
+<testcase>
+ <info>
+ <p>
+ This test checks font syles.
+ </p>
+ </info>
+ <fo>
+ <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
+ <fo:layout-master-set>
+ <fo:simple-page-master master-name="normal" page-width="210mm" page-height="297mm">
+ <fo:region-body/>
+ </fo:simple-page-master>
+ </fo:layout-master-set>
+ <fo:page-sequence master-reference="normal" white-space-collapse="true">
+ <fo:flow flow-name="xsl-region-body">
+ <fo:block font-family="serif">font-family="serif" font-style not given</fo:block>
+ <fo:block font-family="serif" font-style="normal">font-family="serif" font-style="normal"</fo:block>
+ <fo:block font-family="serif" font-style="italic">font-family="serif" font-style="italic"</fo:block>
+ <fo:block font-family="serif" font-style="oblique">font-family="serif" font-style="oblique"</fo:block>
+ <fo:block font-family="serif" font-style="backslant">font-family="serif" font-style="backslant"</fo:block>
+ <fo:block font-family="serif" font-style="obscure">font-family="serif" font-style="obscure"</fo:block>
+
+ <fo:block font-family="sans-serif">font-family="sans-serif" font-style not given</fo:block>
+ <fo:block font-family="sans-serif" font-style="normal">font-family="sans-serif" font-style="normal"</fo:block>
+ <fo:block font-family="sans-serif" font-style="italic">font-family="sans-serif" font-style="italic"</fo:block>
+ <fo:block font-family="sans-serif" font-style="oblique">font-family="sans-serif" font-style="oblique"</fo:block>
+ <fo:block font-family="sans-serif" font-style="backslant">font-family="sans-serif" font-style="backslant"</fo:block>
+ <fo:block font-family="sans-serif" font-style="obscure">font-family="serif" font-style="obscure"</fo:block>
+
+ <fo:block font-family="monospace">font-family="monospace" font-style not given</fo:block>
+ <fo:block font-family="monospace" font-style="normal">font-family="monospace" font-style="normal"</fo:block>
+ <fo:block font-family="monospace" font-style="italic">font-family="monospace" font-style="italic"</fo:block>
+ <fo:block font-family="monospace" font-style="oblique">font-family="monospace" font-style="oblique"</fo:block>
+ <fo:block font-family="monospace" font-style="backslant">font-family="monospace" font-style="backslant"</fo:block>
+ <fo:block font-family="monospace" font-style="obscure">font-family="serif" font-style="obscure"</fo:block>
+ </fo:flow>
+ </fo:page-sequence>
+ </fo:root>
+ </fo>
+ <checks>
+ <eval expected="normal" xpath="//flow/block[1]/lineArea/text/@font-style"/>
+ <eval expected="normal" xpath="//flow/block[2]/lineArea/text/@font-style"/>
+ <eval expected="italic" xpath="//flow/block[3]/lineArea/text/@font-style"/>
+ <eval expected="italic" xpath="//flow/block[4]/lineArea/text/@font-style"/>
+ <eval expected="normal" xpath="//flow/block[5]/lineArea/text/@font-style"/>
+ <eval expected="normal" xpath="//flow/block[6]/lineArea/text/@font-style"/>
+
+ <eval expected="normal" xpath="//flow/block[7]/lineArea/text/@font-style"/>
+ <eval expected="normal" xpath="//flow/block[8]/lineArea/text/@font-style"/>
+ <eval expected="italic" xpath="//flow/block[9]/lineArea/text/@font-style"/>
+ <eval expected="italic" xpath="//flow/block[10]/lineArea/text/@font-style"/>
+ <eval expected="normal" xpath="//flow/block[11]/lineArea/text/@font-style"/>
+ <eval expected="normal" xpath="//flow/block[12]/lineArea/text/@font-style"/>
+
+ <eval expected="normal" xpath="//flow/block[13]/lineArea/text/@font-style"/>
+ <eval expected="normal" xpath="//flow/block[14]/lineArea/text/@font-style"/>
+ <eval expected="italic" xpath="//flow/block[15]/lineArea/text/@font-style"/>
+ <eval expected="italic" xpath="//flow/block[16]/lineArea/text/@font-style"/>
+ <eval expected="normal" xpath="//flow/block[17]/lineArea/text/@font-style"/>
+ <eval expected="normal" xpath="//flow/block[18]/lineArea/text/@font-style"/>
+ </checks>
+</testcase>
Propchange: xmlgraphics/fop/trunk/test/layoutengine/testcases/font-style.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/test/layoutengine/testcases/font-style.xml
------------------------------------------------------------------------------
svn:keywords = Id
Added: xmlgraphics/fop/trunk/test/layoutengine/testcases/font-weight.xml
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/test/layoutengine/testcases/font-weight.xml?rev=232810&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/test/layoutengine/testcases/font-weight.xml (added)
+++ xmlgraphics/fop/trunk/test/layoutengine/testcases/font-weight.xml Mon Aug 15 06:23:27 2005
@@ -0,0 +1,121 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2005 The Apache Software Foundation
+
+ 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.
+-->
+<!-- $Id$ -->
+<testcase>
+ <info>
+ <p>
+ This test checks font weights.
+ </p>
+ </info>
+ <fo>
+ <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
+ <fo:layout-master-set>
+ <fo:simple-page-master master-name="normal" page-width="210mm" page-height="297mm">
+ <fo:region-body/>
+ </fo:simple-page-master>
+ </fo:layout-master-set>
+ <fo:page-sequence master-reference="normal" white-space-collapse="true">
+ <fo:flow flow-name="xsl-region-body">
+ <fo:block>font-weight not specified</fo:block>
+ <fo:block font-weight="normal">font-weight="normal"</fo:block>
+ <fo:block font-weight="bold">font-weight="bold"</fo:block>
+ <fo:block font-weight="100">font-weight="100"</fo:block>
+ <fo:block font-weight="200">font-weight="200"</fo:block>
+ <fo:block font-weight="300">font-weight="300"</fo:block>
+ <fo:block font-weight="400">font-weight="400"</fo:block>
+ <fo:block font-weight="500">font-weight="500"</fo:block>
+ <fo:block font-weight="600">font-weight="600"</fo:block>
+ <fo:block font-weight="700">font-weight="700"</fo:block>
+ <fo:block font-weight="800">font-weight="800"</fo:block>
+ <fo:block font-weight="900">font-weight="900"
+ <fo:block font-weight="lighter">font-weight="lighter"
+ <fo:block font-weight="lighter">font-weight="lighter"
+ <fo:block font-weight="lighter">font-weight="lighter"
+ <fo:block font-weight="lighter">font-weight="lighter"
+ <fo:block font-weight="lighter">font-weight="lighter"
+ <fo:block font-weight="lighter">font-weight="lighter"
+ <fo:block font-weight="lighter">font-weight="lighter"
+ <fo:block font-weight="lighter">font-weight="lighter"
+ <fo:block font-weight="lighter">font-weight="lighter"
+ </fo:block>
+ </fo:block>
+ </fo:block>
+ </fo:block>
+ </fo:block>
+ </fo:block>
+ </fo:block>
+ </fo:block>
+ </fo:block>
+ </fo:block>
+ <fo:block font-weight="100">font-weight="100"
+ <fo:block font-weight="bolder">font-weight="bolder"
+ <fo:block font-weight="bolder">font-weight="bolder"
+ <fo:block font-weight="bolder">font-weight="bolder"
+ <fo:block font-weight="bolder">font-weight="bolder"
+ <fo:block font-weight="bolder">font-weight="bolder"
+ <fo:block font-weight="bolder">font-weight="bolder"
+ <fo:block font-weight="bolder">font-weight="bolder"
+ <fo:block font-weight="bolder">font-weight="bolder"
+ <fo:block font-weight="bolder">font-weight="bolder"
+ </fo:block>
+ </fo:block>
+ </fo:block>
+ </fo:block>
+ </fo:block>
+ </fo:block>
+ </fo:block>
+ </fo:block>
+ </fo:block>
+ </fo:block>
+ </fo:flow>
+ </fo:page-sequence>
+ </fo:root>
+ </fo>
+ <checks><!-- feature not properly implemented, checks are against current implementation -->
+ <eval expected="400" xpath="//flow/block[1]/lineArea/text/@font-weight"/>
+ <eval expected="400" xpath="//flow/block[2]/lineArea/text/@font-weight"/>
+ <eval expected="700" xpath="//flow/block[3]/lineArea/text/@font-weight"/>
+ <eval expected="400" xpath="//flow/block[4]/lineArea/text/@font-weight"/>
+ <eval expected="400" xpath="//flow/block[5]/lineArea/text/@font-weight"/>
+ <eval expected="400" xpath="//flow/block[6]/lineArea/text/@font-weight"/>
+ <eval expected="400" xpath="//flow/block[7]/lineArea/text/@font-weight"/>
+ <eval expected="400" xpath="//flow/block[8]/lineArea/text/@font-weight"/>
+ <eval expected="700" xpath="//flow/block[9]/lineArea/text/@font-weight"/>
+ <eval expected="700" xpath="//flow/block[10]/lineArea/text/@font-weight"/>
+ <eval expected="700" xpath="//flow/block[11]/lineArea/text/@font-weight"/>
+ <eval expected="700" xpath="//flow/block[12]/lineArea/text/@font-weight"/>
+ <eval expected="400" xpath="//flow/block[13]/block/lineArea/text/@font-weight"/>
+ <eval expected="400" xpath="//flow/block[13]/block/block/lineArea/text/@font-weight"/>
+ <eval expected="400" xpath="//flow/block[13]/block/block/block/lineArea/text/@font-weight"/>
+ <eval expected="400" xpath="//flow/block[13]/block/block/block/block/lineArea/text/@font-weight"/>
+ <eval expected="400" xpath="//flow/block[13]/block/block/block/block/block/lineArea/text/@font-weight"/>
+ <eval expected="400" xpath="//flow/block[13]/block/block/block/block/block/block/lineArea/text/@font-weight"/>
+ <eval expected="400" xpath="//flow/block[13]/block/block/block/block/block/block/block/lineArea/text/@font-weight"/>
+ <eval expected="400" xpath="//flow/block[13]/block/block/block/block/block/block/block/block/lineArea/text/@font-weight"/>
+ <eval expected="400" xpath="//flow/block[13]/block/block/block/block/block/block/block/block/block/lineArea/text/@font-weight"/>
+ <eval expected="400" xpath="//flow/block[13]/lineArea/text/@font-weight"/>
+ <eval expected="400" xpath="//flow/block[13]/block/lineArea/text/@font-weight"/>
+ <eval expected="400" xpath="//flow/block[13]/block/block/lineArea/text/@font-weight"/>
+ <eval expected="400" xpath="//flow/block[13]/block/block/block/lineArea/text/@font-weight"/>
+ <eval expected="400" xpath="//flow/block[13]/block/block/block/block/lineArea/text/@font-weight"/>
+ <eval expected="400" xpath="//flow/block[13]/block/block/block/block/block/lineArea/text/@font-weight"/>
+ <eval expected="400" xpath="//flow/block[13]/block/block/block/block/block/block/lineArea/text/@font-weight"/>
+ <eval expected="400" xpath="//flow/block[13]/block/block/block/block/block/block/block/lineArea/text/@font-weight"/>
+ <eval expected="400" xpath="//flow/block[13]/block/block/block/block/block/block/block/block/lineArea/text/@font-weight"/>
+ <eval expected="400" xpath="//flow/block[13]/block/block/block/block/block/block/block/block/block/lineArea/text/@font-weight"/>
+ </checks>
+</testcase>
Propchange: xmlgraphics/fop/trunk/test/layoutengine/testcases/font-weight.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/test/layoutengine/testcases/font-weight.xml
------------------------------------------------------------------------------
svn:keywords = Id
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org