#!/bin/bash
                         
save_settings()
{

case $hinting in

  true)
  
    hintstyle=hintfull
    ;;
    
  false)
   
    hintstyle=hintnone
    ;;
    
esac

  echo "<match target=\"font\">
 <edit name=\"antialias\" mode=\"assign\">
<bool>$antialiasing</bool>
</edit>
<edit name=\"hinting\" mode=\"assign\">
<bool>$hinting</bool>
</edit>
 <edit name=\"autohint\" mode=\"assign\">
<bool>$hinting</bool>
</edit>
<edit name=\"hintstyle\" mode=\"assign\">
<const>$hintstyle</const>
</edit>
</match>" > /root/.fonts.conf

rm /etc/fonts/local.conf
ln -s /root/.fonts.conf /etc/fonts/local.conf
 
 gxmessage "Font appearance settings saved. Only newly started application will be affected."
}

export -f save_settings

export mainWindow='
<window title="Font Appearance" allow-grow="false"> 

   <vbox>
    
   <text><label>Welcome to the Puppy font appearance wizard!</label></text> 
   <text xalign="0"><label>This wizard allows you to change the way fonts appear on your screen: make them either sharper or smoother.</label></text>        
    <text xalign="0"><label>For LCD it is recommend to turn everything on. For CRT screens, do the opposite.</label></text>        
 
   <checkbox tooltip-text="If checked, fonts will be smoothed with antialiasing.">
     <label>Antialiasing</label>
     <variable>antialiasing</variable>
     <default>false</default>
    </checkbox>
       
       <checkbox tooltip-text=" If checked, fonts will be smoothed with hinting.">
         <label>Hinting</label>
         <variable>hinting</variable>
         <default>false</default>
       </checkbox>
       
       <checkbox>
         <label>Automatic hinting</label>
         <variable>autohint</variable>
         <default>false</default>
       </checkbox>
      
     <hbox>
     
      <button>
        <label>Apply</label>
        <action>save_settings</action>
      </button> 

	  <button use-stock="true" label="gtk-quit">
        <label>Exit</label>
        <action type="exit">EXIT_NOW</action>
      </button> 
    
     </hbox>                    
     </vbox>
      
</window>'

gtkdialog3 -p mainWindow

unset mainWindow
