Ideas for a next gen JUCE Text System


#1

I was hoping there would be a way to add Complex Text support with minimal changes to the existing text system. Unfortunately, due to the way Uniscribe (Window’s Complex Text API) works, this simply isn’t possible. Since this would require a complete overhaul I started thinking about what other kinds of features a next gen text system should support. I came up with two basic goals: support complex text, support functionality similar to Microsoft WordPad/Apple TextEdit.

I think these goals can be achieved through the following architecture:

Attributed String -> Script Processor -> Paragraph Processor -> Rectangle Processor -> Text Renderer

Attributed String

  • Add font, color, paragraph attributes to a string as character ranges

Script Processor

  • Determine the Glyphs for a string
  • Determines where line breaks can occur
  • Determines where word breaks can occur
  • Provide caret information

Paragraph Processor

  • Applies paragraph attributes before line breaking (indentation, tab stops)
  • Performs line breaking (word wrap)
  • Applies paragraph attributes after line breaking (alignment, line spacing)

Rectangle Processor

  • Determine rectangles for highlighted text, selected text, underlined text, strikethrough text

Text Renderer

  • Draw Rectangles
  • Draw Text
  • Draw Caret

Mac OS X is the easiest platform to support since Core Text can act as both the Script and Paragraph Processor.
Attributed String -> Core Text -> Rectangle Processor -> Text Renderer

Supporting Windows (XP+) is more involved:
Attributed String -> Uniscribe -> Paragraph Processor -> Rectangle Processor -> Text Renderer

The Linux/Multi-Platform solution look similar:
Attributed String -> Harfbuzz+FreeType -> Paragraph Processor -> Rectangle Processor -> Text Renderer


#2

Sorry - this post deserves a proper in-depth reply, but I’ve not had much time to devote to thinking about it… The whole topic is hugely complicated, but the structure you’ve sketched out sounds pretty sensible to me at first glance!