You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Scenario: I've found the perfect font for my cool new Flutter app, and I want to embed it in my app. Now I have to go download it, put it in the right asset folder, add it to pubspec.yaml, etc.
Wouldn't it be cool if I could run Flutter: Add Font to App, type the name of the font I want and have Dart-Code sweat all the details for me? There's already an extension that does this for web content (lior-chamla.google-fonts), although admittedly that doesn't have to download anything.
Love it (although there are 877 fonts currently there). For the gold-plated version of this feature, you'd be able to filter (e.g. serif, sans-serif, monospace, handwriting) and see a preview -- so you don't even have to go visit the Google Fonts site.
877 words in a completion list that filters as you type doesn't sound bad; I'm sure we probably have more than that very often in Code.
I'm not sure about filtering, but if Google Fonts have images of the font we could use, maybe we could inject that as a markdown image to also give a preview? I'll see what I can find when I get a min :-)
@guidezpl potentially! Although I'm not sure what the workflow would look like. VS Code wouldn't easily know which fonts the users code references (except at the time of - and if - they use code completion to add it). If we want to locate them across the project we'd need to have something in the analyzer that could locate them.
Having a command where the user can select specific fonts (eg. run Flutter: Download Google Font Asset, get a picklist of fonts, check a bunch, click ok, they get downloaded) may be simpler - as long as we have a reasonable way to get the font list and download the files (presumably the API above would work, but since this code runs on end-user machines, I don't think I could ship any API keys in the code).
Perhaps there's value in putting some of that into the Pub package so that other editors could use it? For example, even if VS Code got the font selection from the user, if installation was something like dart pub run google_fonts:download_assets --font foo1 -- font foo2 that would allow the code that does the downloading (and if necessary, modifying the pubspec etc.) sharable by all editors. Perhaps the font list could be supplied that way too (dart pub run google_fonts:list_fonts)?
Activity
DanTup commentedon Jun 15, 2018
Doesn't sound too complicated :)
Though maybe we could do even better? What if you typed:
... we auto-completed the fonts (assuming the list is small enough we can just pull it and cache it) and then did the download when you selected it?
timsneath commentedon Jun 15, 2018
Love it (although there are 877 fonts currently there). For the gold-plated version of this feature, you'd be able to filter (e.g. serif, sans-serif, monospace, handwriting) and see a preview -- so you don't even have to go visit the Google Fonts site.
DanTup commentedon Jun 15, 2018
877 words in a completion list that filters as you type doesn't sound bad; I'm sure we probably have more than that very often in Code.
I'm not sure about filtering, but if Google Fonts have images of the font we could use, maybe we could inject that as a markdown image to also give a preview? I'll see what I can find when I get a min :-)
timsneath commentedon Jun 15, 2018
Looks like the API is here: https://developers.google.com/fonts/docs/developer_api. Doesn't seem as if they offer images though :(
guidezpl commentedon Oct 7, 2021
Now that we have https://github.com/material-foundation/google-fonts-flutter, could the package leverage VS code commands to handle the downloading of fonts to an assets folder?
DanTup commentedon Oct 11, 2021
@guidezpl potentially! Although I'm not sure what the workflow would look like. VS Code wouldn't easily know which fonts the users code references (except at the time of - and if - they use code completion to add it). If we want to locate them across the project we'd need to have something in the analyzer that could locate them.
Having a command where the user can select specific fonts (eg. run Flutter: Download Google Font Asset, get a picklist of fonts, check a bunch, click ok, they get downloaded) may be simpler - as long as we have a reasonable way to get the font list and download the files (presumably the API above would work, but since this code runs on end-user machines, I don't think I could ship any API keys in the code).
Perhaps there's value in putting some of that into the Pub package so that other editors could use it? For example, even if VS Code got the font selection from the user, if installation was something like
dart pub run google_fonts:download_assets --font foo1 -- font foo2that would allow the code that does the downloading (and if necessary, modifying the pubspec etc.) sharable by all editors. Perhaps the font list could be supplied that way too (dart pub run google_fonts:list_fonts)?