I’ve been building internationalised Flash content for years now and it’s always been flawed when it comes to languages like Arabic so the most exciting thing about FP10 to me was the Text Layout engine. I’ve spent the last few days playing round with the Flash Player 10 AS3 Flex 4 Text Layout Engine (formerly Vellum) and trying to get embedding fonts to work. It’s been a bit frustrating as there are few examples online and I haven’t yet been able to get embedding fonts to work without using Flex Builder (was attempting to use FDT and pure actionscript but no dice yet @ May 22 ’09)
UPDATE: Got this working with no MXML in FDT compiling against Flex SDK 220.127.116.1152. FDT Project src below:
@UPDATE May 26t 09h: FDT no MXML version : app here – FDT Project src here
#OLD Anyway here’s what you’re after, an example (some hindi poetry) and some gloriously open source (get the source from the Flex Builder srcview tree):
Examples with embedded fonts using the new Text Engine are thin on the ground, partly due to proprietary font files. I’ve picked JanaHindi as it’s open source and freely downloadable from here courtesy of our friends the Indian Government. Namaskar
If you want to compile this you’ll need the FP10 debuggers, Flex Builder (I have standalone 3.0214193) compiling against the latest Adobe (not open source) SDK from http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4 I had luck with 18.104.22.1685. For the Text Engine Layout components, the package flash.text.engine and flashx.textLayout come bundled with recent builds of the Gumbo SDK. If you want just the textLayout package, use a nightly build from http://labs.adobe.com/downloads/textlayout.html
API changes like the renaming of hostParagraphFormat and DisplayObjectContainerController ( now hostFormat & ContainerController respectively) and function names like flowComposer.updateAllContainers which is now flowComposer.updateAllControllers make things a bit tricky as they change on a per nightly build basis but I found that using the ASDoc from specific builds and some common sense you can get around most of these. Running other examples I kept getting the error :
ArgumentError: Error #1063: Argument count mismatch on flashx.textLayout.property::NumberProperty(). Expected 6, got 5 [/code]
…whenever I instantiated a ParagraphFormat. I am just putting all the issues I came across here as googling them should then show up this post and help people out.
I think the key thing is to remember to add CFF (Compact Font Format) as an embed arg and understand the differences between DefineFont3 and DefineFont4 http://opensource.adobe.com/wiki/display/flexsdk/Gumbo+Font+Embedding
As mentioned I am currently unable to get embedded fonts to transcode and embed correctly using FDT despite compiling against the same SDK. I prefer FDT to Flex Builder and in my opinion Flex has some serious drawbacks, principally in the way it bloats everything with hundreds of kilobytes of framework code that I have no intention of using, though lets not get into the Flex bashing, it’s a post for another day! I have just collected a few things that people may find useful…
Transcoding – I experienced numerous errors with seemingly identical files. OpenType and Truetype information may or may not be present in font files which are identical as far as WinXP is concerned. As I’m not hardcore into typography I don’t have FontLab or any such goodies so I can only conjecture that there must be some sort of metadata required but I know not what. Digging around online a lot of people were able to solve this by using these compiler mods. I was not:
Flex 4 Gumbo SDK issues:
- I kept getting errors related to the Gumbo namespacing e.g: “Could not resolve <Application> to a component implementation.” my solution is in the posted source code.
- Design view doesn’t work with the Text Layout Components (not bothered and doesn’t affect the finished SWF)
- Remember to edit project preferences to target FP10 (I just publish the SWF direct & skip FB’s HTML integration)
There are a few nice articles I recommend checking out too:
That last one explains why Text Engine text is not compatible with flash.text.TextField text and why you’ll have to embed the same font in a project twice at present if you wish to mix and match the methodologies. It also mentions performance issues with Vellum but I can’t verify these yet.
Adobe make great software & it’s only pragmatic that they nail down the API in one branch before they spread it out across their toolsets but why is it the Flex branch rather than the pure Actionscript one where the focus is? I would suspect this is a tactical business decision to flog Flex Builder. In my opinion anything that is possible in Flex should also be possible in Flash/Pure Actionscript and vice versa; they are 2 sides of the same coin – I’ve no vested interest in either I just want tools that make complex jobs simpler. The most annoying aspect of “Flex Creep” is things like the Embed tags creating Classes that extend items within the Flex specific MX package. Here’s an example – this Embed code:
fontName = "JanaHindi",
mimeType = "application/x-font",
public static var JanaHindiClass : Class;
Creates a Class that extends mx.core.FontAsset - forcing you to include the otherwise unnecessay Flex MX framework
Anyone from Adobe listening – Please don’t do this! And also Text Layout Engine is such a mouthful, can we go back to Vellum? Is this a copyright issue?
Anyway, I hope that was useful – thanks to anyone who made it all the way through! Cheerio