dankito / RichTextEditor

Rich text WYSIWYG editor for Android and JavaFX
Apache License 2.0
92 stars 36 forks source link

Standard font family in RichTextEditor #60

Closed wharnisch closed 3 years ago

wharnisch commented 3 years ago

Standard font family in RichTextEditor control seems to be "serif". So if if no font family is set, all text is shown as "serif" text.

In contrary to this standard font in base class WebView control seems to be "sans-serif". So if no font family is set, all text is shown as "sans-serif" text.

This leads to the situation that "serif" text written in RichTextEditor will be shown as "sans-serif".

How can I change this behaviour of RichTextEditor control? I want to use the RichTextEditor in a new app, solving this is crucial for usage.

I tried editor.setEditorFontFamily("sans-serif"); and editor.post( () -> editor.setEditorFontFamily("sans-serif") ); These sometimes work and sometimes do not work!

Thanks for your help!

Regards from Austria

dankito commented 3 years ago

I just guess it's a race condition. It takes some time till RichTextEditor is loaded. So depending on if it's already loaded the editor.setEditorFontFamily("sans-serif"); call will work or not.

To fix that issue you can add a EditorLoadedListener (had that example only in MainActivity.kt, not in JavaShowCaseMainActivity.java, fixed that now):

editor.addEditorLoadedListener(new EditorLoadedListener() {
    @Override
    public void editorLoaded() {
        editor.setEditorFontFamily("sans-serif");
    }
});

Does this solve your issue?

wharnisch commented 3 years ago

Yes, thank you very much, now it works! Regards from Austria