View Full Version : Get Fonts from server

06-12-2008, 07:27 PM
Is it possible to get a dynamically updated font.
For example i have a drop down with a few font options. I have to assume the user doesn't have them so I need to get them from the server. Can this be done with Ajax in such a way that the text with the new font can still be changed by local functions like these:

function changecolor(){
var oldHTML = document.getElementById('boldy').innerHTML;
var color = document.getElementById('input_field_1').value;
var newHTML = "<span style='color:" +color +"'>" + oldHTML + "</span>";
document.getElementById('boldy').innerHTML = newHTML;
///This one would be replaced by the ajax i hope//
function changefont(){
var oldHTML = document.getElementById('boldy').innerHTML;
var font = document.getElementById('font').value;
var newHTML = "<span style='{font-family:" +font +";}'>" + oldHTML + "</span>";
document.getElementById('boldy').innerHTML = newHTML;

function changefontsize(){
var oldHTML = document.getElementById('boldy').innerHTML;
var fontsize = document.getElementById('fontsize').value;
var newHTML = "<span style='{font-size:" +fontsize +";}'>" + oldHTML + "</span>";
document.getElementById('boldy').innerHTML = newHTML;
This is the boldy div:

<div id="boldy" class="boldy"><span style='{font-size:60px;}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></div>

06-12-2008, 10:41 PM
Installing a font requires file system access- not possible with javascript.

06-13-2008, 06:30 AM
So if i hit the server for each of the above functions will i be able to keep the file size of the new text low. It will have to return as an image file with the new font. More of an Ajax PHP question.

06-13-2008, 12:11 PM
there might be an ActiveX script that can do it for you have a look and google it

try some thign like this


06-13-2008, 06:40 PM
Your not giving enough detail about how the form will function .. esp what the actual role and purpose of it is.

with that said, you may be able to use PHP to print in that font for the user
as far as the user would know, it would be an image, but its just the font style you want


Its how CAPCHAs work ;)

06-16-2008, 05:01 PM
Solved it generating small gifs with php image functions and calling them with onkeyup events with Ajax.
Thanks for all suggestions.