Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

JDK-8230231 : font-family not updated in HTMLEditor #573

Open
Maxoudela opened this issue Aug 27, 2019 · 4 comments
Open

JDK-8230231 : font-family not updated in HTMLEditor #573

Maxoudela opened this issue Aug 27, 2019 · 4 comments

Comments

@Maxoudela
Copy link
Contributor

Maxoudela commented Aug 27, 2019

In the HTMLEditor, when positioning the caret in a text, the toolbar is updated to reflect the current position (font-size, bold button etc). The font-family is not updated if the font-family is composed of several words.

Steps to reproduce :

  • Run this sample :

import javafx.application.Application;
import static javafx.application.Application.launch;
import javafx.scene.Scene;
import javafx.scene.web.HTMLEditor;
import javafx.stage.Stage;

public class TestApp extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        HTMLEditor editor = new HTMLEditor();
        
        Scene scene = new Scene(editor);
        primaryStage.setScene(scene);
        primaryStage.show();
    }
}
  • Write "Hello world"
  • Select the word "Hello" and apply the "Arial" font-family
  • Select the word "world" and apply the "Agency FB" font-family.
  • Click on the word "Hello" positioning the caret between the "e" and the "l"
  • Verify "Arial" is selected. Then click on the word "world" positioning the caret between the "o" and the "r"

Actual behavior:

  • The font-family stays on "Arial".

Expected behavior:

  • The font-family should be on "Agency FB"

Reproduced on JDK 8u202, on Windows 10 and also on macOS High Sierra (version 10.13.6)

Issue on JDK bug tracking : https://bugs.openjdk.java.net/browse/JDK-8230231

@Maxoudela
Copy link
Contributor Author

I think I have found the problem, it's coming from the HTMLEditorShuttleSkin in updateToolbarState method.

We have this :

// stripping out apostrophe characters, which are appended to either
            // end of the font face name when the font face has one or more spaces.
            if (fontFamilyStr.startsWith("'")) {
                fontFamilyStr = fontFamilyStr.substring(1);
            }
            if (fontFamilyStr.endsWith("'")) {
                fontFamilyStr = fontFamilyStr.substring(0,fontFamilyStr.length() - 1);
            }

But it seems that the font are not surrounded by single quotes, but by double-quotes. At least on My Windows 10.
So the solution would simply to have this :

// stripping out apostrophe characters, which are appended to either
            // end of the font face name when the font face has one or more spaces.
            if (fontFamilyStr.startsWith("\"")) {
                fontFamilyStr = fontFamilyStr.substring(1);
            }
            if (fontFamilyStr.endsWith("\"")) {
                fontFamilyStr = fontFamilyStr.substring(0,fontFamilyStr.length() - 1);
            }

Seems that this issue could be reproduced in the latest version since the code has not changed :

@kevinrushforth
Copy link
Collaborator

I might recommend looking for either ' or "

@Maxoudela
Copy link
Contributor Author

Should I go directly for a PR on this?

@kevinrushforth
Copy link
Collaborator

Sure, that seems like a good idea.

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

No branches or pull requests

2 participants