Phil,
I did one final optimization. The code handles font/face tag combinations as 
well. If there's no embedascff attribute found on a <font> tag, the default 
value for embedAsCFF in AS3 will be false. If the attribute is set, the 
attribute will be copied over to the face element within 
FontCompiler#compile(Element element)

        <font name="cousine-cffenabled" embedascff="true">
            <face style="plain" src="Cousine-Regular.ttf" />
            <face style="italic" src="Cousine-Italic.ttf" />
            <face style="bold" src="Cousine-Bold.ttf" />
            <face style="bold italic" src="Cousine-BoldItalic.ttf" />
        </font>

- Raju

Change raju-20111014-aaS by [email protected] on 2011-10-14 12:56:41 CEST
    in /Users/raju/src/svn/openlaszlo/tlf
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: Add support of embedAsCFF property for embedded fonts in the SWF10 
runtime

New Features: Font tag supports embedascff property with boolean value

Bugs Fixed: LPP-10093

Technical Reviewer: [email protected] [email protected]
QA Reviewer: (pending)
Doc Reviewer: (pending)

Documentation:


Release Notes:
Add support for CFF font embedding in the ActionScript3 runtime (Flash Player 
10+). Adobe's Text Layout Framework (TLF) requires fonts to be embedded as CFF 
to support all the features of the TLF.

Overview:
You can now set an optional attribute 'embedascff' on the <font> tag (e.g. 
<font name="myFont" src="file.ttf" embedascff="true" />) to embed a font, 
setting the AS3 embedAsCFF option to 'true'. The default value for embedascff 
is "false" (the default value within Flash is 'true'), to be compatible with 
existing code.
    

Details:
FontCompiler#compile copies a possible "embedascff" attribute on a <font> tag 
over to any <face> children for processing.
FontCompiler#compileFont checks for an attribute "embedascff" on the <font> 
tag. If the attribute is not found, the default value is set to "false". 
SWF9Writer#importFontStyle is called with the value as an additional argument 
to the method.
SWF9Writer#importFontStyle passes the embedAsCFF parameter value on to 
SWF9Writer#importFont.
SWF9Writer#importFont - which generates the AS3 font embedding code - has an 
additional parameter 'String embedAsCFF'. 
In ObjectWriter - the abstract base class for SWF9Writer - the signature of 
importFontStyle had to be modified to take the additional embedAsCFF parameter.
For all other classes extending ObjectWriter (SWFWriter.java, DHTMLWriter.java, 
NullWriter.java ), the method importFontStyle has an additional parameter 
embedAsCFF now (value can be ignored).

Tests:
Compile test/tlf/embedascff.lzx using the SWF10 runtime. The font 
KentuckyFriedChickenFont.ttf has been embedded two times: With embedascff set 
to true and false.
1) Validate that the <text> element does not render CFF fonts
The <text> element in line #152 should not be displayed:
        <text font="ChickenCFF" fontsize="15">Text with font ChickenCFF</text>
2) Validate that TextFlow (TLF) renders CFF enabled fonts correctly
You will see two poems in a gray box. Both are rendered using an TFL TextFlow 
instance. The left one uses the CFF enabled font, so you should see the 
KentuckyFriedChickenFont.ttf rendered correctly. The right box does not render 
the font correctly, since it has been embedded with embedAsCFF set to false.
3) Check the generated source code for the [Embed] information
The [Embed] element should show that the font has been embedded two times, once 
with embedAsCFF set to true, once set to false.
[Embed(mimeType='application/x-font', 
source='/Users/raju/src/svn/openlaszlo/tlf/test/resources/ttf/KentuckyFriedChickenFont.ttf',
 fontName='ChickenCFF', 
fontWeight='plain',fontStyle='plain',advancedAntiAliasing='true',embedAsCFF='true')]
[Embed(mimeType='application/x-font', 
source='/Users/raju/src/svn/openlaszlo/tlf/test/resources/ttf/KentuckyFriedChickenFont.ttf',
 fontName='ChickenNoCFF', 
fontWeight='plain',fontStyle='plain',advancedAntiAliasing='true',embedAsCFF='false')]

Files:
A       test/tlf/embedascff.lzx
M       WEB-INF/lps/server/src/org/openlaszlo/compiler/ObjectWriter.java
M       WEB-INF/lps/server/src/org/openlaszlo/compiler/DHTMLWriter.java
M       WEB-INF/lps/server/src/org/openlaszlo/compiler/NullWriter.java
M       WEB-INF/lps/server/src/org/openlaszlo/compiler/SWFWriter.java
M       WEB-INF/lps/server/src/org/openlaszlo/compiler/FontCompiler.java
M       WEB-INF/lps/server/src/org/openlaszlo/compiler/SWF9Writer.java

Changeset: http://svn.openlaszlo.org/openlaszlo/patches/raju-20111014-aaS.tar

Reply via email to