I'm 99.9% sure that what you're attempting can't be done. The livedocs for
TextField says that TextField has a flag (embedFonts) that indicates whether
embeded or device fonts are used, so it's hard to see how both could ever be
used at the same time.
- Dan Freiman
On Mon, Apr 7, 2008 at 9:52 AM, a.hawksworth230 [EMAIL PROTECTED]
wrote:
Hi everyone, I'm having some trouble with embedded fonts. I have read
many many threads/posts about embedded fonts and haven't really
gotten anywhere so far.
No matter what I have tried I cannot seem to apply an embedded font
to a section of text and have a system font applied to another
section of text within the same text field. It almost seems as if you
are restricted to using either system fonts or embedded fonts in the
same text field.
Iv'e got a sample application below which allows me to apply multiple
fonts to different selections with a text field - however when I pick
one of my embedded fonts, a default system font is used in its place:
mx:Application xmlns:mx=http://www.adobe.com/2006/mxml;
layout=absolute
creationComplete=creationComplete(event)
mx:Style source=.\stylesheets\primary.css/
mx:VBox id=vb
mx:Label text=My Title fontFamily=AdLib RM/
mx:TextArea id=textArea fontSize=26 width=200 height=50/
mx:ComboBox id=fontComboBox dataProvider={fontFamilyArray}
labelField=fontName change=fontComboBox_change(event)/
/mx:VBox
mx:Script
![CDATA[
use namespace mx_internal;
[Bindable] private var fontFamilyArray:Array;
private function creationComplete(event:Event):void
{
fontFamilyArray = Font.enumerateFonts(true);
fontFamilyArray.sortOn(fontName, Array.CASEINSENSITIVE);
}
private function fontComboBox_change(event:Event):void
{
var tf:TextFormat = textArea.getTextField().getTextFormat();
var beginIndex:int = textArea.getTextField
().selectionBeginIndex;
var endIndex:int = textArea.getTextField().selectionEndIndex;
tf.font = fontComboBox.selectedLabel;
textArea.getTextField().setTextFormat(tf, beginIndex,
endIndex);
textArea.invalidateDisplayList();
textArea.validateDisplayList();
}
]]
/mx:Script
/mx:Application
I know the font has been embedded correctly because the label control
has the correct font applied to it.
If I initialise the font property on the text area to my embedded
font (fontFamily=AdLib RM) then when I start typing into the text
area the font is correct - and I can select any of the other embedded
fonts and they work fine. But selecting a system font for part of the
text now causes the text to become hidden.
Any advice would be grately appreciated.
Cheers,
Andy.