Sign in to follow this  
tsx5000

Load base64 font

Recommended Posts

I'm making a playable ad for Facebook and there is condition that all of the code should be contained within a single index.html file.
I have managed to do this with all of the audio and images by converting them to base64.

Is there any way I can achieve the same with fonts?

Share this post


Link to post
Share on other sites

I managed to make it work by converting it into a bitmap form and loading it inline.

Here's the code:
 

var font_uri = "data:image/jpeg;base64,encoded_string";
var font_xml = 'minified_xml';

function preload()
{
  game.load.bitmapFont('font', font_uri, "", font_xml);
}

function create{}
{
  var msg = game.add.bitmapText(75, 75, 'font','Bitmap Fonts!', 64);
    msg.fontSize = 90;
	msg.tint = 0x000000;
}

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.