gfonsel stdout problem! [SOLVED]

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

gfonsel stdout problem! [SOLVED]

#1 Post by Argolance »

Bonjour,
I am trying to build a script which lets user define a font of his choice with something like this:

Code: Select all

# FONT="`gfontsel stdout`"
# echo $FONT
Sans 10
# 
The script can then use the value of the variable FONT.
This runs quite well if user really choose a font then click on the gfontsel application button "Close". But if user clicks on the quit button of the window title bar, gfontsel is closed but the process itself not!

Code: Select all

# FONT="`gfontsel stdout`"
????
The script hangs waiting for some operation to be ended. :(

How can this be solved?

Thanks for your attention.

Cordialement.
Last edited by Argolance on Fri 22 Nov 2013, 17:59, edited 1 time in total.

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Re: Application stdout problem!

#2 Post by L18L »

Argolance wrote:How can this be solved?
Don't use gfontsel, use

Code: Select all

yad --font

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#3 Post by Argolance »

Bonsoir L18L,
Don't use gfontsel, use

Code: Select all

yad --font
... Awesome!
Thanks a lot.

Cordialement.

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

--fontname=FONTNAME command line

#4 Post by Argolance »

Bonjour,

Code: Select all

yad --font
The yad font selector is configured by default to point on and show the "Sans" font in the font list.
I saw this on the :arrow: man yad howto page:
Font selection options

Code: Select all

--fontname=FONTNAME
Set the initial font. FONTNAME is a string with font representation in the form [FAMILY-LIST] [STYLE-OPTIONS] [SIZE].

Code: Select all

--preview
Set the preview text.
For example, this works fine:

Code: Select all

yad --font --preview abcdefghijklmno...
But I tried many combinations using the --fontname command and didn't succeed in making this work :oops: !
For example:

Code: Select all

yad --font --fontname DejaVu Sans 12

Code: Select all

yad --font --fontname=DejaVu Sans 12

Code: Select all

...
Does anybody knows how to do?


Cordialement.

User avatar
CatDude
Posts: 1563
Joined: Wed 03 Jan 2007, 17:49
Location: UK

#5 Post by CatDude »

Hello Argolance

Try this:

Code: Select all

yad --font --fontname="DejaVu Sans 12"
CatDude
.
[img]http://www.smokey01.com/CatDude/.temp/sigs/acer-futile.gif[/img]

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#6 Post by Argolance »

Hello mate,
... blasted double quote!!! :evil:
This works perfectly! :D

Thank you a lot for this very quick answer!

Cordialement.

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

Ouch!

#7 Post by Argolance »

Hello catdude,
Not so simple! :?
This is my original code lines which work well:

Code: Select all

function xft_select (){
	XFT="`yad --font stdout`"
	if [ "$XFT" != "" ]; then
		XFT_S="${XFT: -2}"
		echo "$XFT_S" > $CONF_DIR/XFT_S.tmp
		XFT_N=`echo "${XFT// ${XFT_S}}"`
		echo "$XFT_N" > $CONF_DIR/XFT_N.tmp
	fi
	} # End of function
This is the function modified to make yad pointing on the current font:

Code: Select all

function xft_select (){
. $CONF_DIR/current_config #get xft and xft_size current values
	XFT=`yad --font --fontname=\""$xft $xft_size"\" stdout`
	if [ "$XFT" != "" ]; then
		XFT_S="${XFT: -2}"
		echo "$XFT_S" > $CONF_DIR/XFT_S.tmp
		XFT_N=`echo "${XFT// ${XFT_S}}"`
		echo "$XFT_N" > $CONF_DIR/XFT_N.tmp
	fi
	} # End of function
export -f xft_select
Making test in terminal:

Code: Select all

# xft="DejaVu Sans"
# xft_size="12"
# XFT=`echo yad --font --fontname="\"$xft $xft_size\"" stdout`
# echo $XFT
yad --font --fontname="DejaVu Sans 12" stdout
# $XFT #click "Cancel"
Sans 10
# 
This works fine:

Code: Select all

# yad --font --fontname="DejaVu Sans 12" stdout
DejaVu Sans 12 #click "OK" no new font selected
# 
What's wrong?

Cordialement.

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#8 Post by SFR »

Hey Argolance, try:

Code: Select all

XFT=`yad --font --fontname="$xft $xft_size"`
BTW, stdout is redundant in that case (does YAD have such an option at all?), but for example in Xdialog it's necessary indeed:

Code: Select all

XFT=`Xdialog --stdout --fontsel "DejaVu Sans 12" 0 0`
HTH
Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#9 Post by Argolance »

Works fine! :D
Thanks!

Cordialement.

Post Reply