Open2

flutterのcustom fontsでiOSのweightだけ機能しないバグっぽい

ぬるぽぬるぽ

この書き方だとiOSのみweightが機能しなくて禿げた

flutter:
  uses-material-design: true
  assets:
    - assets/images/png/
  fonts:
    - family: 'Hiragino-Sans'
      fonts:
        - asset: assets/fonts/Hiragino-Sans-W4.ttc
          weight: 400
        - asset: assets/fonts/Hiragino-Sans-W5.ttc
          weight: 500
        - asset: assets/fonts/Hiragino-Sans-W6.ttc
          weight: 600
        - asset: assets/fonts/Hiragino-Sans-W7.ttc
          weight: 700
ぬるぽぬるぽ
flutter:
  uses-material-design: true
  assets:
    - assets/images/png/
  fonts:
    # 同じ FamilyName + weight だと、iOSでweightが機能しない
    - family: 'Hiragino-Sans'
      fonts:
        - asset: assets/fonts/Hiragino-Sans-W4.ttc
          weight: 400
    - family: 'Hiragino-Sans-W5'
      fonts:
        - asset: assets/fonts/Hiragino-Sans-W5.ttc
          weight: 500
    - family: 'Hiragino-Sans-W6'
      fonts:
        - asset: assets/fonts/Hiragino-Sans-W6.ttc
          weight: 600
    - family: 'Hiragino-Sans-W7'
      fonts:
        - asset: assets/fonts/Hiragino-Sans-W7.ttc
          weight: 700
  • fontFamilyを分けて、weightをoverrideしないように書く
         Text(
            'あのイーハトー',
            style: TextStyle(
              fontFamily: 'Hiragino-Sans w7',
              color: Colors.black,
              fontSize: 50,
            ),
          ),
          Text(
            'あのイーハトー',
            style: TextStyle(
              fontFamily: 'Hiragino-Sans w6',
              color: Colors.black,
              fontSize: 50,
            ),
          ),
          Text(
            'あのイーハトー',
            style: TextStyle(
              fontFamily: 'Hiragino-Sans w5',
              color: Colors.black,
              fontSize: 50,
            ),
          ),
          Text(
            'あのイーハトー',
            style: TextStyle(
              fontFamily: 'Hiragino-Sans w4',
              color: Colors.black,
              fontSize: 50,
            ),
          ),