【问题标题】:Embedding fonts not working嵌入字体不起作用
【发布时间】:2013-04-11 12:45:25
【问题描述】:

请看下面最简单的示例,它在 Windows 上作为 AIR 桌面运行。

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                       xmlns:s="library://ns.adobe.com/flex/spark" 
                       xmlns:mx="library://ns.adobe.com/flex/mx">

    <fx:Style>
        @namespace s "library://ns.adobe.com/flex/spark";
        @namespace mx "library://ns.adobe.com/flex/mx";

        @font-face{
            src: url("C:/Windows/Fonts/AdobeGothicStd-Bold.otf");
            fontFamily: "AdobeGothic";
            fontWeight: bold;
            embedAsCFF: false;
        }

        s|Button{
            fontFamily: "AdobeGothic";
            fontSize: 20;
            color: #000000;
        }
    </fx:Style>
    <s:Button label="My Button" />

</s:WindowedApplication>

字体未被使用:

我做错了什么?

【问题讨论】:

    标签: apache-flex air flex-spark


    【解决方案1】:

    the docs中所述:

    如果将 embedAsCFF 的值设置为 false,则嵌入字体 不支持 FTE,仅适用于 MX 文本组件。

    此外,您正在尝试将粗体字体 (fontWeight: bold;) 应用于非粗体标签。我不确定这可能会产生什么影响。您可能需要这样做:

    <s:Button label="My Button" fontWeight="bold"/>
    

    【讨论】:

    • 谢谢,我之前尝试过切换 embedAsCFF 但我没有想到要在按钮上设置 fontWeight。
    【解决方案2】:

    还有一个选项,在您的样式声明中使用dot notation

    .mySparkButton
    {
       fontFamily: "AdobeGothic";
       fontSize: 20;
       color: #000000;
    }
    

    然后设置你的按钮的

     <s:Button label="My Button"  styleName = "mySparkButton" />
    

    【讨论】:

      猜你喜欢
      • 2015-01-19
      • 2012-10-21
      • 1970-01-01
      • 1970-01-01
      • 2013-05-25
      • 1970-01-01
      • 2015-07-26
      • 2015-06-21
      • 1970-01-01
      相关资源
      最近更新 更多