PDA

View Full Version : changing the fonts in out put



gurmeet
10-28-2009, 04:47 AM
hi, i am working in a php site, i want to give the output of 1 page in my native language, but i know every computer doesnot have this font installed on his/her computer, so how i can give out put of that page?


should i need to use any javascript or css for this or PHP is sufficient, give ur suggestions plz.......

jscheuer1
10-28-2009, 08:18 AM
Alternate fonts can and should be in the css, as not every computer has any particular font, though they all should have one each of the three generic fonts - serif, sans-serif, and monospace.

So you can do something like:


body {
font-family: arial, sans-serif;
}

The user will see this in arial if they have it, in their default sans-serif font if not. As many font's as desired may be listed, separated by commas as shown above. But the last font listed should always be one of the three generic ones mentioned. If a font listed has one or more spaces in its name, its name should be enclosed in quotes.

gurmeet
10-31-2009, 06:59 AM
actually i was asking abt the font in any specific language, as i want to write in punjabi, so i use AMRIT.ttf font, only a omputer which has this specific font can show page in readable format., others will show page in unreadable format... hope u got the point

james438
10-31-2009, 07:53 AM
I can see only two ways for you to do this. The first is to post a link to the font where the visitor can download and install the font and then will be able to view the page.

Or you could load the font to your website and create an image file in png format where you utilize the font for an image file with the Punjabi font.

Just for fun here is what the code would look like:


<?php
$im = imagecreatetruecolor(110, 40);
$green = imagecolorallocate($im, 0, 255, 0);
$red = imagecolorallocate($im, 255, 0, 0);
imagefilledrectangle($im, 0, 0, 90, 40, $red);
$font = imageloadfont('include/04b.gdf');
imagestring($im, $font, 0, 0, 'Hello', $green);
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>The above assumes that 04b.gdf was uploaded to your site.

Otherwise if a computer does not have the font on their computer I do not see how their computer would be able to interpret the font. Java maybe?

djr33
10-31-2009, 08:19 AM
For this reason, websites usually just tell their visitors to go and download a font.

It sounds like a lot to ask, perhaps, but realistically there is no nice way around it.

Something like using images instead will just slow you (and the website) down and then they can't copy/paste text, etc.

If you need a website in Punjabi, just require visitors to at least have the font. If you serve it in UTF8, it should be generally compatible if the font exists. More systems these days are now preinstalled with lots of fonts, so the situation is getting better.

gurmeet
10-31-2009, 10:52 AM
i can visit yahoo.com in punjabi, but there is no Punjabi font installed on my computer, but still i can read all the news, how its possible, n these are not the images, its simple text only

u can visit this page
http://in.punjabi.yahoo.com/
all the txt is in readable format, either there is no font installed

jscheuer1
10-31-2009, 01:42 PM
That page is served in the UTF-8 character encoding and the literal characters for that language are supported. If you view the source code, you will see the characters. Some basic code page and font support on the receiving computer may still be required. The site's developers probably have a keyboard and OS that writes these characters, but there are probably ways (though laborious) to write them with a standard keyboard and OS as well.

gurmeet
10-31-2009, 02:44 PM
yes i also noticed it when i opened view source,

do u know hw to implement this ?
means how i can give this implement in my web page ?
do i need any additional coding as wel? or what to do...?

is any1 is having any idea how to write in Punjabi kyboard in a web page?

jscheuer1
10-31-2009, 04:19 PM
Generally, (for your page) all you need is the meta tag for the encoding (example on a blank valid page):


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

</head>
<body>

</body>
</html>

However, some servers override these tags and serve the content in some other encoding. If so, you must change that on the server, at least for your site. At the same time, it is generally best for all but the most specialized servers to at least default to utf-8 encoding, though many do not. If you are not in control of this on your host and it prevents your page from being served in the required encoding, there is a good chance that your host would be willing to make the adjustment for you if asked.

As for typing in punjabi on your computer, ideally you would want to get a punjabi keyboard or some sort of overlay for your existing keyboard, so you can see what characters you are typing. But all that is required is that you install and activate the punjabi code page for the keyboard interface. These code pages generally come with your OS or can be obtained from the website of the manufacturer of your OS, as can instructions on installing and setting different code pages for your OS. Many OS versions from various manufacturers come in various language versions already specifically setup for a computer designed to operate in a specific non-English language.