Friday, November 26, 2010

Chinese in FreeBSD revisit

I have some experience on setting up a Chinese desktop with FreeBSD 4.3. Now with 8.1, seems need some enhancement and modification to make it work again.


  1. Chinese Environment. It is really not necessary to change the .login_conf. Read the login_conf man page, all it does is to setup the environment variables. So one just need to add the following three lines into .cshrc. (if csh is used):

    setenv XMODIFIERS "@im=scim"
    setenv LANG zh_CN.UTF-8
    setenv LC_ALL zh_CN.UTF-8
    

  2. Notice above two things. First, I use scim as chinese input method. Second, I use zh_CN.UTF-8 as encoding
  3. The most important part is the display of fonts. 
    1. Chinese font. First thing I did is to install WenQuanYi true type fonts. It provided some good fonts. WenQuanYi Micro Hei, and WenQuanYi Bitmap Song are the two I used.
    2. Create .fonts.conf in home directory:
    3. <?xml version='1.0'?>
      <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
      <fontconfig>
          <!--
            install ==> print/freetype2 [WITH_LCD_FILTERING=yes and assumes BCI not disabled]
            install ==> x11-fonts/dejavu
            install ==> x11-fonts/webfonts
            install ==> x11-fonts/terminus-font
        -->
          <!-- preferred aliases -->
          <alias>
              <family>serif
              <prefer>
                  <family>DejaVu Serif
           <family>WenQuanYi Micro Hei
           <family>WenQuanYi Bitmap Song
              </prefer>
          </alias>
          <!-- preferred aliases -->
          <alias>
              <family>sans-serif
              <prefer>
                  <family>DejaVu Sans
           <family>WenQuanYi Micro Hei
           <family>WenQuanYi Bitmap Song
              </prefer>
          </alias>
          <!-- preferred aliases -->
          <alias>
              <family>monospace
              <prefer>
                  <family>DejaVu Sans Mono
                  <family>Terminus
           <family>WenQuanYi Micro Hei
           <family>WenQuanYi Bitmap Song
              </prefer>
          </alias>
          <!-- default quality settings -->
          <match target="font">
              <edit mode="assign" name="rgba">
                  <const>none
              </edit>
              <edit mode="assign" name="antialias">
                  <bool>true
              </edit>
              <edit mode="assign" name="autohint">
                  <bool>true
              </edit>
              <edit mode="assign" name="hinting">
                  <bool>true
              </edit>
              <edit mode="assign" name="hintstyle">
                  <const>hintfull
              </edit>
          </match>
          <!-- reduce ringing ==> requires freetype2 'WITH_LCD_FILTERING=yes' -->
          <match target="font">
              <edit mode="assign" name="lcdfilter">
                  <const>lcdlight
              </edit>
          </match>
          <!-- disable autohinting for bold fonts -->
          <match target="font">
              <test compare="more" name="weight">
                  <const>medium
              </test>
              <edit mode="assign" name="autohint">
                  <bool>false
              </edit>
          </match>
          <!-- disable autohinting for fonts that don't need it -->
          <match target="pattern" name="family">
              <test name="family" qual="any">
                  <string>Andale Mono
                  <string>Arial
                  <string>Arial Black
                  <string>Comic Sans MS
                  <string>Courier New
                  <string>Georgia
                  <string>Impact
                  <string>Trebuchet MS
                  <string>Tahoma
                  <string>Times New Roman
                  <string>Verdana
                  <string>Webdings
              </test>
              <edit mode="assign" name="hinting">
                  <bool>true
              </edit>
              <edit mode="assign" name="autohint">
                  <bool>false
              </edit>
          </match>
      </fontconfig>
      
    4. Terminal, use urxvt and set the font as:
      urxvt -fn 'xft:dejavu sans mono:size=9,xft:wenquanyi bitmap song:size=9'

Friday, November 12, 2010

Setup Xorg Intel DVI 1920x1200 on Sceptre Monitor

    The FreeBSD box I have is very nice. Except one thing: I cannot get native 1920x1080 resolution with a DVI connection to the 24" display I have (Sceptre X24WG). On VGA, it works but the screen looks very blur.

    When I connect the monitor through DVI, if I do not set the Modes to 1920, it automatically configures 800x600. If I set the mode to 1920x1200, it blacks out.

    Then I found this link from mythtv: http://www.mythtv.org/wiki/Modeline_Database that has a section on the mode line for Scepre X37SV-Naga.


## (37" 1920x1080 60Mhz native resolution LCD)
## Using Nvidia FX5200 DVI->HDMI cable connected to the LCD
## I had to use the following options for any modes greater than 1280x1024 to work when using the DVI->HDMI 
## output, I didn't need these options for VGA output to the LCD.
#   Option "ModeValidation" "NoMaxPClkCheck, NoEdidMaxPClkCheck"
#   Option "UseDisplayDevice" "DFP"
#
#   Modeline for the LCD's native resolution
#   ModeLine "1920x1080p" 148.500 1920 2024 2072 2200 1080 1084 1094 1124 -hsync -vsync


I give it a try and bang! It works!

Actually, the problem appeared again. I think it is because I am using a Mini-ITX motherboard that has an LVDS interface. That seems like a main interface. The DVI interface, seems like an external interface. 8 out 10 times when I startx, monitor became blank. I found a word around is to Ctrl-Alt-<F1> to switch to text mode, then Alt-<F9> to switch back to video mode. That worked around the problem.

Also, if the monitor ran into sleep mode, I also need to do the same thing to make it work. Or, I can turn off the monitor then turn it back on, which also bring back the video display.

Really hope Xorg or FreeBSD or Intel driver, which ever will have this issue fixed.

Tuesday, November 09, 2010

Setup Netgear Printer Server WGPS606 with FreeBSD

Here is the steps to configure FreeBSD to use an HP LaserJet printer on Netgear WGPS606.


  1. Add lpd_enable="YES" in /etc/rc.conf
  2. Add these lines to /etc/printcap
    lp|hp|laserjet|HP LaserJet 3015 on WGPS606:\
        :sh:\
        :rm=192.168.1.110:rp=L1:sd=/var/spool/lpd/hp:lf=/var/log/lpd-errs:\
        :if=/usr/local/libexec/ifhp:
    

    In my setup, the IP address of WGPS606 is 192.168.1.110 and the printer is connected to the first USB port. Therefore, the rm in the printcap is 192.168.1.110 and the rp is L1. If a printer is connected to the second USB port, then rp should be L2.
  3. Now let's copy the hp filter:
    cp /usr/local/share/examples/printing/ifhp /usr/local/libexec/ifhp
  4. We need to make the filter executable by all:
    chmod 0555 /usr/local/libexec/ifhp
  5. Now create the printer spool folder.
    mkdir /var/spool/lpd/hp
  6. Don't forget to start lpd by:
    /etc/rc.d/ldp start
  7. Print a test page: lpr -P hp test.txt
  8. If printing does not happen at all, tail -f /var/log/lpd-errs to see what is going on.