Something like:
Code:
((canvas_width - text_length) div 2)
Maybe I haven't understood your question