Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 17 Dec 2014, 16:10
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
An exec. utility to get text width and height in pixels. PIC
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 1 of 1 Posts_count  
Author Message
sunburnt


Joined: 08 Jun 2005
Posts: 5043
Location: Arizona, U.S.A.

PostPosted: Sat 24 Aug 2013, 12:23    Post_subject:  An exec. utility to get text width and height in pixels. PIC  

### All credit for this utility goes to vovchik who posted the code and helped out at the BaCon forum.

This utility is a life saver for sizing text widgets and their containers and windows.

# With a BaCon label display it can rotate the text and display markup text.

# Very fancy indeed.!

Uses BaCon`s Hug for it`s label widget, so it may not want to work for non-Precise Puppies ( Slacko ).
If I can get more help with it, I`ll use all GTK imports and eliminate Hug. So then it may be more portable.

For help just type: text-size

The caret character "^" is the input separator ( delimiter ).
Code:
Example: text-size ^Many here among us feel that life is but a joke.^Sans Bold 16^0^0


# Figured I ought to show a pic. of what can be done with it. Pretty impressive huh.?

The exec. only calculates the width x height. But additional dialogs can make use of it.

# I could make a text splash dialog like shown here if there`s interest.???
text-size_markup_sm.png
 Description   Pic of vovchik`s BaCon label dialog that can rotate the text, and uses text-size to get the dialog`s size.
 Filesize   73.43 KB
 Viewed   126 Time(s)

text-size_markup_sm.png

text-size.gz
Description 
gz

 Download 
Filename  text-size.gz 
Filesize  16.63 KB 
Downloaded  83 Time(s) 

Edited_time_total
Back to top
View user's profile Send_private_message 
musher0


Joined: 04 Jan 2009
Posts: 4430
Location: Gatineau (Qc), Canada

PostPosted: Sat 31 Aug 2013, 15:24    Post_subject:  

Hi, sunburnt.

Good show!

The graphic equivalent of
Code:
wc -l some.txt
, I suppose?

BFN.

musher0

_________________
"Logical entities must not be multiplied needlessly." / "Il ne faut pas multiplier les êtres logiques inutilement." (Ockham)
Back to top
View user's profile Send_private_message Visit_website 
sunburnt


Joined: 08 Jun 2005
Posts: 5043
Location: Arizona, U.S.A.

PostPosted: Sun 01 Sep 2013, 01:08    Post_subject:  

Hi musher; More or less, like:
W=`wc -c some.txt`
H=`wc -l some.txt`

Except in pixels Wide and High instead of Characters and Lines.
I use to use a mono-font and estimate the text length, it worked fairly well...
But now we can get the exact pixel measurements so you can use any font, style, and size.

GtkDialog and all other GUI kits I`ve seen measure in pixels ( screen measurements ).
Average button is 20 to 25 pixels high, so get the text`s Width and Height + 5 or 10 for padding.

Now I`ve made a menu that allows each button to have an individual font, style, and size.
The same could be done in GtkDialog or most other GUI tool kits.
.
Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0467s ][ Queries: 12 (0.0039s) ][ GZIP on ]