FP10 AS3 TextLayout TTF transcoding

27 05 2009

 Further to my last post about intl text, I have solved some of the issues and found resources for Arabic as well as Hindi. I thought I’d list the error that Flex SDK 4.0.0.7052 chucks when I try to transcode certain TTF files:

Error: unable to build font ‘B Nasim’

[Embed(source=‘/../fonts/arabic/BNasimBd.ttf’,
^

Error: Unable to transcode /../fonts/arabic/BNasimBd.ttf.

^

I’ve also noticed that I only experience these transcoding issues that I mention on fonts where the font name contains a space, this could perhaps be a coincidence but it’s coming up a little too frequently for it to be chance. If you have a font that you are forced to use; I would consider editing it in FontLab or similar and modifying the font name metadata.



Flash Player 10 AS3 Text Layout Engine Dynamic Selectable Embedded TTF’s

26 05 2009

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 4.0.0.7052. 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):

Flash Player 10 text engine vellum example

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  4.0.0.705. 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
 

…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:

  • -managers=flash.fonts.AFEFontManager
  • -managers=flash.fonts.JREFontManager
  • -managers=flash.fonts.BatikFontManager

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:

[Embed(source=‘/../fonts/RKJanaHindi.TTF’,
fontName = “JanaHindi”,
mimeType = “application/x-font”,
cff=‘true’)]
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



Multiple Face detection in AS3 using OpenCV demo

30 04 2009

fdt_as3_me_and_jens.jpg I got a mutiple face detection in Flash application running smoothly which is rather nice :) Thanks a million to Squidder and to the original author of the OpenCV file @ Intel, Rainer Lienhart. The deploy has  a zipped up XML document with Haar Classifier pattern recognition…

The AS3 unzips this data, grabs the blob/face detection data, polls frames from the camera and scans them for faces. When it finds them it will draw a rectangle around the detected faces and render them back on top of the video feed.

Check it out at http://bit.ly/HYkJF

A quick nose at the OpenCV Wikipedia stub will show you just how interesting this technology is as it’s used for:

FDT made knocking this together and sharing it on SVN in house at Glue a breeze. Hopefully I’ll knock something up with this and share some source other than what Squidder has already kindly posted.

Cheerio



Recent work & Cross Domain discoveries

7 04 2009

The Sun workThere have been no posts from me for a while as I’ve been building the AS3 carousel section (eBay items) and a series of DoubleClick Ads utilising Twitter feeds in banners and Ebay listings in banners too.  The ads are in AS2 as the DoubleCick TABS system can’t yet take AS3 FYI (coming soon, Cheers Haden for the inside info!). This is all for The Sun Help for Heroes campaign where Ebayers can apply to become sellers and then donate their profits of the items they sell directly to the campaign. We’ve got loads of Celebrities to donate items too and there is a branded hub site pulling all this activity together live within eBay at:

In my rummagings on Cross Domain I discovered this good hack for accessing the pixels from Video on distributed CDN’s:

More posts soon hopefully although my day to day link posting is all being done via Twitter these days so follow along if you’re interested in these things. I am endeavouring to keep my microblogging professional rather than letting you know I am ‘on the bus’/'popped to the shop’ etc so Flash goodies are promised  ;)



AS3 Efficiency & Optimisation tricks

20 03 2009

Found some truly excellent resources on this (Thanks to Gibo & Mike for the links):

I’ve been trying to save some of these little loops e.g.

list[length] = item;

which for a simple Array push for example is 3x faster than:

list.push(item);

out as FDT  snippets called arrPush for example so that I don’t even have to remember to use them and the benefits will appear throughout production rather than post optimization whcih can be a pain. In other news, I’ve been spending a lot of time getting used to Fabrication this week and it really is incredibly good. I’ll post something about it in the next fortnight. Happy Friday all :)



Grabbing assets out of AIR apps

12 03 2009

I’ve done some work in the past with the Konfabulator (Now Yahoo! Widgets) widget patform and the workflow (no IDE) was that you used to rename the .widge files to .zip and decompress in order to view the JS and XML source. I was nosing at a few AIR apps today (Frienddeck and a Merapi AS3 to Java bridge application - in order to grab Skype metadata) and thought I’d give this method a test and yes you can kind of do the same with AIR! 

 Rename the .air to .zip and decompress (I use Winzip) - it throws an error but you get some source including a .swf which you can then run through a decompiler (I use Sothink) and you get the symbols (PNG’s, Movieclips etc…). This could be useful under certain circumstances so I thought I’d share. Cheerio :)



Excellent free HTML Editor for Eclipse

4 03 2009

Doing some AS3 projects in FDT (Eclipse plug in) with FlashVars & SWFAddress and it’s so good being able to pop into a decent HTML Editor in the same IDE. It’s just as good as EditPlus & free. Lovely. Just drop the .jar in your plugins directory. Details and Sourceforge link hereÂ



Tech news that beggars belief

24 02 2009

Firstly it would appear that Lord Carter’s vision for Digital Britain involves speed reducing, litigation fuelling ISP snooping DRM nonsense á la China, Syria and Australia read more here & behold the zeitgeist in action:

www.guardian.co.uk/technology/2009/feb/10/cory-doctorow-digital-britain

Absolutely not. We will march through the streets of Shoreditch!

And also IE8 actually introduces 2 new browsers to test in because IE7 ‘Compatibility Mode’ does not render sites in the same was as IE7 ????? See news here from IE’s marketing department and a pretty damning analysis from someone with more sense

Google ChromePlease don’t use IE ever! Chrome is blisteringly fast and doesn’t crash because if one tab hangs you can kill that process without losing the whole application and having to kill your session (though god knows what private data is collected while you use it) but I’m split between that and Firefox 3 as it’s got so many amazing tools and I love Mozilla. If Google would only add FFox plugin support though…



PureMVC Forum is ultra useful & friendly

18 02 2009

Pure MVCAbsolutely brilliant forum over at PureMVC. I had some heavy questions today and Cliff & Jason helped me an awful lot with some wide ranging and tricky concepts.  Thanks for the assistance guys :)



Firefox ‘Clear Cache’ Extension. Amazing

17 02 2009

Sometimes the simplest things in life are the greatest Nerd

This little beauty does exactly what it says on the tin. Thanks to Airtight Interactive for the spot and the consistently excellent blog

Firefox Extension - clear cache