LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-03-2015, 05:33 PM   #1
honest_abe
LQ Newbie
 
Registered: Apr 2015
Posts: 20

Rep: Reputation: Disabled
Calculating window size based on font size & number of characters?


When specifying a window size, some programs use
--width=
others use
--geometry=
but in either case, I would like to make a text window be set to cover the longest line of the text. Now the longest line can be calculated. Given that I know he font size (say Courier 18 or Monospace 20), does anyone know a formula that would tell me the window width based on line length and font size?

Similarly, window height based on number of lines and font size?

Of course, I'd have to add some for anything else the window displays but those should be fixed.

For my program, this will apply to yad windows.
 
Old 05-03-2015, 06:30 PM   #2
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,150

Rep: Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856
calculating the width is not just a case of knowing the font size as different fonts will have different widths for the characters, and the same string in the same fontsize will give different widths for different fonts, you will need to examine the font metrics, how you do this will depend on what programming language you are using and probably also what gui toolkit you are using, without the answer to both of those questions you are only going to get general answers like this.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change window size ... to an exact number Skaperen Linux - Desktop 8 05-04-2012 10:14 PM
Inactive window font size & Webpage fonts Norwood Linux - Newbie 1 03-02-2010 02:57 PM
How do I limit the smallest font size to make characters at least recognizable timyang Linux - Desktop 2 09-08-2008 01:41 PM
change font size in terminal window homerjpbody Linux - Newbie 3 08-08-2008 09:26 PM
change font(size) for GTK based applications? the_low Linux - Newbie 2 08-03-2005 03:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration