Skip to content

setting default text style causes arabic characters to be unrecongnized #280

Closed
@moham96

Description

@moham96

To show the problem run this code:

import 'package:flutter/material.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  runApp(const GymApp());
}

class GymApp extends StatelessWidget {
  const GymApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData.dark().copyWith(
        textTheme: const TextTheme(
          bodyText2: TextStyle(
            color: Colors.white,

          ),
        ),
      ),
      home: const Test(),
    );
  }
}

class Test extends StatelessWidget {
  const Test({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    print(
        'bodyText2 fontFamily: ${Theme.of(context).textTheme.bodyText2!.fontFamily}');
    print(
        'bodyText2 fontFamilyFallback: ${Theme.of(context).textTheme.bodyText2!.fontFamilyFallback}');
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: const [
            Text('نص عربي'),
            Text('English Text'),
          ],
        ),
      ),
    );
  }
}

running this on mac os is fine (the text shows fine for both the Arabic and english text) but running it through 'flutter-pi' causes the Arabic text to be shown as rectangles, looking at the output of the print statements I have in the build method, you see that the fontFamily and fontFamilyFallback are being set to null when you set bodyText2 to something instead of leaving it unchanged, in macos somehow the system still shows the character even when the fontFamily is null but in the raspberry pi it causes the characters to be known.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions