Reference/Release Notes/2.40/Modelling/Text

From Blender Developer Wiki
Jump to: navigation, search

<section begin=2.40-Modelling-Text />

unicode font support

Shortlist of features:

  • Unicode character support for Font3D
  • UI to select characters from Unicode character list
  • UI to select Unicode table areas
  • Optimized character loading (Load only those characters which are used in font object)

Further information is available here:

Typefaces and Formatting

  • Support for Plain/Bold/Italic/Bold-Italic typefaces, switchable per character. For each combination, a seperate font file can be loaded. The "B" and "i" togglebuttons toggle bold and italic. For specifying what fonts to use for each combination, just set the desired combination, and then load the appropriate font file. (Yes you currently need to manually load the font files - yuck) Keep switching until all 4 possible font files are specified.
  • Inside editmode, use the "B" and "i" buttons to switch 1) either the selected block of text or, if nothing is selected, 2) the mode for new characters entered.
  • Shortcuts: CTRL-B / CTRL-I
  • Underlining for text objects. Not a lot to explain. New button "U" in the editbuttons, and CTRL-U as hotkey toggle underlining for newly entered characters or for the selection. Underline height (thickness) and Underline position (vertical) can be set in the editbuttons.


  • Support for material indices per character. Just switch to the desired material index in the usual editbuttons, and start typing using that Material index. For switching an entire block, select a block, then switch to the desired material index, then hit "Assign".

Text alignment

  • "Flush" and "Justify". "Flush" *always* flushes the line, even when it's still being entered, it uses character spacing (kerning) to fill lines. Justify only flushes a line when it is *terminated* either by wordwrap or by Enter, it uses *whitespace* instead of *character spacing* (kerning) to fill lines. These only work with at least one textframe.
  • Adjustable word spacing -New button "Word spacing" specifies a factor by which whitespace gets scaled in width.
  • Manual kerning per character - Between any pair of characters, press ALT-Left / ALT-Right to decrease/increase kerning by steps of 0.1 (IIRC).
  • Overlapping characters have no filling errors

Text frames

  • Arbitrary number of freely positionable and resizable text frames per text object, with continuous text flow between them
  • Automatic wordwrap at the border of a text frame
  • A new text object always has one initial text frame, with offset and width/height set to 0.
  • Frames with width set to 0 are ignored completely (no wordwrap happens), frames with height set to 0 flow forever (no switch to the next textframe).
  • Creating/Deleting/Choosing textframes works exactly like material indices.
  • To create a new textframe, press the "Insert" button, which will insert a new textframe after the current one, with the same coordinates and dimensions. You will need to move it (X:/Y: buttons) to see it.
  • The active textframe (choosable with the "1 TextFrame: 1" button) is drawn in the active theme colour.
  • Text flows continuously from the lowest-numbered into the highest-numbered frame.
  • "Delete" deletes the current text frame (but obviously, not the text itself) and removes it from the flow.

Text Editing


Selection works like in any usual word processor.

Pressing SHIFT while moving (Left/Right/Up/Down/PageUp/PageDown/CTRL-Left/Right) selects text (this should be mousified some day).

Moving the cursor without SHIFT will clear the selection. Entering characters or performing other actions with selected text will erase it.

CTRL-C copies the text into a buffer, CTRL-V pastes the buffer (including all formatting information) at current cursor position. CTRL-X cuts and copies into the buffer.

Selections are remembered over exiting editmode.

CTRL-Backspace to delete all text in textediting.

Inserting text at cursor

After the many unsuccessful attempts to provide a sane way to load bigger blocks of text into a text object, I've created a simple "Insert Text" button which pops up a fileselector and inserts the chosen file's contents at the cursor position. Can't get much simpler.

Text Navigation

  • CTRL-Left/Right goes to next/previous word
  • More standard HOME/END keys for going to beginning/end of current line (used to be shift-left/right)
  • Support for PageUp/PageDown for going back/forward 10 lines at a time


  • "Lorem" button for inserting a random paragraph of Lorem Ipsum at the text cursor
  • Increased maximum text size from 1000 to 50000 characters
  • Increased curve filling speed by a factor of about 10 for smaller texts, and 100 and beyond for larger texts, thus text objects are now always filled inside editmode, except if turned off with "Fast Edit". (which only can be toggled OUTSIDE editmode).
  • More complex font files supported, which formerly used to crash Blender


Full compatibility with old text objects not fully restored (word spacing will be 0.0, need to set it manually to 1.0), will either need version upgrade to 238 or a hack. Will check.

Coder notes

The overlapping curves/material indices problem got a bit out of control.

For avoiding the 'overlapping character problem' in Text objects, I had changed the sorting code for filling nurbs to use nu->charidx (a newvariable incremented with each new character) instead of nu->mat_nr (which used to work for material indices inside a 2D Curve).

This broke material indices in normal 2D Curves completely, thus:

nu->charidx is now not only used for seperating characters in text objects for filling, but also for normal 2D curves when they contain material indices. In fact, charidx is just set to the material index.

There's compatibility code in readfile.c that sets nu->charidx to nu->mat_nr when reading curves from files that are not text objects

So, the big conclusion: Instead of using material indices for creating 'filling groups', filldisplist() now uses nu->charidx, which is set appropriately when reading old files and assigning/deleting material indices in curves.

This is all pretty obscure and hard to explain. If I haven't been clear, ask.

In the past, there were bugs with material indices uninitialized, and thus crashes in the renderer with illegal material indices.

Even though I assume they have been fixed, I've put in a check that checks (hah) if the material index of a character is illegal (bigger than ob->totcol), and then sets it to zero, and spits out a warning on stderr.

If you see such warnings, please report and link to the .blend.

If it breaks anything, complain!

Fix Python API to correctly create Text3D objects. This is just a temporary fix (duplicating code again), the *real* fix would be to once make one central function to create and init a text object for all places...

regression test

There's now a regression test file for text objects <section end=2.40-Modelling-Text />