问题
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.
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.
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!
回答1:
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/
回答2:
If you are not seeing it in the Simulator, its likely you have not installed the font in Windows.
Then you are not using the right name in your code. You don't use the .otf or .ttf inside Corona.
local textObject = display.newText( "Hello World", 100, 100, "Alex Brush", 40 )
Next, if you're building for Android, depending on the build, OTF fonts may not supported. I think OTF support was added with one of the recent daily builds, but I don't believe the last public build supports OTF.
来源:https://stackoverflow.com/questions/14404858/how-to-add-custom-font-in-corona-for-android