I’ve been playing around with themes and costume syntaxes for a couple of days and I’ve noticed that JavaScript syntax modifies the font to monospace no matter what font I was previously using. I believe it should be this since going back to another draft after viewing one with a JavaScript syntax also reverts to the font previously used.
I’m stuck however figuring out how the JavaScript syntax selects the font since there is there no font case. I’ve looked at the font code too and found no link either.
This got me wondering, can a custom syntax be used to change the font, font size, and theme? Maybe with a scriptable action, using existing solutions to take care of themes?
I don’t know if this is too picky, haha, but thank you very much!
Editor preferences like font, font size, etc., are specific to the syntax - so your Markdown, TaskPaper, JavaScript drafts each have their own set of settings which are applied when you open a draft with that syntax.
Not sure what your overall goal is…the JavaScript syntax does not modify the font, but, by default, the font used for JavaScript syntax, as selected in Editor Preferences, is a monospaced font.
I see. So would selecting a syntax, changing the font, and exporting the syntax make the font choice stay?
I like to use 2 kinds of fonts depending on what I’m doing in drafts: One’s Apple’s SF in a big size, which makes it easy to write down quick notes, the other is Avenir in a smaller font, which lets me write more lengthy notes comfortably on iPad for instance.
Specific fonts and base font size are user preferences, not part of a syntax. Generally speaking, syntaxes mark areas in a text to have certain “scopes”, then themes determine which attributes each of those scopes will have when rendered. Start here in the docs for more details.
Attributes which can be set by themes are things like bold, italic, color. The only font-related attributes are relative size (small, medium, large, etc.) and whether the scope should be rendered in normal or monospace font. What specific font is used for normal and monospaced are based on the user’s preferences.
So you cannot have a syntax/theme combination assign totally different fonts.
You could have two identical syntax definitions with different names and assign different editor settings for fonts to them.
You can set the syntax associated with a draft using an action, so as long as you have done the preparation in terms of the syntax duplication and editor settings, you could effectively drive the change of font from an action, you just would define the actual font and the syntax details outside of the action.
Themes are an app level setting, and you can set them (dark & light) using an action, but it is not associated with a draft, or with a syntax (though there is a relationship in terms of supported features between the two), so you would be effectively manually managing a relationship there if you use an action to switch syntax and theme, such that when you navigate to a draft with a different syntax, the theme will not automatically change.