运行时在外部 SWF 中加载 CFF 嵌入字体时出现问题
我们有一个大型 Flash 网站,已翻译成 11 种语言。我们有一个字体加载系统,以每种语言显示网站所需的所有字符都嵌入到外部 swf 中(因此 11 个 swf)。
最近该网站的更新要求我们使用文本布局框架(TLF)来显示一个区域的文本,当然,它仅支持嵌入新 CFF 格式的字体。我尝试使用标签 embedAsCFF="true"
嵌入该字体的第二个实例,在加载字体 SWF 后,我可以看到该字体已正确注册,因为它显示在数组中由 Font.enumerateFonts
返回。
我正在使用的 TextFlow 实例设置了以下属性:
textFlow.fontLookup = FontLookup.EMBEDDED_CFF;
textFlow.renderingMode = RenderingMode.CFF;
textFlow.fontFamily = "HeadingFontCFF";
但是,显示的文本未找到嵌入字体。它以 Times New Roman 设备字体显示。我很确定我的 TLF 设置正确,因为当我将 [Embed]
标记放入与我的 TLF 代码相同的类中(即嵌入相同的 SWF 中)时,字体会正确显示。所以它似乎只与外部 SWF 中加载的字体有关。
我认为这个问题与此处列出的问题有关: 使用在运行时 Flex 4 运行时加载模块加载的嵌入字体的示例,尽管本文指的是 Flex 4 构建,而我们的是纯 Flash 10 构建。
We have a large flash site which is translated into 11 languages. We have a font loading system whereby all the characters required to display the site in each language are embedded in external swfs (so 11 swfs).
A recent update to the site requires us to use the Text Layout Framework (TLF) for one area of text display, which of course only supports fonts embedded in the new CFF format. I've attempted to embed a second instance of the font using the tag embedAsCFF="true"
, and after loading in the font SWF I can see this font is correctly registered as it shows up in the array returned by Font.enumerateFonts
.
The TextFlow instance I am using has the following properties set:
textFlow.fontLookup = FontLookup.EMBEDDED_CFF;
textFlow.renderingMode = RenderingMode.CFF;
textFlow.fontFamily = "HeadingFontCFF";
However the text that is displayed is not finding the embedded font. It is displayed in the Times New Roman device font. I'm pretty sure I have the TLF set up correct, as when I put the [Embed]
tag in the same class (i.e. embedding in same SWF) as my TLF code, the font is displayed correctly. So it seems to relate just to fonts loaded in external SWFs.
I think this problem is related to the one listed here: Example of using embedded fonts loaded at runtime Flex 4 runtime loaded modules, although this post refers to a Flex 4 build whereas ours is a pure Flash 10 build.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,经过大量挖掘后我找到了答案。事实证明,我们使用的编译器参数
指示编译器在转码字体时使用 AFEFontManager,而不是默认值(BatikFontManager/AFEFontManager/JREFontManager)。这些字体管理器获取字体文件并将其转换为矢量轮廓以在 Flash 中呈现。这里有更多信息:关于字体管理器 。
看起来,当包含此参数时,所有字体都会使用旧的 DefineFont3 方法嵌入,而不是 DefineFont4 (CFF),即使您使用标签
embedAsCff="true"
也是如此。要查看实际使用哪种方法来嵌入字体,一个简单的方法是检查
Font.enumerateFonts()
返回的字体的fontType
属性。如果该值是“embedded”,则使用 DefineFont3,如果是“embeddedCFF”,则使用 DefineFont4。希望这对那里的人有帮助!
Okay so after a lot of digging I found the answer. It turns out we were using a compiler argument
which instructs the compiler to use the AFEFontManager when transcoding the fonts, rather than the default (BatikFontManager/AFEFontManager/JREFontManager). These font managers take font files and turn them into vector outlines to be rendered in Flash. There's more information here: About the font managers.
It seems that when this argument is included, all fonts are embedded using the old DefineFont3 method, rather than DefineFont4 (CFF), even if you use the tag
embedAsCff="true"
.An easy way to see which method was actually used to embed the font is by checking the
fontType
property of the fonts returned byFont.enumerateFonts()
. If the value is "embedded" then DefineFont3 was used, if it's "embeddedCFF" then DefineFont4 was used.Hope this helps someone out there!
我发现这非常有用:“默认情况下,MX 组件使用 TextField 进行文本显示,而 TextField 无法使用 CFF 字体。如果告知 TextField 使用嵌入字体,但没有可以使用的字体或字形,则 TextField 将显示空白对于字体中的该字符,Spark 组件使用 FTE,而 FTE 需要 CFF 字体,因此您可以使用 CFF true 和 false 嵌入两种字体,但在大多数情况下,这不是很有效。 MXFTEText.css 文件或选中项目属性中的复选框,MX 组件将切换为使用 FTE 和 CFF 字体。” 作者:Alex Harui - 2010 年 9 月 2 日晚上 9:12
正如所见 此处与该主题相关的非常详细(且很长)的解释。
I found this very useful: "By default MX components use TextField for text display and TextField cannot use CFF fonts. TextField will show blanks if it is told to use embedded fonts but there isn’t a font it can use or glyphs for that character in the font. Spark components use FTE and FTE requires CFF fonts. Thus mixing the two is problematic. You could embed a font twice, both with CFF true and false, but that’s not very efficient. In most cases if you use the MXFTEText.css file or check the box in the project properties, the MX components will switch to using FTE and CFF fonts." by By Alex Harui - 9:12 PM on September 2, 2010
As seen here on a very detailed (and long) explanation related to the subject.