Quantcast
Channel: magick Discussions Rss Feed
Viewing all articles
Browse latest Browse all 3693

New Post: Custom font from file.

$
0
0
Hi. I've tried the method above, as well as adding the font to a types.xml that I've placed in the bin directory of my web application (I don't have access to directories outside the web root). My code uses the HttpSeverUtility.MapPath method to get an absolute path to a ttf file in the web application like so:
DrawableFont font = new DrawableFont(HttpContext.Current.Server.MapPath("/includes/font/boton-700-webfont.tff"));
DrawablePointSize size = new DrawablePointSize(24);
DrawableStrokeColor strokeColor = new DrawableStrokeColor(new MagickColor("#FFF"));
DrawableFillColor fillColor = new DrawableFillColor(new MagickColor("#FFF"));
DrawableText drawableText = new DrawableText(135, 730, text);
result.Draw(font, size, strokeColor, fillColor, drawableText);
But using a path like "D:\another-random-font.ttf" doesn't work either. The text is rendered, but using a plain (Sans-serif) font.

The types.xml (generated by imagick_type_gen with the path to the ttf file as argument) looks like this:
<?xml version="1.0"?>
<typemap>

  <type
     format="ttf"
     name="BotonB"
     fullname="Boton Bold"
     family="Boton"
     glyphs="D:\www\MyApp\Website\includes\font\boton-700-webfont.ttf"
     />

</typemap>
Maybe the types.xml file is in the wrong location, but I'd rather use a path anyway. What am I doing wrong?

Thanks in advance.

Viewing all articles
Browse latest Browse all 3693

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>