Discussion:
[Slackbuilds-users] proposed addition to doinst template
B Watson
2018-09-28 23:26:34 UTC
Permalink
Any build that installs non-TTF fonts in the global font path
(/usr/share/fonts/*) should include this in doinst.sh:

# Update the X font indexes:
if [ -x /usr/bin/mkfontdir -o -x /usr/X11R6/bin/mkfontdir ]; then
( cd /usr/share/fonts/misc
mkfontscale .
mkfontdir -e /usr/share/fonts/encodings -e
/usr/share/fonts/encodings/large .
)
fi
if [ -x /usr/bin/fc-cache ]; then
/usr/bin/fc-cache -f
fi

The above was taken from one of Pat's font-* packages (it's included in
multiple ones).

Change the "fonts/misc" to e.g. "fonts/100dpi" or whatever your package
actually installs fonts to (if multiple subdirs, mkfontscale and mkfontdir
will have to be run in all of them).

Ideally, packages won't install fonts.dir files at all, but Pat's font-*
packages do (and then immediately overwrite them via the doinst.sh).

For those not familiar with it, fonts.dir is a list of all the installed
fonts in a directory. If a font is present, but not mentioned in
fonts.dir, "old-style" X apps (ones that don't use fontconfig) won't be
able to use that font.

For a specific example of a SBo build that needs this, see libdockapp. It
installs 2 fonts in /usr/share/fonts/misc, and includes a fonts.dir
that only lists those 2 fonts. After installing this package, other apps
(e.g. xterm) have problems loading fonts, depending on what font they're
configured to use.
_______________________________________________
SlackBuilds-users mailing list
SlackBuilds-***@slackbuilds.org
https://lists.slackbuilds.org/mailman/listinfo/slackbuilds-users
Archives - https://lists.slackbuilds.org/pipermail/slackbuilds-users/
FAQ - https://slackbuilds.org/faq/
Ricardo J. Barberis
2018-09-29 22:51:49 UTC
Permalink
Hello all!

While we're at it, how about passing the dir to the function (and some basic
error control)?

update_font_index() {
if [ -x /usr/bin/mkfontdir -o -x /usr/X11R6/bin/mkfontdir ]; then
( cd $1 &&
mkfontscale . &&
mkfontdir -e /usr/share/fonts/encodings \
-e /usr/share/fonts/encodings/large .
)
fi
if [ -x /usr/bin/fc-cache ]; then
/usr/bin/fc-cache -f
fi
}


Then you can call it for every needed dir:

(...)
# Update the X font indexes:
update_font_index /usr/share/fonts/misc
update_font_index /usr/share/fonts/100dpi
(...)


Cheers!

El Sábado 29/09/2018 a las 10:30, Luiz Carlos Ramos via SlackBuilds-users
Hello,
I'm not used to reply in this list, but I keep watching the message
flow... let me add a suggestion.
This addition could be added as a function, that is, it would be like
update_font_index() {
if [ -x /usr/bin/mkfontdir -o -x /usr/X11R6/bin/mkfontdir ]; then
( cd /usr/share/fonts/misc
mkfontscale .
mkfontdir -e /usr/share/fonts/encodings \
-e /usr/share/fonts/encodings/large .
)
fi
if [ -x /usr/bin/fc-cache ]; then
/usr/bin/fc-cache -f
fi
}
That is, it's the same code, but encapsulated as a function. This
function could be in the template for all packages. If a specific
package needs to do it, it could simply add one line to the "main"
(...)
update_font_index
(...)
IMHO, this makes things more clear for folks who will maintain the code.
That is, the task to be done would be synthesized in that one line in
the install step (the call to "update_font_index"); and the way it's
done is coded in the function itself. Someone who needs to code the same
thing in a new slackbuild could copy the template and add one line to
the "main" procedure.
Only my 2 cents,
thanks,
Luiz Carlos Ramos
Post by B Watson
Any build that installs non-TTF fonts in the global font path
if [ -x /usr/bin/mkfontdir -o -x /usr/X11R6/bin/mkfontdir ]; then
( cd /usr/share/fonts/misc
mkfontscale .
mkfontdir -e /usr/share/fonts/encodings -e
/usr/share/fonts/encodings/large .
)
fi
if [ -x /usr/bin/fc-cache ]; then
/usr/bin/fc-cache -f
fi
The above was taken from one of Pat's font-* packages (it's included in
multiple ones).
Change the "fonts/misc" to e.g. "fonts/100dpi" or whatever your package
actually installs fonts to (if multiple subdirs, mkfontscale and
mkfontdir will have to be run in all of them).
Ideally, packages won't install fonts.dir files at all, but Pat's font-*
packages do (and then immediately overwrite them via the doinst.sh).
For those not familiar with it, fonts.dir is a list of all the installed
fonts in a directory. If a font is present, but not mentioned in
fonts.dir, "old-style" X apps (ones that don't use fontconfig) won't be
able to use that font.
For a specific example of a SBo build that needs this, see libdockapp. It
installs 2 fonts in /usr/share/fonts/misc, and includes a fonts.dir
that only lists those 2 fonts. After installing this package, other apps
(e.g. xterm) have problems loading fonts, depending on what font they're
configured to use.
--
Ricardo J. Barberis
Usuario Linux Nº 250625: http://counter.li.org/
Usuario LFS Nº 5121: http://www.linuxfromscratch.org/
Senior SysAdmin / IT Architect - www.DonWeb.com
_______________________________________________
SlackBuilds-users mailing list
SlackBuilds-***@slackbuilds.org
https://lists.slackbuilds.org/mailman/listinfo/slackbuilds-users
Archives - https://lists.slackbuilds.org/pipermail/slackbuilds-users/
FAQ - https://slackbuilds.org/faq/
Loading...