Menu

#251 --fontname= doesn't work.

New
nobody
None
Medium
Defect
2023-08-22
2015-05-02
No

Using --fontname= doesn't appear to work. No change in font size.

Three different thing tried
--fontname="Monospace 16"
--fontname="Monospace Regular 16"
--fontname="Courier 10 Pitch 18" # This was based on the output of yad --font.

Ubuntu 14.04
yad 0.28.1

Discussion

  • Victor Ananjevsky

    what version of gtk+ you use with yad?
    and please, illustrate this problem with some screenshots

     
  • John Pezzano

    John Pezzano - 2015-05-03

    I probably need to clarify my problem. I am using the --list option and I expected the --fontname to change the size of the data that is being displayed in the list. I did find out that for each list item, I can use the "span" command but it is not only a kluge because the span has to be used for each entry and when an entry is selected, to recover the value, I have to peel off the "span" command from the output I want.

    am using gtk2

    This is the code I use now for the list:
    FileDir=`let Count=1
       while [ $Count -lt ${#line[@]} ]; do
       echo -n "'" ; echo -n '<span color="red" font="20">'${DisplayLine[$Count]}'</span>' ;echo "'"
        Count=$((Count+1))
    done | yad --list --timeout=60 --width 500 --height 400  \
         --text '<span color=\"red\" font="16">Pick a topic then\n select "OK"to begin</span>' \
         --column "Topic"  --center --button="gtk-ok:0" \
         -align=center \
         --no-click --limit=10 --timeout-indicator="bottom" |
         sed -e s'/.<span color="red" font="20">//' -e s'/<.span>..//' `
    

    This snippet demonstrates the difference between using --fontname and the span

    Winxsize=600
    read Xsize Ysize <<<$(xdpyinfo |grep dimensions |sed -e s'/p.*//' -e s'/.*    //' -e s'/x/ /')
    Winxpos=$(( $((Xsize / 2 )) - $((Winxsize / 2 )) ))
    yad --image=dialog-question --timeout=0 \
    --text='<span color=\"red\" font="16">Select "OK" when you are ready to begin</span>' \
      --button="gtk-ok:0"  --undecorated --geometry="${Winxsize}x50+${Winxpos}+0"
    
    yad --image=dialog-question --timeout=0 \
    --text='Select "OK" when you are ready to begin' \
    --fontname="Courier Bold 20"\
      --button="gtk-ok:0"  --undecorated --geometry="${Winxsize}x50+${Winxpos}+0"
    

    The first yad outputs size 16 font. The second outputs small font

     
  • Victor Ananjevsky

    for --list there are three special types of columns - @fore@, @back@ and @font@ which describes decoration of text in list

    for example

    yad --list --column=text --column=@fore@ --column=@font@ " big red font" "#FF0000" "Monospace 20" "normal blue font" "blue" ""

     
  • John Pezzano

    John Pezzano - 2015-05-04

    So how would that work with this snippet of code? Would I have to put a "red" "monospace 20" before each item?

    let Count=1
    while [ $Count -lt ${#line[@]} ]; do
    echo -n "'" ; echo -n ''${DisplayLine[$Count]}'' ;echo "'" Count=$((Count+1)) done | yad --list --timeout=60 --width 500 --height 400 \ --text 'Pick a topic then\n select "OK"to begin' \ --column "Topic" --center --button="gtk-ok:0" \ -align=center \ --no-click \ --limit=10 --timeout-indicator="bottom"

    This didn't work as yad thinks each line is the whole line
    let Count=1
    while [ $Count -lt ${#line[@]} ]; do
    echo -n '"'"red"'"'
    echo -n '"'"Monospace 20"'"'
    echo '"'${DisplayLine[$Count]}'"'
    Count=$((Count+1))
    done | yad --list --timeout=60 --width 500 --height 400 \ --text 'Pick a topic then\n select "OK"to begin' \ --column @fore@ --column=@font@ --column=text --center --button="gtk-ok:0" \ -align=center \ --no-click \ --limit=10 --timeout-indicator="bottom"

    All I get is an error that it doesn't recognize the whole line
    '"red" "Monospace 20" "[my text here]"' as a color

     

    Last edit: John Pezzano 2015-05-04
  • Victor Ananjevsky

    one string from stdin is one cell in --list

    let Count=0
    while [ $Count -lt ${#line[@]} ]; do
        echo "red"
        echo "Monospace 20"
        echo "${DisplayLine[$Count]}"
        Count=$((Count+1))
    done | yad --list --timeout=60 --width 500 --height 400 \
        --text 'Pick a topic then\n select "OK"to begin' \
        --column @fore@ --column=@font@ --column=text --center --button="gtk-ok:0" \
        --align=center --no-click --limit=10 --timeout-indicator="bottom" 
    
     
    • John Pezzano

      John Pezzano - 2015-05-04

      Victor,

      I intentionally skip the "0" (first) item. It was not a mistake.

      I'd swear this was the way I started writing the code with the @font@/@fore@ and it did not work. It does now. My error. Thanks. Must have had other mistakes.

      I love yad but I wish there were many more examples.

      You can close this problem.

       
    • sid-the-sloth

      sid-the-sloth - 2023-08-22

      @v1c0nt That WHILE loop does not work. Must use a FOR loop, such as:

      for line in ${RNDLINES[@]}; do
        echo "Roboto Mono 10"
        echo "${line}"
      done | yad --list --title="Here are your passwords" --text="\nCopy and paste your fresh password from below:\n" --column=@font@ --column=text --no-escape --no-markup --center --editable --no-click --grid-lines=hor --button=_Close:0 --no-headers --width=360 --height=400
      
       

Log in to post a comment.