Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
229 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 Answer

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/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...