You are not logged in.

#1 2025-07-21 07:17:09

jpka
Member
Registered: 2024-12-04
Posts: 7

[Solved] Tell installer that fonts shall be unpacked on install

Hello.
In order to solve font related issue which have simple solution [1], i am unpacking .pcf.gz fonts after install manually. This is quite easy, but required to repeat manually after updates. So i am search if similar to NixOS installer option mentioned at [1],

 decompressFonts = true;

, is exist for Archlinux world. Preferably for both Pacman and AUR install methods.
Is this possible?
I also check Archwiki fonts section, but not found something similar.
Thanks to developers for useful and valuable work.

[1] https://bugs.kde.org/show_bug.cgi?id=507268

Last edited by jpka (2025-07-22 11:19:09)

Offline

#2 2025-07-21 08:20:08

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 71,583

Online

#3 2025-07-21 20:23:26

jpka
Member
Registered: 2024-12-04
Posts: 7

Re: [Solved] Tell installer that fonts shall be unpacked on install

Thanks @seth, it is exactly what i need. I've created two hooks and two scripts and it works fine for install and remove. But, for reinstall (upgrade), it works, but show

warning: could not get file information for (...)

warnings. It is due to :: Running pre-transaction hooks... occurs after some file checking, i.e., it is File checking - Running pre-transaction hooks - reinstalling package - Running post-transaction hooks flow. Of course, .pcf.gz files are not exist before my pre-transaction hook, but only after it. Iiuc, it is impossible to change processing order to Running pre-transaction hooks - File checking - reinstalling package - Running post-transaction hooks ?

a_unpack_fonts.hook
-------------------
[Trigger]
Type = Path
Operation = Install
Operation = Upgrade
Target = usr/share/fonts/*

[Action]
Description = Exec /etc/pacman.d/hooks/unpack_fonts.sh
When = PostTransaction
Exec = /etc/pacman.d/hooks/unpack_fonts.sh
NeedsTargets


unpack_fonts.sh
---------------
#!/bin/bash

sort -r | while read -r d; do
  [[ ! -d $d ]] || continue
  ext="${d##*.}"
  if [[ $ext = "gz" ]]; then
    gunzip -d -f $d
  fi
done


a_pack_fonts.hook
-----------------
[Trigger]
Type = Path
Operation = Upgrade
Operation = Remove
Target = usr/share/fonts/*

[Action]
Description = Exec /etc/pacman.d/hooks/pack_fonts.sh
When = PreTransaction
Exec = /etc/pacman.d/hooks/pack_fonts.sh
NeedsTargets


pack_fonts.sh
-------------
#!/bin/bash

sort -r | while read -r d; do
  [[ ! -d $d ]] || continue
  ext="${d##*.}"
  # Names are as per database, it thinks they are gzipped.
  if [[ $ext = "gz" ]]; then
    # Mimic as .gz for following correct delete by installer.
    mv ${d::-3} $d
  fi
done

warnings example
----------------
:: Proceed with installation? [Y/n]
(1/1) checking keys in keyring                     [######################] 100%
(1/1) checking package integrity                   [######################] 100%
(1/1) loading package files                        [######################] 100%
(1/1) checking for file conflicts                  [######################] 100%
(1/1) checking available disk space                [######################] 100%
warning: could not get file information for usr/share/fonts/misc/ter-x12b.pcf.gz
warning: could not get file information for usr/share/fonts/misc/ter-x12n.pcf.gz
(more warnings...)
:: Running pre-transaction hooks...
(1/1) Exec /etc/pacman.d/hooks/pack_fonts.sh
:: Processing package changes...
(1/1) reinstalling terminus-font                   [######################] 100%
:: Running post-transaction hooks...
(1/5) Arming ConditionNeedsUpdate...
(2/5) Exec /etc/pacman.d/hooks/unpack_fonts.sh
(3/5) Updating fontconfig cache...
(4/5) Updating 32-bit fontconfig cache...
(5/5) Updating X fontdir indices...

Offline

#4 2025-07-21 21:00:14

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 71,583

Re: [Solved] Tell installer that fonts shall be unpacked on install

I don't think so.
You could leave the compressed fonts (or dummies) in place but oc. that sucks, too (fontconfig might get confused) so you end up essentially breaking the installed package (which is the point of all of this) and run into that on the next update.

Evil plan: have you tried to fool fontconfig by extracting the font but keeping the .gz suffix?
Or is KDE happy (this btw. smells like a libkate bug - wtf would it reload/decompress the same font multiple times) with recompressing the font -1 (defaults -6, might come at -9)?

Online

#5 2025-07-22 11:18:37

jpka
Member
Registered: 2024-12-04
Posts: 7

Re: [Solved] Tell installer that fonts shall be unpacked on install

Hello.
Thank you so much @seth, it was very precise and helpful, and this plan works. While re-gzippin with -1 almost not have any effect; but, renamed to .pcf.gz, uncompressed fonts are works (and installs/remove/upgrade) just fine.
I am wonder too, why cache is so non effective, after more than quarter of century of sharpening it; while my case which exposes it, is rare, of course. Anyway it have now this straightforward fix, which have (almost *) no side effects; i even think that also other parts of system are can go faster now due to uncompressed fonts. And only one unpack hook need now.
Thanks again!
(*) One i found is this font not opens w/ Fontforge, uncompress error, can be easily overcome.

unpack_fonts.sh
---------------
#!/bin/bash

sort -r | while read -r d; do
  [[ ! -d $d ]] || continue
  ext="${d##*.}"
  if [[ $ext = "gz" ]]; then
    zcat $d > $d"_"
    mv $d"_" $d
  fi
done

Offline

Board footer

Powered by FluxBB