git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@554088 13f79535-47bb-0310-9956-ffa450edef68pull/36/head
@@ -132,23 +132,18 @@ public class CommonFont { | |||
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; |
@@ -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; | |||
} | |||
} | |||
} |
@@ -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> | |||
@@ -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> |