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

[QUESTION] How to change the default font family in the Editor? #93

Closed
sigmapie8 opened this issue Jul 27, 2021 · 6 comments
Closed

[QUESTION] How to change the default font family in the Editor? #93

sigmapie8 opened this issue Jul 27, 2021 · 6 comments
Labels
question Further information is requested

Comments

@sigmapie8
Copy link

I want to remove the font-family drop down and set one default font. How can I do that?

@sigmapie8 sigmapie8 added the question Further information is requested label Jul 27, 2021
@tneotia
Copy link
Owner

tneotia commented Jul 28, 2021

To set the default font I think you can do:

HtmlEditor(
   callbacks: Callbacks(
      onInit: () {
         controller.execCommand('fontName', argument: "font_name_here");
      }
   )
)

Your font name has to be inserted in the exact same way it would be in HTML, for example sans-serif or Times New Roman.

I haven't tested this but I think it should work, and you can use defaultToolbarButtons to remove the font dropdown. If it doesn't work please post the code you tried and I will try to make a working solution tomorrow. Thanks!

@tneotia
Copy link
Owner

tneotia commented Aug 4, 2021

Hope this helped you, let me know if you have further questions.

@indyfmn
Copy link

indyfmn commented Sep 10, 2021

@tneotia Just bringing something to your attention here. Commit - 9cbd9f3 links to this issue as the recommended way to set the default font. However, as per your reply in the issue #125 , execCommand should be used via onFocus callback and not onInit as suggested in this issue.

@tneotia
Copy link
Owner

tneotia commented Sep 10, 2021

Thanks for bringing to my attention, that was a mistake on my part. Fixing right now :)

@posawatji
Copy link

I try to set fontName like you, but I can't change the default font family in the editor. (I don't use defaultToolbarButtons.)
@tneotia

To set the default font I think you can do:

HtmlEditor(
   callbacks: Callbacks(
      onInit: () {
         controller.execCommand('fontName', argument: "font_name_here");
      }
   )
)

Your font name has to be inserted in the exact same way it would be in HTML, for example sans-serif or Times New Roman.

I haven't tested this but I think it should work, and you can use defaultToolbarButtons to remove the font dropdown. If it doesn't work please post the code you tried and I will try to make a working solution tomorrow. Thanks!

@alfaruqrizqi18
Copy link

I try to set fontName like you, but I can't change the default font family in the editor. (I don't use defaultToolbarButtons.) @tneotia

To set the default font I think you can do:

HtmlEditor(
   callbacks: Callbacks(
      onInit: () {
         controller.execCommand('fontName', argument: "font_name_here");
      }
   )
)

Your font name has to be inserted in the exact same way it would be in HTML, for example sans-serif or Times New Roman.
I haven't tested this but I think it should work, and you can use defaultToolbarButtons to remove the font dropdown. If it doesn't work please post the code you tried and I will try to make a working solution tomorrow. Thanks!

sama for me

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

No branches or pull requests

5 participants