0

我使用一个文件来声明 CSS 样式:

/* CSS file */
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/mx";
@namespace view "com.myviews.*";
@namespace comp "com.myviews.mycomponents.*"; 

@font-face {
    font-family:arial_s;
    src:url("Fonts/Arial.ttf");
    embed-as-cff:true;
    font-weight:normal;
    font-style:normal
}

@font-face {
    font-family:arial_mx;
    src:url("Fonts/Arial.ttf");
    embed-as-cff:false;
    font-style:normal;
    font-weight:normal;
}

global {
    font-family:arial_s; font-size:12.5;  
}

s|DropDownList {
    cornerRadius:0;
}

Q1:我在上面的 s|DropDownList 行中收到此警告:

The CSS type selector 'spark.components.DropDownList' was not processed, because the type was not used in the application.

但它是在应用程序中使用的,在这里改变它的值确实有效果。知道为什么我会收到此警告吗?

Q2:当我在调试模式下运行应用程序时,我收到警告:

warning: incompatible embedded font 'arial_s' specified for mx.core::UITextFormat. This component requires that the embedded font be declared with embedAsCFF=false.

警告来了,因为我在global上面使用了 spark 组件的属性,这导致它应用于所有组件,包括一些 mx 组件。这里感兴趣的组件是 DataGrid 单元格中的文本。我只需要弄清楚如何分别定义 mx.core::UITextFormat 的样式。知道这个的语法是什么吗?我试过了:

mx|UITextFormat {
    font-family:arial_mx;
}  

但它不起作用。不知道该怎么办。 http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/core/UITextFormat.html

4

3 回答 3

2

UITextFormat 的文档不包含任何 CSS 样式。

这只是一种预感,但由于 UITextFormat 实际上只是一种应用于 UITextField 的格式,也许您可​​以将字体样式应用于 UITextField 对象:

mx|UITextField {
    font-family:arial_mx;
}

关于关于 DropDownList 的第一个问题,DownDownList 是否可能在库项目中,而不是在应用程序项目中?如果是这样,您可以为库项目创建一个 defaults.css。

[编辑]

字体问题困扰着我 :) 我查看了 DefaultGridItemRenderer:它扩展了 UITextField。因此,要使用嵌入字体,它必须将其embedFonts属性设置为 true。然后它还需要一个引用嵌入字体的 UITextFormat 对象。

您可以扩展 DefaultGridItemRenderer 来执行此操作,但我认为 Adob​​e 可能会使这更容易,并查看了以下 DataGrid 样式。对于非移动应用程序,DataGrid 文档将您指向 ITextLayoutFormat,这是我在此处链接的内容:

我想知道您的 DataGrid 中是否实际使用了嵌入字体,因为默认渲染器似乎不会使用它们(除非 DataGrid 指示它使用)。

实际上,您的 css 将字体嵌入两次(?),我认为您应该只需要这样做一次——通过在 DataGrid 上适当地设置样式:

s|DataGrid {
    font-family:arial_s;
    fontLookup: embeddedCFF;
    renderingMode: cff; 
}
于 2012-05-23T18:55:10.883 回答
0

我也遇到过这个。我认为您可能需要在 MX 组件集中使用 Flash 文本引擎。您可以在编译器选项中执行此操作:

在 Flash Builder 中,进入 Project Properties > Flex Compiler 并选中“Use Flash Text Engine in MX components”。

于 2014-11-20T07:02:25.743 回答
0

在我的情况下,以下设置修复了所有嵌入的字体问题:

  1. 在“项目属性 > Flex 编译器”中选中“在 MX 组件中使用 Flash 文本引擎

  2. 在您的styles.css 中添加以下行:

    global {
        textFieldClass: ClassReference("mx.core.UIFTETextField");
    }
    
于 2015-02-11T12:44:15.867 回答