note 49505 added to function.printf

From: Date: Sun, 30 Jan 2005 16:24:11 +0000
Subject: note 49505 added to function.printf
Groups: php.notes 
Request: Send a blank email to php-notes+get-84241@lists.php.net to get a copy of this message
Several people have commented about problems with aligning numbers. I just wanted to add a bit of clarification. According to the spec all True Type Fonts (especially porpotional spaced fonts) use a fixed width for numeric digits. All digits have the same width which is equal to the width of "0". Where things go haywire when trying to align numbers is that the space character does not have the same width as a digit when using a porportional spaced font. Therefore if you want to line up a column of numbers, you can not use leading spaces to position them unless you use the same quantity of space characters for each row. e.g. your numbers have leading zeros etc. The simplest solution is to switch to a monospaced font. Alternativly you can use positioning tags. Summary: Your numbers will always line up properly regardless of the font used, if you get the starting position to be consistant. ---- Manual Page -- http://www.php.net/manual/en/function.printf.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+49505 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49505&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49505&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49505&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49505&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49505&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+49505&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#84241) next »