savoryink / setfont

Set the font of your favorite editors and terminals
MIT License
0 stars 2 forks source link

App: Chime #22

Open nvzqz opened 4 years ago

nvzqz commented 4 years ago

App Suggestion

Full name: Chime

Argument value: chime

Supports ligatures: needs investigation

Website: https://www.chimehq.com/

Versions: all

Platforms:

Motivation

It's a text editor for Go that's been around since 2017.

Approach

Execute the following:

defaults write com.chimehq.Edit CHQFont <FONT_NAME>
nvzqz commented 4 years ago

Currently, the only way to change the font seems to be ViewFontShow Fonts, which presents the native font selector with the default as Monaco. There doesn't seem to be any font selection options in the app's preferences window.

Hey @mattmassicotte are there any plans to add custom font and ligature support?

mattmassicotte commented 4 years ago

Hi @nvzqz ! Actually, Chime's UI is quite themeable, it just isn't yet well-exposed via Prefs. And fonts with ligatures should work - are you seeing a problem with that?

If you check out Help > Themes you can see a bit of documentation. Basically, there's a custom JSON document that can be used to control fonts for most elements in the UI. Are you trying to control the font via a user default? When you manipulate the font via the menu, it sets the CHQFont and CHQFontSizeDelta fields in the apps NSUserDefaults storage for persistence.

nvzqz commented 4 years ago

Thanks for the quick response! The goal of this tool is to set the font or enable ligatures for a given programming app. I recently came across Chime and gave it a brief try to investigate how I could accomplish that programmatically.

I checked out HelpTheming and it reads:

Chime supports UI theming. Themes are defined using files containing JSON data. They can control syntax highlighting, as well as many non-textual aspects of the user interface.

We include a number of built-in themes. But, Chime will also load theme files at ~/Library/Application Support/com.chimehq.Edit/Themes. Just be sure to restart the app when making changes to that directory.

Unfortunately this text doesn't tell me anything about the schema of the custom JSON document or what options are expected. However, I did find themes at Chime.app/Contents/Resources/Themes/. The relevant font option seems to be fontseditor.default.

And for getting the current theme (if changed), it seems I can do:

defaults read com.chimehq.Edit CHQELastTheme

This is all good for reading current values but doesn't help much with writing new values. Especially since I'm not sure if I want to edit files within Chime.app. @mattmassicotte would you recommend this tool to set the font strictly through CHQFont?

mattmassicotte commented 4 years ago

Yes, you cannot edit the files within an app's bundle, as it will break the signature. Chime will also load themes from ~/Library/Application Support/com.chimehq.Edit/Themes. Sorry, I've forgotten the contents of the help for themes is sparse :(

Given what you are trying to do, I think the safest thing would be to read/write to CHQFont using the defaults system. That value will override whatever is in the current theme. Right now, the app doesn't expect that value to change spontaneously. But I'll keep this in mind for a future update so it will work without needed to quit and relaunch.

nvzqz commented 4 years ago

Thanks for the insight, I'll use CHQFont then!

In the documentation for NSUserDefaultsDidChangeNotification, it notes:

This notification isn't posted when changes are made outside the current process, or when ubiquitous defaults change. You can use key-value observing to register observers for specific keys of interest in order to be notified of all updates, regardless of whether changes are made within or outside the current process.

So KVO will be the best way to listen to spontaneous changes 😄

mattmassicotte commented 4 years ago

Yes, you got it! I use that exact mechanism for observing other fields. This just wasn't one hadn't needed it.