[Select]

Application Suite: Draw


 

Text area objects

A text area is a special sort of object that allows you to do simple 'desktop publishing'. A text area consists of a piece of text divided into one or more rectangular regions called text columns. Draw breaks up the text into lines which are just wide enough to fit into the columns, splitting it (principally) at spaces. A text area may have more than one column. Draw again works out how to divide the text between the columns, filling up each one before moving to the next.

Create a text area by using a text editor (such as Edit) to prepare a file containing the text, annotated with special commands (described below). When the text file is loaded into a Draw diagram, the text is formatted into columns. The number of columns is given by an annotation, By using Select mode, you can move the text columns and change their size As you do this, Draw will reformat the text between the columns.

Text areas only use anti-aliased fonts: you cannot create a text area in the system font. If you try to use the system font you will find that it is automatically converted into the Trinity font. See the sub-section Default text area header later.

If you wish to create a text area in system font, use the outline font version of the system font instead of the normal system font. You can choose the outline version, called System Fixed, from the Font name sub-menu off the Style menu.

Creating and editing text areas

To create a text area object from a text file drag the file into a Draw window. The columns in the text area are initially set up to standard sizes. If you drag the text file over the top of an existing text area, the old text in the area is replaced with the contents of the new file. Use this method for altering the text in a text area.

Text area selection works in two slightly different ways, depending on how many text columns there are in the text area:

  • When there is a single text column in the text area, selection works in the same way as any other object. You can move the text area, scale it, change its style, and so on, as described above.
  • When there is more than one text column, selection is a two-stage process, When you first click SELECT (or ADJUST, in multiple object selection) over the text area, the entire area is selected. You can move the area, but it cannot be scaled. Double-click SELECT (or ADJUST) to select a column of the text area. The individual columns can be moved and scaled. Their new position and size need not lie within the original text area. When the size of a text column changes, the text is reformatted to fit the new size of the column. At the end of the operation. The bounding box of the text area is changed to reflect any changes made to the column: it is arranged to contain all of the text columns, with a small additional border. To select more than one column of a text area, select the first as described above, and select further ones by first clicking ADJUST and then double-clicking SELECT over the column.

Text areas and columns cannot be rotated.

Some select mode actions cannot be applied to text columns. If there are any text columns selected when you do the action they are deselected first. An example of this is object deletion; you can delete a text area as a whole, but not a text column from within it.

An example

The text shown below, typed into Edit and loaded into Draw as an Edit file, creates the text area shown following:

\! 1
\AD
\D2
\F0 Trinity.Medium 24
\L24
\P24
\0A sample text area

This is an example of a text area containing two columns. The text was created in Edit, and then saved directly into Draw. The columns were then stretched to the right size, using select mode, and the rectangles added.

The appearance of a text area is determined from commands which are included in the text used to create it. Each command starts with a backslash character. The full list of sequences is given below but the following is a brief description of the commands used in the example

  • \! 1 tells Draw that this is a text area.
  • \AD causes the text to be justified to left and right in its columns.
  • \D2 indicates the number of columns to be used.
  • \FO Trinity.Medium 24 specifies font 0 as Trinity.Medium, 24 point.
  • \L24 sets the line spacing to 24 points.
  • \P24 sets the spacing between paragraphs to 24 point. In this example, this just affects the space after the title.
  • \0 selects font 0 for the following text.

Text area commands

The following is a complete list of text area commands. Some commands must be terminated with either a newline or a slash (/) character. Others do not need a terminator (for example, where the command has a fixed number of characters), but may optionally end with a slash character. For clarity, it is often useful to include it. Note especially that all commands are case sensitive: this is unusual in RISC OS applications.

In the following descriptions

  • Items in italics, for example code. indicate a parameter you must supply.
  • Items in square brackets are optional, for example [/] indicates an optional slash character
  • Commands and parameters must normally be separated by spaces though there does not have to be a space between the command and the first parameter.
  • nl means a single newline character, and nl/ means newline or /.

The full list of annotations is as follows:

CommandEffect
\ version nl/This is a special line which must appear at the start of any file which is to be used for a text area. Version must be 1. However, it forms part of a default header which is inserted at the start of the text; this is described below.
\A code [/]Set alignment, code may be L (left aligned), R (right aligned), C (centred) or D (double, ie justified to both margins). An alignment setting forces a line break. The default setting is left aligned.
\B red green blue nl/Set the background colour to the given red/green/blue intensity, or the best available approximation. Each intensity is in the range 0 to 255: values outside this range will be limited to it (ie a value set higher than 255 will be realised as 255; a value set to less than 0 will be realised as 0). Background colour is used in the same way as for text objects; you should set it to be the same as the area of the drawing that the text area is to appear in front of (the text area itself is effectively transparent). The default is the background style attribute of the text area object, normally white (equivalent to \B 255 255 255).
\C red green blue nl/Set the text colour to the given red/green/blue intensity, or the best available approximation. Each intensity is in the range 0 to 255; values outside this range will be limited to it. The default is the text colour style attribute of the text area object, normally black (equivalent to \C 0 0 0).
\D columns nl/Indicates that the text area is to contain the indicated number of columns. This must appear before any printing text. The default is 1.
\F font-number name size [width] nl/Defines a font reference, font-number is either one or two digits. The font number is used subsequently to set the font. Name is a font name such as Trinity.Medium. size and width are the height and width of the font in points. If width is omitted, the size is used for both height and width. There are no defaults
\font number [/]Indicates that the text from the point at which the command appears is to appear in the specified font. If the font is not available when the text is being drawn the effect is undefined. Draw will attempt to check that the font number and the corresponding definition are reasonable. There is no default.
\L line-spacing nlSets the line spacing (the distance from the base of the characters in one line to the base of the characters in the next) to the given value, measured in points. Line spacing changes take effect from the end of the output line in which the command appears. The default is 10 points.
\M left-margin right-margin nlSets the left and right margins to the given values, measured in points. If the total size of the margins is greater than the width of the column, no text is displayed. Margin settings apply from the end of the output line in which the command appears. The default is 1 point at each side.
\P paragraph-spacing nlSets the extra space inserted between paragraphs to the given value, measured in points. Paragraph spacing changes take effect from the end of the output paragraph in which they appear. The default is 10 points.
\U position thickness nlSwitches on underlining, at the given position relative to the base of the characters, position is limited to the range-128 to 127, and thickness to the range 0 to 255. Both values are measured in units of 1/256 of the current font size. Underlining may be turned off by specifying a thickness of 0.
\U. [/]An alternative way of turning underlining off.
\V|-| vertical-move [/]Moves the following text by the given amount, measured in points, relative to the current character position. This is intended for superscripts and subscripts; use positive values for superscripts, negative values for subscripts.
\-Inserts a soft hyphen. This tells Draw that it may split the word at this point if necessary, inserting a hyphen character in the output. If the word is not split at the soft hyphen, it has no printing effect.
\nlForces a line break.
\\Inserts a backslash character.
\;text nlTreated as a comment. Characters up to and including the next newline are ignored.

Rules for displaying text

Line splitting

Draw displays text in text areas by splitting it into lines and columns. When working out where to split the text, Draw first tries to split it at the space or soft hyphen that gives the most characters that will fit in the column. If this is not possible, the text is split at the character that gives the longest line that just fits in the column.

Special characters and paragraph formatting

Certain characters have special interpretations:

  • All control characters are ignored, except tabs, which are treated as spaces.
  • Newline characters appearing before any printing text insert a paragraph spacing.
  • A single newline character in the body of the text is treated as being equivalent to a space, unless it is preceded or followed by a space, in which case it is ignored.
  • A sequence of n newline characters in the body of the text inserts n-1 paragraph spacings.

For columns other than the first, paragraph spacings at the head of the column are ignored. Lines which protrude vertically beyond the limits of the column are not displayed; however, all commands occurring in them are interpreted. This can occur if the line spacing is significantly smaller than the font height. You should take care (by using the \M command) to ensure that lines do not protrude beyond the limits of the column horizontally, since the text may not be displayed correctly in this case. The only circumstances in which this is likely to happen are when an italic font is used and the margin setting does not allow for it.

Font usage

When a text area is being constructed from a text file, or being loaded as part of a Draw file, checks are made on the fonts contained in it. If a font is not available, a warning message is displayed. Text that should be in this font will appear in the most recently used font. If no valid font has ever been seen, the text is not displayed

Exporting text from a text area

Text used to construct a text area may be re-exported into a text file, by choosing Text area from the Save menu. This can be useful for altering text areas in a Draw file, when the original text file used to create them is no longer available.

Default text area header

If the text does not start with a version number line (\! I), Draw will insert the following standard header:

\! 1
\F 0 Trinity.Medium 12
\F 1 Corpus-Medium 12
\0
\AD
\L12

This defines two font references, sets the text to be displayed in font 0 (Trinity Medium), justified to both left and right margins, with a line spacing of 12 points.

If you subsequently export the text, the standard header will be exported as well.

DXF files

Draw can read files in DXF (data interchange) format. This is a file format used by other graphics programs such as AutoSketch. Draw cannot save files in DXF format.

When you load a DXF file into Draw by dragging it into a window or onto the Draw icon, a dialogue box appears, in which you can specify;

  • whether coordinates and sizes in the file are to be interpreted as being in inches or centimetres;
  • a scaling unit to be applied to all coordinates and sizes;
  • the name of the font in which text is to be plotted. If the name you give is blank, or is not the name of an outline font known to Draw, the text will be plotted in the system font

To load the file click on OK If you click on Abandon, the file is not loaded.

The following restrictions apply to DXF files loaded into Draw:

  • The following DXF object types are not implemented: SHAPE, ATTDEF, ATTRIB, 3DLINE, 3DFACE, DIMENSION.
  • Line types are ignored: all lines are created as solid.
  • Layers are not implemented.
  • Text justification may be approximate in outline fonts.
  • Straight line objects are drawn in a single width and colour.
  • Colours are guessed from a set of standard values. Unknown colours are converted to black.
  • Text may not be rotated or oblique. The text style table is not used. There is no backwards or upside-down plotting.
  • A single font is used for all the text in the file.
  • There is no curve fitting.
  • Block inserts do not use column and row values, attribute entries, rotation, or z scaling

Next


This documentation is copyright 3QD Developments Ltd 2013 and may not be reproduced or published in any form without the copyright holder's permission. RISC OS is subject to continuous development and improvement as such all information is provided by 3QD Developments Ltd in good faith and is believed to be correct at the time of publication E&OE. 3QD Developments Ltd cannot accept any liability for any loss or damage arising from the use of any information provided as part of the RISC OS Documentation.

HTML document version r23142 (3rd November 2015)