Jump to content


Photo

Add font for imagestring?


  • Please log in to reply
14 replies to this topic

#1 high6

high6

    Young Padawan

  • Members
  • Pip
  • 57 posts

Posted 25 July 2007 - 09:15 PM

How do I install font on my server so imagestring can use a custom font?

#2 _*Creative Insanity_*

_*Creative Insanity_*
  • Guests

Posted 25 July 2007 - 09:17 PM

You can't. Only default fonts are used by a browser. It also depends what the viewer has installed and 99% of the time they have not got the one you are using. If you want to use a special font for some reason use it as an image.

#3 rc69

rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 25 July 2007 - 11:30 PM

I believe he is talking PHP, not CSS.

If that's the case, check the manual.
http://php.net/manua...imagefttext.php

#4 Chaos King

Chaos King

    Senior Programmer

  • P2L Staff
  • PipPipPip
  • 676 posts
  • Gender:Male
  • Location:Florida

Posted 25 July 2007 - 11:35 PM

You can't. Only default fonts are used by a browser. It also depends what the viewer has installed and 99% of the time they have not got the one you are using. If you want to use a special font for some reason use it as an image.

Wrong, WRONG! =/
You can install fonts onto your server if you have root access to do so. Otherwise, you can upload them if they are on your computer and point it to the absolute font path.

For instance:

/home/jamie/public_html/fonts/Arial.ttf

Or what ever the font format is. <_<

#5 Mr. Matt

Mr. Matt

    Moderator

  • Validating
  • PipPipPipPip
  • 1,945 posts
  • Gender:Not Telling

Posted 26 July 2007 - 06:30 AM

Not 100% confirmed on this. But i remember a while back trying to use some fancy font i found on a site i was doing. It worked for me while viewing, but for others it just restored back to default. So maybe if the font is on the users machine, it may be used.

Like I said, not fully sure.

Matt

#6 curthard89

curthard89

    Young Padawan

  • Members
  • Pip
  • 226 posts

Posted 26 July 2007 - 07:17 AM

yer ur right, if its on users system it will work, otherwise default to a system font, hence why you have font family's in CSS

if you really need the font, use flash text replacement sifr thingy works a treat

#7 Chaos King

Chaos King

    Senior Programmer

  • P2L Staff
  • PipPipPip
  • 676 posts
  • Gender:Male
  • Location:Florida

Posted 26 July 2007 - 03:26 PM

Not 100% confirmed on this. But i remember a while back trying to use some fancy font i found on a site i was doing. It worked for me while viewing, but for others it just restored back to default. So maybe if the font is on the users machine, it may be used.

Like I said, not fully sure.

Matt



yer ur right, if its on users system it will work, otherwise default to a system font, hence why you have font family's in CSS

if you really need the font, use flash text replacement sifr thingy works a treat


Guys, he is talking about using custom font with his GD library in PHP. I don't know where you guys got CSS From all this.

#8 high6

high6

    Young Padawan

  • Members
  • Pip
  • 57 posts

Posted 26 July 2007 - 04:21 PM

This isn't gonna be echoed to the user and displayed in their browser like that. It is going to be on an image generated by php on my server so as long as my server has it it will work but I don't know how to install a font on my server.

#9 pirateXcore

pirateXcore

    Young Padawan

  • Members
  • Pip
  • 281 posts
  • Gender:Male

Posted 26 July 2007 - 04:27 PM

This might be tedious, idk...but could you just make all the images yourself?
letters, numbers & special chars you plan on using.
then just have php call those images depending on what the user input is?

#10 Demonslay

Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 973 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 26 July 2007 - 05:06 PM

Why do that when all he has to do is upload a font file, and call it with imagettfstring()?

Just follow the link Matt gave and all you need is right there.

#11 rc69

rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 26 July 2007 - 10:55 PM

Demonslay, you're slipping. Matt hasn't posted any links :D

I believe he is talking PHP, not CSS.

If that's the case, check the manual.
http://php.net/manua...imagefttext.php


Seriously though, this isn't a complicated matter. It takes 2 steps

1. Upload the font file. I don't care where you put it just put it some where and know where some where is.
2. Use the function i told you about in the 3rd post. Read the manual for EXACT info on how to use it.

If for some reason you don't like/want to use the method i provided, heres a couple more straight out of the PHP MANUAL.
http://php.net/manua...ageloadfont.php
http://php.net/manua...magettfbbox.php

Edited by rc69, 26 July 2007 - 10:56 PM.


#12 high6

high6

    Young Padawan

  • Members
  • Pip
  • 57 posts

Posted 27 July 2007 - 01:22 AM

Demonslay, you're slipping. Matt hasn't posted any links :D

I believe he is talking PHP, not CSS.

If that's the case, check the manual.
http://php.net/manua...imagefttext.php


Seriously though, this isn't a complicated matter. It takes 2 steps

1. Upload the font file. I don't care where you put it just put it some where and know where some where is.
2. Use the function i told you about in the 3rd post. Read the manual for EXACT info on how to use it.

If for some reason you don't like/want to use the method i provided, heres a couple more straight out of the PHP MANUAL.
http://php.net/manua...ageloadfont.php
http://php.net/manua...magettfbbox.php


Thankyou for the links, Now is there a function to get all the fonts on the server?


My php doesn't support imagettftext.
"Call to undefined function: imagettftext()"

imageloadfont wont work because my fonts are .ttf

Edited by high6, 27 July 2007 - 02:54 AM.


#13 Chaos King

Chaos King

    Senior Programmer

  • P2L Staff
  • PipPipPip
  • 676 posts
  • Gender:Male
  • Location:Florida

Posted 27 July 2007 - 07:32 AM

*sigh*

Just contact your host and tell them to install the GD library.

#14 high6

high6

    Young Padawan

  • Members
  • Pip
  • 57 posts

Posted 27 July 2007 - 11:46 AM

*sigh*

Just contact your host and tell them to install the GD library.


It is installed... The newest version too.

#15 rc69

rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 27 July 2007 - 12:31 PM

Thankyou for the links, Now is there a function to get all the fonts on the server?


My php doesn't support imagettftext.
"Call to undefined function: imagettftext()"

imageloadfont wont work because my fonts are .ttf

Nothing specifically for that reason, no. But through the use of something like glob() i'm sure you can come up with something.

As for the .ttf problem, have you tried read the user comments? Often times those are more useful than the manual itself.
http://www.php.net/m...dfont.php#72223

*sigh*

Just contact your host and tell them to install the GD library.

*sigh*

Note: This function requires GD 2.0.1 or later (2.0.28 or later is recommended).

Note: This function is only available if PHP is compiled with freetype support (--with-freetype-dir=DIR)


Edited by rc69, 27 July 2007 - 12:32 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users