I am loading Google font-families name into a select-list. When user select any font-family from the list, then I load that font dynamically. My code:
$.get("https://www.googleapis.com/webfonts/v1/webfonts?key=...", {}, function (data) {
$.each(data.items, function (index, value) {
$('#fc').append($("<option></option>").attr("value", value.family)
.text(value.family));
});
$('#fc').selectmenu({ select: function () {
$('body').append("<link rel='stylesheet' id='colorbox-css' href='http://fonts.googleapis.com/css?family=" + escape($(this).selectmenu("value")) + "' type='text/css' media='all' />");
}
});
});
Now I want to show the preview of the font to the user before loading that font.
Is this possible?
I ran into this challenge myself, so used some console action and open sourced the following: https://github.com/onassar/GoogleWebFonts-FontFamilyPreviewImages
I'll be pretty active in maintaining it (just gotta write up the docs now).
Try HiGoogleFonts. It shows all the google fonts in a drop down with a preview of each. it only loads the font which is selected. It uses a single image for fonts preview.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With