-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Desktop: Add monospace enforcement for certain elements #4689
Conversation
Checkboxes, Code blocks, and tables will all have a monospace font enforced This allows the use of proportional fonts
I'm already using a monospace font in Joplin (Codemirror editor). Does this override my settings? If so, can I please have an option to disable this behavior? P.S.: What I meant was, will my font change to a different monospace font? But I think that your last sentence answers my question, unless it will just use the one I'm already using:
I can test it later tonight. |
Yes it will override your set font. I've just pushed another commit that adds an option for for the monospace font, so you'll need to set both if you want them to be the same. |
Btw, it's still in a draft state. |
Thanks @tessus Just wanted to give it another review myself before taking it out of the draft state. As a summary, this PR enforces monospace for
|
Thanks for the pull request @CalebJohn, that looks good. What would be the default fonts? Is it monospace everywhere by default or regular font for text, and monospace for table, code, etc.? |
It's monospace everywhere by default. Currently, there are still cases where the transition from proportional font -> monospace, can cause a "pop" when the width of text changes, so for users sake I left monospace as the default. |
Yes if you could make the proportional font the default that would be great, as I think it's the better default. Let's see what feedback we get and if it causes problem we can review the default afterwards. I'm not sure Open Sans is available everywhere? Would it make sense to make the generic "sans-serif" as default instead? |
Open sans is the new editor font default sans-serif is the new editor font fallback
editor font fallback is now Avenir, Arial, sans-serif
Sadly, that's a bug. I've just fixed it in this commit.
For some reason I thought Open Sans was the default viewer font. I changed the fallback font to use Avenir, Arial, sans-serif, to align with the viewer. I undid the previous change that adds Open Sans. |
All good then, let's merge. |
This adds forced monospace for Tables, Code blocks and Checkboxes in the CodeMirror editor.
This was briefly discussed on the forum
For checkboxes and code blocks, I piggy back on the CodeMirror highlighting and add the monospace class.
For tables I couldn't do that. Instead table check for a valid header, and then enter table mode. This just means that all lines following the valid header will be monospace until a line is reached that does not contain a '|' character.
I also enforce monospace on any line that begins with a '|', the assumption being that those lines are likely going to become a part of a table, and it's better to start writing in monospace rather than snapping to monospace once the header is finished.
Something I haven't done yet is to add a setting that enables this behaviour. I'm not sure if it will be necessary.
We'll at least need a way for the user to specify which monospace font they want to use.