ChimeHQ / Neon

A Swift library for efficient, flexible content-based text styling
BSD 3-Clause "New" or "Revised" License
319 stars 17 forks source link

Default attributes #34

Closed DivineDominion closed 10 months ago

DivineDominion commented 10 months ago

33 brings up the issue that there's no auto fallback when using stored attributes.

Text view font and textColor aren't permanent, either, and cannot be used to compute the "reset to this" style. They'll default to whatever is near, more or less. (As you type in differently colored regions, you can observe how they change).

See the difference of computed vs stored default attributes here -- the default font of the text view is supposed to be dark gray, but changing the first line's markup doesn't properly set the color or font:

Computed

https://github.com/ChimeHQ/Neon/assets/59080/b93e8aa5-69d3-429f-bd51-e314fc6072cf

Stored

https://github.com/ChimeHQ/Neon/assets/59080/5f17738f-500e-48dd-bbd3-7e2f94e3829d

With stored attributes, stored fallback attributes are required to get similar behavior to temporary layout attributes.

DivineDominion commented 10 months ago

Upside of this approach: it works with TextKit 1 and TextKit 2 just the same, on iOS and macOS