LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   LinuxQuestions.org Member Success Stories (https://www.linuxquestions.org/questions/linuxquestions-org-member-success-stories-23/)
-   -   Making non-antialiased fonts looks nice. (https://www.linuxquestions.org/questions/linuxquestions-org-member-success-stories-23/making-non-antialiased-fonts-looks-nice-257705/)

Franklin 11-21-2004 04:55 PM

Making non-antialiased fonts looks nice.
 
Hello all.

From time to time I see posts from people who feel that linux has ugly fonts and want to know how can they be improved. More often than not, people are looking for font antialiasing, much like the way Apple/OSX renders fonts.

I, for one, dislike that manner of font rendering. The fonts always seem slightly blurry and I feel like I'm straining my eyes to create a clearer image. For this reason, I set out to create a situation where my fonts in linux render exactly as they do in windows - the manner of rendering I prefer.

As any one who uses linux will tell you, turning of antialiasing can produce... well, really crappy results. This situation can be improved considerably, as I have tried to show here. These screen shots are aimed at trying to show several things:

* Well rendered, non-antialiased fonts
* Consistency between KDE and GTK2 applications
* Readable terminal fonts
* Consistent and well rendered fonts across all browsers

While this look is not for everyone, I am very happy with it. If anyone is interested, I would be happy to detail what needs to be done to achieve this on your box.

Thanks for reading.

MWtee 11-22-2004 06:06 AM

Your screenshots look really nice for me and it would be great to read how you achieved this results.
I'm the half-way doing the same thing :)

sunilgeo 11-22-2004 08:37 AM

I have gone through several forums trying to get the fonts look just like as in windows for my linux installation and so far everything failed. Your screenshots looks like exactly what I want, could you please tell me how to achieve this?

Franklin 11-22-2004 09:01 AM

Thank for the replies!

I'll write up something and try to get it posted tonight.

Franklin 11-22-2004 11:18 PM

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.
Code:

make
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
Code:

make install
While you are still root run
Code:

ldconfig
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.

pesari 12-05-2004 08:12 AM

Thank you!
 
Franklin,

Thanks a lot! I really appreciate instructions that are straight-forward enough for people to understand. :)

Oh, I forgot... Worked well with Fedora Core 2. I installed Freetype 2.1.9 without problems *cnock cnock*. :) It looks very good.

Franklin 12-14-2004 12:53 PM

Glad to hear it!
Been away for a few weeks. I'll add the browser info later this week - tho it's pretty self explanatory really.

Anyway, glad to hear my instructions worked for others.

Steve

jordzz 12-15-2004 05:51 AM

Quote:

Originally posted by Franklin
Glad to hear it!
Been away for a few weeks. I'll add the browser info later this week - tho it's pretty self explanatory really.

Anyway, glad to hear my instructions worked for others.

Steve

It also worked for me :) thnx! Im looking forward to the browsers part.
Because often they don't render nice fonts :)

Franklin 01-01-2005 08:52 AM

Hi again. Sorry this took so long - I was away for a while and returned to too much work.

I posted some new screenshots that are meant to show the Firefox, Mozilla, and Konqueror browsers with the font configurations
that I use. This is nothing you couldn't arrive at easily through trial and error, but since I was asked - here it is:

screenshots

All three browsers are set up to provide a consistant look between the three. I use all three for different tasks since, unfortunately,
there is no one browser that doesn't have some failing involving what I need a browser to do.

Like I said before, this style of font rendering isn't for everyone - most people on this forum seem to prefer the antialiased look.
But, for those who like thin fonts at small point sizes, I hope you have found this helpful.

Happy New Year.

jferrando 01-01-2005 07:01 PM

For me it worked installing nice making Linux (Suse 9.1 and Mandrake 10.1) display nice fonts with the help from http://convexhull.com/mandrake_fonts.html
I was desperate about fonts in Linux, so this is the answer!

mysterio 01-02-2005 10:00 AM

Nice Franklin, especially like the screenshots of the browsers with the settings.

Franklin 01-02-2005 10:27 AM

Quote:

Originally posted by mysterio
Nice Franklin, especially like the screenshots of the browsers with the settings.
Thanks!

It's amazing how much work I'll go through just to avoid a lot of typing ;)

Franklin 01-02-2005 02:31 PM

In the interest of fairness, I have included some shots of Gnome 2.8 (Dropline) on slackware-current running kernel 2.6.10 with the font setup for Epiphany. This is a new install on a separate partition to test the 2.6 kernel. I removed Dropline's freetype tgz prior to compiling and installing my own. I did a standard ./configure --prefix=/usr, make, make install. Just a word of warning - Dropline Gnome will not work correctly and definitely will not re-load untill you re-install freetype so don't fart arround too much and put everything where you know where to look in case you end up back at the command line.


BjornErik 01-06-2005 03:27 AM

Fonts in Firefox
 
Hi,

Thanks for the good instructions!
I've followed the guide and managed to get all the programs I run except Firefox 1.0 to look like your screenshots.
I've read a lot about fonts in Firefox but I still can't get them look like yours (Mozilla 1.7.5 looks nice though).

Can you please give me some hints about fonts in Firefox?

Thank you!

Idle 01-11-2005 06:22 AM

Marvellous! Thanks for the tips, it works just fine for me. There's one small problem after the changes, though. Firefox doesn't seem to like my blog anymore, it just crashes when I try to view it (idleblog.iceware.net, if someone else wants to try). Seems to be the only page I have the problem with. Ideas, anyone?


All times are GMT -5. The time now is 04:47 PM.