Skip to content

Feature Idea: Add a Google Font #1014

Open

Description

@timsneath

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.

Activity

  1. added
    is enhancement
    in flutter
    on Jun 15, 2018
  2. added this to the On Deck milestone on Jun 15, 2018
  3. DanTup commented on Jun 15, 2018

    @DanTup
    Member

    Doesn't sound too complicated :)

    Though maybe we could do even better? What if you typed:

    new TextStyle(fontFamily: '

    ... 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?

  4. timsneath commented on Jun 15, 2018

    @timsneath
    ContributorAuthor

    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.

  5. DanTup commented on Jun 15, 2018

    @DanTup
    Member

    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 :-)

  6. timsneath commented on Jun 15, 2018

    @timsneath
    ContributorAuthor

    Looks like the API is here: https://developers.google.com/fonts/docs/developer_api. Doesn't seem as if they offer images though :(

  7. guidezpl commented on Oct 7, 2021

    @guidezpl
    Contributor

    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?

  8. DanTup commented on Oct 11, 2021

    @DanTup
    Member

    @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)?

  9. modified the milestones: On Deck, Backlog on Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in flutteris enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions