OK, here it is. My "Make Your Fonts Looks Like They Do in Windows" Howto - Hope it helps someone.
First, some warnings:
1. Some of the things I will be suggesting may be in violation of patent laws depending on where you live. They also require you to install fonts that I will assume you have the right to use because you paid for them by buying Windows or a computer with Windows installed. Nuff said.
2. Recompiling freetype2 may have some undesired effects such as 1) Breaking the KDE font installer in KDE 3.2.x (no observed problem in 3.3.1) 2) Changing the way antialiased fonts are rendered in Fluxbox. Blackbox is not adversely effected because it does not use aa. This is likely very fixable but since I don't use it, I don't care. 3) Possibly changing the antialising in KDE/Gnome ever so slightly for the worse. This last one is really a subjective assessment and mentioned only because I seen it mentioned elsewhere (i.e. SuSE newsgroups) so I felt you should be warned. Your distro and your mileage may vary.
3. I have NOT tested this on every distro. My screenshots are from Slackware-current, up to date as of Pat getting sick (11/16 last official changelog). For those who don't know, slack uses Xorg, KDE 3.3.1, Gnome 2.6, freetype 2.1.9, kernel 2.4.27. I have done this before in SuSE 8.2, slackware 9.1, slackware 8.1, and will be trying this with Debian over the next several days, however I "hear" freetype already is compiled with the byte code interpreter enabled in Debian so I don't expect much difference. That being said I see room for improvement so who knows. I am VERY new to Debian.
Alright - enough BS.
Step 1: Deciding on a good resolution.
This is mostly determined by your monitor/vidcard combo and your personal prefs. I have a 19 inch ViewSonic that works well at 1280x1024 @ 75hz. 17 inch monitors generally run best at 1024x768 - YMMV. Configure XF86Config or xorg.config to display your desired resolution and refresh rate. (If you don't know how, man xorg.conf) Don't worry if your fonts are too small - we'll take care of that later by changing the dpi.
Step 2: WWWD - What Would Windows Do?
Windows does three things that we need to make linux do. 1. Use decent quality fonts 2. Use a sane DPI (dots per inch) 3. BYTE_CODE_INTERPRETER
1. Getting TrueType Fonts
Some distros like SuSE come with a little script that allows you to download the Windows Core Font package. If you own a windows disk, there are some cabextract programs out there that will allow you to mine the disc for fonts. If you dual-boot, like me, then just mount your windows partition and copy the font folder to /home/<user>. Copying the font folder is not needed, but may be a good idea seeing as you never know when something will hose your windows partition. At least then you'll have it for easy access in the future.
Now we need to add the True Type fonts to linux. Fonts in linux are usually located in the /usr/X11R6/lib/X11/fonts directory. A quick peek at xorg/XF86Config will tell you where yours are:
Code:
# FontPath "/usr/X11R6/lib/X11/fonts/local"
# FontPath "/usr/X11R6/lib/X11/fonts/CID"
# FontPath "/usr/X11R6/lib/X11/fonts/Speedo"
FontPath "/usr/X11R6/lib/X11/fonts/misc"
FontPath "/usr/X11R6/lib/X11/fonts/TTF"
FontPath "/usr/X11R6/lib/X11/fonts/100dpi"
FontPath "/usr/X11R6/lib/X11/fonts/75dpi"
FontPath "/opt/kde/share/fonts"
FontPath "/usr/X11R6/lib/X11/fonts/Type1"
FontPath "/usr/X11R6/lib/X11/fonts/cyrillic"
FontPath "/usr/local/share/fonts"
FontPath "/usr/X11R6/lib/X11/fonts"
FontPath "/usr/local/share/fonts/TTF" <-- Created by KDE font installer
FontPath "/usr/share/fonts"
FontPath "/usr/share/fonts/default"
In my case, True Type fonts are in the TTF directory. Yours may be in truetype directory, or you may need to create a TTF folder. You can also add then to your ~/fonts directory if you don't want them system-wide, but I usually do install them system wide. If you do create a new folder for them, be sure to install a FontPath line to let X know where to find them.
The simplest way to install new fonts is with the KDE font installer module in the Control Center under System Administration. Be sure to use Administrator Mode (system-wide) and click on the TTF directory in the tree. Click the "Add Fonts" button in the tool bar. Navigate to the directory where the windows fonts are and select all the fonts you want to add: Arial, Comic Sans MS, Courier New, Tahoma, Times New Roman, and Verdana are the main ones you will need. You can add whatever you want of course. If you use this method, the fonts will be installed to the /usr/local/share/fonts/TTF directory and a path will be created in xorg.conf as you can see above. We do this first because recompiling freetype2 can break the font installer - this allways happened to me in 3.2.x.
While you are editing xorg.conf, you should do one more bit of housekeeping and make sure that the 100dpi fonts are listed above the 75dpi font lines
2. DPI - dots per inch
Windows uses a default setting of 96 dpi. Linux defaults to 75 or 81 dpi. This is why linux fonts are always so damn small compared to the same fonts in windows at the same screen resolution and font size. There are several things we need to do to get linux to run at 96 dpi depending on your situation:
A) If you boot into runlevel 3 and use "startx" to start X, we need to edit the /usr/X11/bin/startx script. Depending on your distro, this may be a symlink to /usr/X11R6/bin/startx.
Code:
userclientrc=$HOME/.xinitrc
userserverrc=$HOME/.xserverrc
sysclientrc=/usr/X11R6/lib/X11/xinit/xinitrc
sysserverrc=/usr/X11R6/lib/X11/xinit/xserverrc
defaultclient=/usr/X11R6/bin/xterm
defaultserver=/usr/X11R6/bin/X
defaultclientargs=""
defaultserverargs="-dpi 96" <--- LOOK HERE
clientargs=""
serverargs=""
Just add the "-dpi 96" to the end of the 'defaultserverargs=' line and that's it. Now, everytime you use startx, you will boot to 96x96 dpi which can be confirmed from the command line after starting X by typing:
Code:
xdpyinfo | grep resolution
B) If you automatically startx by using KDM or GDM, then we need to edit xorg.conf or XF86Config. This is a little more complicated. We need to use the DisplaySize variable and this will be different for each resolution. I use 1280x1024:
Code:
# **********************************************************************
# Monitor section
# **********************************************************************
# Any number of monitor sections may be present
Section "Monitor"
Identifier "My Monitor"
# HorizSync is in kHz unless units are specified.
# HorizSync may be a comma separated list of discrete values, or a
# comma separated list of ranges of values.
# NOTE: THE VALUES HERE ARE EXAMPLES ONLY. REFER TO YOUR MONITOR'S
# USER MANUAL FOR THE CORRECT NUMBERS.
HorizSync 31 - 86
# HorizSync 30-64 # multisync
# HorizSync 31.5, 35.2 # multiple fixed sync frequencies
# HorizSync 15-25, 30-50 # multiple ranges of sync frequencies
# VertRefresh is in Hz unless units are specified.
# VertRefresh may be a comma separated list of discrete values, or a
# comma separated list of ranges of values.
# NOTE: THE VALUES HERE ARE EXAMPLES ONLY. REFER TO YOUR MONITOR'S
# USER MANUAL FOR THE CORRECT NUMBERS.
VertRefresh 50-180
Option "dpms"
DisplaySize 337.5 270.0 <--- LOOK HERE
EndSection
The [DisplaySize 337.5 270.0] setting will cause X to load at 96x96 dpi when at 1280x1024 resolution. When the numbers go up, the dpi will go down. When the resolution goes down, the dpi goes down as well, so this is not a constant if you are one to change resolutions. The startx script edit is a constant regardless of resolution. The following may help you figure your own values:
Code:
1280 1024
------ X ------ 1280 * 270 = 345600; 1024 * 337.5 = 345600
337.5 270.0
C) If you use Gnome, then even if we have done both of the above, we need to go into Gnome/Desktop Prefs/Fonts/Details and change the DPI setting at the top of the page to read 96. Even if you don't use gnome, but use the gnome-setting daemon to carry the Gnome themes into KDE, you will need to do this to maintain consistency. Even If you don't, apps like evolution, I believe, still carry the dpi setting into KDE and may lead to font-size inconsistency.
OK, so now we have TT Fonts, and or dpi is set at 96x96 now we need to...
3. Recompile Freetype2 to enable the Bytecode Interpreter.
Download the source from
http://www.freetype.org/
While it likely doesn't matter, I alway make sure that I am installing the same version that is already installed in my distro. For example, for a while slack-current used 2.1.8 even though 2.1.9 had been released, so I only recompiled the 2.1.8 source. I just feel that the fewer the variables, the less to troubleshoot. Download and extract the tarball - I always compile in /tmp - and read the readme's!!!!
The following is from the TRUETYPE readme in the source package of freetype2:
Code:
How to enable the TrueType native hinter if you need it
--------------------------------------------------------
The TrueType bytecode interpreter is disabled in all public releases
of the FreeType packages for patents reasons (see
http://www.freetype.org/patents.html for more details).
However, many Linux distributions do enable the interpreter in the
FreeType packages (DEB/RPM/etc.) they produce for their platforms. If
you are using TrueType fonts on your system, you most probably want to
enable it manually by doing the following:
- open the file "include/freetype/config/ftoption.h"
- locate a line that says:
#undef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
- change it to:
#define TT_CONFIG_OPTION_BYTECODE_INTERPRETER
These steps must be done _before_ compiling the library.
--- end of TRUETYPE ---
Couldn't have said it better myself
Before compiling freetype and installing, you may want to uninstall the package that is currently installed on the system. I've seen this said other places, but I have not had a problem NOT doing that - slackware's stock freetype is imbedded in the X packages and cannot be uninstalled as a seperate package so I didn't. Made no difference.
Another thing you should do before installing is check your symlinks.
Code:
steve@peggyo:~$ cd /usr/lib
steve@peggyo:/usr/lib$ ls -la libfreetype*
-rw-r--r-- 1 root root 2431914 2004-11-11 00:28 libfreetype.a
-rwxr-xr-x 1 root root 816 2004-11-11 00:28 libfreetype.la*
lrwxrwxrwx 1 root root 20 2004-11-11 00:28 libfreetype.so -> libfreetype.so.6.3.7*
lrwxrwxrwx 1 root root 20 2004-11-11 00:28 libfreetype.so.6 -> libfreetype.so.6.3.7*
-rwxr-xr-x 1 root root 415008 2004-06-05 17:48 libfreetype.so.6.3.5* <-- OLD and UNLINKED;
-rwxr-xr-x 1 root root 1521734 2004-11-11 00:28 libfreetype.so.6.3.7*
steve@peggyo:/usr/lib$
This can be very helpful if you choose to upgrade and you want to check that the links point to the new libs. This is also helpful if you want to delete the libraries before installing the new compile and want to see if new links were created. If not, the old listing will tell you what you need to do.
Also, be sure you have all the dev packages installed so you CAN compile!!!
OK then, time to compile.....
Code:
./configure --prefix=/usr
I use this setting for slack, it may work for you, you may not need it. If libfreetype is in /usr/lib, them it's probably OK. Read ./configure --help to see defaults.
dum dee dum dum dum.....
things wizzing by....
lots of error messages like "blah blah violates strict antialiasing rules yada yada" ignore them.
su to root
While you are still root run
and that should do it.
If you are in KDE, go to /Control Center/Appearance/Fonts and keep antialiasing enabled, but exclude range 0.0 pt to 14.0 or 15.0 pt. Change all fonts to arial or verdana at 9 or 10 and restart X.
You should see a big difference in how these fonts are rendered without antialiasing (at this size).
STEP 3: GTK2 (Gimp Tool Kit) Applications in KDE
Applications like Mozilla, Gnumeric, Gaim, Abiword, Blufish, Pan are GTK2 applications. They will not follow the font type and size rules you set up when you use them in KDE unless you create a hidden file in your /home/<user> directory.
Create a text file, call it .gtkrc-2.0, and add the line:
gtk-font-name = "Verdana 9"
or whatever your chosen font and size in KDE is.
That should be it.
I'll post some stuff about browsers tomorrow as well as some links I have regarding font issues. Too late now- time for bed.
Hopefully I did not forget too much.