CodeEditApp / CodeEditSourceEditor

A code editor view written in Swift powered by tree-sitter.
https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor
MIT License
504 stars 74 forks source link

Add Letter Spacing #174

Closed thecoolwinter closed 1 year ago

thecoolwinter commented 1 year ago

Description

Adds a letterSpacing parameter that determines the amount of space between characters. The parameter is a multiplier of the font's character width so 1.0 indicates no space, 2.0 indicates a full character width's space. This is exactly as described in #153.

In detail:

This PR also adds documentation for a couple undocumented parameters in the initializer and moves lineHeight into the STTextViewController initializer for a cleaner CodeEditTextView.

Related Issues

Checklist

Screenshots

The below recording shows a placeholder settings adjusting the letter spacing, as well as the spacing being applied while typing.

https://user-images.githubusercontent.com/35942988/230160550-c540523c-4fb9-4984-8564-5bdebb7fbcb3.mov

austincondiff commented 1 year ago

Very nice! Just thinking ahead here, but how would this affect ligatures?

thecoolwinter commented 1 year ago

@austincondiff After some investigation, any letterSpacing > 1.0 disables ligatures as each character can no longer be connected visually. In CE we could add a small warning when enabling both ligatures and letterSpacing > 1 but that should be expected behavior.

austincondiff commented 1 year ago

@thecoolwinter I was trying to find this comment yesterday to respond to it. I think we disable the ligatures toggle if letters spacing is greater than one and add a description to why it is disabled.