Flex-Flash Builder设计视图未正确显示嵌入字体
工具:Air 2、Flex SDK 4.1、Flash Builder、Halo组件集(根本不使用Spark) 当运行应用程序时,字体可以完美工作,但在“设计”视图中不能。这实际上使设计视图变得毫无价值,因为在不知道真实大小的情况下,不可能正确定位组件或标签(它会根据字体而变化…) 根组件中包含的CSS如下所示:Flex-Flash Builder设计视图未正确显示嵌入字体,flash,apache-flex,flex4,flash-builder,halo,Flash,Apache Flex,Flex4,Flash Builder,Halo,工具:Air 2、Flex SDK 4.1、Flash Builder、Halo组件集(根本不使用Spark) 当运行应用程序时,字体可以完美工作,但在“设计”视图中不能。这实际上使设计视图变得毫无价值,因为在不知道真实大小的情况下,不可能正确定位组件或标签(它会根据字体而变化…) 根组件中包含的CSS如下所示: <fx:Style source="style.css"/> 有趣的是(或者buggily?),当我尝试将样式标记粘贴到子组件(低于顶级容器)中时,我在子组件编辑器视图
<fx:Style source="style.css"/>
有趣的是(或者buggily?),当我尝试将样式标记粘贴到子组件(低于顶级容器)中时,我在子组件编辑器视图中收到一系列警告,指出中不支持CSS类型选择器。。(样式表中的所有组件)。然而,当应用程序执行时,它们确实起作用。嗯 这就是我如何将字体嵌入到root级别容器中的方法:
[Embed(source="/assets/segoepr.ttf", fontName="Segoe", mimeType="application/x-font-truetype", embedAsCFF='false')]
public static const font:Class;
[Embed(source="/assets/segoeprb.ttf", fontName="Segoe", mimeType="application/x-font-truetype", fontWeight="bold", embedAsCFF='false')]
public static const font2:Class;
那么,有没有一种方法可以让嵌入式字体在设计视图中工作?我不知道这是否有帮助,但值得一试。如果您正在使用css,则不需要使用嵌入元标记嵌入字体。尝试删除字体类嵌入并将嵌入添加到css文件中。这在Flex中的设计视图中可能会更好
// using system font
@font-face {
src: local("Myriad Web Pro");
fontFamily: myFontFamily;
advancedAntiAliasing: true;
}
// using url to font file
@font-face {
src: url("../assets/MyriadWebPro.ttf");
fontFamily: myFontFamily;
advancedAntiAliasing: true;
}
在设计视图中尝试以下代码:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Style>
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/mx";
@font-face {
src: url("Arial Bold.ttf");
fontFamily: "Arial Bold";
embedAsCff: true;
}
s|Application
{
color: #000000;
fontFamily: "Arial Bold";
font-size: 48;
}
</fx:Style>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Label text="This is the first label" width="488" x="43" y="39" height="54"/>
<s:Label text="This is the second label" width="488" x="45" y="129" height="54" rotation="-4"/>
<s:Label text="This is the third label" width="488" x="43" y="208" height="54"/>
</s:Application>
@命名空间s“library://ns.adobe.com/flex/spark";
@名称空间mx“library://ns.adobe.com/flex/mx";
@字体{
src:url(“Arial Bold.ttf”);
fontFamily:“Arial粗体”;
embedAsCff:正确;
}
s |应用
{
颜色:#000000;
fontFamily:“Arial粗体”;
字号:48 ;;
}
似乎默认情况下标签和文本区域需要字体Verdana
,如果我们不嵌入它,则设计视图不会考虑任何其他嵌入字体
请嵌入Verdana
字体,您应该能够在设计视图中看到标签和文本区域
@font-face {
src: local("Verdana");
font-family: verdana;
font-weight: normal;
}
希望这能有所帮助。仍然不行:(难道没有人真正使用design view吗?在Flex 3中,没有它我就无法生存。
@font-face {
src: local("Verdana");
font-family: verdana;
font-weight: normal;
}