它看起来像AIR中的一个错误。
我在此报告:https://bugbase.adobe.com/index.cfm?event=bug&id=2955444
我试图在FlashPlayer&amp ;;的彩色背景上显示白色文字。 AIR运行时。不幸的是,AIR运行时中显示的文本看起来比FlashPlayer更糟糕。
以下是它的外观(顶部的AIR版本,底部的FlashPlayer):
IMG:http://imageshack.us/photo/my-images/710/fontcomparison.png/
所以,问题是,
码 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;
}
答案 0 :(得分:0)
我终于找到了一种解决方法(基于事实,在位图上正确绘制了字体)。您可以随意使用它,只需将<s:Label ...>
替换为<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
}
}
}