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

Paragraph's Line-Spacing CSS doesn't work #382

Closed
ASchmidt84 opened this issue Oct 16, 2016 · 7 comments
Closed

Paragraph's Line-Spacing CSS doesn't work #382

ASchmidt84 opened this issue Oct 16, 2016 · 7 comments
Labels

Comments

@ASchmidt84
Copy link

Hi,
I am working with the new Version of the Editor 7.2 and try to modify it for using it in scala.
For the axuliary problem I will open a complete new issue. But for this here is my question, how I can change the line-spacing of paragraphs?

Thank you

André

@JordanMartinez
Copy link
Contributor

Use TextFLow's CSS:

    /* when lines are wrapped, the number (double) of pixels between lines */
    -fx-line-spacing: <number>;

@JordanMartinez
Copy link
Contributor

JordanMartinez commented Oct 17, 2016

Also, have you seen the RichTextFX CSS Reference Guide?

@ASchmidt84
Copy link
Author

Hi,
line-spacing had no effect. I will try again and checkout the reference guide again.
Yes I looked at the guide, that was the reason for my question :)
I will show you the code later.

@JordanMartinez
Copy link
Contributor

@IntelligyScience Can you give me an update on this?

@JordanMartinez
Copy link
Contributor

I can reproduce this bug using this code:

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import javafx.scene.text.TextFlow;
import javafx.stage.Stage;
import org.fxmisc.flowless.VirtualizedScrollPane;
import org.fxmisc.richtext.InlineCssTextArea;

public class BugDemo extends Application {

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

    @Override
    public void start(Stage primaryStage) {
        InlineCssTextArea area = new InlineCssTextArea("AREA TEXT:\n text here\nadnd\nadfsdf\nadf\ndfasdf\n");
        TextFlow flow = new TextFlow(new Text("TEXTFLOW TEXT:\n"), new Text("some more stuff\n"), new Text("some additional stuff"));

        String css = "-fx-line-spacing: 10px;";
        area.setStyle(css);
        flow.setStyle(css);

        VBox root = new VBox(area, new Text("--------------------"), flow);

        Scene scene = new Scene(root, 500, 500);
        primaryStage.setScene(scene);
        primaryStage.show();
    }

}

@JordanMartinez JordanMartinez changed the title Line Spacing Paragraph's Line-Spacing CSS doesn't work Mar 17, 2017
@JordanMartinez
Copy link
Contributor

The Line Spacing CSS doesn't work, but now that I've documented Flowless, I think I understand why.

When the VIrtualFlow's navigator lays out the ParagraphBox objects, it does not have any indication of how much space to put in-between those objects. Rather, it lays them out sequentially. So, I think the way to get around this is to add padding to the ParagraphBox objects.

However, when I ran the above demo with a longer line of text on a single line and wrapped the text, the line spacing CSS for TextFlow did not work. I'm not sure if this is supposed to work, but it's something to know.

@JordanMartinez
Copy link
Contributor

Thinking about this more, TextFlow's line spacing CSS only applies when it has Text objects that contain a newline character in its text. If one wanted to have line spacing apply on a multi-line TextFlow object, TextFlow doesn't support that. Since RTFX only uses TextFlow to layout text and custom objects that never have a newline character, applying the CSS will never do anything.

As stated before and in the wiki, to add line spacing between lines, one needs to modify the padding values of ParagraphBox. I've updated the CSS guide to forewarn users about this quirk.

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

No branches or pull requests

2 participants