Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Mar 2008
    Posts
    88
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Get Fonts from server

    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:
    Code:
    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:
    Code:
    <div id="boldy" class="boldy"><span style='{font-size:60px;}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></div>

  • #2
    Regular Coder
    Join Date
    Mar 2006
    Posts
    728
    Thanks
    35
    Thanked 132 Times in 123 Posts
    Installing a font requires file system access- not possible with javascript.

  • #3
    New Coder
    Join Date
    Mar 2008
    Posts
    88
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Ok.
    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.

  • #4
    Regular Coder
    Join Date
    Nov 2007
    Location
    Leeds, UK
    Posts
    514
    Thanks
    24
    Thanked 19 Times in 19 Posts
    there might be an ActiveX script that can do it for you have a look and google it

    try some thign like this

    http://www.bestvistadownloads.com/so...-dvxmuncr.html

  • #5
    Regular Coder
    Join Date
    Dec 2005
    Posts
    141
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

    http://us2.php.net/gd

    Its how CAPCHAs work

  • #6
    New Coder
    Join Date
    Mar 2008
    Posts
    88
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Solved it generating small gifs with php image functions and calling them with onkeyup events with Ajax.
    Thanks for all suggestions.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •