Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 2113 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

GD Question - Aligning text

Thread title: GD Question - Aligning text
Closed Thread    
    Thread tools Search this thread Display Modes  
08-01-2007, 08:59 PM
#1
PicoDeath is offline PicoDeath
Status: Junior Member
Join date: Jun 2007
Location: United Kingdom
Expertise:
Software:
 
Posts: 63
iTrader: 0 / 0%
 

PicoDeath is on a distinguished road

  Old  GD Question - Aligning text

When aligning text on an image i have no idea sometimes how long the text will be, so sometimes it doesn't align nicely. Check the preview for example.




I'd like it to end where 'Underground' does no matter how many characters are displaying thanks.

08-01-2007, 10:21 PM
#2
Salathe is offline Salathe
Salathe's Avatar
Status: Community Archaeologist
Join date: Jul 2004
Location: Scotland
Expertise: Software Development
Software: vim, PHP
 
Posts: 3,820
iTrader: 25 / 100%
 

Salathe will become famous soon enough

Send a message via MSN to Salathe

  Old

You can use GD's imagettfbbox function to calculate the 'bounding box' of the text (in this case "Pro") then do a few quick calculations for the x and y co-ordinates to be fed into imagettftext (or whatever you're using to render the text).

08-01-2007, 11:15 PM
#3
CreativeLogic is offline CreativeLogic
CreativeLogic's Avatar
Status: Request a custom title
Join date: Feb 2005
Location:
Expertise:
Software:
 
Posts: 1,078
iTrader: 6 / 100%
 

CreativeLogic is on a distinguished road

Send a message via MSN to CreativeLogic

  Old

That's exactly what you need to do.

08-01-2007, 11:45 PM
#4
PicoDeath is offline PicoDeath
Status: Junior Member
Join date: Jun 2007
Location: United Kingdom
Expertise:
Software:
 
Posts: 63
iTrader: 0 / 0%
 

PicoDeath is on a distinguished road

  Old

alright, Thanks.

I'll try this tomorrow when I'm wide awake.

08-02-2007, 04:23 PM
#5
PicoDeath is offline PicoDeath
Status: Junior Member
Join date: Jun 2007
Location: United Kingdom
Expertise:
Software:
 
Posts: 63
iTrader: 0 / 0%
 

PicoDeath is on a distinguished road

  Old

I'm not sure how I'm supposed to do it and the examples on PHP.net seem a little complicated for what i need to do.

I want it to end 61 pixels from the left ALL the time. For most of the text on the image, could one of you do an example of exactly what i need?

Thanks.

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed