Skip to content
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

How to custome fontFamily global? #64

Closed
leavky opened this issue May 13, 2024 · 22 comments
Closed

How to custome fontFamily global? #64

leavky opened this issue May 13, 2024 · 22 comments

Comments

@leavky
Copy link

leavky commented May 13, 2024

In materialTheme, we can set fontFamily, but there not have fontFamily in ShadThemeData.

@leavky
Copy link
Author

leavky commented May 13, 2024

if dont't have fontFamily, the font look not good.
image

@nank1ro
Copy link
Owner

nank1ro commented May 13, 2024

@leavky
Copy link
Author

leavky commented May 13, 2024

I want to change the gloal, and I can't change the font of the button.
image

image

image

@leavky
Copy link
Author

leavky commented May 13, 2024

Because there is a problem with the default Chinese font, so must specify the font family

@leavky leavky changed the title How to custome fontFamily gloal? How to custome fontFamily global? May 13, 2024
@nank1ro
Copy link
Owner

nank1ro commented May 13, 2024

Don't you see the custom font in the buttons? Did you add it to the pubspec?
My side I can change the font correctly.
Screenshot 2024-05-13 at 18 20 10

@leavky
Copy link
Author

leavky commented May 13, 2024

yes, i add font in pubsec, but the button font not change
image

@leavky
Copy link
Author

leavky commented May 13, 2024

but the material theme button font changed

@leavky
Copy link
Author

leavky commented May 13, 2024

Maybe I should create a new project to test

@nank1ro
Copy link
Owner

nank1ro commented May 13, 2024

Can you try adding all the other font assets (regular, light, etc.) and specify the font weights like in the documentation?

@leavky
Copy link
Author

leavky commented May 13, 2024

It may be that the theme of another package does not take effect in my project, but I found a problem that I could not launch in Windows after using this package.

@nank1ro
Copy link
Owner

nank1ro commented May 14, 2024

Can you share the error?

@leavky
Copy link
Author

leavky commented May 14, 2024

use flutter-shadcn-ui\example.

➜ flutter run
Connected devices:
Windows (desktop) • windows • windows-x64    • Microsoft Windows [版本 10.0.22631.3447]
Chrome (web)      • chrome  • web-javascript • Google Chrome 124.0.6367.202
Edge (web)        • edge    • web-javascript • Microsoft Edge 124.0.2478.80
[1]: Windows (windows)
[2]: Chrome (chrome)
[3]: Edge (edge)
Please choose one (or "q" to quit): 1
Launching lib\main.dart on Windows in debug mode...
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(456,5): error MSB8020: �޷��ҵ� ClangCL �����ɹ���(ƽ̨���߼� =��ClangCL��)����Ҫʹ�� ClangCL ���ɹ��߽������ɣ��밲װ ClangCL ���ɹ��ߡ����ߣ�������������ǰ Visual Studio ���ߣ���ʽ��ͨ��ѡ����Ŀ���˵����Ҽ������ý��������Ȼ��ѡ���ض��������Ŀ�ꡱ�� [C:\Users\flowray\Desktop\flutter-shadcn-ui\example\build\windows\x64\plugins\rive_common\rive_common_plugin.vcxproj]
Building Windows application...                                     5.8s
Error: Build process failed.

@leavky
Copy link
Author

leavky commented May 14, 2024

look because rive package
image

@nank1ro
Copy link
Owner

nank1ro commented May 14, 2024

Please try with the latest commit on main, I removed rive because it caused many issue to a lot of people

@dickermoshe
Copy link
Contributor

dickermoshe commented May 14, 2024 via email

@nank1ro
Copy link
Owner

nank1ro commented May 14, 2024

Does this issue happen without shadcn too?

On Tue, May 14, 2024, 5:24 AM Alexandru Mariuti @.> wrote: Please try with the latest commit on main, I removed rive because it caused many issue to a lot of people — Reply to this email directly, view it on GitHub <#64 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASDJ6267IBT4AHTUYSYJCF3ZCHJ6BAVCNFSM6AAAAABHUOCFNGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBZG4YDSNZWHE . You are receiving this because you are subscribed to this thread.Message ID: @.>

Many people who have tried to add shadcn_ui as a package have encountered the error. Especially on Windows. there is some problem with the rive_common library.
Since the feature it brought was quite small (supporting riv in the ShadImage component) I decided to remove the dependency. If one then wants a riv it integrates rive in the pubspec.

@leavky
Copy link
Author

leavky commented May 14, 2024

Thanks, i have solve this problem by rive-app/rive-flutter#308, rive need install clang.

@leavky
Copy link
Author

leavky commented May 14, 2024

After test, In riverpod and go_router, the global setting font does not take effect. In this example, https://github.com/lucavenir/go_router_riverpod.

set ShadApp textTheme
image

image

@nank1ro
Copy link
Owner

nank1ro commented May 14, 2024

Be aware that in the materialThemeBuilder you should copy the theme provided to you, not providing a new instance.

(context, theme) {
  return theme.copyWith(primarySwatch: Colors.cyan)
}

I would try your font and let you know

@leavky
Copy link
Author

leavky commented May 14, 2024

but ShadButton text font is not right, My font can download in https://github.com/lxgw/LxgwWenKai

image

I guess it's not a matter of fonts

@nank1ro
Copy link
Owner

nank1ro commented May 14, 2024

Screenshot 2024-05-14 at 18 02 05

To me seems working fine.
To the pubpec.yaml I added this:

  fonts:
    - family: LXGW
      fonts:
        - asset: fonts/LXGWWenKai-Bold.ttf
          weight: 700
        - asset: fonts/LXGWWenKai-Light.ttf
          weight: 300
        - asset: fonts/LXGWWenKai-Regular.ttf

My ShadApp

ShadApp(
          debugShowCheckedModeBanner: false,
          themeMode: themeMode,
          routes: routes,
          theme: ShadThemeData(
            brightness: Brightness.light,
            colorScheme: const ShadZincColorScheme.light(),
            textTheme: ShadTextTheme(
              colorScheme: const ShadZincColorScheme.light(),
              family: 'LXGW',
            ),
          ),
          home: const MainPage(),
        )

@leavky
Copy link
Author

leavky commented May 14, 2024

Thanks, It's normal now, and I understand what's wrong, because i set darkTheme.

Thank you very much for developing this package~

@nank1ro nank1ro closed this as completed May 15, 2024
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