-
Notifications
You must be signed in to change notification settings - Fork 29.1k
Open
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projecta: typographyText rendering, possibly libtxtText rendering, possibly libtxtfound in release: 3.13Found to occur in 3.13Found to occur in 3.13found in release: 3.16Found to occur in 3.16Found to occur in 3.16frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-engineOwned by Engine teamOwned by Engine teamtriaged-engineTriaged by Engine teamTriaged by Engine team
Description
Is there an existing issue for this?
- I have searched the existing issues
- I have read the guide to filing a bug
Steps to reproduce
- Add a
fontFamily
that uses a variable weight font to aTextStyle
. - Add a
FontVariation
for the weight toTextStyle
. - Add a
FontWeight
ofw600
or higher to theTextStyle
. - Render
Text
component using the style.
Expected results
I expect fontWeight
to have no effect.
Actual results
The rendered texts is bolder than the weight specified by the FontVariation
.
I can confirm this happens on Linux, Android, and Desktop Web.
Code sample
Code sample
lib/main.dart
import 'dart:ui';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'Flutter Demo',
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
const MyHomePage({super.key});
@override
Widget build(BuildContext context) {
const baseStyle = TextStyle(
fontFamily: "Noto Sans JP",
fontSize: 12.0,
);
return Scaffold(
appBar: AppBar(
title: const Text("Variable Fonts"),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
..._fontWeightsOf(
baseStyle.copyWith(
fontVariations: [const FontVariation("wght", 400)]),
),
..._fontWeightsOf(
baseStyle.copyWith(
fontVariations: [const FontVariation("wght", 900)]),
),
],
),
));
}
List<Widget> _fontWeightsOf(TextStyle style) {
final fontWeights = [
FontWeight.w100,
FontWeight.w200,
FontWeight.w300,
FontWeight.w400,
FontWeight.w500,
FontWeight.w600,
FontWeight.w700,
FontWeight.w800,
FontWeight.w900,
];
return fontWeights.map((weight) {
final newStyle = style.copyWith(fontWeight: weight);
return Text("$newStyle with ${newStyle.fontVariations}", style: newStyle);
}).toList();
}
}
pubspec.yaml
name: variable_fonts_debug
description: A new Flutter project.
publish_to: 'none'
version: 1.0.0+1
environment:
sdk: '>=3.1.3 <4.0.0'
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0
flutter:
uses-material-design: true
fonts:
- family: Noto Sans JP
fonts:
- asset: fonts/NotoSansJP.ttf
fonts/NotoSansJP.ttf
Used this font: https://fonts.google.com/noto/specimen/Noto+Sans+JP
Screenshots or Video
Flutter Doctor output
Doctor output
[✓] Flutter (Channel stable, 3.13.7, on Pop!_OS 22.04 LTS 6.5.4-76060504-generic, locale
en_US.UTF-8)
• Flutter version 3.13.7 on channel stable at /home/work/snap/flutter/common/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 2f708eb839 (8 days ago), 2023-10-09 09:58:08 -0500
• Engine revision a794cf2681
• Dart version 3.1.3
• DevTools version 2.25.0
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
• Android SDK at /home/work/Android/Sdk
• Platform android-33, build-tools 33.0.2
• Java binary at: /usr/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.8.1+1-Ubuntu-0ubuntu122.04)
• All Android licenses accepted.
[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Linux toolchain - develop for Linux desktop
• clang version 10.0.0-4ubuntu1
• cmake version 3.16.3
• ninja version 1.10.0
• pkg-config version 0.29.1
[!] Android Studio (not installed)
• Android Studio not found; download from
https://developer.android.com/studio/index.html
(or visit https://flutter.dev/docs/get-started/install/linux#android-setup for
detailed instructions).
[✓] VS Code (version 1.83.1)
• VS Code at /usr/share/code
• Flutter extension can be installed from:
🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected device (2 available)
• Pixel 5a (mobile) • 17081JECB12298 • android-arm64 • Android 14 (API 34)
• Linux (desktop) • linux • linux-x64 • Pop!_OS 22.04 LTS
6.5.4-76060504-generic
[✓] Network resources
• All expected network resources are available.
! Doctor found issues in 2 categories.
chrisbobbe
Metadata
Metadata
Assignees
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projecta: typographyText rendering, possibly libtxtText rendering, possibly libtxtfound in release: 3.13Found to occur in 3.13Found to occur in 3.13found in release: 3.16Found to occur in 3.16Found to occur in 3.16frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onteam-engineOwned by Engine teamOwned by Engine teamtriaged-engineTriaged by Engine teamTriaged by Engine team