开发者

How to get users try the fonts they want online

开发者 https://www.devze.com 2023-01-10 18:11 出处:网络
I\'m trying to get the following done: I have a set of fonts and I want users to be able to try these fonts online, but i want the result to appear in an image so no one can use the font unless they

I'm trying to get the following done:

I have a set of fonts and I want users to be able to try these fonts online, but i want the result to appear in an image so no one can use the font unless they buy it. I found an example about what I exactly want here. Can anyone tell me how to do it ?? 开发者_开发问答

Thanks


The src of the image is a server side page that renders an image:

  • http://1001freefonts.com/image.php?text=test&font=KatyBerry

So what you want to do is to set the src to an aspx-page with the input text as a querystring. From that you create a graphics object, and use the font to draw the specified text onto that

excerpt from article

private void button4_Click(object sender, System.EventArgs e)
{
  Graphics grf = this.CreateGraphics();
  try
  {
    grf.Clear(Color.White);
    using (Font myFont = new Font("Arial", 14))
    {
      grf.DrawString("Hello .NET Guide!", myFont, Brushes.Green, new PointF(10, 100));
    }
  }
  finally
  {
    grf.Dispose();
  }
}

After that, you need to do a Response.Clear() so that you don't get any other text content rendered, and set Response.ContentType = "image/jpeg"; (or whatever content type you'll be using), and then write your image to the response output buffer.


If you don't need to display user-entered text, won't using static images be the KISS solution?


There are a number of solutions to this problem :

  1. render the font on the server - this is probably the best approach and from a copyright pov (if any) the safest. The answer from David outlines an approach.

  2. Render the font on the client. For a busy site this would place less load on your server. There are a number of solutions in javascript, my favourite being Cufon. The browser downloads the cufon runtime as well as a font file and this is rendered by the browser. You need to be aware of font licensing when using this approach, but it does require no setup on the server, and can even be used offline.

You can also use Flash to render the fonts, without licensing issues.

0

精彩评论

暂无评论...
验证码 换一张
取 消