嵌入 AS3 字体。如何?

发布于 2024-12-04 14:41:14 字数 107 浏览 0 评论 0原文

我使用 Flash Professional CS5 嵌入了字体,但仍然无法在我的 AS 代码中使用它。我应该如何嵌入字体才能在 AS3 以及 Flash Professional CS5 中使用它?

I embedded font using Flash Professional CS5, but I still can't use it in my AS code. How should I embed the font to be able to use it in AS3 as well in Flash Professional CS5?

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

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

发布评论

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

评论(2

像极了他 2024-12-11 14:41:14

我做了一些稍微不同的事情。 :D embedAsCFF 如果您希望使用旧的文本字段,则应为 false,如果您使用新的文本引擎,则应为 true。

public class Font_Arial
{

    [Embed(source   = 'Arial.ttf'
    ,fontFamily     ='_Arial_'
    ,fontStyle      = 'normal'  // normal|italic
    ,fontWeight     = 'normal'  // normal|bold
    ,mimeType       = "application/x-font-truetype"
    ,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'
    ,embedAsCFF     = 'false'
    )]
    private const _regular:Class;

    [Embed(source   = 'Arial_i.ttf'
    ,fontFamily     ='_Arial_'
    ,fontStyle      = 'italic'  // normal|italic
    ,fontWeight     = 'normal'  // normal|bold
    ,mimeType       = "application/x-font-truetype"
    ,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'
    ,embedAsCFF     = 'false'
    )]
    private const _italic:Class;

    [Embed(source   = 'Arial_b.ttf'
    ,fontFamily     ='_Arial_'
    ,fontStyle      = 'normal'  // normal|italic
    ,fontWeight     = 'bold'    // normal|bold
    ,mimeType       = "application/x-font-truetype"
    ,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'
    ,embedAsCFF     = 'false'
    )]
    private const _bold:Class;

    [Embed(source   = 'Arial_bi.ttf'
    ,fontFamily     ='_Arial_'
    ,fontStyle      = 'italic'  // normal|italic
    ,fontWeight     = 'bold'    // normal|bold
    ,mimeType       = "application/x-font-truetype"
    ,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'
    ,embedAsCFF     = 'false'
    )]
    private const _boldItalic:Class;

    public static const name:String = "_Arial_";

    public function Font_Arial()
    {
        Font.registerFont(_regular);
        Font.registerFont(_italic);
        Font.registerFont(_bold);
        Font.registerFont(_boldItalic);
    }
}

然后您可以使用类似的内容

var _format:TextFormat = new TextFormat(Font_Arial.name, 16,....)

您需要确保 name 静态常量与字体中的 fontFamily 相同。它们都具有相同的名称,因此它们都充当 1 种字体,如果文本字段设置为粗体或斜体或粗体斜体或只是普通的旧常规,则文本字段将选择要使用的正确样式。

然后我会为不同的字体“集”创建一个不同的类

I do something slightly more different. :D embedAsCFF should be false if you wish to use old TextFields or true of you use the new text engine.

public class Font_Arial
{

    [Embed(source   = 'Arial.ttf'
    ,fontFamily     ='_Arial_'
    ,fontStyle      = 'normal'  // normal|italic
    ,fontWeight     = 'normal'  // normal|bold
    ,mimeType       = "application/x-font-truetype"
    ,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'
    ,embedAsCFF     = 'false'
    )]
    private const _regular:Class;

    [Embed(source   = 'Arial_i.ttf'
    ,fontFamily     ='_Arial_'
    ,fontStyle      = 'italic'  // normal|italic
    ,fontWeight     = 'normal'  // normal|bold
    ,mimeType       = "application/x-font-truetype"
    ,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'
    ,embedAsCFF     = 'false'
    )]
    private const _italic:Class;

    [Embed(source   = 'Arial_b.ttf'
    ,fontFamily     ='_Arial_'
    ,fontStyle      = 'normal'  // normal|italic
    ,fontWeight     = 'bold'    // normal|bold
    ,mimeType       = "application/x-font-truetype"
    ,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'
    ,embedAsCFF     = 'false'
    )]
    private const _bold:Class;

    [Embed(source   = 'Arial_bi.ttf'
    ,fontFamily     ='_Arial_'
    ,fontStyle      = 'italic'  // normal|italic
    ,fontWeight     = 'bold'    // normal|bold
    ,mimeType       = "application/x-font-truetype"
    ,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'
    ,embedAsCFF     = 'false'
    )]
    private const _boldItalic:Class;

    public static const name:String = "_Arial_";

    public function Font_Arial()
    {
        Font.registerFont(_regular);
        Font.registerFont(_italic);
        Font.registerFont(_bold);
        Font.registerFont(_boldItalic);
    }
}

Then you can use something like

var _format:TextFormat = new TextFormat(Font_Arial.name, 16,....)

You will need to make sure the name static constant is identical to the fontFamily within the font. They are all given the same name so they all act as 1 font, the textfield will pick the correct style to use if the textfield is set to bold or italic or bold and italic or just plain old regular.

I would then make a different class for different font "sets"

寂寞美少年 2024-12-11 14:41:14
  1. 将字体嵌入到 fonts.fla 文件中。
    http://www.adobe.com/devnet/flash/quickstart/embedding_fonts。 html

  2. 将 fonts.fla 导出到 SWC 库。 (在导出设置下选中 Flash CS5 中的 SWC 框)

  3. 将 SWC 与代码一起使用!

然后您应该能够看到它:

在此处输入图像描述

  1. Embed the font inside your fonts.fla file.
    http://www.adobe.com/devnet/flash/quickstart/embedding_fonts.html

  2. Export fonts.fla to the SWC library. ( under export settings check the SWC box in Flash CS5 )

  3. Use the swc with the code!

Then you should be able to see it:

enter image description here

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