B4J Question Relationship between text area height and font size?

rspitzer

Active Member
I have a text field, using the default font (I also tried some other fonts) . I noticed the height of the text field was abnormally large (height wise) to the actual pixel height of the font. In fact, the height of the text field is almost double the height of the font being used. A lot of white space under the font. This also displays itself in the WYSIWYG screen. So I literally changed the height of the text field to 1. Still double the height. I then found by adjusting the font size, then this adjusted the text field height. I find this rather curious. Is there anyway to control the white space under the font to hug the lower part of the character a bit better. Its a bit visually unappealing to have a text area so large in height in comparison to the font itself? It also wastes some valuable screen space.
 

rspitzer

Active Member
Unfortunately, since I don't know how to use a CSS file, though the answer may be relevant, does not help me. Anyway.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
since I don't know how to use a CSS file
This is not a rule. You can learn. I assure you that it will not take you more than 4 minutes.

- Create a file named style.css.
- Add the first code snippet to this file.
- Add the file to the Files folder.
- Add the second code snippet to AppStart.
 
Upvote 0

rspitzer

Active Member
Just wanted to follow up on using the CSS example above to try to fix the white space problem in the textarea control. First using the CSS script above had no effect. I also tried using setPrefHeight and setPrefRowCount (the row count is used to calculate the height). From my limited investigation and I could be very wrong, I think this is actually an issue with the control itself. The white space below the characters seem to be pre defined to make room for a horizontal scroll bar if needed. It does not matter what font size you use, tried extremely small sizes as an example, there still was a default white space. This unfortunately for me is more of an visual problem than anything else. I am going to leave this alone for now . The textarea has a lot of nice built in coding features and handles the text input quite well, so there are trade offs for this.
 
Upvote 0

Bob Spielen

Active Member
Licensed User
This is not a rule. You can learn. I assure you that it will not take you more than 4 minutes.

- Create a file named style.css.
- Add the first code snippet to this file.
- Add the file to the Files folder.
- Add the second code snippet to AppStart.
I followed the orientations but it didn't work out.... So I tried to place the first code snippet directly to the designers CSS direct field.....
and getting now the error message....why could it be?
B4X:
    at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
    at java.base/java.lang.Thread.run(Thread.java:834)
jan 25, 2021 11:23:54 PM javafx.css.CssParser parse
WARNING: CSS Error parsing '*{-fx-font-size:12.00;-fx-border-color:#000000;
-fx-border-width:0.00;.text-area .content {
    -fx-padding: 0;
}}: Expected RBRACE at [2,22]
 
Last edited:
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
(you should have started a new thread)
looks like you are missing a closing brace after the code below (I guess you added the new code and accidentally deleted the closing brace)
B4X:
-fx-border-width:0.00;
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…