[embed] 标签和字体的问题

发布于 2024-09-01 17:04:22 字数 474 浏览 2 评论 0原文

我对 [embed] 标签有一些问题。即使我将文本字段的 embedFonts 属性设置为 true,文本也不会显示。

问题是它之前可以工作,但经过一些更改(与字体无关)后就不行了。我想了解字体的嵌入过程如何工作以查找代码中的错误。

我声明:

[Embed(source = 'asset/font.ttf', fontName="font", mimeType="application/x-font-truetype")] private static var font:String;

将字体分配给程序。

然后我在声明我的 textFormat 时调用“font”。 “fontName”属性是与 textformat 的链接吗?

我使用flashdevelop和flex_sdk_4.0.0.14159(大的adobe,带有空气(~140mo))

谢谢!

-腿

I have some issue with the [embed] tag. Even if I set the embedFonts property of the textfield to true the text doesn't show up.

The thing is that it worked previously and after some changes (not related to fonts) it doesn't. I'd like to understand how the embed process for font works to find the error in my code.

I declare :

[Embed(source = 'asset/font.ttf', fontName="font", mimeType="application/x-font-truetype")] private static var font:String;

to assign the font to the program.

Then i call "font" when declaring my textFormat. Is the "fontName" property the link with the textformat ?

I work with flashdevelop and the flex_sdk_4.0.0.14159 (the big adobe one, with air (~140mo))

Thx !

-Leg

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

安人多梦 2024-09-08 17:04:22

要做到恰到好处可能是一件很棘手的事情。大约 10 天前,我不得不与这个问题作斗争,只有尝试了嵌入的名称和参数的几种组合才能让它工作。

我读过博客报告,其中有一些轶事建议,如果您需要粗体或其他什么,则必须包含 fontStyle。以下是对我有用的咒语:

[Embed(source="assets/HelveticaBold.ttf",
       fontName="HelveticaBold",
       fontWeight="bold",
       unicodeRange='U+0020-U+002F,U+0030-U+0039,U+003A-U+0040,U+0041-U+005A,U+005B-U+0060,U+0061-U+007A,U+007B-U+007E')]
private static var HelveticaBold:Class;

我不认为 unicodeRange 是绝对必要的,但我不需要整个字体,上面的内容为您提供了 IDE 中“Basic Latin”的等效内容。

当我想使用该字体时,我会这样做:

    var titleFormat:TextFormat = new TextFormat();
    titleFormat.font = "HelveticaBold";
    titleFormat.bold = true;
    titleFormat.color = 0x0;
    titleFormat.size = 18;

    var errorTitle:TextField = new TextField();
    addChild(errorTitle);
    errorTitle.embedFonts = true;
    errorTitle.autoSize = TextFieldAutoSize.LEFT;
    errorTitle.antiAliasType = AntiAliasType.ADVANCED;
    errorTitle.x = 5;
    errorTitle.y = 5;
    errorTitle.defaultTextFormat = titleFormat;

我不敢相信我错过了最重要的部分。直到我强制 mxmlc 编译器使用自定义字体管理器后,上述方法才起作用。

添加以下内容作为编译器选项:

-managers=flash.fonts.AFEFontManager

Flex 3 中的字体故障排除列出了可用的字体管理器。尝试它们,直到找到一种有效的方法。

This can be a tricky thing to get just right. I had to fight with this about 10 days ago and only though trying several combinations of names and parameters to the embed could I get it to work.

I read blog reports that had anecdotal advice that you had to include the fontStyle if you need bold or whatnot. Here is the incantation that worked for me:

[Embed(source="assets/HelveticaBold.ttf",
       fontName="HelveticaBold",
       fontWeight="bold",
       unicodeRange='U+0020-U+002F,U+0030-U+0039,U+003A-U+0040,U+0041-U+005A,U+005B-U+0060,U+0061-U+007A,U+007B-U+007E')]
private static var HelveticaBold:Class;

I don't think unicodeRange is strictly necessary but I didn't need the entire font and the above gives you the equivalent of "Basic Latin" in the IDE.

When I want to use the font I do so like this:

    var titleFormat:TextFormat = new TextFormat();
    titleFormat.font = "HelveticaBold";
    titleFormat.bold = true;
    titleFormat.color = 0x0;
    titleFormat.size = 18;

    var errorTitle:TextField = new TextField();
    addChild(errorTitle);
    errorTitle.embedFonts = true;
    errorTitle.autoSize = TextFieldAutoSize.LEFT;
    errorTitle.antiAliasType = AntiAliasType.ADVANCED;
    errorTitle.x = 5;
    errorTitle.y = 5;
    errorTitle.defaultTextFormat = titleFormat;

I can't believe I missed the most important piece. The above didn't work until I forced the mxmlc compiler to use a custom font manager.

Add the following as a compiler option:

-managers=flash.fonts.AFEFontManager

There is an Adobe technote on troubleshooting fonts in Flex 3 that lists the available font managers. Try them until you find one that works.

掩耳倾听 2024-09-08 17:04:22

该问题来自 4.0 Flex SDK

http:// opensource.adobe.com/wiki/display/flexsdk/Font+Embedding+Reprise

我设置了与 Flash Player 9(带有 sdk 3.4)的兼容性,它再次工作。

The problem was coming from a modification in the 4.0 Flex SDK

http://opensource.adobe.com/wiki/display/flexsdk/Font+Embedding+Reprise

I set the compatibility to Flash player 9 (with sdk 3.4) and it is working again.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文