Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fancy Fonts for Headings Advice 1

Status
Not open for further replies.

SteveAudus

Technical User
Oct 4, 2001
409
GB
I'd like some advice...

I have a client with alot of predesigned artwork, they would like turning into web pages.

The problem is, they still want them editable,
so the heading and titles on the page are in bubbley none standard font, so I can't do them as graphic.

I have throught of doing them in Flash, but the problem is client only using Contribute to edit pages, so flash files are far too advance for them.

Any suggestions would be very welcome.

Thanks,

Steve

 
You could look at building a page that accepts some text and returns an image (turning the supplied text into an image using your non-standard font). You might then call this on your page like this:

Code:
<img src="makeheading.aspx?text=Something" />

I have done exactly this using asp.net (it was no more than about 20 lines of code total I think). Looking into php, I think there are libraries to do this as well (and I'm certain you can do it using JSP too).

The thing is to have the font installed on the server that is making these images for you. To comply with accessability you could also append the text string to the alt tag in the image as well.

Just a suggestion!
Jeff
 
Thanks Jeff,

I understand what you mean, it's simliar to the valid codes display often on registration forms for websites.

Where a string of charactors are displayed as a bmp.

That is the kind of thing I need.

Trouble is I've never used asp or php, and I wouldn't know where to start.

But if you can suggest a JSP code that would be great.

Cheers for your help.

Steve

 
OK... here is the (condensed) asp.net solution - maybe someone can port it to jsp (and php?). I'll take a look over lunch to see if I can port it to jsp (just a matter of finding the right library calls I imagine).

Code:
<%@ Page Language="JavaScript" aspcompat=true debug="True"%>
<%@ Import Namespace = "System.Drawing" %>
<%@ Import Namespace = "System.Drawing.Imaging" %>
<%@ Import Namespace = "System.Drawing.Text" %>
<%
var TEXTHEADING = "This is a special heading";

var objBitmap = new System.Drawing.Bitmap(350, 100, PixelFormat.Format24bppRgb);
var objGraphics = Graphics.FromImage(objBitmap);

// start location of text
var textLocationPoint = new PointF(0, 0);

// build up header heading
objMyFontFamily = new System.Drawing.FontFamily("Eurostile");
var objMyFont = new System.Drawing.Font(objMyFontFamily, 16, FontStyle.Bold, GraphicsUnit.Pixel);	// use bold font
objGraphics.DrawString(TEXTHEADING, objMyFont, new SolidBrush(ColorTranslator.FromHtml("#669999")), textLocationPoint);
textLocationPoint.Y += objMyFont.Height;
objMyFont.Dispose();

// "write" GIF
Response.ContentType = "image/gif";
objBitmap.Save(Response.OutputStream, ImageFormat.Gif);

objGraphics.Dispose()
objBitmap.Dispose();
%>

Oh... and you would save this as an .aspx file (note the extra x) and it will run on IIS (with the .net framework installed).


Cheers,
Jeff
 
The solution I posted needs to be server-side. You could use a CGI and write something in Perl or some other language if you have the skills for this (I certainly don't). I can only help with the more mainstream server-side solutions.

The asp.net solution will work on any IIS 5.0 or greater that is able to run the .net framework (a small, free download to extend IIS from Microsoft). This will only be of use of you are using IIS (and asp etc).

I know it can be done in php as well... and suggested it would also be possible in JSP. I posted the code this morning from home hoping that someone else might be able to build on it... and provide a solution in those languages.

Regardless... if you want to implement this solution for your client, then you will have to do so using server-side code. First step is to find out what options are available for you to code server side (specifically: what file extensions - what server-side languages can be used).

Let us know the server-side technologies supported by your hosting account and we can take it from there!

Jeff
 
Another alternative would be to use embedded fonts. Take a look at faq215-4042 for a "how-to". It lets you use any TrueType font you like (copyright permitting) and allows you to stick with text instead of images.

The only drawback is that it only works in IE. Users of other browsers will see some other font. If the fancy font is just "chrome" this shouldn't be a problem.

If you want to see it in action, look at the top of . The quote should be in Viner Hand, even if you don't have that font on your PC.


-- Chris Hunt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top