Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
233 views
in Technique[技术] by (71.8m points)

coronasdk - How to add custom font in Corona for Android?

I just tried everthing on the forums but I couldn't add my custom font to system. Here's what I have done:

I made sure that family name and font name are same with Typelight program.

enter image description here

Then I just change the name of the file in the root directory and drag it to Outlaw. After that write the filename in display.newText.

enter image description here

Can you tell me where I am doing wrong?

[EDIT] Well, the problem was that I haven't installed the font with Windows Font Viewer. After installing it with WFV and removing the extension from font parameter thx krs, I finally displayed the text with customized font =) YAY!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Once you have your font file handy (ex. Harrowprint.ttf), you’ll need to first place it in your project directory (the same place your main.lua resides).

For Android apps, nothing needs to be done apart from including the font in your project folder.

There is an edit you have to do in your code as follows :

 local textObject = display.newText( "See my new font?", 100, 100, "Harrowprint", 40 ) -- no need to use extension here

If it doesn't works again then , you just use a font file with '.ttf' extension. This may work.

Courtesy : http://www.coronalabs.com/blog/2011/07/13/custom-fonts-corona/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...