wiki:CocoaIde/FontSupportImplementation

Version 1 (modified by rme, 6 years ago) (diff)

--

To implement character properties, the line structure is augmented with a charprops-changes slot. If all the characters on the line have default properties, this slot will contain NIL. Otherwise, it will be an adjustable vector with a fill pointer which contains one or more charprops-change structures.

A charprops-change structure contains an index, which is the character position at which the change takes effect, and a plist, which represents the properties of the run of characters following the index. The properties are in effect until the index of the next charprops-change, or to the end of the line.

The properties of the other lines do not affect a given line at all.

A line always starts with the default character properties. This means that the first change in a line's charprops-changes vector may not have an index of 0. For instance, if the first 5 characters of a line had default properties, and the rest of the line was in bold, the charprops change vector would look like

#(#S(HI::CHARPROPS-CHANGE :INDEX 5 :PLIST (:FONT-WEIGHT :BOLD)))

Note that the run of characters is implicit at the beginning. This makes for some added complexity in the code that searches and manages the charprops-changes vector.