TIP #119 Version 1.5: Angled Text on a Canvas

This is not necessarily the current version of this TIP.


TIP:119
Title:Angled Text on a Canvas
Version:$Revision: 1.5 $
Author:Simon Geard <simon dot geard at ntlworld dot com>
State:Draft
Type:Project
Tcl-Version:8.5
Vote:In progress
Created:Monday, 18 November 2002

Abstract

The current text object on a canvas does not support the creation of text strings at an arbitrary angle. For some applications this is limitation is sufficiently serious to disqualify Tk from use. This TIP removes this restriction.

Rationale

Using a Tk canvas to display e.g. an engineering drawing from a CAD application is limited - such applications will output angled text and there is simply no way of displaying such text on a canvas.

Another consideration is the competition. Both Qt and Java canvas objects support angled text on their canvas object - most new users would I believe be surprised to discover that this functionality is not supported.

Due to the internal architecture of Tk a side effect of this work would be to enable buttons (and possibly other widgets) to have their text written at an angle as well. This TIP does not expose that functionality.

Implementation

At the command level there would be an extra attribute, -angle, added to the canvas's text object:

<canvas> create text <x> <y> -text <str> ?-angle <angle>? ...

where the angle is specified in degrees. Manipulation of the angle would be done in the usual way through the itemconfigure and itemcget subcommands:

<canvas> itemconfigure <tag> -angle <angle>

Note that PostScript naturally supports rotation of text.

Reference Implementation

I have done an initial assessment of the amount of work required and have and have created a patch to implement it in Tk 8.4.5 . This initial work was fairly straightforward but the internal housekeeping work maintaining and interacting with an angled box will be more substantial. The patch [1] is for X only. It doesn't use any X extensions and should work for X11R3 and above. I don't know how it would be done on non-X systems but hopefully they'll (Win & MacOS at least) provide native tools to make their implementation straightforward as well.

Copyright

This document has been placed in the public domain.


Powered by TclThis is not necessarily the current version of this TIP.

TIP AutoGenerator - written by Donal K. Fellows