Jump to content
Compatible Support Forums
Sign in to follow this  
Shoikan

Truetype fonts in XFree86 4.2.0

Recommended Posts

I am sure everyone can agree that the standard fonts of XFree are rather crappy. There are many howtos on making them look better, or using other fonts. Here you will find yet another howto, cookbook or whatever you want to call it....

 

The guys from Redmond have a habit of taking care of the looks quite a bit more than of security and that is actually to our advantage. We can 'borrow' their fonts for use in X. Note that the use of those fonts is only allowed if you have a valid windows license, or if you have downloaded the fonts from their site.

 

This text assumes you use XFree 4.2.0, that you have a reasonable knowledge of the CLI and *NIX commands, that you have a working setup of X and a reasonably recent distribution. You should also have perl and freetype on your system.

 

Step 1: Preparing the fonts and the directory.

 

Unpack and/or move (from a windows partition) the ttf files to a directory under /usr/X11R6/lib/X11/fonts, for instance Truetype. The fontserver prefers the filenames to be in lowercase, so use this script on the files (I am reasonably sure the use is selfexplanatory?). Download the program ttmkfdir here. Unpack it and put the file ttmkfdir.linuxbin.glibc2 somewhere where you can run it from, such as /usr/local/bin. Then make a symlink to it called ttmkfdir since I am sure you don't want to type all of that every time you use it wink Next, download this file and also put it in the /usr/local/bin directory. Once you have all that set up, you cd into the directory with the truetype fonts. Run the command:

Code:
$ cd /usr/X11/lib/X11/fonts/Truetype$ chmod u+x /usr/local/bin/mkfontalias.py$ ttmkfdir -o fonts.scale$ mkfontdir$ mkfontalias.py

After these commands you should see the following files: fonts.alias, fonts.dir and fonts.scale.

 

Step 2: Modifying the config files.

 

Next thing to do is modifying the various configuration files to reflect the new fonts you have added and make the most of them. Go and find the file XF86Config-4 or XF86Config. If both are found, the -4 version gets used. They can usually be found at /etc/X11 or /usr/X11/lib/X11. Open it and look for the following section:

Code:
Section "Files"

Modify the lines under that section to look like this:

Code:
	FontPath		"/usr/X11R6/lib/X11/fonts/Type1"	FontPath		"/usr/X11R6/lib/X11/fonts/util"	FontPath		"/usr/X11R6/lib/X11/fonts/misc:unscaled"	FontPath		"/usr/X11R6/lib/X11/fonts/100dpi:unscaled"	FontPath		"/usr/X11R6/lib/X11/fonts/75dpi:unscaled"	FontPath		"/usr/X11R6/lib/X11/fonts/Speedo"	FontPath		"/usr/X11R6/lib/X11/fonts/TTF"	FontPath		"/usr/X11R6/lib/X11/fonts/Truetype"	FontPath		"/usr/X11R6/lib/X11/fonts/cyrillic"	FontPath		"/usr/X11R6/lib/X11/fonts/encodings"	RgbPath		"/usr/X11R6/lib/X11/rgb"	ModulePath	"/usr/X11R6/lib/modules"

This will make sure X can find the fonts. Next, hunt for the file called XftConfig. It can usually be found in the same directory as XF86Config. Look for the line:

Code:
dir "/usr/X11R6/lib/X11/fonts/Type1"

Modify the lines there to show:

Code:
dir "/usr/X11R6/lib/X11/fonts/Type1"dir "/usr/X11R6/lib/X11/fonts/TTF"dir "/usr/X11R6/lib/X11/fonts/TrueType"

This will make sure the fontserver will be able to find the fonts as well.

 

Step 3: Sit back and enjoy your work.

 

Fire up X again and you should be able to see that you now have the use of Truetype fonts in X.

 

In the next installment, you will learn how you can get KDE to show your fonts anti-aliased. I assure you, that looks positively stunning.

Share this post


Link to post

H

i Nice to read your artical. Iam intereseted to install the TTF Pinyin fonts that I have installed and use in Win 98 Se.

Have yet to be able to type Pinyin text iunder linux Mandrake 8.2 Kde Open Office.

Will study your information concerning TTF then should be able to type to china in Pinyin

regards

Maurice

Share this post


Link to post
Quote:
H
i Nice to read your artical. Iam intereseted to install the TTF Pinyin fonts that I have installed and use in Win 98 Se.
Have yet to be able to type Pinyin text iunder linux Mandrake 8.2 Kde Open Office.
Will study your information concerning TTF then should be able to type to china in Pinyin
regards
Maurice


The fonts -should- show up in OpenOffice too after all these steps. Not too sure about older versions of StarOffice. It has a slightly different way of doing things frown

Share this post


Link to post

Hi

Thanks for further information, will give it a try

Maurice

Share this post


Link to post

I noticed a few minor errors in my story above in the order and the correct commands frown . I edited them, so they should be fine now.

 

I also decided the commands might warrant a bit of an explanation:

Code:
chmod u+x /usr/local/bin/mkfontalias.py

This command makes the file mkfontalias.py executable. This makes sure that you can execute it without having to tell bash (or whatever shell you are using) that it needs perl to run it.

Code:
ttmkfdir -o fonts.scale

This command creates fonts.scale, which is basically a list of files with their associated filesizes. The fontsizes, I assume, are ignored, but X needs the list of fonts to be able to offer them.

Code:
mkfontdir

This next command creates fonts.dir which is more or less a copy of fonts.scale as far as I can tell. I am sure it has some purpose, and if you know, by all means, enlighten me smile

Code:
mkfontalias.py

Now, you have your awesome fonts all blazing away on your screen. Looks awesome, up to the point where you fire up Netscape 4.07 (or so) and all you can recognise in the UI are little boxes where the characters are supposed to be. This is because Netscape expects a specific font and that font only, to display it's stuff. A couple more programs have this problem (VMWare is another I can think of). This perl script makes sure that fonts.alias is created, which should take care of this problem. No more boxes for you!

 

In the next step you have to modify your XF86Config file.

Code:
FontPath      "/usr/X11R6/lib/X11/fonts/100dpi:unscaled" 

By adding the :unscaled at the end of the line, you tell X not to scale the fonts in that directory. Why wouldn't you want to scale them, you ask? Simple: the fonts in that directory are bitmapped fonts, which means that scaling them makes them blocky. Blocky == ugly.

 

Keep reading to make the most of your X windows environment!

Share this post


Link to post

Wow, I think that these actually work. However, I brought a rather large amount of fonts over from my Windows install, and I don't see even a tenth of them in OpenOffice (which you already mentioned that you weren't entirely too sure how it would behave) and AbiWord will no longer start as it's looking for "Nimbus Roman Regular". Any thoughts on correcting this? I don't even know where the original font would be, and I thought about just reinstalling the app.

 

Also, I didn't have the "mkfontalias.py" file, but I did have the other components installed. So, I put a link to the file itself below for anyone else that might not have it.

 

http://home.c2i.net/dark/mkfontalias.py

Share this post


Link to post
Quote:
Wow, I think that these actually work. However, I brought a rather large amount of fonts over from my Windows install, and I don't see even a tenth of them in OpenOffice (which you already mentioned that you weren't entirely too sure how it would behave) and AbiWord will no longer start as it's looking for "Nimbus Roman Regular". Any thoughts on correcting this? I don't even know where the original font would be, and I thought about just reinstalling the app.

Also, I didn't have the "mkfontalias.py" file, but I did have the other components installed. So, I put a link to the file itself below for anyone else that might not have it.

http://home.c2i.net/dark/mkfontalias.py


Please give some more information please? Your distribution, the version of OpenOffice, a copy of your XftConfig, etc.? With this I might be able to do a little trouble shooting..

Share this post


Link to post

I am using RH 7.3, OO 1.0.1, and here is my config file as asked for:

 

Code:
# $XFree86: xc/lib/Xft/XftConfig.cpp,v 1.5 2000/12/14 23:03:53 keithp Exp $dir "/usr/X11R6/lib/X11/fonts/Type1"dir "/usr/X11R6/lib/X11/fonts/TTF"dir "/usr/X11R6/lib/X11/fonts/truetype"# Red Hat additionsdir "/usr/X11R6/lib/X11/fonts/TTF"dir "/usr/share/fonts/default/TrueType"dir "/usr/share/fonts/default/Type1"dir "/usr/share/fonts/ja/TrueType"dir "/usr/share/fonts/ko/TrueType"dir "/usr/share/fonts/zh_CN/TrueType"dir "/usr/share/fonts/zh_TW/TrueType"## alias 'fixed' for 'mono'#match any family == "fixed"		edit family =+ "mono";## Don't antialias small fonts#match        any size < 11        any size > 8        edit antialias=false;## Don't antialias wingding symbols and similar types of symbol fontsets#match        any family == "webdings"        edit antialias = false;        encoding += "glyphs-fontspecific";match        any family == "wingdings"        edit antialias = false;        encoding += "glyphs-fontspecific";## Check users config file#includeif	"~/.xftconfig"## Use Luxi fonts for default faces#match any family == "serif"		edit family += "Luxi Serif";match any family == "sans"		edit family += "Luxi Sans";match any family == "mono"		edit family += "Luxi Mono";## Alias between XLFD families and font file family name, prefer local# fonts#match any family == "charter"		edit family += "bitstream charter";match any family == "bitstream charter" edit family =+ "charter";## Alias older name for Luxi fonts#match any family == "LuciduxSerif"	edit family += "Luxi Serif";match any family == "Lucidux Serif"	edit family += "Luxi Serif"; match any family == "LuciduxSans"	edit family += "Luxi Sans";match any family == "Lucidux Sans"	edit family += "Luxi Sans"; match any family == "LuciduxMono"	edit family += "Luxi Mono";match any family == "Lucidux Mono"	edit family += "Luxi Mono";## TrueType font aliases (disabled - experimental)##match any family == "Comic Sans"        edit family += "Comic Sans MS";#match any family == "Comic Sans MS"     edit family =+ "Comic Sans";#match any family == "Trebuchet"         edit family += "Trebuchet MS";#match any family == "Trebuchet MS"      edit family =+ "Trebuchet";#match any family == "Monotype"          edit family =+ "Monotype.com";#match any family == "Andale Mono"       edit family += "Monotype.com";#match any family == "Monotype.com"      edit family =+ "Andale Mono";## Set some sane defaults for Anti-Aliased desktops#match any family == "helvetica"		edit family += "Nimbus Sans L";match any family == "helv"		edit family += "Nimbus Sans L";match any family == "verdana"		edit family += "Nimbus Sans L";match any family == "times"		edit family += "Nimbus Roman No9 L";match any family == "helvetica"		edit family += "Helmet";match any family == "helv"		edit family += "Helmet";match any family == "verdana"		edit family += "Helmet";match any family == "times"		edit family += "Helmet";# XFree86 default fontsmatch any family == "Verdana"           edit family += "Luxi Sans";match any family == "Times New Roman"   edit family += "Luxi Serif";## Japanese#match any foundry == "watanabe"		edit antialias = false;match any foundry == "wadalab"		edit antialias = false;## Fixes a problem in KDE with konsole#match any family == "fixed"			edit antialias =+ "false";match any family == "console"		edit antialias =+ "false";

 

I have also been getting errors as Xserver shuts down complaining that certain fonts don't support something. Yes, I know that's a *vague* error, and if you can point me to a log that would keep this kind of info I'll be more than glad to post it. smile

Share this post


Link to post

What I can see is that there seem to be a couple of 'double' lines in your 'dir' lines, but that shouldn't be a big issue. I use Slack myself, so I may find my logs somewhere else than you, but we'll see.

 

I am going to assume you boot up straight into the GUI (RH style :)), which means that (if RH didn't change it), you should find the log in /var/log/XFree86.0.log. I would really like that log... smile

Share this post


Link to post

Here's the log file. However, I normally go into the command prompt at boot up because of all my "experimentation" with the nvidia drivers as of late...

 

smile

Share this post


Link to post

Looking at your logfile, I can see a couple of things.

 

The first is that way at the start, X seems to complain about the fonts.dir. It's either missing or invalid for the directories /usr/X11R6/lib/X11/fonts/util and /usr/X11R6/lib/X11/fonts/encodings. You will need to cd into those directories and run the command

Code:
mkfontdir
It does not require any switches. It then rebuilds the file fonts.dir.

 

Next thing I see in the logfile, way at the end, is that it cannot find, or cannot seem to handle the directories /usr/X11R6/lib/X11/fonts/Type1, /usr/X11R6/lib/X11/fonts/Speedo, /usr/X11R6/lib/X11/fonts/TTF and /usr/X11R6/lib/X11/fonts/truetype. Double check if they are there and if you have not made any typos in the directory names. Remember that *NIX is casesensative and that truetype and TrueType are two different values. Also double check if you have done the all the steps in the original post for each of these directories that contain TT fonts. The Speedo and the Type1 directory should work all by themselves, but you do need to load the modules for them. To check if you tell X to load it, check the /etc/X11/XF86Config-4 file for lines saying something like

Code:
Load	"speedo"Load	"type1"
If the module isn't loaded, it won't handle the corresponding font directory.

 

Let's see if that helps any...

Share this post


Link to post
Quote:
My truetype directory is indeed all lowercase, and here is XF86Config-4 file:

www.asysttech.com/otherfiles/xf86config-4.txt


Ehrmm.. Darn... Here we run into my lack of knowledge of RedHat. Looks like I may have to dig into it some more. It looks like the font server for RedHat does things a little different than the default one that comes with X. I am not quite familiar with the fontserver that RedHat uses, so I can't help you any further (yet)... frown

Share this post


Link to post

OK, if you happen to see anything just let me know. I will probably scout around a bit to see if I find out anything else on this topic.

Share this post


Link to post

For RedHat and other RPM-supporting users, give this a shot:

 

http://corefonts.sourceforge.net/

 

It works really well, and while they tested it in 7.3 I found it works in 8.0. Also, there is "supposed" to be a way to simply drag and drop your fonts into a directory named ".fonts" in your user's root dir (at least that's what I assume they mean by stating "~/.fonts" as the new directory to make for the fonts) and then restart X server. This doesn't seem to work for me, while using this other RPM-based method does seem to according to the test at the bottom of the page where you list the available MS fonts on your system. Let me know what you guys think if you try it.

Share this post


Link to post

After the steps of ttmkfdir, mkfontdir and mkfontalias.py you can add the fontpath with the command (as root I think):

Code:
 xset fp+ /usr/X11R6/lib/X11/fonts/truetype

Worked for me!

 

Grz.

Share this post


Link to post

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×