FLTK logo

[fltk.general] Re: Fl_Button label line spacing

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: Fl_Button label line spacing Ian MacArthur Aug 11, 2021  
 

On Wednesday, 11 August 2021 at 13:55:17 UTC+1 supe...@gmail.com wrote:
Hi, I'm trying to put vertical text in a button, I'm using the \n newline, but the vertical spacing is too big, is it possible to put less spacing?
Thanks


OK, so I interpret your question like this: You have a tall, thin button and are setting this label as "T\nh\ni\ns" to try and get (ASCII art alert!)

-----
| T |
| h |
| i |
| s |
-----

Is that correct?
If so, there might be no trivial answer...
Note that to keep things simple, fltk just uses the line height to set the vertical spacing, so it is not readily changed (it is tied to the font size, in effect.)
In the past, I have derived my own button and then used fl_text_extents() to measure the minimum bounds around each glyph and position it suitably, but that's a fair bit of work. (Contrast with fl_measure() which will use a vertical bound based on the line spacing, which is in essence what you are seeing at present.)
An alternative, if you derive your own button, might be to just rotate the entire label 90 degrees (without the embedded "\n" in the labels) and see how that looks. The "rotated_text" demo illustrates that approach - though I do not know if that would be any use to you or not.


--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/6177ba45-7223-4970-acda-4b8b131d3937n%40googlegroups.com.
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.