设备字体看起来在Flash播放器和放大器不同;空气 [英] Device font looks different in Flash player & AIR
问题描述
修改
它看起来像在空气中的bug。
我在这里报告吧:的https://bugbase.adobe .COM / index.cfm事件=错误和放大器;?ID = 2955444
请投票就可以了↑
问题:
我试图显示在flash播放器和放大器,彩色背景白色文字; AIR运行时。不幸的是,在AIR运行时显示的文本看起来更糟糕的是,比flash播放器之一。
下面是如何看待(AIR版本顶部,FlashPlayer的底部):
IMG: http://imageshack.us/photo/my-images /710/fontcomparison.png/
所以,问题是,
- 为什么会有这样的差别?
- 如何解决这个问题,所以在AIR的文字看起来酷似FlashPlayer的一(无字体嵌入)?
code: main.mxml:的
< XML版本=1.0编码=UTF-8&GT?;
< S:应用的xmlns:FX =http://ns.adobe.com/mxml/2009
XMLNS:S =库://ns.adobe.com/flex/spark
的xmlns:MX =库://ns.adobe.com/flex/mx=了minWidth955了minHeight =600>
< FX:样式源=style.css文件/>
< S:标签文本=()示例文本()的styleName =测试/>
< / S:用途>
的style.css 的:
/ *的style.css CSS文件* /
@namespace的库://ns.adobe.com/flex/spark;
@namespace MX库://ns.adobe.com/flex/mx;
。测试 {
字体-family:宋体;
字体大小:10;
字体重量:大胆的;
颜色:白色;
背景颜色:#BC2C49;
paddingBottom会:10px的;
以下属性来:10px的;
paddingRight:10px的;
paddingTop:10px的;
}
我终于找到了一个解决方法(基于事实,即字体位图的正确绘制)。随意使用它,只需更换< S:标签...>
,与<组件:LabelWorkaround ... />
。
封装组件
{
匹配import flash.display.Bitmap;
进口flash.display.BitmapData;
进口spark.components.Label;
/ **
*< P>这类是一个简单的解决方法错误
*所述; A HREF =https://bugbase.adobe.com/index.cfm?event=bug&id=2955444>#2955444&所述; / a取代。
*诀窍是利用一个与其中的基础文本; U>非透明< / U>位图,所以它呈现正确&所述; / P>
*
*< P>您将遗憾的是,如果想有背景颜色较白等,与LT; BR />
*那么你必须使用样式将它传递< / P>
*
* @author菲利普•扎瓦达
* @license免费商业用途。
*
* @see spark.components.Label
* @see flash.display.BitmapData
* /
公共类LabelWorkaround扩展标签
{
私人VAR textBitmapData:的BitmapData;
私人常量textBitmap:位图=新位图();
公共职能LabelWorkaround()
{
超();
的addChild(textBitmap);
}
覆盖保护功能的updateDisplayList(参数unscaledWidth:编号,unscaledHeight属性:编号):无效
{
super.updateDisplayList(参数unscaledWidth,unscaledHeight属性);
textBitmap.visible = FALSE; //关闭位图层,绘制基础文本
textBitmapData =新的BitmapData(参数unscaledWidth,unscaledHeight属性,FALSE);
textBitmapData.draw(本); //使修改的基础文本
textBitmap.bitmapData = textBitmapData;
textBitmap.visible = TRUE; //打开位图层
}
}
}
EDIT:
It looks like a bug in AIR.
I've reported it here: https://bugbase.adobe.com/index.cfm?event=bug&id=2955444
please vote on it ↑
Problem:
I've tried to display white text on a colored background in FlashPlayer & AIR runtime. Unfortunately, the text displayed in the AIR runtime looks much worse, than FlashPlayer one.
Here is how does it look (AIR version at top, FlashPlayer at bottom):
IMG: http://imageshack.us/photo/my-images/710/fontcomparison.png/
So, the question is,
- why there is such a difference?
- how to resolve this issue, so the text in AIR looks exactly like FlashPlayer one (without font embedding)?
code: main.mxml:
<?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 source="style.css" />
<s:Label text="() sample text ()" styleName="test" />
</s:Application>
style.css:
/* style.css CSS file */
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/mx";
.test {
font-family: Arial;
font-size: 10;
font-weight: bold;
color: white;
background-color: #BC2C49;
paddingBottom:10px;
paddingLeft:10px;
paddingRight:10px;
paddingTop:10px;
}
I've finally found a workaround (based on fact, that fonts are drawn correctly on bitmaps). Feel free to use it, just replace <s:Label ...>
, with <components:LabelWorkaround .../>
.
package components
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import spark.components.Label;
/**
* <p>This class is a simple workaround for a bug
* <a href="https://bugbase.adobe.com/index.cfm?event=bug&id=2955444">#2955444</a>.
* The trick is to draw base text on a <u>non-transparent</u> bitmap, so it renders correctly.</p>
*
* <p>Unfortunately if you would like to have background color other than white, <br/>
* then you have to pass it using styles.</p>
*
* @author Filip Zawada
* @license Free to commercial use.
*
* @see spark.components.Label
* @see flash.display.BitmapData
*/
public class LabelWorkaround extends Label
{
private var textBitmapData:BitmapData;
private const textBitmap:Bitmap = new Bitmap();
public function LabelWorkaround()
{
super();
addChild(textBitmap);
}
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
textBitmap.visible = false; // turn off bitmap layer, to draw base text
textBitmapData = new BitmapData(unscaledWidth, unscaledHeight, false);
textBitmapData.draw(this); // render modified base text
textBitmap.bitmapData = textBitmapData;
textBitmap.visible = true; // turn on bitmap layer
}
}
}
这篇关于设备字体看起来在Flash播放器和放大器不同;空气的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!