DrawKit documentation

Styles and Text

«  Rasterizer Groups   ::   Contents   ::   Style Registry  »

Styles and Text

Given how useful the ability to share styles among multiple objects can be for many applications, DKStyle also supports text attributes that can be shared among text objects in exactly the same way. All styles support text attributes independently of any rasterizers they might also have, but by default the text attributes are not set. The category DKStyle+Text provides numerous additional methods on a DKStyle for setting attributes such as the font, paragraph style, alignment and so forth.

Objects such as DKTextShape can use their attached style’s text attributes or their own local attributes - again it’s up to the application design to decide how such objects should typically operate. The text attributes of rasterizers such as DKTextAdornment are independent of the style’s attributes, if it has any, except for the case of dragging text onto an object, where the style’s text attributes, if any, are used for the adornment’s initial attributes.

It is possible to define a style with only text attributes - in fact DKStyle+Text returns such a style by default, having 18pt Helvetica centred text. Styles that only have text attributes are also usually named after the font for ease of easily identifying them, but this is up to your application - there is a class method to generate a suitable name from the font info.

The DKTextShape object is also able to set its style’s text attributes if the style is not locked, by directly responding to standard Text menu commands such as Bold, Italic and so forth, and to the Font Panel. If the style is shared all objects sharing the style will be updated as well. Currently Drawkit requires that the text attributes apply to all of the text at once (because where a style’s attributes can be shared by different pieces of text, applying the text in ranges is not really feasible as each piece of text is generally different). However if you elect to disconnect a DKTextShape from its style and allow it to use its local attributes, different attributes can be applied to different ranges of the text if required. The disadvantage of course is that this “style” is then unique to that particular DKTextShape object.

«  Rasterizer Groups   ::   Contents   ::   Style Registry  »