Idea for underlining in GD text functions
| From: | Tim Toohey | Date: | Sat, 06 Nov 2004 06:21:58 +0000 |
| Subject: | Idea for underlining in GD text functions | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-13752@lists.php.net to get a copy of this message | ||
I've had a need to draw underlines in text created with the GD image
functions, specifically ImagePSText(). As far as I could tell there's no
way to do this (apart from using ImageLine(), which would be difficult to
really get right). [I'm happy to hear suggestions if I've missed the
obvious :-)]
An added complication of what I wanted to achieve was to underline only part
of the string being drawn, while maintaining kerning between characters.
The system I've come up with is to embed "control sequences" into the string
that is passed to ImagePSText(). A control sequence contains commands which
change various characteristics of the output, for instance, toggle
underlining. I'm currently using the escape character (chr(27)) to indicate
the start of a control sequence, and a semi-colon to end the sequence.
For example:
$str="Some text with an " . chr(27) . "u;underlined" . chr(27) . "u;
word";
I've attached a patch for gd.c which does what I'm talking about.
I wondering whether people think this is a good way to go, and if so if I
should commit this code? If it's not a good idea, any suggestions for
drawing underlines?
Thanks,
Tim
Attachment: [text/x-diff] imagepstext-control-seq.20041106.diff
Attachment: [text/x-diff] imagepstext-control-seq.20041106.diff