[Slackbuilds-users] proposed addition to doinst template

Luiz Carlos Ramos lramos.prof at yahoo.com.br
Mon Oct 1 12:40:08 UTC 2018


Hello,

I'd add one more suggestion, based on Ricardo's: add some code to take
/usr/share/fonts/misc as the default value, like this:

update_font_index() {
  local _dir=$1
  _dir=${_dir:-/usr/share/fonts/misc}
  if [ -x /usr/bin/mkfontdir -o -x /usr/X11R6/bin/mkfontdir ]; then
    ( cd "$_dir" &&
      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
}

Another suggestion, which requires more code, is to consider a group of
a reasonable set of directories as the default.


My 2 cents,

Luiz


On Sat, Sep 29, 2018 at 07:51:49PM -0300, Ricardo J. Barberis wrote:
> 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 
> escribió:
> > 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"
> > script:
> >
> > (...)
> > # Update the X font indexes:
> > 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
> > lramos.prof at yahoo.com.br
> >
> > On Fri, Sep 28, 2018 at 07:26:34PM -0400, B Watson wrote:
> > > 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.
> 
> 
> -- 
> 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-users at slackbuilds.org
> https://lists.slackbuilds.org/mailman/listinfo/slackbuilds-users
> Archives - https://lists.slackbuilds.org/pipermail/slackbuilds-users/
> FAQ - https://slackbuilds.org/faq/
> 


More information about the SlackBuilds-users mailing list