How do you enable a local user fonts directory?

This forum is dedicated to basic help and support :

Ask here your questions about basic installation and usage of Mageia. For example you may post here all your questions about getting Mageia isos and installing it, configuring your printer, using your word processor etc.

Try to ask your questions in the right sub-forum with as much details as you can gather. the more precise the question will be, the more likely you are to get a useful answer

How do you enable a local user fonts directory?

Postby tarazed » May 25th, '15, 19:05

This is a procedure I use after installing a new system.
Copy type1.tar to /usr/share/fonts/default and untar it into ghostscript/ then
run type1inst. This has always worked well in the past.

In Cauldron a problem has arisen with fontconfig, which until now I had never heard of. Copying any file anywhere into the /usr/share/fonts tree causes the system to freeze after the copy and require a crash reboot. It has been pointed out that fontconfig is very fragile and is known to cause crashes when already mapped fonts are overwritten. The problem actually seems wider than this. My bug report is regarded as invalid so I have to find a safer alternative when using imported fonts (TTFs processed via ttf2pt1 and type1inst). drakfont installs specified fonts but then the system freezes. drakfont ignores the ghostscript directory, which is where I need to find the new fonts. No idea how to force its hand. I run it like so
Code: Select all
 $ drakfont --application=1 --install /data/ttf

in view of the fontconfig problem maybe that should include the --replace option.

Some time ago I attempted to reduce the initial housekeeping after an install by setting the environment variable GS_FONTPATH but as far as I can see it is ignored by ghostscript. It is the only suggestion which came up in a web search that seemed to fit the bill.
Code: Select all
 $ setenv GS_FONTPATH /home/lcl/Type1
$ gs -h
Search path:
   /usr/share/ghostscript/9.10/Resource/Init :
   /usr/share/ghostscript/9.10/lib :
   /usr/share/ghostscript/9.10/Resource/Font :
   /usr/share/ghostscript/fonts : /usr/share/fonts/default/ghostscript :
   /usr/share/fonts/default/type1 : /usr/share/ghostscript/fonts :
   /usr/share/ghostscript/9.10/Resource : /usr/share/ghostscript/Resource :
   /usr/share/ghostscript/CIDFont : /usr/share/fonts/ttf :
   /usr/share/fonts/type1 : /usr/share/fonts/default/Type1

Sorry for the complicated spiel but it is a complex problem when you have no real idea how to configure the system so that postscript can find user imported fonts.
Last edited by tarazed on May 29th, '15, 09:28, edited 2 times in total.
tarazed
 
Posts: 273
Joined: Sep 18th, '11, 01:49

Re: How do you enable a local user fonts directory?

Postby doktor5000 » May 25th, '15, 19:50

Maybe you can get some pointers from viewtopic.php?f=41&t=5687
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18059
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: How do you enable a local user fonts directory?

Postby tarazed » May 25th, '15, 20:49

Thanks for the pointer but I cannot see anything relevant there, certainly nothing about setting up search paths. I had already looked at some of the fontconfig config files and understood very little of it. I had better do some more googling and maybe search some more here and maybe check out the fc utiliies.
tarazed
 
Posts: 273
Joined: Sep 18th, '11, 01:49

Re: How do you enable a local user fonts directory?

Postby doktor5000 » May 25th, '15, 21:03

Well, the arch wiki page linked there should help if you read it all the way, or at least the parts about font paths.
Check viewtopic.php?f=7&t=8000
and section 3.1 in http://ghostscript.com/doc/current/Inst ... stall_Unix

Also, the output of
Code: Select all
gs -help
will show where ghostscript looks for fonts as "Search path:"
If you only need the fonts for ghostscript, you need to edit a file called Fontmap.GS
for Mageia 5 that's located in /usr/share/ghostscript/9.14/Resource/Init/

AND gs -help will tell you on how to use fontconfig:
┌─[doktor5000@Mageia5]─[21:05:11]─[~]
└──╼ gs -help | grep -A15 -i 'search path'
Search path:
/home/doktor5000/.fonts : /usr/share/ghostscript/9.14/Resource/Init :
/usr/share/ghostscript/9.14/lib :
/usr/share/ghostscript/9.14/Resource/Font :
/usr/share/ghostscript/fonts : /usr/share/fonts/default/ghostscript :
/usr/share/fonts/default/type1 : /usr/share/ghostscript/fonts :
/usr/share/ghostscript/9.14/Resource : /usr/share/ghostscript/Resource :
/usr/share/ghostscript/CIDFont : /usr/share/fonts/ttf :
/usr/share/fonts/type1 : /usr/share/fonts/default/Type1
Ghostscript is also using fontconfig to search for font files
For more information, see /usr/share/doc/ghostscript-doc-9.14/Use.htm.

Please report bugs to bugs.ghostscript.com.
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18059
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: How do you enable a local user fonts directory?

Postby tarazed » May 25th, '15, 21:17

Right, thanks again. I used gs -h as quoted above to see which font paths are defined. And I looked at the local documentation but saw nothing relevant to user font paths.
Looks like I have a lot of work to do to find the relevant information. I hoped that somebody already had a simple solution; you managed to set up a user path so it is obviously possible. I may be gone a little while...
tarazed
 
Posts: 273
Joined: Sep 18th, '11, 01:49

Re: How do you enable a local user fonts directory?

Postby doktor5000 » May 25th, '15, 21:51

tarazed wrote:you managed to set up a user path so it is obviously possible.

I didn't set up anything, ~/.fonts is a standard folder for user-installed fonts, although it might be deprecated in newer fontconfig versions.
You didn't read the arch wiki page that I mentioned - check https://wiki.archlinux.org/index.php/Fo ... Font_paths

The default font paths are those:
Code: Select all
┌─[doktor5000@Mageia5]─[21:27:41]─[~]
└──╼ grep '<dir>' /etc/fonts/fonts.conf
        <dir>/usr/share/fonts</dir>
        <dir>/usr/lib/X11/fonts</dir> <dir>/usr/X11R6/lib/X11/fonts</dir> <dir>/opt/ttfonts</dir>
        <dir>~/.fonts</dir>


Also check /etc/fonts/conf.d/README and maybe https://www.suse.com/documentation/sles ... onfig.html
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18059
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: How do you enable a local user fonts directory?

Postby tarazed » May 26th, '15, 01:21

I appreciate your patience. I did in fact read the README file but could not understand it. It notes that paths can be indicated in files named 00 - 09 symlinked to other conf files. That is totally beyond me. And I have been reading the archwiki documentation while completing another mga5 install. These learning tasks take me several hours. Ging to try pasting the message I was preparing:

Not getting very far with this. Most of the documentation seems opaque to me so I am not really understanding where I am going. It is just a huge muddle in my old grey head. So far, on a virgin install, have tried building the type1 directory as ~/.local/share/fonts because I read somewhere that fontconfig scans that directory if it exists and sure enough the fonts became visible to X. One document pointed out that ghostscript uses a search path rather than font path so I tried
Code: Select all
setenv GS_FONTMAP /home/lcl/.local/share/fonts

but that did not affect ghostscript at all (gs -h did not show the new path).
I generated a postscript file utilizing some of the new fonts and viewed it on screen with gs and it looked perfect (X of course) but when printed via lpr got several of them wrong. One other thing I spotted was "don't mess with /etc/fonts/fonts.conf". The instruction is to use a local.conf in that directory but gives no idea how to construct it. There is a stanza in fonts.conf which deals with paths so I could model local.conf on that, but I have no idea how to wrap it because I do not know XML and there is no example.
This stuff is obviously not for novices.

Web search results reveal that I have been chasing postscript/ghostscript problems for at least two years. The copy to /usr/share/fonts/default/ghostscript procedure is one I have been using for many years before that.
tarazed
 
Posts: 273
Joined: Sep 18th, '11, 01:49

Re: How do you enable a local user fonts directory?

Postby tarazed » May 26th, '15, 01:33

Starting to look at the SuSE document...

So maybe local.conf would look like this:
Code: Select all
<!-- Font directory list -->
<dir>/home/lcl/.local/share/fonts</dir>


There is a remark in the 'gs -h' comments about ghostscript also using fontconfig so maybe this would work even though fontconfig is already aware of that directory as evinced by the fact that something loaded the new fonts into X.

Worth a try.
tarazed
 
Posts: 273
Joined: Sep 18th, '11, 01:49

Re: How do you enable a local user fonts directory?

Postby doktor5000 » May 26th, '15, 01:51

tarazed wrote:So maybe local.conf would look like this:
Code: Select all
<!-- Font directory list -->
<dir>/home/lcl/.local/share/fonts</dir>


That way you use all the other fonts in the other locations systemwide, meaning for all applications.
Probably better using something like this as /etc/fonts/conf.d/09-additional-fonts.conf

Code: Select all
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<!-- additional fonts -->
        <dir>~/.local/share/fonts</dir>
</fontconfig>

Then check if it's listed in fc-list output, then run fc-cache -v to recreate fontconfig caches.

That environment variable approach using GS_FONTMAP requires a font map, and not a directory with fonts, see my previous posts on that.
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18059
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: How do you enable a local user fonts directory?

Postby tarazed » May 26th, '15, 02:51

Thanks again for the suggestions. I had in fact found the conf files in conf.avail and constructed an XML stanza almost identical to your example. Called it local.conf in conf.avail and symlinked it as 01-local.conf in conf.d and the extra fonts do now appear in the fc-list list. And I amended GS_FONTMAP to point to Fontmap rather than its parent directory. No result for ghostscript though. gs -h returns all the /usr/share font directories but not mine.

Had to urpmi ghostscript-doc. Looking at it now.
After GS_LIB was set to the new fonts directory gs -h picked it up. Hoorah! However, no change to the printout from the postscript file. I shall follow this up tomorrow (today now). Have been working on this for fourteen hours - need some sleep.
tarazed
 
Posts: 273
Joined: Sep 18th, '11, 01:49

Re: How do you enable a local user fonts directory?

Postby tarazed » May 28th, '15, 01:52

Success eventually, after tidying things up and removing redundant directories. To summarize from all doktor5000's hints and tips, using my own system as an example where the additional fonts needed to be available to ghostscript for printing encapsulated postscript files:
Create local directory, e.g. /home/<user>/localfonts
Populate that with the Type1 font files, then create Fontmap
Code: Select all
$ cd ~/localfonts
$ sudo type1inst

Use fontconfig to create the font cache for the additional fonts
Code: Select all
$ sudo fc-cache ~/localfonts

Ghostscript needs at least one environment variable to use the new directory:
I set the following three to be sure, writing them into my .tcshrc file.
Code: Select all
setenv GS_LIB /home/lcl/localfonts
setenv GS_FONTMAP /home/lcl/localfonts/Fontmap
setenv GS_FONTPATH /home/lcl/localfonts

To check that the search path has been augmented for Ghostscript run e.g.
Code: Select all
$ gs -h | grep localfonts

There should be an entry at the head of the list of search paths matching `echo ${GS_LIB}` or `printenv GS_LIB`.
The next step is to update the fontconfig configuration files in /etc/fonts.
In my case the localfonts XML file was called 01-local.conf. You should use any prefix in the range 0[1] to 0[9].
The standard procedure is to place this config file in conf.avail and then create a symlink in conf.d (as root):
Code: Select all
$ ln -s ../conf.avail/01-local.conf 01-local.conf

Code: Select all
$ cat 01-local.conf
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fontconfig SYSTEM "../fonts.dtd">
<fontconfig>
  <!-- Font directory list -->
  <dir>/home/lcl/localfonts</dir>
</fontconfig>


fontconfig is quite fragile. You may encounter frequent system freezes if you make any changes to directories already processed for its cache. Beware in particular of the /usr/share/fonts tree and also the user's .local/share/fonts, if it exists, which is scanned periodically by default by fontconfig.

Once the preceding steps have been taken, run
Code: Select all
$ fc-list | grep localfonts

as user to confirm that fontconfig finds the new directory. `fc-cache -v` can be used in the same way to find out the status of the fonts in the cache.
e.g. /home/lcl/localfonts: skipping, existing cache is valid: 186 fonts, 0 dirs

The command
Code: Select all
$ gs somefile.ps
displays a page and on the terminal shows from where ghostscript loads the font files and how it interprets them; sometimes you will see aliases and sometimes substitutions if the font is not on the system.

Ecco:
Code: Select all
$ gs abc-0.ps
GPL Ghostscript 9.14 (2014-03-26)
Copyright (C) 2014 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Loading AlienEncounters font from /home/lcl/localfonts/ALIEE___.pfb... 3823168 2273950 3995072 2613458 3 done.
Loading AlienEncountersSolid font from /home/lcl/localfonts/ALIEES__.pfb... 3851784 2364635 4035440 2620465 3 done.
Loading AlienLeague font from /home/lcl/localfonts/ALIEN5.pfb... 3814736 2277797 4075808 2629151 3 done.
Scanning /home/lcl/localfonts for fonts... 377 files, 98 scanned, 0 new fonts.
Can't find (or can't open) font file /usr/share/ghostscript/9.14/Resource/Font/AlmonteWoodgrain-Italic.
Can't find (or can't open) font file AlmonteWoodgrain-Italic.
Querying operating system for font files...
**** Warning: glyf overlaps cmap, truncating.
**** Warning: glyf overlaps cmap, truncating.
**** Warning: glyf overlaps cmap, truncating.
**** Warning: glyf overlaps cmap, truncating.
**** Warning: glyf overlaps cmap, truncating.
**** Warning: glyf overlaps cmap, truncating.
Can't find (or can't open) font file /usr/share/ghostscript/9.14/Resource/Font/AlmonteWoodgrain-Italic.
Can't find (or can't open) font file AlmonteWoodgrain-Italic.
Didn't find this font on the system!
Substituting font Helvetica-Oblique for AlmonteWoodgrain-Italic.
Loading NimbusSanL-ReguItal font from /usr/share/fonts/default/Type1/adobestd35/n019023l.pfb... 4112264 2647598 6094208 3054066 3 done.
Loading AndaleMono font from /home/lcl/localfonts/andalemo.pfb... 4301320 2760415 6094208 3046133 3 done.
Loading Angelica font from /home/lcl/localfonts/angelica.pfb... 4272640 2831233 6094208 3047741 3 done.
Loading Anklepants font from /home/lcl/localfonts/anklepan.pfb... 4361808 2936453 6094208 3049573 3 done.
Loading AppleGaramond font from /home/lcl/localfonts/Apple_Garamond.pfb... 4490480 3076354 6094208 3051411 3 done.
Loading Ardour3DGM font from /home/lcl/localfonts/ardour3d.pfb... 4685152 3264696 6094208 3053237 3 done.
Loading NimbusSanL-Regu font from /usr/share/fonts/default/Type1/n019003l.pfb... 4849040 3407251 6111136 3079619 3 done.
Can't find (or can't open) font file /usr/share/ghostscript/9.14/Resource/Font/ArialBlack.
Can't find (or can't open) font file ArialBlack.
Didn't find this font on the system!
Substituting font Helvetica-Bold for ArialBlack.
Loading NimbusSanL-Bold font from /usr/share/fonts/default/Type1/n019004l.pfb... 5323832 3828862 6144448 3218168 3 done.
Can't find (or can't open) font file /usr/share/ghostscript/9.14/Resource/Font/Ariston-Italic.
Can't find (or can't open) font file Ariston-Italic.
Didn't find this font on the system!
Substituting font Helvetica-Oblique for Ariston-Italic.
Loading BastardusSans font from /home/lcl/localfonts/BastardusSans.pfb... 5137480 3645032 6094208 3062426 3 done.
Loading Belmar-Condensed-Normal font from /home/lcl/localfonts/Belmar-Condensed-Normal.pfb... 5324088 3870955 6111136 3194031 3 done.
Loading BetaDance font from /usr/share/fonts/default/ghostscript/betadance.pfa... 5593824 4113915 6111136 3317128 3 done.
Loading CharterBT-Roman font from /home/lcl/localfonts/bchr.pfa... 5849704 4332919 6111136 3441665 3 done.
Loading BitstreamVeraSerif-Roman font from /home/lcl/localfonts/VeraSe.pfb... 6158080 4600853 6128064 3572900 3 done.
Loading BlueHighway font from /usr/share/fonts/ttf/western/Bluehigh.ttf... 6158080 4603619 6217368 3933035 3 done.
Can't find (or can't open) font file /usr/share/ghostscript/9.14/Resource/Font/BlueHighwayCondensed-Bold.
Can't find (or can't open) font file BlueHighwayCondensed-Bold.
Didn't find this font on the system!
Substituting font Helvetica-Narrow-Bold for BlueHighwayCondensed-Bold.
Loading NimbusSanL-BoldCond font from /usr/share/fonts/default/Type1/adobestd35/n019044l.pfb... 6438808 4865190 6217368 3943426 3 done.
Loading BorzoiRegular font from /home/lcl/localfonts/BorzoiRegular.pfb... 7030216 5379088 6250680 4079126 3 done.
Can't find (or can't open) font file /usr/share/ghostscript/9.14/Resource/Font/Callistroke-Italic.
Can't find (or can't open) font file Callistroke-Italic.
Didn't find this font on the system!
Substituting font Helvetica-Oblique for Callistroke-Italic.
>>showpage, press <return> to continue<<
GS>quit


Many thanks to the indefatigable doktor5000 and apologies for labouring the point.
tarazed
 
Posts: 273
Joined: Sep 18th, '11, 01:49

Re: [SOLVED] How do you enable a local user fonts directory?

Postby tarazed » May 28th, '15, 02:02

Forgot to look at Fontmap.GS. I think I prefer to deal with adding new font files at user level rather than modifying the system GS Fontmap. I have still to find out if crashes occur when making either of these changes.
tarazed
 
Posts: 273
Joined: Sep 18th, '11, 01:49

Re: [SOLVED] How do you enable a local user fonts directory?

Postby tarazed » May 29th, '15, 09:28

No, this is not solved. :oops: On a fresh install, after my recommendations had been carried out, the additional fonts could not be printed until the /usr/share/fonts/default/ghostscript directory was populated with them, which caused several system freezes until the job was done. At user interface level the fonts are all available without the operations on the default ghostscript directory. So this topic should now be narrowed down to a printing problem. I did also fumble around with Fontmap.GS but could make no headway and the need for frequent crash reboots was driving me insane; something close to 100 per day and this so far has taken five days.
tarazed
 
Posts: 273
Joined: Sep 18th, '11, 01:49

Re: How do you enable a local user fonts directory?

Postby doktor5000 » May 29th, '15, 22:07

It's probably easiest to read through http://www.ghostscript.com/doc/9.14/Fonts.htm and then maybe ask on some ghostscript mailing list about that ... ?
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18059
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: How do you enable a local user fonts directory?

Postby tarazed » May 29th, '15, 22:31

Yes, maybe. It seems that other users do not experience this problem. It has been suggested that the problem may well be system specific which would turn this whole thing into a red herring. It will be interesting to see if it affects my other machines. If it does not then the thread will be marked SOLVED.

And as ever, many thanks for your help doktor5000. It has been interesting to read up on the background to the problem.
tarazed
 
Posts: 273
Joined: Sep 18th, '11, 01:49


Return to Basic support

Who is online

Users browsing this forum: No registered users and 1 guest