malcommac / SwiftRichString

👩‍🎨 Elegant Attributed String composition in Swift sauce
MIT License
3.1k stars 211 forks source link

FEATURE REQUEST: A font "size" attribute within StandardXMLAttributesResolver would be immensely useful. #141

Open pkclsoft opened 2 years ago

pkclsoft commented 2 years ago

I've tried to implement this in my own subclass of StandardXMLAttributesResolver, however we don't seem to have enough access to the information required. Originally, I was going to implement it as a string point size (which would be normal), but given the font size of the active style, when the attribute is parsed may provide something specific to a device class, I thought it would be more useful to add an attribute called "fontScale" so that you could scale the font up or down.

For this to work, I think we also need the ability to apply an attribute to whatever the "current" or "active" style is.

e.g.

"This is normal, <activeStyle fontScale=\"1.5\">but this text is larger by half, and < activeStyle fontScale=\"0.5\">this is smaller by half.; returning to normal size now".

Would render something like:

image