简体   繁体   English

在Flex4的TextArea中嵌入字体

[英]Embedd fonts in a TextArea in Flex4

I'm trying to embedd fonts to use with a TextArea that I have extended using the code below, but it doesn't work. 我正在尝试嵌入字体,以便与使用下面的代码扩展的TextArea一起使用,但是它不起作用。 I have used this code before with a TextFlow object and then set the containers with the flowComposer, but I can't get it to work with the TextArea. 之前,我已经将这个代码与TextFlow对象一起使用,然后通过flowComposer设置了容器,但是我无法使其与TextArea一起使用。

When using the code below and set the text with setText, all I get is Times New Roman font. 当使用下面的代码并使用setText设置文本时,我得到的只是Times New Roman字体。 (Everything else is working fine) (其他一切都很好)

<s:TextArea ... >

...

<fx:Style>

    @font-face {
     src: url("./fonts/arial.ttf");
     font-family: ArialEmbedded;
   }

</fx:Style>

...

public function setText(text:String):void 
{
  var format:TextLayoutFormat = new TextLayoutFormat();
  format.color = 0x000000;
  format.renderingMode = RenderingMode.CFF;
  format.fontLookup = FontLookup.EMBEDDED_CFF;

  var config:Configuration = new Configuration();
  config.textFlowInitialFormat = format;     

  textFlow = TextConverter.importToFlow(text, TextConverter.TEXT_LAYOUT_FORMAT, config);
  textFlow.interactionManager = new EditManager(); 
}  

</s:TextArea>

I am seeing this same type of behavior with a TextArea and TextInput. 我看到了与TextArea和TextInput相同类型的行为。 The spark components will not render embedded fonts. spark组件将不会呈现嵌入字体。

i guess you should set embedAsCFF to true. 我猜你应该将embedAsCFF设置为true。 From the spark component, text-related components are re-based on Flash Player 10's text rendering engine(FTE). 从spark组件中,与文本相关的组件将基于Flash Player 10的文本呈现引擎(FTE)重新建立。

http://blog.flexexamples.com/2008/10/15/embedding-fonts-in-flex-gumbo/ http://blog.flexexamples.com/2008/10/15/embedding-fonts-in-flex-gumbo/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM