Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
moham96 opened this issue Aug 27, 2022 · 2 comments
Closed

Comments

@moham96
Copy link

moham96 commented Aug 27, 2022

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.

@DoumanAsh
Copy link
Contributor

You need to use custom font, it is probably that flutter engine uses some default font depending on your locale or available system fonts with no option for extended unicode symbols.
Hence best approach is bundling your own fonts with application.

You can also set system locale to arabic one and see if flutter engine picks up better fonts (I think arabic would be ar_AE.utf8)

@ardera
Copy link
Owner

ardera commented Sep 19, 2022

what @DoumanAsh said 😄

Closing this for now because there's no response, feel free to reopen if the issue persists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants