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 ad...@apache.org on 2007/07/07 01:30:15 UTC
svn commit: r554088 - in /xmlgraphics/fop/trunk:
src/java/org/apache/fop/fo/properties/ test/fotree/testcases/
test/layoutengine/standard-testcases/
Author: adelmelle
Date: Fri Jul 6 16:30:14 2007
New Revision: 554088
URL: http://svn.apache.org/viewvc?view=rev&rev=554088
Log:
Improvement in handling relative font-weights
Added:
xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/FontWeightPropertyMaker.java (with props)
xmlgraphics/fop/trunk/test/fotree/testcases/font-weight_relative2.fo (with props)
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/CommonFont.java
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/block_font-weight.xml
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/CommonFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/CommonFont.java?view=diff&rev=554088&r1=554087&r2=554088
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/CommonFont.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/CommonFont.java Fri Jul 6 16:30:14 2007
@@ -132,23 +132,18 @@
if (fontState == null) {
/**@todo this is ugly. need to improve. */
- int font_weight = 400;
- if (fontWeight == Constants.EN_BOLDER) {
- // +100 from inherited
- } else if (fontWeight == Constants.EN_LIGHTER) {
- // -100 from inherited
- } else {
- switch (fontWeight) {
- case Constants.EN_100: font_weight = 100; break;
- case Constants.EN_200: font_weight = 200; break;
- case Constants.EN_300: font_weight = 300; break;
- case Constants.EN_400: font_weight = 400; break;
- case Constants.EN_500: font_weight = 500; break;
- case Constants.EN_600: font_weight = 600; break;
- case Constants.EN_700: font_weight = 700; break;
- case Constants.EN_800: font_weight = 800; break;
- case Constants.EN_900: font_weight = 900; break;
- }
+ int font_weight;
+ switch (fontWeight) {
+ case Constants.EN_100: font_weight = 100; break;
+ case Constants.EN_200: font_weight = 200; break;
+ case Constants.EN_300: font_weight = 300; break;
+ case Constants.EN_400: font_weight = 400; break;
+ case Constants.EN_500: font_weight = 500; break;
+ case Constants.EN_600: font_weight = 600; break;
+ case Constants.EN_700: font_weight = 700; break;
+ case Constants.EN_800: font_weight = 800; break;
+ case Constants.EN_900: font_weight = 900; break;
+ default: font_weight = 400;
}
String style;
Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/FontWeightPropertyMaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/FontWeightPropertyMaker.java?view=auto&rev=554088
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/FontWeightPropertyMaker.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/FontWeightPropertyMaker.java Fri Jul 6 16:30:14 2007
@@ -0,0 +1,129 @@
+/*
+ * 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.fo.properties;
+
+import org.apache.fop.fo.Constants;
+import org.apache.fop.fo.FObj;
+import org.apache.fop.fo.PropertyList;
+import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.fo.expr.PropertyInfo;
+import org.apache.fop.fo.expr.PropertyParser;
+
+public class FontWeightPropertyMaker extends EnumProperty.Maker {
+
+ /**
+ * Main constructor
+ * @param propId the property id
+ */
+ public FontWeightPropertyMaker(int propId) {
+ super(propId);
+ }
+
+ /**
+ * @see org.apache.fop.fo.properties.PropertyMaker#make(PropertyList, String, FObj)
+ */
+ public Property make(PropertyList pList, String value, FObj fo)
+ throws PropertyException {
+ if ("inherit".equals(value)) {
+ return super.make(pList, value, fo);
+ } else {
+ String pValue = checkValueKeywords(value);
+ Property newProp = checkEnumValues(pValue);
+ int enumValue = -1;
+ if (newProp != null
+ && ((enumValue = newProp.getEnum()) == Constants.EN_BOLDER
+ || enumValue == Constants.EN_LIGHTER)) {
+ /* check for relative enum values, compute in relation to parent */
+ Property parentProp = pList.getInherited(Constants.PR_FONT_WEIGHT);
+ if (enumValue == Constants.EN_BOLDER) {
+ enumValue = parentProp.getEnum();
+ switch (enumValue) {
+ case Constants.EN_100:
+ newProp = EnumProperty.getInstance(Constants.EN_200, "200");
+ break;
+ case Constants.EN_200:
+ newProp = EnumProperty.getInstance(Constants.EN_300, "300");
+ break;
+ case Constants.EN_300:
+ newProp = EnumProperty.getInstance(Constants.EN_400, "400");
+ break;
+ case Constants.EN_400:
+ newProp = EnumProperty.getInstance(Constants.EN_500, "500");
+ break;
+ case Constants.EN_500:
+ newProp = EnumProperty.getInstance(Constants.EN_600, "600");
+ break;
+ case Constants.EN_600:
+ newProp = EnumProperty.getInstance(Constants.EN_700, "700");
+ break;
+ case Constants.EN_700:
+ newProp = EnumProperty.getInstance(Constants.EN_800, "800");
+ break;
+ case Constants.EN_800:
+ case Constants.EN_900:
+ newProp = EnumProperty.getInstance(Constants.EN_900, "900");
+ break;
+ default:
+ //nop
+ }
+ } else {
+ enumValue = parentProp.getEnum();
+ switch (enumValue) {
+ case Constants.EN_100:
+ case Constants.EN_200:
+ newProp = EnumProperty.getInstance(Constants.EN_100, "100");
+ break;
+ case Constants.EN_300:
+ newProp = EnumProperty.getInstance(Constants.EN_200, "200");
+ break;
+ case Constants.EN_400:
+ newProp = EnumProperty.getInstance(Constants.EN_300, "300");
+ break;
+ case Constants.EN_500:
+ newProp = EnumProperty.getInstance(Constants.EN_400, "400");
+ break;
+ case Constants.EN_600:
+ newProp = EnumProperty.getInstance(Constants.EN_500, "500");
+ break;
+ case Constants.EN_700:
+ newProp = EnumProperty.getInstance(Constants.EN_600, "600");
+ break;
+ case Constants.EN_800:
+ newProp = EnumProperty.getInstance(Constants.EN_700, "700");
+ break;
+ case Constants.EN_900:
+ newProp = EnumProperty.getInstance(Constants.EN_800, "800");
+ break;
+ default:
+ //nop
+ }
+ }
+ } else if (enumValue == -1) {
+ /* neither a keyword, nor an enum
+ * still maybe a valid expression, so send it through the parser... */
+ newProp = PropertyParser.parse(value, new PropertyInfo(this, pList));
+ }
+ if (newProp != null) {
+ newProp = convertProperty(newProp, pList, fo);
+ }
+ return newProp;
+ }
+ }
+
+}
Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/FontWeightPropertyMaker.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/FontWeightPropertyMaker.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: xmlgraphics/fop/trunk/test/fotree/testcases/font-weight_relative2.fo
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/fotree/testcases/font-weight_relative2.fo?view=auto&rev=554088
==============================================================================
--- xmlgraphics/fop/trunk/test/fotree/testcases/font-weight_relative2.fo (added)
+++ xmlgraphics/fop/trunk/test/fotree/testcases/font-weight_relative2.fo Fri Jul 6 16:30:14 2007
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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$ -->
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:test="http://xmlgraphics.apache.org/fop/test">
+ <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="900">font-weight="900"
+ <test:assert property="font-weight" expected="900" />
+ <fo:block font-weight="lighter">font-weight="lighter"
+ <test:assert property="font-weight" expected="800" />
+ <fo:block font-weight="lighter">font-weight="lighter"
+ <test:assert property="font-weight" expected="700" />
+ <fo:block font-weight="lighter">font-weight="lighter"
+ <test:assert property="font-weight" expected="600" />
+ <fo:block font-weight="lighter">font-weight="lighter"
+ <test:assert property="font-weight" expected="500" />
+ <fo:block font-weight="lighter">font-weight="lighter"
+ <test:assert property="font-weight" expected="400" />
+ <fo:block font-weight="lighter">font-weight="lighter"
+ <test:assert property="font-weight" expected="300" />
+ <fo:block font-weight="lighter">font-weight="lighter"
+ <test:assert property="font-weight" expected="200" />
+ <fo:block font-weight="lighter">font-weight="lighter"
+ <test:assert property="font-weight" expected="100" />
+ <fo:block font-weight="lighter">font-weight="lighter"
+ <test:assert property="font-weight" expected="100" />
+ </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"
+ <test:assert property="font-weight" expected="100" />
+ <fo:block font-weight="bolder">font-weight="bolder"
+ <test:assert property="font-weight" expected="200" />
+ <fo:block font-weight="bolder">font-weight="bolder"
+ <test:assert property="font-weight" expected="300" />
+ <fo:block font-weight="bolder">font-weight="bolder"
+ <test:assert property="font-weight" expected="400" />
+ <fo:block font-weight="bolder">font-weight="bolder"
+ <test:assert property="font-weight" expected="500" />
+ <fo:block font-weight="bolder">font-weight="bolder"
+ <test:assert property="font-weight" expected="600" />
+ <fo:block font-weight="bolder">font-weight="bolder"
+ <test:assert property="font-weight" expected="700" />
+ <fo:block font-weight="bolder">font-weight="bolder"
+ <test:assert property="font-weight" expected="800" />
+ <fo:block font-weight="bolder">font-weight="bolder"
+ <test:assert property="font-weight" expected="900" />
+ <fo:block font-weight="bolder">font-weight="bolder"
+ <test:assert property="font-weight" expected="900" />
+ </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>
+
Propchange: xmlgraphics/fop/trunk/test/fotree/testcases/font-weight_relative2.fo
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/test/fotree/testcases/font-weight_relative2.fo
------------------------------------------------------------------------------
svn:keywords = Id
Modified: xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/block_font-weight.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/block_font-weight.xml?view=diff&rev=554088&r1=554087&r2=554088
==============================================================================
--- xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/block_font-weight.xml (original)
+++ xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/block_font-weight.xml Fri Jul 6 16:30:14 2007
@@ -86,7 +86,7 @@
</fo:page-sequence>
</fo:root>
</fo>
- <checks><!-- feature not properly implemented, checks are against current implementation -->
+ <checks>
<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"/>
@@ -99,24 +99,24 @@
<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="700" xpath="//flow/block[12]/block/lineArea/text/@font-weight"/>
+ <eval expected="700" xpath="//flow/block[12]/block/block/lineArea/text/@font-weight"/>
+ <eval expected="700" xpath="//flow/block[12]/block/block/block/lineArea/text/@font-weight"/>
+ <eval expected="400" xpath="//flow/block[12]/block/block/block/block/lineArea/text/@font-weight"/>
+ <eval expected="400" xpath="//flow/block[12]/block/block/block/block/block/lineArea/text/@font-weight"/>
+ <eval expected="400" xpath="//flow/block[12]/block/block/block/block/block/block/lineArea/text/@font-weight"/>
+ <eval expected="400" xpath="//flow/block[12]/block/block/block/block/block/block/block/lineArea/text/@font-weight"/>
+ <eval expected="400" xpath="//flow/block[12]/block/block/block/block/block/block/block/block/lineArea/text/@font-weight"/>
+ <eval expected="400" xpath="//flow/block[12]/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"/>
+ <eval expected="700" xpath="//flow/block[13]/block/block/block/block/block/lineArea/text/@font-weight"/>
+ <eval expected="700" xpath="//flow/block[13]/block/block/block/block/block/block/lineArea/text/@font-weight"/>
+ <eval expected="700" xpath="//flow/block[13]/block/block/block/block/block/block/block/lineArea/text/@font-weight"/>
+ <eval expected="700" xpath="//flow/block[13]/block/block/block/block/block/block/block/block/lineArea/text/@font-weight"/>
+ <eval expected="700" xpath="//flow/block[13]/block/block/block/block/block/block/block/block/block/lineArea/text/@font-weight"/>
</checks>
</testcase>
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org