missing fonts on HTML5?

I was trying to make a site converted to HTML5 from Flash. While everything went well, the fonts, which are using TextFormat, do not show up on HTML5?! The main site is in Flash but coded in haXe, so transition was not a problem but then is there are way …

Viewing 1 to 15 (15 Total)
missing fonts on HTML5?

saumya

saumya
Total Posts: 56
Joined: November 19, 2011

I was trying to make a site converted to HTML5 from Flash. While everything went well, the fonts, which are using TextFormat, do not show up on HTML5?! The main site is in Flash but coded in haXe, so transition was not a problem but then is there are way to convert the dynamic texts with TextFormats to HTML5 or its not possible yet !
Thanks
saumya

Tags:
Posted on December 20, 2011 at 12:26 PM

singmajesty

singmajesty
Total Posts: 2146
Joined: August 25, 2011

Re: missing fonts on HTML5?

Fonts are supported on HTML5.

First, make sure that the fonts are included as assets through your NMML file. This will cause the font hash to be generated (as necessary) when compiling your project. Then you should be using nme.Assets to get a reference to the font:

var font = Assets.getFont ("asset/path/to/font.ttf");
var format = new TextFormat (font.fontName, 24, 0xFF0000);
var textField = new TextField ();
textField.defaultTextFormat = format;

Posted on December 20, 2011 at 12:44 PM

saumya

saumya
Total Posts: 56
Joined: November 19, 2011

Re: missing fonts on HTML5?

thanks @singmajesty
I was missing the embedding in resource part.

well, then its possibly work for iPhone compilation too ?

Posted on December 20, 2011 at 12:47 PM

singmajesty

singmajesty
Total Posts: 2146
Joined: August 25, 2011

Re: missing fonts on HTML5?

If you're using nme.Assets.getFont, it should work on all targets.

There was a minor bug that prevented embedded fonts from appearing for iOS, but that was corrected in the last release

Posted on December 20, 2011 at 1:34 PM

saumya

saumya
Total Posts: 56
Joined: November 19, 2011

Re: missing fonts on HTML5?

thanks.
NOw while compiling it says "Uncaught exception - fontNameRecord not found" !!

Posted on December 20, 2011 at 1:57 PM

saumya

saumya
Total Posts: 56
Joined: November 19, 2011

Re: missing fonts on HTML5?

it compiles fine for iPhone target, but HTML5 target throws the error above!

Posted on December 20, 2011 at 2:13 PM

singmajesty

singmajesty
Total Posts: 2146
Joined: August 25, 2011

Re: missing fonts on HTML5?

Hmm, that's strange. I just tried it again on my end, and worked correctly.

In the same directory of the font, it should create a *.hash file. For example, I have a "Brady Bunch Remastered" font, named "BradBunR.ttf". When I publish for HTML5 the first time, it creates "BradBunR.ttf.hash" then uses that to embed font details with my project.

Are you using a TTF font? It looks like the font tools for hxswfml are designed for TTF

Posted on December 20, 2011 at 2:35 PM

saumya

saumya
Total Posts: 56
Joined: November 19, 2011

Re: missing fonts on HTML5?

I am using "Herculanum.ttf" and can not see any .hash neither in source folder nor in export folder.
It compiles fine!!

Posted on December 20, 2011 at 2:45 PM

singmajesty

singmajesty
Total Posts: 2146
Joined: August 25, 2011

Re: missing fonts on HTML5?

Would you mind seeing what happens if you run hxswfml manually?

In the "tools/command-line/html5" directory of NME, there is a file called "hxswfml.n" that is used to generate the hash file:

neko hxswfml.n ttf2hash /path/to/font.ttf -glyphs 32-255

Posted on December 20, 2011 at 3:14 PM

saumya

saumya
Total Posts: 56
Joined: November 19, 2011

Re: missing fonts on HTML5?

hey singmajesty,
thanks a lot.
How i run that manually?!

When I navigate to the lib folder and fireup
neko hxswfml.n
I think that run successfully with some information on screen to provide the required parameters. Is that fine or I need to do something else to see.

Posted on December 21, 2011 at 1:13 PM

saumya

saumya
Total Posts: 56
Joined: November 19, 2011

Re: missing fonts on HTML5?

opps sorry for my hurry.
I think I found the problem.

Now I run the command you specified from the same folder I was trying to publish to HTML. And the error is as below

Uncaught exception - load.c(176) : Module not found : hxswfml.n

So, whats the fix?! thanks a lot.

Posted on December 21, 2011 at 1:18 PM

singmajesty

singmajesty
Total Posts: 2146
Joined: August 25, 2011

Re: missing fonts on HTML5?

If you are running from the directory of your project, you will need to specify an absolute path to hxswfml.n.

Or, this is easier:

Copy hxswfml.n to the directory with your font, then try and run it (using the name of your font)

Posted on December 21, 2011 at 1:22 PM

saumya

saumya
Total Posts: 56
Joined: November 19, 2011

Re: missing fonts on HTML5?

I copied to the fonts folder and run the command. Now it says

Uncaught exception - fontNameRecord not found

Posted on December 21, 2011 at 1:31 PM

saumya

saumya
Total Posts: 56
Joined: November 19, 2011

Re: missing fonts on HTML5?

ok, now updated my NMe lib to latest version. That also did not fix this issue. I am sure what that error is saying even! Does that mean I do not have the font needed! nyway going to try that with some other font.
Any input would be a good help.
thanks
saumya

Posted on December 22, 2011 at 1:51 PM

saumya

saumya
Total Posts: 56
Joined: November 19, 2011

Re: missing fonts on HTML5?

ok. go it working locally in the folder.
I mean I changed the font with another font and there is no error now while trying the
neko hxswfml.n ttf2hash /path/to/font.ttf -glyphs 32-255

But still could not compile to HTML5!

Posted on December 22, 2011 at 2:16 PM