Can't get a workflow for font creation - Windows 10 64 bit


#1

Found another roadblock for new and apparently dumb users like me. :smiley:

I tried following the instructions here:

I got as far as needing to use python to convert the font. The python command in the console just throws this error, even after running the Windows X86-64 MSI Installer (2.7.6) [1] (sig) version from the python 2.7.6 release page, located here:

'python' is not recognized as an internal or external command, operable program or batch file.

I’m trying to use the windows Command Prompt, in the directory I downloaded the python file to. I renamed my font to match the command’s name too. I assume this is the “console” I am supposed to be putting the command into? (I don’t use python much, being a windows user and all.)

I’m a bit lost now as to what to do in order to make a font for use with Play Canvas. The GitHub readme doesn’t say anything about what to do if I can’t use python, and the python installer for the version specified in the readme does not seem to install so we can use it like the readme says to.

And of course without a .json file I can’t make any text on the screen. Help?


#2

Currently you need Python to run that converter script. Maybe this link on installing Python helps http://docs.python-guide.org/en/latest/starting/install/win/ ?

If you’ve installed Python and typing it in cmd doesn’t work it’s probably an Environmental Variables issue which I think that link above explains.

Alternatively you can use HTML for your UI.


#3

–EDIT: UPDATE: I’m a bit of an idiot today. My font name is Basic.fnt, not font.fnt. The script worked right after I changed the command to:

python fnt_to_json.py Basic.fnt font.fnt

Still leaving the below part of my post, cause I am curious how one would implement the other interface mentioned, though it’s probably more like another question entirely. For now I’m going to try hammering with the new json file and the font display script.


I’m not sure how to use HTML to make interface text in game. The user manual doesn’t seem to say anything on the topic (Searched for “html UI”, got random irrelevant stuff instead, and the part 6 tutorial that redirects back to me using these tools to make a font).

Nor do I think that will actually work for something like a clock or a speedometer, both of which need to react very quickly and dynamically turn invisible if a game isn’t in progress. I need text to show speed, current time, and also dynamic text prompts like “tap on these sides of the screen to turn”, or “lap 2 of 3”, and such. (I’m making a racing game in case you couldn’t tell by now.)


#4

In general it’s much more powerful to use HTML / CSS for your user interface because this is the Web and you can do a lot more stuff with these technologies. The downside is that you kinda need to know how to write HTML and CSS :slight_smile:

There is no tutorial on HTML / CSS UI’s although we could write a basic one to get people started. The general way it would work is you would have an HTML asset where you would write your HTML code, a CSS asset that would contain the styling for your UI, and then a script that would create the UI using the assets above. You would use a script to get buttons etc in your HTML and attach click handlers on them or to change the displayed text of various elements.

Here is a sample project that demonstrates some of the above https://playcanvas.com/project/354600/overview/htmlcss--live-updates .


#5

I’m having a similar issue when trying to run the python script. I have set up my environment variables correctly, I believe, and when I try to run the script in the command line, I get the following error:

File “fnt_to_json.py”, line 7

SyntaxError: invalid syntax

I’m not sure what to make of this error or where to go from here. Any ideas? Thanks!


#6

You probably have a more recent version of Python installed? This script requires Python 2.7


#7

Hi Vaios, thanks for your reply!

I made sure to have Python 2.7.6 installed as per the instructions, so that’s not the reason. Wish it were that simple though! I’m sure it is something simple that I’m missing, but I can’t put my finger on what it is. :frowning:


#8

What’s you operating system? And how exactly are you running the script? Can you type the exact copy from your terminal? Can you also share the entire stack trace of the error you’re getting?

Line 7 seems to be import os. Not sure why you’d get an error there unless you haven’t installed Python properly.


#9

Hi vaios,

Sorry for the delay!

My OS is Windows 8.1. I’m running the script through the command prompt. This is exactly how I’m running the script and the steps I used to install Python:

(1) I downloaded Python 2.7.6 and installed to the folder C:\Python27. I moved the font files that I created (fnt file and the png files) to the Python27 folder.

(2) I added the following line to my environment variables:

Variable Name: Path
Variable Value: C:\Python27;C:\Python27\Scripts\

(3) In the command prompt, I typed the following:

cd Python27

python fnt_to_json.py C:\Python27\constantia72px.fnt C:\Python27\constantia72px.json

(4) I then get the following output:

File “fnt_to_json.py”, line 7

SyntaxError: invalid syntax

I’m assuming some of the steps are likely redundant, like going to the Python27 path. But if I try doing python call just at C:\ I get this error:

python: can’t open file ‘fnt_to_json.py’: [Errno 2] No such file or directory

So I’m guessing I didn’t add the path correctly to the environment variables. But going directly to the folder seems to work regardless.

Let me know if this gives you any more insight. Thanks so much!