Jump to content

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?

Link to comment
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;


Link to comment
Share on other sites

  • 1 year later...

Hi, i was trying to get Audio to work within Playable ad and have been unsuccesful so far. I have converted the audio the base 64 and added to my html

This is how i am adding sound to my project: ("sorry its all crammed into single HTML file, since playable ad zipped folder with images does not seem to work for me)

Boot state preload {
this.load.image('top', topBar);
game.load.audio('gamesound', [
uri: gameSound,
type: 'mp3',
// gamesound is a base 64 string i store as a variable

// adding the sound in the create phase
game state: create {
this.mySound = this.game.add.audio('gamesound', 1, false);

// initiating the sound context, since there are no other screens where user interacts. the ontouch is a callback function on input down

ontouch: function () {
if (game.sound.context.state == 'suspended') {


 I was unable to get a zipped folder to run as a playable ad. so i converted all images to base 64. this worked. both locally and as a playable ad
I then tried to add the audio in the same base 64 way, this works locally. but does not work on facebook playable ad previewer

link to github project: https://github.com/dr-mogambo/Phaser-2-Falling-and-Catching

Link to comment
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.

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.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...