简体   繁体   English

在AS3 Flash动态字段中嵌入粗体字体

[英]Embedding bold font in AS3 Flash dynamic field

I have already googled and read a lot of different topics relating to this problem, but still cant solve mine. 我已经用Google搜索并阅读了很多与此问题相关的不同主题,但仍然无法解决我的问题。 I have this dynamic text field in a movieclip, and I embeded upper case, lower case and numbers. 我在动画片段中有这个动态文本字段,我嵌入了大写,小写和数字。 I exported that movieclip, then used it in my class and it's loading data from xml. 我导出了那个movieclip,然后在我的类中使用它,它从xml加载数据。

However, after I embedded the bold fonts, it stopped displaying data from xml, if I use regular, it's fine. 但是,在我嵌入粗体字体后,它停止显示来自xml的数据,如果我使用常规,那很好。 Then I created a font symbol and add the bold font in the library, it still doesn't give me anything. 然后我创建了一个字体符号并在库中添加粗体字体,它仍然没有给我任何东西。

Does anyone know how to solve this problem? 有谁知道如何解决这个问题?

thanks. 谢谢。

The easiest way to fix this problem is to create a set of textfields off screen. 解决此问题的最简单方法是在屏幕外创建一组文本字段。 Each field will handle the embedding for a single font and weight combination that you need. 每个字段都将处理您需要的单个字体和重量组合的嵌入。 So, for example, if you need regular, bold, italic and both bold and italic for a single font, they you will have 4 textfields - each with embedding turned on, and the characters you need selected. 因此,例如,如果您需要常规,粗体,斜体以及单个字体的粗体和斜体,它们将具有4个文本字段 - 每个都打开嵌入,以及您需要选择的字符。

Then you can simply turn on font embedding for any other textfield and it will be able to use all four styles (of that font). 然后你可以简单地为任何其他文本字段打开字体嵌入,它将能够使用所有四种样式(该字体)。

I tried changing every instance to the embedded version font with no success. 我尝试将每个实例更改为嵌入式版本字体但没有成功。 I WAS however, able to use the solution suggested on the Adobe Forum here: 但是,我可以使用Adobe论坛上建议的解决方案:

http://forums.adobe.com/thread/716363 http://forums.adobe.com/thread/716363

Instead of using myTextFieldInstance.text , use myTextFieldInstance.htmlText and specify "<b>" + yourStringValue + "</b>" during assignment. 不要使用myTextFieldInstance.text ,而是使用myTextFieldInstance.htmlText并在赋值期间指定"<b>" + yourStringValue + "</b>" While kludgey to the max, it was an easy solution to the problem. 虽然最大限度地使用了kludgey,但这是解决问题的简单方法。

I assume you are using one of the recent versions of the Flash IDE. 我假设您使用的是最新版本的Flash IDE之一。

Sounds to me like a conflict. 听起来像是冲突。 If you have another text field in that Movie with the same font and weight but not set to the embedded font there would be a silent (and annoying) conflict. 如果该影片中的另一个文本字段具有相同的字体和重量但未设置为嵌入字体,则会出现静默(和烦人)冲突。 Solution is to make sure that all the text fields, including static and input are set to the font in the font list with the asterisk ie Arial*. 解决方法是确保所有文本字段(包括静态和输入)都设置为字体列表中的字体,并带有星号,即Arial *。

If this doesn't fix it for you I suggest you should embed the font using the [embed] MXML tag (only cs4). 如果这不适合你,我建议你应该使用[embed] MXML标签(仅限cs4)嵌入字体。 Lee Brimelow has a great video tutorial on this technique you can watch it at gotoAndLearn . Lee Brimelow有一个关于这项技术的精彩视频教程,您可以在gotoAndLearn上观看。

I had some trouble with embedded fonts before and the embed tag fixed it for me. 我以前使用嵌入字体时遇到了一些问题,embed标签为我修复了它。 Have a look at my post and see if it helps. 看看我的帖子 ,看看它是否有帮助。

There is definitely an issue with applying Bold type font. 应用粗体字体肯定存在问题。

The font is not set as BOLD with following code, if you dynamically update the text later on somewhere in the code. 如果您稍后在代码中的某处动态更新文本,则该字体不会设置为BOLD以及以下代码。

var myTextFormat:TextFormat = new TextFormat();
myTextFormat.font = "Arial";
myTextFormat.bold = true;
myTextField.setTextFormat(myTextFormat);

//
myTextField.text = "some dynamic text";

Instead, you need to apply the text format each time you update the text. 相反,每次更新文本时都需要应用文本格式。

var myTextFormat:TextFormat = new TextFormat();
myTextFormat.font = "Arial";
myTextFormat.bold = true;

//
myTextField.text = "some dynamic text";
myTextField.setTextFormat(myTextFormat);

But, i generally set it as default font as shown below, 但是,我通常将其设置为默认字体,如下所示,

var myTextFormat:TextFormat = new TextFormat();
myTextFormat.font = "Arial";
myTextFormat.bold = true;
myTextField.defaultTextFormat = myTextFormat;

//
myTextField.text = "some dynamic text";

Not a perfect way for robust project but it works. 对于健壮的项目来说,这不是一个完美的方式

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM