chordsoflife Posted October 31, 2008 Share Posted October 31, 2008 I was just thinking (I don't know a lot of PHP) about a possible idea, at least for headers. Would it be possible to type out the alphabet in a given font, caps and lowercase, spaces and special characters, then slice it and save them all as the appropriate character.jpg or something. Then, write a class that explodes a given input into its individual characters, and outputs that same input in the corresponding images. I would imagine that if that was possible, it would be done. So I must be missing something. Thoughts? Link to comment https://forums.phpfreaks.com/topic/130925-solved-use-any-font-with-php/ Share on other sites More sharing options...
Mchl Posted October 31, 2008 Share Posted October 31, 2008 It is possible and probably done. It's just not practical in most cases. Link to comment https://forums.phpfreaks.com/topic/130925-solved-use-any-font-with-php/#findComment-679632 Share on other sites More sharing options...
chordsoflife Posted October 31, 2008 Author Share Posted October 31, 2008 Do you have any idea about load times and whatnot? Is that why it's impractical? Link to comment https://forums.phpfreaks.com/topic/130925-solved-use-any-font-with-php/#findComment-679634 Share on other sites More sharing options...
Mchl Posted October 31, 2008 Share Posted October 31, 2008 Loading times should not be an issue actually. Problem is, large font sizes[1] need to have kerning adjusted (i.e. spaces between letters). This is done on letter to letter basis, so distance between WW is different than between MW. Otherwise things start to look really ugly. A script to take care of this would not be that simple. There are also other typographic concerns. [1]: With small font sizes lack of kerning is not as visible. Link to comment https://forums.phpfreaks.com/topic/130925-solved-use-any-font-with-php/#findComment-679640 Share on other sites More sharing options...
chordsoflife Posted October 31, 2008 Author Share Posted October 31, 2008 Cool, thanks for the input. Luckily, the site I'm designing is based on a handwritten font, so really... the messier the better. I'm learning PHP so this is a good opportunity to learn a bit about creating a function. Stoked. Link to comment https://forums.phpfreaks.com/topic/130925-solved-use-any-font-with-php/#findComment-679647 Share on other sites More sharing options...
Mchl Posted October 31, 2008 Share Posted October 31, 2008 One thing I always lacked in 'handwritten' fonts is that same letters look the same... So 'a' looks always the same, so does 'b' etc... With the technique you described, you could create more than one 'picture' for each letter and then use them randomly. Link to comment https://forums.phpfreaks.com/topic/130925-solved-use-any-font-with-php/#findComment-679661 Share on other sites More sharing options...
chordsoflife Posted October 31, 2008 Author Share Posted October 31, 2008 That's a really good idea- I also have the same issue with the fonts. I'm going to start with step one and then try to get more complex from there. If When I'm successful I'll post the script back here. Optimism Amiright? Link to comment https://forums.phpfreaks.com/topic/130925-solved-use-any-font-with-php/#findComment-679673 Share on other sites More sharing options...
Mchl Posted October 31, 2008 Share Posted October 31, 2008 It won't be something devilishly difficult (or at least doesn't look like), so you might be optimistic Link to comment https://forums.phpfreaks.com/topic/130925-solved-use-any-font-with-php/#findComment-679679 Share on other sites More sharing options...
futurshox Posted October 31, 2008 Share Posted October 31, 2008 You should have a look at GD fonts. Have a Google for GD font converter*, and check out http://us2.php.net/manual/en/function.imageloadfont.php. The idea is to use the fonts to write onto an image, and then output the image. Which may or may not be suitable for what you want to do. This may also be useful but I've not played with it yet: http://us2.php.net/manual/en/function.imagettftext.php * You'll see a lot of references to a converter by a chap named Phillip, but this seems to have gone. Link to comment https://forums.phpfreaks.com/topic/130925-solved-use-any-font-with-php/#findComment-679710 Share on other sites More sharing options...
chordsoflife Posted November 1, 2008 Author Share Posted November 1, 2008 Well, for the most part, I got this working. There are way more variables than I originally expected though. For instance, my function took two arguments: the text and the font size. I suppose I could have eliminated font size but that wouldn't make it very usable. Anyway, I wound up only working with A, a, B, b, C and c, and saving each one of those at 12, 14, 16... through 38px high. Then I set up a few if/else statements to determine what size lowercase should be relative to uppercase. Then I realized I would have to save 46 more characters in 14 sizes, never mind all the *(Q@#^$&*%}{:" and whatnot. So yea, it worked. But no. Link to comment https://forums.phpfreaks.com/topic/130925-solved-use-any-font-with-php/#findComment-679874 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.