MakG10 / jquery-meme-generator

A jQuery plugin for interactive creating images with captions (memes) with basic image editing tools.
http://maciej.gierej.pl/en/jquery-meme-generator
59 stars 16 forks source link

Can the font be changed by the user? #13

Open DannyCarlton opened 7 years ago

DannyCarlton commented 7 years ago

I'm trying to create a Bible verse meme generator and I'd like the user to be able to choose from several fonts. I've managed to substitute a Google font for the standard font used, but only as part of the initial settings. I still can't figure out how to change the fonts after the page is loaded, or how to set a different font for the second canvas layer.

DannyCarlton commented 7 years ago

Okay, here's the solution I found...

in jquery.memegenerator.js (which needs to be used instead of the min version for easy editing) just above the "PRIVATE METHOD" marker I added...

this.setFont = function(){ MG.settings.defaultTextStyle.font=newfont; }; ...then in the html I create "newfont" as a global font (by creating it outside any function) and triggered the change with... $(".example.save img").memeGenerator("setFont");

...of course after changing the variable "newfont" to the desired font. Once the font is changed the text needs to be redrawn which can be done with trigger("change") of the input for that textbox.

MakG10 commented 7 years ago

Yeah, I guess you have to use this workaround for now. I will add an "option" method to manually change any of the initial settings.