phpknight Posted June 27, 2007 Share Posted June 27, 2007 I am writing a program with the GD library and need to arc a font like Photoshop does. I know how to write text, slant a font, etc., but I cannot figure out how to arc it and do other things. Is this possible with PHP? phpknight Link to comment https://forums.phpfreaks.com/topic/57394-solved-can-you-arc-a-font-with-php/ Share on other sites More sharing options...
Barand Posted June 27, 2007 Share Posted June 27, 2007 It's certainly possible if you know the trigonometry involved. You'd have to place each character individually. positioned on the curve and at an angle tangential to the curve at that point. Character spacing would also need calculating. Or, as in my sig, do it by displacing pixels to follow (in this case) a sine wave Link to comment https://forums.phpfreaks.com/topic/57394-solved-can-you-arc-a-font-with-php/#findComment-284020 Share on other sites More sharing options...
phpknight Posted June 27, 2007 Author Share Posted June 27, 2007 Barand, Thanks. It seems like the latter option--getting it to follow a curve--is more like what I would be looking for since the characters themselves would be curved. Please send any info along to help me get started--possible useful functions, etc. phpknight Link to comment https://forums.phpfreaks.com/topic/57394-solved-can-you-arc-a-font-with-php/#findComment-284402 Share on other sites More sharing options...
Barand Posted June 27, 2007 Share Posted June 27, 2007 You need a source image containing the text placed using http://www.php.net/imagettftext and you need a destination image. Loop through the rows and columns of the source image to get each individual pixel http://www.php.net/imagecolorat Place them in the destination image off-setting the y position according the curve you want to follow http://www.php.net/imagesetpixel Link to comment https://forums.phpfreaks.com/topic/57394-solved-can-you-arc-a-font-with-php/#findComment-284418 Share on other sites More sharing options...
phpknight Posted June 27, 2007 Author Share Posted June 27, 2007 Okay, then every pixel in the same column would be offset by the same amount, right? Basically, I would be adjusting every column by adjusting every pixel in that column. Is this what you mean? phpknight Link to comment https://forums.phpfreaks.com/topic/57394-solved-can-you-arc-a-font-with-php/#findComment-284427 Share on other sites More sharing options...
Barand Posted June 27, 2007 Share Posted June 27, 2007 Yes. In my sig image I complicated it a little by also applying a linear skew so the x positions are also offset by ever-increasing amounts from bottom to top Link to comment https://forums.phpfreaks.com/topic/57394-solved-can-you-arc-a-font-with-php/#findComment-284433 Share on other sites More sharing options...
redarrow Posted June 27, 2007 Share Posted June 27, 2007 Barand Do a quick tutoral for all of us pretty please lol. I love ur tutorals m8. Link to comment https://forums.phpfreaks.com/topic/57394-solved-can-you-arc-a-font-with-php/#findComment-284441 Share on other sites More sharing options...
phpknight Posted June 28, 2007 Author Share Posted June 28, 2007 Barand, I was just thinking about that horizontal thing. What is the function for that skew? Or how do you know which way to adjust each pixel horizontally? phpknight Link to comment https://forums.phpfreaks.com/topic/57394-solved-can-you-arc-a-font-with-php/#findComment-284442 Share on other sites More sharing options...
Barand Posted June 28, 2007 Share Posted June 28, 2007 Maximum x offset, say -50 px (left skew) Image height 50 px So at bottom of the image the offset is zero, at the top it is -50 px If you are on row Y, the offset is maxOffset * Y / imageHeight Link to comment https://forums.phpfreaks.com/topic/57394-solved-can-you-arc-a-font-with-php/#findComment-284445 Share on other sites More sharing options...
Barand Posted June 28, 2007 Share Posted June 28, 2007 Correction maxOffset * (imageHeight - Y) / imageHeight as y increases from top to bottom Link to comment https://forums.phpfreaks.com/topic/57394-solved-can-you-arc-a-font-with-php/#findComment-284452 Share on other sites More sharing options...
Barand Posted June 28, 2007 Share Posted June 28, 2007 Do a quick tutoral for all of us pretty please lol. OK, Red, see http://www.phpfreaks.com/forums/index.php/topic,147174.msg630982.html#msg630982 Link to comment https://forums.phpfreaks.com/topic/57394-solved-can-you-arc-a-font-with-php/#findComment-284766 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.