Installing a new font.

Discussion in 'Getting started' started by Naif, Oct 12, 2014.

  1. Hi,
    Our website generates some images based on a user input (converts text to image). It uses some fonts which are not installed in the DiscountAsp server.
    Is it possible that we install these fonts (3 fonts) in the server? If yes, how can we install them? If NO, is there any solution?
     
  2. You won't be able to get custom fonts installed on a shared host DiscountASP.NET web server; I'm sure a DASP staff member will be along soon to confirm what I've said.

    There's nothing to stop you uploading your 3 font files to your own account space but whether this works for you as expected will depend on the process you have that "generates some images based on a user input (converts text to image)"
     
    martino and Naif like this.
  3. Thank you for participating your knowledge.

    I am sorry, do you mean I will be able to use the new font despite it NOT being installed in the system.
     
  4. There definitely is a way to use fonts that aren't installed on the server but as I said in my last post, whether this will work for you as expected will depend on the process you have that "generates some images based on a user input (converts text to image)".

    If it happens that you're in full control of the application code in this process, you could try something like this example (C#.NET code sample):

    Code:
    public static PrivateFontCollection LoadFontCollection(string fontFileName) {
    var fontCollection = new PrivateFontCollection();
    fontCollection.AddFontFile(fontFileName);
    return fontCollection;
    }
    With usage something like this:
    Code:
    using(var fontCollection = LoadFontCollection("aFont.ttf"))
    using(var aFont = new Font(fontCollection.Families[0], 10.0f))
    {
    //do some work with aFont..
    }
    More info here: http://msdn.microsoft.com/en-us/library/system.drawing.text.privatefontcollection(v=vs.110).aspx

    Please note this sample comes without warranty, is untested and it's unknown if this actually works on the DASP web server; in short YMMV ;-)
     
    mjp, RayH, martino and 1 other person like this.
  5. Many thanks.
    I will try this tip. However, you have, really, provided me with a fantastic solution.
     
  6. You're welcome. Please update this thread with your results if you end up trying this out on the DASP server - I'm sure it will help others in future.
     
    RayH and martino like this.
  7. For sure, I will do.
     
  8. martino

    martino DiscountASP.NET Staff

    Very true we don't install custom fonts on the web server.
     
  9. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

    Just wanted to toss my 2 cents into the discussion since I'm not sure how exactly you are using the fonts. If you just want to render them on your webpage, then I personally use the CSS3 @font-face rule.
     
    Naif likes this.
  10. Hi CrystalCMS,
    Many thanks again :) the code works very well.
     
    martino and RayH like this.
  11. Thanks for the update, that's great to hear
     
    martino and RayH like this.

Share This Page