-
Notifications
You must be signed in to change notification settings - Fork 236
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 update font size of an empty line? #149
Comments
Sorry for late response on this. Style information is only associated with text (that is, characters). No text means no way of specifying style. This will change when paragraph-level styles are supported (#6). To change the default font size of the whole text area, setting the Binding line number font size to the value from your drop-down menu should work, independently of any style remapping. Do you mind sharing the code of your line number factory? |
No worries! The lateness was an exception, not the norm. Thanks for the response. I was using an InlineStyleTextArea that was initialized with a style object that could restyle the font size of the text. There was a second object that styled any text a user typed into the area. That was why I was using the style remapping approach. However, if the style object's |
The LineNumberFactory (LNF) below was a quick test solution. The code below shows where I made minor modifications to yours and isn't the full class. // DEFAULT_FONT was changed from a Font into a Closure (which is basically a method)
private static final Closure<Font> DEFAULT_FONT = { double size ->
return Font.font("monospace", FontPosture.ITALIC, size)
}
// the property used to determine the font size is held within a class of all static variables.
// when calling its apply method, I reference that property like so:
public Node apply(int idx) {
Label lineNo = new Label()
// 'UserSettings.fontSize.get()' was abbreviated to 'UserSettings.fontSize()'
lineNo.setFont(DEFAULT_FONT(UserSettings.fontSize()))
lineNo.setBackground(DEFAULT_BACKGROUND)
lineNo.setTextFill(DEFAULT_TEXT_FILL)
lineNo.setPadding(DEFAULT_INSETS)
To create a Line Number Factory that also updates according to a font size change, could it...
|
Yes, the CSS returned from If your style object has the capacity to override font size, but in a particular case does not (e.g. has
Yes, conceptually this: lineNo.fontProperty().bind(UserSettings.fontSizeProperty); but in order to make sure that the line numbers do not keep being updated (and thus be prevented from garbage collection) after they disappear from the scene, use this trick where the binding to lineNo.fontProperty().bind(Val.flatMap(
lineNo.sceneProperty(),
scene -> scene != null
? UserSettings.fontSizeProperty
: Val.constant(null))); Same trick is already used in the original LineNumberFactory with observing area's total number of lines. |
(Sorry for the late reply. I've been sick the past few days.) The above did the trick. Thank you again! |
No need to be sorry. Get well soon! |
Hello Tomas,
This relates to #148. I am trying to change the font size of an area's text and line number, so that they are the same.
I'm using the style-remapping approach (#142) to update the text's style. I learned that, after remapping, the area only updates the text and line numbers if the mapper returns a new Style object. I can return a new Style object for every line that has content or text, but I can't do that if it's an empty line.
For example, the sixth line below (a blank line) does not update when I use this approach.
The text was updated successfully, but these errors were encountered: