cocoonJS fonts

Get help using Construct 2

Post » Sun Dec 23, 2012 12:57 pm

You just need to import a TTF file to your project files, then when exporting to CocoonJS C2 automatically puts it in a Fonts subfolder. If that doesn't work, might be best to contact @Ludei.
Scirra Founder
B
359
S
214
G
72
Posts: 22,948
Reputation: 178,532

Post » Sun Dec 23, 2012 1:04 pm

Aaaaaaah you need to import into c2 I see thank you!
B
29
S
9
G
6
Posts: 525
Reputation: 8,294

Post » Mon Dec 24, 2012 1:09 am

Tried and it still won't work. It needs to be explicitly set with "set font face"? I really don't understand the reason why it won't work..

@Ludei
B
29
S
9
G
6
Posts: 525
Reputation: 8,294

Post » Wed Dec 26, 2012 12:24 pm

try a different font, then you can see if it is a font problem or something else.
B
22
S
7
G
3
Posts: 189
Reputation: 4,270

Post » Thu Jan 03, 2013 10:10 am

I make a folder call "fonts" put the ttf into it, and move the folder into the "zip file I get from C2 when I choose to export to cocoonjs", and use cloud compilation to compile it to apk.

result->Doesn't work.

Puzzled.

@superkew
Oh ya, you mention in other post that it wasn't working in android yet. erm, do you have more info on that?

eg.
When will it work?
Will it ever work?
ZhaoYun2013-01-03 10:14:45
B
12
S
4
G
4
Posts: 64
Reputation: 4,014

Post » Mon Jan 07, 2013 4:25 am

We kind need mor info, how the font get loaded, by whom? Automatically by cocoonJS that applies it to everything or is C2 that handles this?
B
29
S
9
G
6
Posts: 525
Reputation: 8,294

Post » Tue Jan 08, 2013 8:32 am

Ok, we've been seeing some users having trouble with this, while for others it works just fine. After some digging, we think we've found a couple of issues.

First of all, CocoonJS searches for fonts by filename, and not by the internal font name. This means that if the font name is "my super font!", but your file is named "my_super_font_0.ttf", Construct should ask CocoonJS for a font named "my_super_font_0". We know this is not "standards compliant", but it was the easiest way for us to add this feature.

Also, there seems to be some trouble with some Construct exports we're getting, which instead of having a folder named "fonts", have font filenames that start with "fonts\" (which on Unix file systems is a valid part of a filename). This means CocoonJS doesn't see any "fonts" folder, so no ttf files are loaded.

We are guessing the way Construct generates the zip file doesn't correctly generate folders, but we're not quite sure yet. If you want to check if a zip file is correctly constructed, just unzip it on an OSX machine, and you'll see if the "fonts" folder is created or not.
B
9
S
4
G
4
Posts: 383
Reputation: 3,616

Post » Fri Feb 15, 2013 3:48 pm

I can't seem to get this to work either, I have tried so many iteration of moving fonts and renaming them, I'm now just at a complete lost of what to do next.

Currently I have the font imported into the "Files" directory in construct2 and it's name there is "Tw Cen MT Condensed Extra Bold.tff"
Set my objects font to : "Tw Cen MT Condensed Extra Bold" and set an action @OnLoad to : Set font fact to "tw cen mt condensed extr abold"

Something I've noticed is that in the CocoonJs Log is saying :
[code]
Custom font loaded: game/fonts/twcenmtcondensedextrabold.tff
Custom font loaded: game/fonts/tw cen mt condensed extr abold.tff
[/code]

Even though I have only included one font Cocoon is loading two both in lower case and one without spaces. I have tried renaming the files in C2 to be lowercase and without spaces and tried setting the font face to same, all with same null result.

Is this not working because the fonts are loaded into 'game/' and not just 'fonts/'

I have tried webfont (but that's not supported) and I have tried using a stylesheet like the tutorial.

Soooo.... has anyone got a bullet proof way to do this?
B
24
S
11
G
5
Posts: 140
Reputation: 5,004

Post » Sun Feb 17, 2013 1:10 am

@labithiotis 99.9% is your fault (it was in my case).
Basically the font name (the name of the actual ttf) must be the same as the name of the font that construct2 picks up.

If your objects font is: Tw Cen MT Condensed Extra Bold than you have to name it Tw Cen MT Condensed Extra Bold.ttf (case sensitive).

You don't need to set the font name. Hope it helped.
B
29
S
9
G
6
Posts: 525
Reputation: 8,294

Post » Sun Feb 17, 2013 7:36 pm

@0+1

Got it, only took me like forever

Sooo.. I thought you had to place the fonts in the zip in a folder called fonts. Also when I was first doing this I must have got the case wrong.

Thank you for your help.

Just to recap for others on how to use a local font in CocoonJS:

1) You need to import the font into the Files directory in your project (right click on Files and choose Import).

2) The file-name should be Font + FontStyle and of the same case. Example I had a font called Tw Cen MT with a style called Condensed Extra Bold, so full file-name is Tw Cen MT Condensed Extra Bold.tff

3) Every time you export to cocoonJS, open the zip and rename font file to be correct case (it always default to lower-case).
labithiotis2013-02-17 19:37:34
B
24
S
11
G
5
Posts: 140
Reputation: 5,004

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: Braus, jatin1726 and 15 guests