Description
Currently, flutterNesTheme() hardcodes the Press Start 2P font via GoogleFonts.pressStart2pTextTheme(). This works great for Latin-character projects, but makes it difficult to use nes_ui in projects that need non-Latin scripts (Korean, Japanese, Chinese, etc.).
Google Fonts does not offer pixel fonts for CJK languages, so bundling custom fonts (e.g. Galmuri for Korean) is the only option for non-Latin NES-style projects.
Current Workaround
The only workaround is to override textTheme via .copyWith() after calling flutterNesTheme():
theme: flutterNesTheme(...).copyWith(
textTheme: ThemeData.light().textTheme.apply(fontFamily: 'Galmuri11'),
),
However, this has a subtle issue: internal theme calculations in flutterNesTheme() (e.g. NesContainerTheme.labelTextStyle, NesProgressBarTheme.background, NesTooltipTheme.background) are already computed using the Press Start 2P textTheme before the .copyWith() override is applied.
Proposed Solution
Add an optional TextTheme? customTextTheme parameter to flutterNesTheme():
ThemeData flutterNesTheme({
TextTheme? customTextTheme,
// ... existing params
}) {
final textTheme = customTextTheme
?? GoogleFonts.pressStart2pTextTheme(themeData.textTheme);
// ...
}
Usage Example
MaterialApp(
theme: flutterNesTheme(
customTextTheme: ThemeData.light().textTheme.apply(
fontFamily: 'Galmuri11',
),
),
)
This is a non-breaking, backward-compatible change. When customTextTheme is not provided, the behavior is identical to the current implementation.
I am happy to submit a PR for this if the approach looks good!
Description
Currently,
flutterNesTheme()hardcodes thePress Start 2Pfont viaGoogleFonts.pressStart2pTextTheme(). This works great for Latin-character projects, but makes it difficult to usenes_uiin projects that need non-Latin scripts (Korean, Japanese, Chinese, etc.).Google Fonts does not offer pixel fonts for CJK languages, so bundling custom fonts (e.g. Galmuri for Korean) is the only option for non-Latin NES-style projects.
Current Workaround
The only workaround is to override
textThemevia.copyWith()after callingflutterNesTheme():However, this has a subtle issue: internal theme calculations in
flutterNesTheme()(e.g.NesContainerTheme.labelTextStyle,NesProgressBarTheme.background,NesTooltipTheme.background) are already computed using the Press Start 2P textTheme before the.copyWith()override is applied.Proposed Solution
Add an optional
TextTheme? customTextThemeparameter toflutterNesTheme():Usage Example
This is a non-breaking, backward-compatible change. When
customTextThemeis not provided, the behavior is identical to the current implementation.I am happy to submit a PR for this if the approach looks good!