Open NigelBreslaw opened 1 month ago
Especially for (a) it would be awesome to offer code completion; each completion entry is the family name and (if a locally imported font) the file name on parentheses. The locally imported fonts come first, followed by the system fonts.
From the LSP, If we want to auto-complete: font-familly: "|"
(where |
is the cursor),
Then this if condition https://github.com/slint-ui/slint/blob/f85cb45e88ce6610c9d7723802628e6039761351/tools/lsp/language/completion.rs#L39 tell us that we are in a string literal.
But we don't want to complete fonts for every string literal. We'd have to check that we are in a Expression context (node.kind() == Expression
). And that we are in a binding for font-familly
: The with_lookup_ctx
can give you a LookupCtx that have a property_name
field.
I am not sure how to query the list of available font though.
I have 2 use cases:
a) You import a font with
import ../fonts/foo.woff
and it's not clear you did manage to import it and what the actual font name you the font has that you should refer to. So the user can see it is in the list if theydebug
it. b) Demos where we want to offer a drop down of some fonts and don't know ahead of time what fonts are on the device.