Skip to main content
Participating Frequently
April 2, 2010
Question

Flex 4 Release Build breaks text editor

  • April 2, 2010
  • 1 reply
  • 3407 views

I was working on an editor using FB4 beta 2. Fonts were loaded at runtime ... CFF is being used.

In Flex 4 SDK that comes with FB4 beta 2, my spark rich text field sitting in a group in my application looks fine - proper font families applied and renders correctly. My font + style drop down lists are all fine as well.

As soon as I switch to the release SDK, or any SDK later than FB4 beta 2 (well, major releases) the font styles are not longer properly applied to the field. Changes to the family no longer apply to the rich text field.

The rich editable text that I'm using is basically as follows:

                <s:RichEditableText id="editor" fontLookup="embeddedCFF" renderingMode="cff"
                                    focusEnabled="false" x="100" y="50" focusIn="focusInEditor(event)" focusOut="focusOutEditor(event)"
                                    width="300" height="200">
                    <s:textFlow>
                        <s:TextFlow fontFamily="HelveticaNeueLTStd-MdCn">
                            <s:p fontFamily="HelveticaNeueLTStd-MdCn" fontSize="14" color="0x999999">Test first line of text</s:p>
                            <s:p fontFamily="HelveticaNeueLTStd-Blk" fontSize="18" color="0xFFFFFF">Test second line of text</s:p>
                        </s:TextFlow>
                    </s:textFlow>
                </s:RichEditableText>

That probably isn't too important but I figured I would paste it anyway. I'm using setFormatOfRange primarily and this block of textFlow was only to get some initial content into the text area.

There is a ton of other related code for editing, selection, etc. It seems any font family related change does not get applied.

I know there have been a ton of changes and this may be difficult to pin down. However, this is pretty awkward. The application I was building loaded up fine, fonts loaded up all fine and all editing worked perfectly until going to release SDK.

Is there any change that would cause this to happen?

This topic has been closed for replies.

1 reply

Participating Frequently
April 2, 2010

THIS is the issue:

http://marcel-panse.blogspot.com/2010/03/embedded-fonts-in-tlf-and-swfcontexts.html

So, what can be done about this? I'm building an editor that loads multiple font SWF files that may be from any location, any domain... anywhere.

The single editable text field that will be used will contain multiple fonts from these multiple domains.

I tried to implement the solution shown here but the font families in my editor are still not shown properly.

Participating Frequently
April 2, 2010

Some more specifics...

I am registering the embedded fonts with Font.registerFont(). Flex does load up the font and enumeration works. Fonts display properly in a drop down list with a custom item renderer that shows what the font looks like...but will not apply to a rich editable text component.

I tried avoiding registerFont, setting the ISWFContext an the context of the flow composer, or setting the font lookup in global settings to null. None of those solutions work at all.

Matter of fact, the simple solution shown by Peter in the jira case (with two ttf embedded fonts and a simple flow) will not work ... with my versions of embedded fonts.

That's weird because there is nothing special about the actionscript only project i created to generate the embedded swf files. They are doing everything properly and the right properties are set on the embed. The font is registered and it does display in the UI - only in a drop down list with separate item renderers though.

Any other reasons embedded fonts might break in any build after FB4 beta 2?

Participating Frequently
April 2, 2010

Ok, so I finally got it working but this is not ideal at all. Adobe really needs to give us some direction on how to properly deal with font embedding and TLF now that the release build breaks all functionality with loading runtime fonts and TLF.

Problem:

I am embedding collections of fonts (faces) into single family classes. Each individual face is registered with Font.registerFont(). I need to do this because I have to have mixed fonts within text flows - at least according to Alex H's recent blog post.

Fonts do not display in TLF without doing the following:

1. GlobalSettings.resolveFontLookupFunction = null;

2. editor.textFlow.flowComposer.swfContext = ISWFContext(this.getFontContext("AnyFamilyNameFromAnyFontEmbedded", false, false, FontLookup.EMBEDDED_CFF));

3. Instead of #2, use editor.textFlow.invalidateAllFormats();

Either #2 or #3 need to be performed. If I have a spark richEditableText control in MXML with defined familes from the loaded fonts. I even tried placing the control into a separate state so it wasn't created until after the fonts were loaded... I still needed to invalidate the formats or set the context.

The "AnyFamilyNameFromAnyFontEmbedded" does not need to be all of the embedded family names. It only needs to be one of them. Once one is used, all embedded fonts work. Also, I have to use the internal namespace to even get access to getFontContext, another oddity that, in my humble opinion, should never be necessary to create mixed style TLF content.


My questions are then:

1. Why am I required to use ISWFContext if I am using Font.registerFont()?

2. Why is GlobalSettings.resolveFontLookupFunction = null; also required for this to work?

3. What is the recommended workflow to embed fonts from multiple SWF files into the release build and have it work without having to jump through all these hoops?