1.

http://www.angelcode.com/products/bmfont/ 에서 폰트 변환 프로그램을 통해, 원하는 폰트, 원하는 글자를 변환 (*.tga, *.fnt) 파일 생성


예) mybmpfont.tga, mybmpfont.fnt



2.

strings.xml 파일 작성


...

<key>hello</key>

<string>안녕하세요</string>


...



3.

CCDictionary *strings = CCDictionary::create("strings.xml");

const char *hello= ((CCString*)strings->objectForKey(" hello "))->m_sString.c_str();


CCLabelBMFont *label1 = CCLabelBMFont::create( hello , "mybmpfont.fnt", 200, kCCTextAlignmentLeft);



4.

만약 오류가 난다면, mybmpfont.tga를 mybmpfont.png로 변환하고, mybmpfont.fnt을 열어서

file="mybmpfont.tga" 를 file="mybmpfont.png" 로 수정






1.

http://www.angelcode.com/products/bmfont/ 에서 폰트 변환 프로그램을 통해, 원하는 폰트, 원하는 글자를 변환 (*.tga, *.fnt) 파일 생성


우선 Font Settings 에서 원하는 한글 출력 가능한 폰트를 선택한다.

Charset는 Unicode를 선택한다.


Export Options 에서 File format를 XML이 아닌 Text로 선택하고, Textures를 tga가 아닌 png를 선택한다. 생성하기 원하는 한글을 선택한 후, Save bitmap font as ... 로 저장한다.


그러면 *.png 와 *.fnt 파일이 생성 될 것이다. 참고로 *.fnt는 ANSI여도 된다.








2.

strings.xml 파일을 Unicode나 UTF-8로 생성한다.


...

<key>hello</key>

<string>안녕하세요</string>


...

다음과 같은 형태로 작성하되, <string>에 해당하는 한글은 반드시 *.fnt, *.png에 있어야 한다.





3.

CCDictionary *strings = CCDictionary::createWithContentsOfFile("strings.xml");

const char *strHello= ((CCString*)strings->objectForKey("hello"))->m_sString.c_str();


CCLabelBMFont *label1 = CCLabelBMFont::create( strHello, "mybmpfont.fnt", 200, kCCTextAlignmentLeft);


요렇게 사용하면 된다.



4.

mybmpfont3.fnt에서

info face="맑은 고딕" size=32 bold=0 italic=0 charset="" unicode=1 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=1,1 outline=0

common lineHeight=32 base=26 scaleW=256 scaleH=256 pages=3 packed=0 alphaChnl=1 redChnl=0 greenChnl=0 blueChnl=0

page id=0 file="mybmpfont3_0.png"

page id=1 file="mybmpfont3_1.png"

page id=2 file="mybmpfont3_2.png"

...


중에서 page가 1이 아닌 값이면 안된다.

CCBitfontAtlas는 1페이지만 지원한다.



Posted by Нуеоп