-
Notifications
You must be signed in to change notification settings - Fork 76
Add configurable font paths #360
base: master
Are you sure you want to change the base?
Conversation
This is looking like a good change. I'm a little wary of searching fonts every time configuration changes, since it's so easy to trigger -- though that can be partially addressed if I have the time to improve how config is handled. Is that something that can happen in the background? |
Indeed, I'm not too happy with that either. I thought about caching the font paths in a Set-like object and comparing so we can know when the font paths actually changed. This could be improved further by fully caching system fonts (by e.g. saving the partial Builder somewhere, as long as it's
Likely, yes. Right now, I believe it runs this in its own task (not sure though - if it requires an explicit call to |
This very much feels like it should not be implemented explicitely by typst-lsp, but be exposed by typst itself, so that there's no chance of a discrepancy between what fonts typst-cli would use and typst-lsp. |
@PgBiel I see now that the searching will run in its own async task. However, it looks like the search is done synchronously, so it will block the executor, so it does need something like Your point about the write lock is a bigger one. It doesn't really matter where the searching happens, since not much else can happen until the lock is released. It is correct to hold some kind of write lock here: if we change fonts, then compile a document which may involve an added/removed font, we can't compile until we know the updated font set. Using caching to only search changed paths is a good idea, and really should be implemented as part of The best solution might be fine-grained locking. It would add a lot of complexity, but holding one (or several) write lock(s) internal to the font searching system would allow read access to most of the |
So, just an update: I ended up not having enough time to keep going with this, since I'm now focusing on multiple PRs to the Typst compiler with improvements to tables. However, it's very much possible for me to come back to this after I'm done. However, if anyone wants to see this happening sooner and would be interested in picking this up, please let me know! |
Adds the equivalent of Typst CLI's
--font-path
option to the LSP. (I recommend merging #359 first if possible, as it will require a few changes to this PR when merged, but they should be very tiny changes!)Closes #75 , related to #267
Supported features
~
to indicate the home folder;TYPST_FONT_PATHS
in the CLI)?Looking for testers
Tested in:
Screenshots
VSCode Configuration
Font is recognized