상세 컨텐츠

본문 제목

[AS] AIR 안드로이드 개발 한글이 깨져 나오는 경우 관련

ADOBE/ ActionScript

by AlrepondTech 2014. 12. 22. 16:57

본문

반응형
728x170

 

 

 

 

=================================

=================================

=================================

 

 

 

출처: http://vulcan9.tistory.com/115

 

 

안드로이드는 4.4 kikat 으로 나날이 버전업되고 Flex는 Apache Flex 4.12, AIR 14로 지속적인 업데이트가 이루어지고 있음에도 물구하고 여전히 Flex4.6에 AIR 3.7기반으로 뭔가를 열심히 나름 뚝딱거리고 있는 가운데 중대 버그 발견으로 블로깅 할만한 꺼리가 생겨 널리 이롭게 하고자...

 

문제의 증상

한글이 깨져서 박스모양으로 나타나거나 글자가 사라지는 증상이 있었습니다.

 

 


문제가 발생한 디바이스

* 안드로이드 4.3, 4.4 가 설치된 일부 (삼성)디바이스

* 갤럭시 노트 10.1인치, 갤럭시 노트 12.2인치

Bug report 링크

[Adobe bugbase] https://bugbase.adobe.com/index.cfm?event=bug&id=3732973

[Adobe]
Korean characters are displayed as blank box on the TextField in Galaxy Note 3/Android 4.4/AIR 
http://forums.adobe.com/message/6130947

Chinese and Japanese text gone in Adobe Air 4.0b and Android 4.4
http://forums.adobe.com/message/5983828

Displaying Chinese in spark List does not work in Android 4.4.2
https://issues.apache.org/jira/browse/FLEX-34115

[Apatch]
Flex SDK 4.11 some components cannot display Chinese characters on Android 4.4.x
https://issues.apache.org/jira/browse/FLEX-34037

Apatch Flex 버그 등록 (34257)
https://issues.apache.org/jira/browse/FLEX-34257

vote를 많이 해주셔야 빨리 수정됩니다.!!

추가) http://apache-flex-users.2333346.n4.nabble.com/Korean-text-not-displayed-in-spark-Label-td4053.html


테스트 후 문제 해결이 확인된 SDK

* Flex4.6 with AIR3.7 확인됨

* Apatch Flex4.12.1 with AIR14.0 확인됨


해결 원리

폰트를 Embeding하여 랜더링을 일괄적으로 적용
단, 컴포넌트마다 Embeding 옵션이 달라야 정상적으로 표시됨
(폰트 용량 플러스 알파로 파일크기 증가함)

그런데 StyleableTextField는 embedAsCFF=false로 임베딩된 폰트만 지원된다고 하네요. 
(
Embedding Fonts in Flex Mobile Projects - http://blogs.adobe.com/jasonsj/2011/08/embedding-fonts-in-flex-mobile-projects.html)

  • All mobile skins, LabelItemRenderer and IconItemRenderer use StyleableTextField (based on TextField) instead of the Flash Text Engine (FTE)
  • The Spark Label component uses FTE
  • StyleableTextField only supports embedded fonts with embedAsCFF=false
  • You have to embed fonts twice, once with embedAsCFF=false and again as embedAsCFF=true, to use fonts in both types of text components
  • Avoid using embedded fonts with editable text (TextInput and TextArea)

정리하면 Label을 제외한 모든 모바일 스킨은 모두 StyleableTextField를 사용하는데, StyleableTextField는 embedAsCFF=false인 폰트만 지원한다는 겁니다.


해결 방법

Step 1: mxml 파일에 css 파일을 링크시킨다.

<fx:Style source="fontEmbedcss.css"></fx:Style>

 

Step 2: css 파일에서 폰트를 Embeding 시킨다.

폰트는 두가지 방식으로 임베딩 시킨다. embedAsCFF = true인것과 embedAsCFF = false인것 두가지로...

@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/mx";

@font-face{
src:url("asset/malgun.ttf");
fontFamily:"malgun";
embedAsCFF:false;
}
@font-face{
src:url("asset/malgun.ttf");
fontFamily:"malgun_CFF";
embedAsCFF:true;
}
global{
fontFamily:"malgun";
}

 

Step 3: 텍스트가 표현되는 컴포넌트에 임베딩된 폰트를 적용한다.

embedAsCFF = true 인 글꼴을 사용할 컴포넌트 :

RichEditableText는 아쉽게도 softKeyBoard로 한글입력이 되지 않았다. (레퍼런스에 따르면 mobileDevice profile로 설정된 application에서 사용하지 말것을 권하고 있다.)

s|RichEditableText{
fontFamily:"malgun_CFF";
}
s|Label{
fontFamily:"malgun_CFF";
}

 

embedAsCFF = false 인 글꼴을 사용할 컴포넌트 : 
(global style이 적용되었으므로 따로 지정해 주지 않아도 됨)

s|TextInput{
skin-class:ClassReference("spark.skins.mobile.TextInputSkin");
fontFamily:"malgun";
}
s|TextArea{
skin-class:ClassReference("spark.skins.mobile.TextAreaSkin");
fontFamily:"malgun";
}
s|RadioButton{
skin-class:ClassReference("spark.skins.mobile.RadioButtonSkin");
fontFamily:"malgun";
}
s|CheckBox{
skin-class:ClassReference("spark.skins.mobile.CheckBoxSkin");
fontFamily:"malgun";
}
......

 

fontWeight: bold 인 글꼴을 사용할 컴포넌트 : (볼드체 임베딩)

@font-face{
src:url("asset/malgunbd.ttf");
fontFamily:"malgun_b";
embedAsCFF:false;
fontWeight:bold;
}
s|Button{
fontFamily:"malgun_b";
}

그런데 제 경우엔 폰트 임베딩 할때 css 파일에서 
embedAsCFF:false; fontWeight: bold;
이렇게 설정하면 아예 임베딩이 안된다는 에러가 납니다. 볼드체를 지원하는 글꼴이어야 합니다.
그래서 저는 다음과 같이 합의보았습니다.

s|Button{

fontFamily:"malgun";
fontWeight: normal;
}

 

Step 4: embedAsCFF 값이 맞지않는 폰트를 지정하는 경우

콘솔창에 다음과 같은 문구가 나옵니다.

warning: incompatible embedded font 'malgun_CFF' specified for spark.skins.mobile::RadioButtonSkin (RadioButtonSkin13) . 

This component requires that the embedded font be declared with embedAsCFF=false.

이 문구는 RadioButtonSkin에는 embedAsCFF=false로 지정된 폰트를 사용하라는 경고문구입니다. 
경고대로 수정해주면 됩니다.

다른 컴포넌트들도 위 문구를 확인하여 해당 폰트를 지정해줍니다.

 

 

 

=================================

=================================

=================================

 

 

 

 

출처: http://divillysausages.com/blog/as3_font_embedding_masterclass

 

 

One of the people I follow on Twitter, Jesse Freeman, twitted that he was having some problems getting embedded fonts working properly in Flash. As the problem sounded immediately familiar (the amount of time you spend cursing out something in Flash is inversly proportional to the amount of time it takes to remember what it was), I chimed in with what turned out to be the solution. Long story short, if you're having problems embedding fonts in AS3, try setting embedAsCFF = "false" in your embed code.

Simply finishing this post at that doesn't really satisfy my need to have mountains of text on the internet and thus look like I know what I'm talking about, so I figured to share the info I gathered up about a year ago when I hit the same problem. So why is embedded fonts in AS3 such a Pain In The Ass™ ?

There are 3 main ways to embed a font in a SWF:

Direct embedding

This is probably the most common for Flash game devs looking to embed a specific font for their game. For this, we're using the [Embed] metatag:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// to embed a font file that's relative to your project
[Embed(source="../someFont.ttf",
    fontName = "myFont",
    mimeType = "application/x-font",
    fontWeight="normal",
    fontStyle="normal",
    unicodeRange="englishRange",
    advancedAntiAliasing="true",
    embedAsCFF="false")]
private var myEmbeddedFont:Class;
 
// to embed a system font
[Embed(systemFont="Arial",
    fontName = "myFont",
    mimeType = "application/x-font",
    fontWeight="normal",
    fontStyle="normal",
    unicodeRange="englishRange",
    advancedAntiAliasing="true",
    embedAsCFF="false")]
private var myEmbeddedFont:Class;

It doesn't matter what you call the variable under the Embed tag as you don't use it. You also don't need all of these parameters, but I'll explain each one briefly.

  • source/systemFont
    Use source if you're embedding a font file that's relative to your file (the .as file, not the SWF). UsesystemFont to embed a font from your computer's Fonts folder. In this case, you pass the name of the font (e.g. "Arial", "Trebuchet Ms" etc.)
  • fontName
    This is the name you supply to your font. It can be anything you want, though if you use systemFontrather than source, then it shouldn't be the same name as the font (the compiler should throw a warning). This is what you supply to the font parameter of your TextFormat object.
  • mimeType (Optional) 
    The mimeType in which to embed the font. I didn't notice much difference between using"application/x-font" and "application/x-font-truetype". Perhaps one is for OpenType fonts and the other's for TrueType fonts. In any case, Flex should pick the right one for you, so you can pretty much ignore this. See http://livedocs.adobe.com/flex/3/html/help.html?content=embed_3.html#176407 for more info on the [Embed] mimeTypes.
  • fontWeight (Optional) 
    Can be "normal""bold", or "heavy". This will embed only that specific weight for the font. If you specify "bold", but your TextFormat/TextField is set up for normal text, it will display bolded, and vice versa. The default is "normal".
  • fontStyle (Optional) 
    Can be "normal""italic", or "oblique". Works in the same manner as fontWeight.
  • unicodeRange (Optional but recommended) 
    If you don't want to embed the full font (probably a smart move on your part), you can specify a range of characters to embed. This can be in the form of "U+0030-0039,U+002E" (for numbers), or a language range set in the Flex config file (if you're the sort of loser that doesn't know unicode ranges by heart). There's a list of language ranges defined in flash-unicode-table.xml (found inPATH_TO_FLEX_SDK/frameworks), that you can copy over to flex-config.xml (same folder - scroll down until you see the <fonts> tag, and you should see a commented-out example). Finding the right place to put them should be obvious. Useful ones include "Numerals", "Basic Latin" and "englishRange".
    NOTE: If you're using AIR, note that it reads from air-config.xml/airmobile-config.xml depending, notflex-config.xml, so make sure you copy over your ranges to here as well.
  • advancedAntiAliasing (Optional) 
    Can be either "true" or "false". When set to true, additional information is added that lets the fonts display clearer and sharper at smaller font sizes. However, this can increase your memory usage. Embedding 4 or 5 fonts with advancedAntiAliasing can increase your memory by a few MB or so. It's set to true by default.
  • embedAsCFF (Optional but recommended) 
    With Flex 4, font embedding has changed, with fonts coming in as embeddedCFF or Compact Font Format. This is to work with the new Flash Text Engine (FTE), but unless you're using Flex Spark components, you probably don't care. Without going into too much detail (see the links at the bottom of the page), setting this to "false" means that you can actually use your font with the Flex 4 SDK. An alternative to this is to specify that you're using the Adobe Font Manager rather than the default BatikFontManager, by compiling with the line -manager=flash.fonts.AFEFontManager in the compiler options of your project. If you're not changing your font manager, then setting this is important, as Flash can tell you that your font is embedded, but you won't be able to use it. By default (under Flex 4), embedAsCFF is true, or you can set the compatibility-version to 3.0 to set the default to false.

Using an embedded font

To use this in your project, you first set up a TextFormat object with the font parameter set to the fontNamethat you specified in your Embed statement. Also make sure to specify embedFonts = true; on your TextField otherwise you won't use them/it won't show up. To easily know if your TextField is using the embedded fonts, just rotate your TextField slightly, as only embedded fonts can be rotated.

1
2
3
4
5
6
7
8
9
// create our TextFormat
var tf:TextFormat = new TextFormat( "myFont", 20 );
 
var t:TextField     = new TextField;
t.embedFonts        = true; // very important to set
t.autoSize          = TextFieldAutoSize.LEFT;
t.defaultTextFormat = tf;
t.text              = "Hello World";
this.addChild( t );

Embedding using a SWF

Embedding fonts using a SWF is somewhat easier. If you've ever created a game in Flash and used the Flash IDE to produce graphics, you've probably done everything you need to before.

  • Create a new FLA file and create a TextField on the stage.
  • Keep it as static and type some text if you want a very specifc set of characters. Otherwise, set it to dynamic.
  • If you want to used advanced anti-aliasing, make sure that the Anti-Alias for Readability or Custom Anti-Alias is the selected anti-alias mode. Any other option and Flash won't include anti-aliasing information for the font in the SWF file.
  • If your TextField is a dynamic one, in the Properties panel, click the Embed button, and embed whichever characters you want.
  • Create any other TextFields as needed (different fonts, bold, italic, etc.)
  • Export your SWF

Here, I've created two TextFields, one static and one dynamic. The static TextField is using the Futura Md font, while the dynamic TextField is using the Courier New font and embedded with the characters for Basic Latin.

 

If you're using FlashDevelop, then you can see what fonts are embedded in a SWF, including the number of characters:

 

As you can see, there's two fonts available for me to use. There's only 11 characters for Futura Md, as thatTextField was static, so Flash only includes the characters used.

For our AS code, we change the Embed call to:

1
2
[Embed(source="../assets/test.swf", fontName="Courier New" )]
private var myEmbeddedFont:Class;

Note that the fontName is the name of the font that you used in Flash. If you embedded a bold/italic version, then you'll also have to set fontWeight = "bold" or fontStyle = "italic".

NOTE: If you use a static TextField you MUST set it as selectable, otherwise you won't be able to access the font.

1
2
3
4
// create our TextFormat
var tf:TextFormat = new TextFormat( "Courier New", 20 );
 
// create the TextField the same as above

Embedding using a font symbol

Finally, we can embed fonts using a font symbol in Flash.

  • In your library, create a new font symbol by right-clicking or using the small down arrow in the upper right corner.
  • Give the font symbol a name (can be anything), select the font that you want and its properties (bold, italic...). Don't set the symbol name to the same as the font name - this is just to make it clearer, it won't stop the code from working.
  • Right-click on the font symbol and select Linkage. Select Export for Actionscript. Add an identifier for the symbol, or just use the default (the name of the font symbol in the library).
  • Export your SWF.

Here, I added a font symbol for the Times New Roman font and gave it an export linkage name of "myFontSymbol":

 

You'll notice that there's 243 characters in our font symbol. That's because there's no way (at least that I've found in CS3; it might be different in CS5) to say that you only want to export a specific set of glyphs.

In our AS code, we make a change to the Embed code like this:

1
2
[Embed(source="../assets/test.swf", symbol="myFontSymbol" )]
private var myEmbeddedFont:Class;

As we're embedding a symbol here, don't set the mimeTypefontStyle etc. or the compiler will throw an Error along the lines of Error: transcoding parameters 'symbol' and 'fontStyle' are incompatible. For the fontproperty of your TextFormat object, we change it to the name of the font, not the font symbol name, or the symbol linkage name.

1
2
3
4
// create our TextFormat
var tf:TextFormat = new TextFormat( "Times New Roman", 20 );
 
// create the TextField the same as above

Problems

"My TextField fonts still look ugly, even though the font is embedded!"
Make sure you've set the TextField's embedFonts property to true. To make sure that you're using an embedded font, set the rotation property to a value other than 0, as only embedded fonts will show when the TextField is rotated.

"Flash says my font is embedded but I can't get it to work!"
When you're embedding your font, set embedAsCFF to false, or compile with -manager=flash.fonts.AFEFontManager to use the Adobe Font Manager, or compile with compatibility-version set to 3.0, where the default value for embedAsCFF is false.

"I get an 'unable to transcode' error!"
Check the embed path to your font. Make sure it's relative to the file that's doing the embedding, not your project root or the SWF file.

"I get a 'transcoding parameters 'x' and 'y' are incompatible' error!"
You're probably trying to embed a symbol and not a font. See the Embedding using a font symbol section.

"I get an 'unable to build font' error!"
Try using the Adobe Font Manager by compiling with -manager=flash.fonts.AFEFontManager.

"I get an 'invalid Unicode range 'ENGLISHRANGE'' error! (or similar)
If you're hardcore, and entering unicode ranges by hand, make sure it's actually valid. They should be in the form unicodeRange="U+0041-U+005A,U+0061-U+007A" (upper- and lower-case a-z) and you can find a list of the ranges online.
If you're using named ranges, make sure they're defined in the right config file (all found inPATH_TO_FLEX_SDK/frameworks): flex-config.xml for AS3/Flex, air-config.xml or airmobile-config.xml for AIR - scroll down until you see the <fonts> tag and you'll find a commented-out example. You can find a handy list of them in flash-unicode-table.xml.

"Only some of my characters are showing up!
This is a bit of a hairy bug, but it's probably this. Basically it can happen when you embed the same font in two different SWFs/SWCs that are used in one project. Say you have SWF A and SWF B that you include in your main project. SWF A embeds Arial and the characters a, b and c. SWF B embeds the full Arial font (same weight as the font in SWF A). If SWF A is compiled in your project first, then Flash will only take those glyphs (i.e. a, b, and c), ignoring those in SWF B. This is why only some characters in your TextFields are showing up. Take note that static TextFields also count towards embedded text. If you code in FlashDevelop you can click the [+] beside the SWF, and again on the font so see how many glyphs have been embedded.
As this bug doesn't look like it's going to get fixed, there's a few solutions you can employ:

  • Embed the same glyphs in both SWFs/SWCs. Can be an upkeep nightmare.
  • Embed each font under a different name so there's no conflict. Requires foreknowledge of the use of the SWF (not ideal for shared libs).
  • Create a separate "module" SWF that has the font, and use that SWF in all SWFs that need it.
  • Remove the font entirely from SWF A and SWF B and put it in your main SWF. Sometimes not possible to do entirely (static TextFields).
  • Embed each font under a different weight (i.e. SWF A embeds as "normal", while SWF B embeds as "bold").

I found all of these links useful when digging into this. The first two are manadatory reading, the rest explain the subject a bit better.

Code

I've created a project that includes everything I talked about here. It has the code and Flash files necessary to to just about all the types of font embedding you could wish for. You can download it here.

 

 

 

 

=================================

=================================

=================================

 

 

 

 

출처: http://wooyaggo.tistory.com/54

 

 

 

플래시로 개발하면서

가장 짜증나는 부분중에 하나가

신나게 프로그래밍하다가 테스트해보기 위해서 모니터에

모든 정신 쏟은 채로 두근두근 하며

Ctrl + Enter 작렬!!!

 


...

기운 쭉 빠지는 순간이 아닐 수 없다.

다름아닌 폰트 임베딩 때문인데

매번 컴파일할때마다 폰트를 임베드 하기 때문에

개발속도가 느려져버리는건 당연하고 의욕도 떨어지고 짜증만 늘어난다.



자 그럼 이번에는 SWC 를 이용해서 폰트 임베등을 가볍게 하는 방법을 알아보자.

우선 새로운 fla 를 생성하고 (저장할 필요 없다.)

 


텍스트필드를 바탕에 하나 만들어준다.

 


그리고 Property 패널에 Embed 버튼을 선택해서 임베트할 Character-set 을 설정한다.

 


그리고 텍스트필드를 무비클립으로 생성해준다.

(한글이나 특수문자는 안되고 일반 변수명 작명하는 방법으로 네이밍한다. 때문에 한글폰트의 경우 네이밍을 잘 해야 혼동되지 않는다.)

 


그런다음 Library 패널에서 무비클립을 우클릭하여 나오는 메뉴중에서

Export SWC File 을 선택해서 swc 파일로 export 한다.

 


export 할 위치는 플래시의 컴퍼넌트 폴더여야 하며

보통 사용자폴더\AppData\Local\Adobe\Flash CS3\en\Configuration\Components\

로 되어 있다. 반드시 확인을 하자.

파일명은 한글로 해도 상관없다.

본인은 폰트만 따로 모아둘 요량으로 Fonts 라는 폴더를 따로 만들어 그안에 저장했다.

 


그런다음 컴퍼넌트 패널에서 우측의 쪼마난 메뉴에서 Reload 메뉴를 선택하자.

 



그러면 컴퍼넌트 패널이 업데이트 되면서 방금 export 한 폰트가 생성됐다.

이제 맑은 고딕이라는 폰트를 만드는 것은 성공이다.

이제 사용하는 법만 알면 된다.

 


이제 새로운 fla 를 생성해서

컴퍼넌트패널에서 생성된 폰트를 드래그하여 Library 창에 추가한다.

이게 끝이다.

이제 폰트가 embed 되어있는지 확인해볼 차례다.

액션창에 아래 소스를 넣어보자.

var fonts:Array = Font.enumerateFonts();

var font:Font;

for each(font in fonts)
     trace(font.fontName);


임베드한 폰트의 이름을 확인할 수 있을것이다.

자 그럼 사용을 직접 해보자.

우선 Library 에 있는 폰트 swc 를 지워서 깨끗하게 해놓은 다음에

역시 마찬가지로 액션창에 아래와 같이 써보자.

var txt:TextField = new TextField();
txt.defaultTextFormat = new TextFormat("맑은 고딕", 12);
//txt.embedFonts = true;
txt.text = "abcdef";

addChild(txt);


embedFonts 가 주석처리 되어 있기 때문에

아마 텍스트가 잘 보일것이다.

이번엔 주석을 풀고 다시 해보자.

var txt:TextField = new TextField();
txt.defaultTextFormat = new TextFormat("맑은 고딕", 12);
txt.embedFonts = true;
txt.text = "abcdef";

addChild(txt);


폰트가 임베드되어 있지 않기 때문에 텍스트가 보이지 않는다.

그러면 이제 컴퍼넌트 패널에서 폰트를 드래그하여

Library 에 추가한다음 다시 컴파일해보자.



이뿌게 Embed 되어 있는 폰트를 볼 수 있을것이다.

이제 폰트 때문에 짜증날일은 없을것이다.

많은 유저들에게 도움이 되었으면 좋겠다.

 

 

 

 

 

 

=================================

=================================

=================================

 

 

 

출처: http://sarangsai.com/321

 

문제  :  Nexus 7 4.2 업그레이드된 기기에서는 Adobe Air 를 통해 개발된 게임의 한글이 깨지거나 출력이 안된다.

 

 

 

무턱대로 올린 4.2 버전

 

 

 

 

 


Apple|iPhone 4S|Normal program|Spot|1/15sec|F/2.4|4.3mm|ISO-800|Off Compulsory|2012:11:21 17:56:14

adobe Air로 제작된 Flash게임은 FONT 출력이 안된다.

 

 

 

그럼 개발환경에서 직접 테스트를...

 

 

 

대충 만들고...


 

 

 


Apple|iPhone 4S|Normal program|Pattern|1/20sec|F/2.4|4.3mm|ISO-64|Off Compulsory|2012:11:21 18:27:35

 

..뭐지.. 뭐지!!!~

 

 


Apple|iPhone 4S|Normal program|Pattern|1/20sec|F/2.4|4.3mm|ISO-100|Off Compulsory|2012:11:21 18:35:57

Flex Mobile Project에서 기본적으로 나와야할 한글도 깨짐...

 

 

뭐지!!!~

 

 

 

해결할려면 AIR에 FONT EMBEDED 해서 출력...

 

<?xml version="1.0" encoding="utf-8"?>

<s:TabbedViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 

  xmlns:s="library://ns.adobe.com/flex/spark" applicationDPI="160">

 

<fx:Style>

@namespace s "library://ns.adobe.com/flex/spark";

@font-face {

src: url("NanumGothic.otf");

fontFamily: "NaNumGothic_CFF";

embedAsCFF: true;

}

 

@font-face {

src: url("NanumGothic.otf");

fontFamily: "NaNumGothic";

embedAsCFF: false;

}

 

 

s|Application

{

embedFonts: true; 

fontWeight: normal; 

fontFamily: NaNumGothic;

}

 

s|ViewNavigator{ 

embedFonts: true; 

fontWeight: normal; 

fontFamily: NaNumGothic; 

}

 

s|RichText {

embedFonts: true; 

fontWeight: normal; 

fontFamily: NaNumGothic_CFF;

}

</fx:Style>

 

<s:ViewNavigator label="목록" width="100%" height="100%" firstView="views.ListView" fontFamily="NaNumGothic"/>

<s:ViewNavigator label="보기" width="100%" height="100%" firstView="views.View"/>

<s:ViewNavigator label="설정" width="100%" height="100%" firstView="views.SettingView"/>

<fx:Declarations>

<!-- Place non-visual elements (e.g., services, value objects) here -->

</fx:Declarations>

</s:TabbedViewNavigatorApplication>

 

 

 

 

 

 

 

 

=================================

=================================

=================================

 

 

 

출처: https://forums.adobe.com/thread/1396521?tstart=0

How to embed a font air Android App????

이 질문은 답변 안 됨 상태입니다.

sreejithg04Community Member

Hi, im new to this forum so please forgive me if i question in the wrong section.

 

I am Beginner and am working on an air android game in flash cs6.. i need embed fonts please help me sort out htis problem..

 
평균 사용자 등급: 평가 없음 (0 등급)
평균 사용자 등급
평가 없음
(0 등급)
    • 1. Re: How to embed a font air Android App????
      cisnkyCommunity Member

      Create a css file for your project. Embed font as both types.

       

      @font-face {

         srcurl("assets/fonts/Arial-Regular.ttf");

        fontFamily"arialCFF";

        embedAsCFFtrue;

      }

       

      @font-face {

        srcurl("assets/fonts/Arial-Regular.ttf");

        fontFamily"arial";

      embedAsCFFfalse;

      }

       

      .anCFF11 {

      fontSize11;

      fontFamilyarialCFF;

      }

       

      Then for a label just change the stylename to 'anCFF11'

       

      For StyleableTextField set via the html text -

       

      var fullnameSS:StyleSheet = new StyleSheet();

      fullnameSS.parseCSS( '.fullname{color: #333333; fontSize: 15; font-Family: "arial"; fontWeight: bold}');

      _status.styleSheet = fullnameSS;

      _status.htmlText = "<span class='fullname'><b>My Text</b>";

    • 2. Re: How to embed a font air Android App????
      AsterLUXmanCommunity Member

      The easiest for me is to simply embed your font into your main document class, like this:

       

       

      package

      {

       

           import flash.display.Sprite;

           import flash.text.*;

       

           public final class MyApp extends Sprite

           {

                [Embed(source="../fonts/ITCAvantGardeStd-Bold.otf", embedAsCFF = "false", fontWeight="bold", fontName = "ITCAvantGardeStd_DemiAndBold", mimeType = "application/x-font-truetype", unicodeRange="U+0021-U+007E, U+00A9, U+00AE")] // Main characters + Copyright and Registered glyphs

                static public var ITCAvantGardeStdBold:Class; // that's what the embed gets baked into

                Font.registerFont( ITCAvantGardeStdBold ); // do this once per font

       

                public function MyApp():void // Constructor

                {

                     // Create a textformat that uses the font

                     var tft:TextFormat = new TextFormat( "ITCAvantGardeStd_DemiAndBold", 20, 0xffff00, true );  // size = 20 pix, color is yellow, bold = true, matching the font weight

       

                     // create a text field

                     var tf:TextField = new TextField();

       

                     with ( tf )

                     {

                          antiAliasType = AntiAliasType.ADVANCED; // optional

                          defaultTextFormat = tft;

                          embedFonts = true; // this is using an embedded font

                          width = 100;

                          autoSize = TextFieldAutoSize.LEFT;

                          wordWrap = true;

                          text = "Hello world ! blah blah blah blah blah blah blah blah blah blah blah blah";

                          height = textHeight + 8; // nice and tight

                          border = true; // for fun

                          borderColor = 0xffff00; // yellow

                     }

       

                     addChild( tf );

                }

           } // end of: class

      } // end of: package

       

       

      The embed statement contains several optional properties, like fontWeight, fontStyle, and fontFamily.

       

      Check here for info:  http://divillysausages.com/blog/as3_font_embedding_masterclass

       

      Note: Alternatively, you could use Flash Professional to embed the font into the document class via the IDE ( like so:http://www.adobe.com/devnet/flash/quickstart/embedding_fonts.html ).

       

      Also, for these kinds of questions, I recommend:

       

      1) O'Reilly -- Essential ActionScript 3.0

      2) O'Reilly -- ActionScript 3.0 Cookbook

     

     

    =================================

    =================================

    =================================

     

     

    반응형
    그리드형


    관련글 더보기

    댓글 영역