Author: czadra
Date: Tue Dec 4 08:48:51 2012
New Revision: 1416819
URL: http://svn.apache.org/viewvc?rev=1416819&view=rev
Log:
implemented missing methods getSourceType() & getSourceValue() and
getEmbedAsCFF() in CSSFontFace
Modified:
incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSFontFaceTests.java
incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/css/CSSFontFace.java
Modified:
incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSFontFaceTests.java
URL:
http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSFontFaceTests.java?rev=1416819&r1=1416818&r2=1416819&view=diff
==============================================================================
---
incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSFontFaceTests.java
(original)
+++
incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/css/CSSFontFaceTests.java
Tue Dec 4 08:48:51 2012
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertTha
import java.util.List;
+import org.apache.flex.compiler.css.FontFaceSourceType;
import org.apache.flex.compiler.css.ICSSFontFace;
import org.junit.Test;
@@ -66,11 +67,9 @@ public class CSSFontFaceTests extends CS
assertThat("fontface.getFontStyle()" , fontface.getFontStyle(),
is( "normal" ) );
assertThat("fontface.getFontWeight()" ,
fontface.getFontWeight(), is( "normal" ) );
assertThat("fontface.getAdvancedAntiAliasing()" ,
fontface.getAdvancedAntiAliasing(), is( true ) );
-
- //TODO Implement missing methods getSourceType() &
getSourceValue() & getEmbedAsCFF()
- //assertThat("fontface.getSourceType()" ,
fontface.getSourceType(), is( FontFaceSourceType.URL ) );
- //assertThat("fontface.getSourceValue()" ,
fontface.getSourceValue(), is( "font.ttf" ) );
- //assertThat("fontface.getEmbedAsCFF()" ,
fontface.getEmbedAsCFF(), is( true ) );
+ assertThat("fontface.getSourceType()" ,
fontface.getSourceType(), is( FontFaceSourceType.URL ) );
+ assertThat("fontface.getSourceValue()" ,
fontface.getSourceValue(), is( "font.ttf" ) );
+ assertThat("fontface.getEmbedAsCFF()" ,
fontface.getEmbedAsCFF(), is( true ) );
}
@@ -94,11 +93,9 @@ public class CSSFontFaceTests extends CS
assertThat("fontface.getFontStyle()" , fontface.getFontStyle(),
is( "italic" ) );
assertThat("fontface.getFontWeight()" ,
fontface.getFontWeight(), is( "bold" ) );
assertThat("fontface.getAdvancedAntiAliasing()" ,
fontface.getAdvancedAntiAliasing(), is( true ) );
-
- //TODO Implement missing methods getSourceType() &
getSourceValue() & getEmbedAsCFF()
- //assertThat("fontface.getSourceType()" ,
fontface.getSourceType(), is( FontFaceSourceType.URL ) );
- //assertThat("fontface.getSourceValue()" ,
fontface.getSourceValue(), is( "font.ttf" ) );
- //assertThat("fontface.getEmbedAsCFF()" ,
fontface.getEmbedAsCFF(), is( true ) );
+ assertThat("fontface.getSourceType()" ,
fontface.getSourceType(), is( FontFaceSourceType.URL ) );
+ assertThat("fontface.getSourceValue()" ,
fontface.getSourceValue(), is( "font.ttf" ) );
+ assertThat("fontface.getEmbedAsCFF()" ,
fontface.getEmbedAsCFF(), is( true ) );
}
@Test
@@ -121,11 +118,9 @@ public class CSSFontFaceTests extends CS
assertThat("fontface.getFontStyle()" , fontface.getFontStyle(),
is( "oblique" ) );
assertThat("fontface.getFontWeight()" ,
fontface.getFontWeight(), is( "heavy" ) );
assertThat("fontface.getAdvancedAntiAliasing()" ,
fontface.getAdvancedAntiAliasing(), is( true ) );
-
- //TODO Implement missing methods getSourceType() &
getSourceValue() & getEmbedAsCFF()
- //assertThat("fontface.getSourceType()" ,
fontface.getSourceType(), is( FontFaceSourceType.URL ) );
- //assertThat("fontface.getSourceValue()" ,
fontface.getSourceValue(), is( "font.ttf" ) );
- //assertThat("fontface.getEmbedAsCFF()" ,
fontface.getEmbedAsCFF(), is( true ) );
+ assertThat("fontface.getSourceType()" ,
fontface.getSourceType(), is( FontFaceSourceType.URL ) );
+ assertThat("fontface.getSourceValue()" ,
fontface.getSourceValue(), is( "font.ttf" ) );
+ assertThat("fontface.getEmbedAsCFF()" ,
fontface.getEmbedAsCFF(), is( true ) );
}
@@ -145,11 +140,9 @@ public class CSSFontFaceTests extends CS
assertThat("fontface.getFontStyle()" , fontface.getFontStyle(),
is( "normal" ) );
assertThat("fontface.getFontWeight()" ,
fontface.getFontWeight(), is( "normal" ) );
assertThat("fontface.getAdvancedAntiAliasing()" ,
fontface.getAdvancedAntiAliasing(), is( true ) );
-
- //TODO Implement missing methods getSourceType() &
getSourceValue() & getEmbedAsCFF()
- //assertThat("fontface.getSourceType()" ,
fontface.getSourceType(), is( FontFaceSourceType.LOCAL ) );
- //assertThat("fontface.getSourceValue()" ,
fontface.getSourceValue(), is( "Myriad Web Pro" ) );
- //assertThat("fontface.getEmbedAsCFF()" ,
fontface.getEmbedAsCFF(), is( true ) );
+ assertThat("fontface.getSourceType()" ,
fontface.getSourceType(), is( FontFaceSourceType.LOCAL ) );
+ assertThat("fontface.getSourceValue()" ,
fontface.getSourceValue(), is( "Myriad Web Pro" ) );
+ assertThat("fontface.getEmbedAsCFF()" ,
fontface.getEmbedAsCFF(), is( true ) );
}
@Test
@@ -168,13 +161,53 @@ public class CSSFontFaceTests extends CS
assertThat("fontface.getFontStyle()" , fontface.getFontStyle(),
is( "normal" ) );
assertThat("fontface.getFontWeight()" ,
fontface.getFontWeight(), is( "normal" ) );
assertThat("fontface.getAdvancedAntiAliasing()" ,
fontface.getAdvancedAntiAliasing(), is( true ) );
+ assertThat("fontface.getSourceType()" ,
fontface.getSourceType(), is( FontFaceSourceType.URL ) );
+ assertThat("fontface.getSourceValue()" ,
fontface.getSourceValue(), is( "assets/font.ttf" ) );
+ assertThat("fontface.getEmbedAsCFF()" ,
fontface.getEmbedAsCFF(), is( true ) );
+ }
+
+ @Test
+ public void CSSFontFaceTests_embedAsCFF()
+ {
+ String code =
+ " src: url(\"assets/font.ttf\");" + EOL +
+ " fontFamily: font;" + EOL +
+ " embedAsCFF: false;";
+
+ List<ICSSFontFace> fontfaces = getCSSFontFace(code);
+ assertThat("fontfaces.size()" , fontfaces.size(), is(1) );
- //TODO Implement missing methods getSourceType() &
getSourceValue() & getEmbedAsCFF()
- //assertThat("fontface.getSourceType()" ,
fontface.getSourceType(), is( FontFaceSourceType.URL ) );
- //assertThat("fontface.getSourceValue()" ,
fontface.getSourceValue(), is( "Myriad Web Pro" ) );
- //assertThat("fontface.getEmbedAsCFF()" ,
fontface.getEmbedAsCFF(), is( true ) );
+ CSSFontFace fontface = (CSSFontFace) fontfaces.get(0);
+ assertThat("fontface.getOperator()" , fontface.getOperator(),
is( CSSModelTreeType.FONT_FACE ) );
+ assertThat("fontface.getFontFamily()" ,
fontface.getFontFamily(), is( "font" ) );
+ assertThat("fontface.getFontStyle()" , fontface.getFontStyle(),
is( "normal" ) );
+ assertThat("fontface.getFontWeight()" ,
fontface.getFontWeight(), is( "normal" ) );
+ assertThat("fontface.getAdvancedAntiAliasing()" ,
fontface.getAdvancedAntiAliasing(), is( true ) );
+ assertThat("fontface.getSourceType()" ,
fontface.getSourceType(), is( FontFaceSourceType.URL ) );
+ assertThat("fontface.getSourceValue()" ,
fontface.getSourceValue(), is( "assets/font.ttf" ) );
+ assertThat("fontface.getEmbedAsCFF()" ,
fontface.getEmbedAsCFF(), is( false ) );
}
-
+ @Test
+ public void CSSFontFaceTests_advancedAntiAliasing()
+ {
+ String code =
+ " src: url(\"assets/font.ttf\");" + EOL +
+ " fontFamily: font;" + EOL +
+ " advancedAntiAliasing: false;";
+
+ List<ICSSFontFace> fontfaces = getCSSFontFace(code);
+ assertThat("fontfaces.size()" , fontfaces.size(), is(1) );
+
+ CSSFontFace fontface = (CSSFontFace) fontfaces.get(0);
+ assertThat("fontface.getOperator()" , fontface.getOperator(),
is( CSSModelTreeType.FONT_FACE ) );
+ assertThat("fontface.getFontFamily()" ,
fontface.getFontFamily(), is( "font" ) );
+ assertThat("fontface.getFontStyle()" , fontface.getFontStyle(),
is( "normal" ) );
+ assertThat("fontface.getFontWeight()" ,
fontface.getFontWeight(), is( "normal" ) );
+ assertThat("fontface.getAdvancedAntiAliasing()" ,
fontface.getAdvancedAntiAliasing(), is( false ) );
+ assertThat("fontface.getSourceType()" ,
fontface.getSourceType(), is( FontFaceSourceType.URL ) );
+ assertThat("fontface.getSourceValue()" ,
fontface.getSourceValue(), is( "assets/font.ttf" ) );
+ assertThat("fontface.getEmbedAsCFF()" ,
fontface.getEmbedAsCFF(), is( true ) );
+ }
}
Modified:
incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/css/CSSFontFace.java
URL:
http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/css/CSSFontFace.java?rev=1416819&r1=1416818&r2=1416819&view=diff
==============================================================================
---
incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/css/CSSFontFace.java
(original)
+++
incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/css/CSSFontFace.java
Tue Dec 4 08:48:51 2012
@@ -57,6 +57,7 @@ public class CSSFontFace extends CSSNode
ICSSPropertyValue fontFamilyValue = null;
ICSSPropertyValue fontStyleValue = null;
ICSSPropertyValue fontWeightValue = null;
+ ICSSPropertyValue embedAsCFFValue = null;
ICSSPropertyValue advancedAAValue = null;
for (final ICSSProperty property : properties)
@@ -79,6 +80,10 @@ public class CSSFontFace extends CSSNode
{
fontWeightValue = value;
}
+ else if (name.equals("embedAsCFF"))
+ {
+ embedAsCFFValue = value;
+ }
else if (name.equals("advancedAntiAliasing"))
{
advancedAAValue = value;
@@ -97,6 +102,8 @@ public class CSSFontFace extends CSSNode
fontStyle = fontStyleValue == null ? "normal" :
fontStyleValue.toString();
fontWeight = fontWeightValue == null ? "normal" :
fontWeightValue.toString();
+ isEmbedAsCFF = embedAsCFFValue == null ?
+ true : embedAsCFFValue.toString().equalsIgnoreCase("true");
isAdvancedAntiAliasing = advancedAAValue == null ?
true : advancedAAValue.toString().equalsIgnoreCase("true");
@@ -106,18 +113,23 @@ public class CSSFontFace extends CSSNode
private final String fontFamily;
private final String fontStyle;
private final String fontWeight;
+ private final boolean isEmbedAsCFF;
private final boolean isAdvancedAntiAliasing;
@Override
public FontFaceSourceType getSourceType()
{
- throw new UnsupportedOperationException("need an css function call sub
parser");
+ return Enum.valueOf(FontFaceSourceType.class,
source.name.toUpperCase());
}
@Override
public String getSourceValue()
{
- throw new UnsupportedOperationException("need an css function call sub
parser");
+ String sourceValue = null;
+ if(FontFaceSourceType.URL.equals(getSourceType())
+ || FontFaceSourceType.LOCAL.equals(getSourceType()))
+ sourceValue =
CSSFunctionCallPropertyValue.getSingleArgumentFromRaw(source.rawArguments);
+ return sourceValue;
}
@Override
@@ -137,6 +149,11 @@ public class CSSFontFace extends CSSNode
{
return fontWeight;
}
+
+ public boolean getEmbedAsCFF()
+ {
+ return isEmbedAsCFF;
+ }
@Override
public boolean getAdvancedAntiAliasing()
@@ -153,6 +170,7 @@ public class CSSFontFace extends CSSNode
.append(source)
.append(";\n");
result.append(" fontFamily : ").append(fontFamily).append(";\n");
+ result.append(" embedAsCFF : ").append(isEmbedAsCFF);
result.append(" advancedAntiAliasing : ")
.append(isAdvancedAntiAliasing)
.append(";\n");