How to use a specific font from a list of fonts specified in a asset family in pubspec.yaml











up vote
1
down vote

favorite












Let's say i have added following lines to the pubspec.yaml file
fonts:



fonts:
- family: GreatVibes
fonts:
- asset: fonts/GreatVibes-Regular.ttf
- asset: fonts/GreatVibes-Bold.ttf


I am using it in my app with the following lines of code.



new Text('My New Font',
style: new TextStyle(
color: Colors.white,
fontFamily: 'GreatVibes',
fontSize: 16.0,
)),


My question is that ,among the two .ttf files provided earlier, how does flutter decides which file to use?



And Let's say if flutter decides to use GreatVibes-Bold.ttf, what can i do to make it use GreatVibes-regular.ttf










share|improve this question




























    up vote
    1
    down vote

    favorite












    Let's say i have added following lines to the pubspec.yaml file
    fonts:



    fonts:
    - family: GreatVibes
    fonts:
    - asset: fonts/GreatVibes-Regular.ttf
    - asset: fonts/GreatVibes-Bold.ttf


    I am using it in my app with the following lines of code.



    new Text('My New Font',
    style: new TextStyle(
    color: Colors.white,
    fontFamily: 'GreatVibes',
    fontSize: 16.0,
    )),


    My question is that ,among the two .ttf files provided earlier, how does flutter decides which file to use?



    And Let's say if flutter decides to use GreatVibes-Bold.ttf, what can i do to make it use GreatVibes-regular.ttf










    share|improve this question


























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      Let's say i have added following lines to the pubspec.yaml file
      fonts:



      fonts:
      - family: GreatVibes
      fonts:
      - asset: fonts/GreatVibes-Regular.ttf
      - asset: fonts/GreatVibes-Bold.ttf


      I am using it in my app with the following lines of code.



      new Text('My New Font',
      style: new TextStyle(
      color: Colors.white,
      fontFamily: 'GreatVibes',
      fontSize: 16.0,
      )),


      My question is that ,among the two .ttf files provided earlier, how does flutter decides which file to use?



      And Let's say if flutter decides to use GreatVibes-Bold.ttf, what can i do to make it use GreatVibes-regular.ttf










      share|improve this question















      Let's say i have added following lines to the pubspec.yaml file
      fonts:



      fonts:
      - family: GreatVibes
      fonts:
      - asset: fonts/GreatVibes-Regular.ttf
      - asset: fonts/GreatVibes-Bold.ttf


      I am using it in my app with the following lines of code.



      new Text('My New Font',
      style: new TextStyle(
      color: Colors.white,
      fontFamily: 'GreatVibes',
      fontSize: 16.0,
      )),


      My question is that ,among the two .ttf files provided earlier, how does flutter decides which file to use?



      And Let's say if flutter decides to use GreatVibes-Bold.ttf, what can i do to make it use GreatVibes-regular.ttf







      flutter flutter-layout flutter-dependencies






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 9 at 11:03









      CopsOnRoad

      2,24511017




      2,24511017










      asked Nov 9 at 5:23









      hemant bansal

      82




      82
























          2 Answers
          2






          active

          oldest

          votes

















          up vote
          0
          down vote













          If I understand these font things correctly - it has to be like this:



          fonts:
          - family: GreatVibes
          fonts:
          - asset: fonts/GreatVibes-Regular.ttf
          - asset: fonts/GreatVibes-Bold.ttf
          weight: 700
          - asset: fonts/GreatVibes-Italic.ttf
          style: italic


          And then



          new Text('My New Font',
          style: new TextStyle(
          color: Colors.white,
          fontFamily: 'GreatVibes',
          fontWeight: FontWeight.w700,
          fontSize: 16.0,
          )),





          share|improve this answer























          • Sorry, it is just changing the weight of the font, what if i had placed italic style font in there, i want to give multiple font choices to the app user but if i have to specify 'family' for each of those fonts, it will become really hard to manage, that's the sole purpose of me asking this question.
            – hemant bansal
            Nov 9 at 13:42










          • I've edited answer - add option for italic. I don't know how you can put many different fonts in one family and work with them like as list
            – Andrey Turkovsky
            Nov 9 at 13:51










          • yes, the fact is that we can use any name for family, it does not need to be same as the font's name, so if it has to choose b/w let say roboto and open sans, which of them will it choose
            – hemant bansal
            Nov 9 at 14:13


















          up vote
          -1
          down vote













          Checkout these links :



          How to use a custom font style in flutter?



          https://flutter.io/docs/cookbook/design/fonts






          share|improve this answer























          • Are you sure, you said about flutter?
            – Andrey Turkovsky
            Nov 9 at 7:09










          • @Sandep, downvoting it, cause your solution is for Android. The question asked is for Flutter.
            – CopsOnRoad
            Nov 9 at 11:02










          • @CopsOnRoad I changed it for flutter.
            – Sandeep Insan
            Nov 9 at 11:09










          • Don't use link to provide answer. You have comments for this purpose.
            – CopsOnRoad
            Nov 9 at 11:12











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53220294%2fhow-to-use-a-specific-font-from-a-list-of-fonts-specified-in-a-asset-family-in-p%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          If I understand these font things correctly - it has to be like this:



          fonts:
          - family: GreatVibes
          fonts:
          - asset: fonts/GreatVibes-Regular.ttf
          - asset: fonts/GreatVibes-Bold.ttf
          weight: 700
          - asset: fonts/GreatVibes-Italic.ttf
          style: italic


          And then



          new Text('My New Font',
          style: new TextStyle(
          color: Colors.white,
          fontFamily: 'GreatVibes',
          fontWeight: FontWeight.w700,
          fontSize: 16.0,
          )),





          share|improve this answer























          • Sorry, it is just changing the weight of the font, what if i had placed italic style font in there, i want to give multiple font choices to the app user but if i have to specify 'family' for each of those fonts, it will become really hard to manage, that's the sole purpose of me asking this question.
            – hemant bansal
            Nov 9 at 13:42










          • I've edited answer - add option for italic. I don't know how you can put many different fonts in one family and work with them like as list
            – Andrey Turkovsky
            Nov 9 at 13:51










          • yes, the fact is that we can use any name for family, it does not need to be same as the font's name, so if it has to choose b/w let say roboto and open sans, which of them will it choose
            – hemant bansal
            Nov 9 at 14:13















          up vote
          0
          down vote













          If I understand these font things correctly - it has to be like this:



          fonts:
          - family: GreatVibes
          fonts:
          - asset: fonts/GreatVibes-Regular.ttf
          - asset: fonts/GreatVibes-Bold.ttf
          weight: 700
          - asset: fonts/GreatVibes-Italic.ttf
          style: italic


          And then



          new Text('My New Font',
          style: new TextStyle(
          color: Colors.white,
          fontFamily: 'GreatVibes',
          fontWeight: FontWeight.w700,
          fontSize: 16.0,
          )),





          share|improve this answer























          • Sorry, it is just changing the weight of the font, what if i had placed italic style font in there, i want to give multiple font choices to the app user but if i have to specify 'family' for each of those fonts, it will become really hard to manage, that's the sole purpose of me asking this question.
            – hemant bansal
            Nov 9 at 13:42










          • I've edited answer - add option for italic. I don't know how you can put many different fonts in one family and work with them like as list
            – Andrey Turkovsky
            Nov 9 at 13:51










          • yes, the fact is that we can use any name for family, it does not need to be same as the font's name, so if it has to choose b/w let say roboto and open sans, which of them will it choose
            – hemant bansal
            Nov 9 at 14:13













          up vote
          0
          down vote










          up vote
          0
          down vote









          If I understand these font things correctly - it has to be like this:



          fonts:
          - family: GreatVibes
          fonts:
          - asset: fonts/GreatVibes-Regular.ttf
          - asset: fonts/GreatVibes-Bold.ttf
          weight: 700
          - asset: fonts/GreatVibes-Italic.ttf
          style: italic


          And then



          new Text('My New Font',
          style: new TextStyle(
          color: Colors.white,
          fontFamily: 'GreatVibes',
          fontWeight: FontWeight.w700,
          fontSize: 16.0,
          )),





          share|improve this answer














          If I understand these font things correctly - it has to be like this:



          fonts:
          - family: GreatVibes
          fonts:
          - asset: fonts/GreatVibes-Regular.ttf
          - asset: fonts/GreatVibes-Bold.ttf
          weight: 700
          - asset: fonts/GreatVibes-Italic.ttf
          style: italic


          And then



          new Text('My New Font',
          style: new TextStyle(
          color: Colors.white,
          fontFamily: 'GreatVibes',
          fontWeight: FontWeight.w700,
          fontSize: 16.0,
          )),






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 9 at 13:48

























          answered Nov 9 at 12:38









          Andrey Turkovsky

          1,3671515




          1,3671515












          • Sorry, it is just changing the weight of the font, what if i had placed italic style font in there, i want to give multiple font choices to the app user but if i have to specify 'family' for each of those fonts, it will become really hard to manage, that's the sole purpose of me asking this question.
            – hemant bansal
            Nov 9 at 13:42










          • I've edited answer - add option for italic. I don't know how you can put many different fonts in one family and work with them like as list
            – Andrey Turkovsky
            Nov 9 at 13:51










          • yes, the fact is that we can use any name for family, it does not need to be same as the font's name, so if it has to choose b/w let say roboto and open sans, which of them will it choose
            – hemant bansal
            Nov 9 at 14:13


















          • Sorry, it is just changing the weight of the font, what if i had placed italic style font in there, i want to give multiple font choices to the app user but if i have to specify 'family' for each of those fonts, it will become really hard to manage, that's the sole purpose of me asking this question.
            – hemant bansal
            Nov 9 at 13:42










          • I've edited answer - add option for italic. I don't know how you can put many different fonts in one family and work with them like as list
            – Andrey Turkovsky
            Nov 9 at 13:51










          • yes, the fact is that we can use any name for family, it does not need to be same as the font's name, so if it has to choose b/w let say roboto and open sans, which of them will it choose
            – hemant bansal
            Nov 9 at 14:13
















          Sorry, it is just changing the weight of the font, what if i had placed italic style font in there, i want to give multiple font choices to the app user but if i have to specify 'family' for each of those fonts, it will become really hard to manage, that's the sole purpose of me asking this question.
          – hemant bansal
          Nov 9 at 13:42




          Sorry, it is just changing the weight of the font, what if i had placed italic style font in there, i want to give multiple font choices to the app user but if i have to specify 'family' for each of those fonts, it will become really hard to manage, that's the sole purpose of me asking this question.
          – hemant bansal
          Nov 9 at 13:42












          I've edited answer - add option for italic. I don't know how you can put many different fonts in one family and work with them like as list
          – Andrey Turkovsky
          Nov 9 at 13:51




          I've edited answer - add option for italic. I don't know how you can put many different fonts in one family and work with them like as list
          – Andrey Turkovsky
          Nov 9 at 13:51












          yes, the fact is that we can use any name for family, it does not need to be same as the font's name, so if it has to choose b/w let say roboto and open sans, which of them will it choose
          – hemant bansal
          Nov 9 at 14:13




          yes, the fact is that we can use any name for family, it does not need to be same as the font's name, so if it has to choose b/w let say roboto and open sans, which of them will it choose
          – hemant bansal
          Nov 9 at 14:13












          up vote
          -1
          down vote













          Checkout these links :



          How to use a custom font style in flutter?



          https://flutter.io/docs/cookbook/design/fonts






          share|improve this answer























          • Are you sure, you said about flutter?
            – Andrey Turkovsky
            Nov 9 at 7:09










          • @Sandep, downvoting it, cause your solution is for Android. The question asked is for Flutter.
            – CopsOnRoad
            Nov 9 at 11:02










          • @CopsOnRoad I changed it for flutter.
            – Sandeep Insan
            Nov 9 at 11:09










          • Don't use link to provide answer. You have comments for this purpose.
            – CopsOnRoad
            Nov 9 at 11:12















          up vote
          -1
          down vote













          Checkout these links :



          How to use a custom font style in flutter?



          https://flutter.io/docs/cookbook/design/fonts






          share|improve this answer























          • Are you sure, you said about flutter?
            – Andrey Turkovsky
            Nov 9 at 7:09










          • @Sandep, downvoting it, cause your solution is for Android. The question asked is for Flutter.
            – CopsOnRoad
            Nov 9 at 11:02










          • @CopsOnRoad I changed it for flutter.
            – Sandeep Insan
            Nov 9 at 11:09










          • Don't use link to provide answer. You have comments for this purpose.
            – CopsOnRoad
            Nov 9 at 11:12













          up vote
          -1
          down vote










          up vote
          -1
          down vote









          Checkout these links :



          How to use a custom font style in flutter?



          https://flutter.io/docs/cookbook/design/fonts






          share|improve this answer














          Checkout these links :



          How to use a custom font style in flutter?



          https://flutter.io/docs/cookbook/design/fonts







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 9 at 11:08

























          answered Nov 9 at 5:29









          Sandeep Insan

          1836




          1836












          • Are you sure, you said about flutter?
            – Andrey Turkovsky
            Nov 9 at 7:09










          • @Sandep, downvoting it, cause your solution is for Android. The question asked is for Flutter.
            – CopsOnRoad
            Nov 9 at 11:02










          • @CopsOnRoad I changed it for flutter.
            – Sandeep Insan
            Nov 9 at 11:09










          • Don't use link to provide answer. You have comments for this purpose.
            – CopsOnRoad
            Nov 9 at 11:12


















          • Are you sure, you said about flutter?
            – Andrey Turkovsky
            Nov 9 at 7:09










          • @Sandep, downvoting it, cause your solution is for Android. The question asked is for Flutter.
            – CopsOnRoad
            Nov 9 at 11:02










          • @CopsOnRoad I changed it for flutter.
            – Sandeep Insan
            Nov 9 at 11:09










          • Don't use link to provide answer. You have comments for this purpose.
            – CopsOnRoad
            Nov 9 at 11:12
















          Are you sure, you said about flutter?
          – Andrey Turkovsky
          Nov 9 at 7:09




          Are you sure, you said about flutter?
          – Andrey Turkovsky
          Nov 9 at 7:09












          @Sandep, downvoting it, cause your solution is for Android. The question asked is for Flutter.
          – CopsOnRoad
          Nov 9 at 11:02




          @Sandep, downvoting it, cause your solution is for Android. The question asked is for Flutter.
          – CopsOnRoad
          Nov 9 at 11:02












          @CopsOnRoad I changed it for flutter.
          – Sandeep Insan
          Nov 9 at 11:09




          @CopsOnRoad I changed it for flutter.
          – Sandeep Insan
          Nov 9 at 11:09












          Don't use link to provide answer. You have comments for this purpose.
          – CopsOnRoad
          Nov 9 at 11:12




          Don't use link to provide answer. You have comments for this purpose.
          – CopsOnRoad
          Nov 9 at 11:12


















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53220294%2fhow-to-use-a-specific-font-from-a-list-of-fonts-specified-in-a-asset-family-in-p%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Guess what letter conforming each word

          Port of Spain

          Run scheduled task as local user group (not BUILTIN)