Xfce Forum

Sub domains
 

You are not logged in.

#1 2026-08-15 04:06:59

Pheeble
Member
Registered: 2015-06-22
Posts: 32
LinuxFirefox 140.0

[SOLVED] Mime types mess vs tumbler font thumbnails

I'm using XFCE 4.18 in Linux Mint 22.1 XFCE.

I've been working with many .ttf and .otf fonts recently, and I wondered if it was possible for Thunar to display a distinct thumbnail for each font file. I investigated and it seemed that the installed tumbler should already be creating thumbnails for font files, but it wasn't happening.

I hunted around and eventually discovered how to run tumbler in debug mode:

pkill tumblerd
G_MESSAGES_PREFIXED= G_MESSAGES_DEBUG=all /usr/lib/x86_64-linux-gnu/tumbler-1/tumblerd

This debug output suggests that tumbler is only recognising font files that match specific mime types:

tumbler-font-thumbnailer-DEBUG: 12:20:06.988: Supported mime types:
  application/x-font-otf
  application/x-font-pcf
  application/x-font-ttf
  application/x-font-type1

The failure to create thumbnails for fonts seems to be caused by the fact that font files on my system do not have those mime types. In fact, the mime types situation seems to be a bit of a mess:

$>file --mime-type Arial-BoldMT.ttf
Arial-BoldMT.ttf: font/sfnt

$>mimetype Arial-BoldMT.ttf
Arial-BoldMT.ttf: font/ttf

$>file --mime-type Angie-SmallCaps.otf
Angie-SmallCaps.otf: application/vnd.ms-opentype

$>mimetype Angie-SmallCaps.otf
Angie-SmallCaps.otf: application/vnd.oasis.opendocument.formula-template

I checked /etc/mime.types for the mime types registered for those extensions:

$>grep -E --word-regexp 'ttf|otf' /etc/mime.types
font/otf					otf
font/ttf					ttf

The 'application/vnd.oasis.opendocument.formula-template' mime type in /etc/mime.types doesn't even have an extension specified:

$>grep 'application/vnd.oasis.opendocument.formula-template' /etc/mime.types
application/vnd.oasis.opendocument.formula-template

It turns out that mime types are also specified in /usr/share/mime/application/ xml files:

$>grep 'otf' /usr/share/mime/application/*
/usr/share/mime/application/vnd.oasis.opendocument.formula-template.xml:  <glob pattern="*.otf"/>

It looks like the OpenDocument formula template file type has taken over the '.otf' file extension.

So given this mess of conflicting mime types, is there any way for me to get tumbler to create and display thumbnails for font files?

Added later 58 min 56 s:
Answering my own question after I stumbled onto a solution shortly afterwards 🙄.

I created a new mime type XML file for each of the .ttf and .otf file types, assigning the mime types that tumbler requires:

user-font-otf.xml:

<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
 <mime-type type="application/x-font-otf">
  <comment>OpenType Font</comment>
  <glob pattern="*.otf"/>
 </mime-type>
</mime-info>

user-font-ttf.xml:

<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
 <mime-type type="application/x-font-ttf">
  <comment>TrueType Font</comment>
  <glob pattern="*.ttf"/>
 </mime-type>
</mime-info>

Then I installed those mime types in my user directory.

xdg-mime install user-font-otf.xml
xdg-mime install user-font-ttf.xml

Finally, I updated the local mime database:

update-mime-database ~/.local/share/mime/

At that point, tumbler immediately created thumbnails for otf and ttf font files when I opened a font folder in Thunar.

Added later 2 h 17 min 14 s:
And finally, a dash shell script to automate the process of creating the required mime types and associating them with their respective file extensions:

#!/usr/bin/dash
###############################################################################
#                                                                             #
#                          Description                                        #
#                                                                             #
# The XFCE thumbnailer 'tumbler' can create thumbnails for OpenType and       #
# TrueType font files, but only if the mime types 'application/x-font-otf'    #
# and 'application/x-font-ttf' are associated with the '.otf' and '.ttf' file #
# extensions respectively.                                                    #
#                                                                             #
# The system mime type associations can be a mess due to installed            #
# applications blindly assigning their own mime types to file extensions.     #
#                                                                             #
# Local mime type associations installed in the user directory will over-ride #
# the system configuration, enabling tumbler to recognise font files and      #
# create thumbnails for them.                                                 #
#                                                                             #
# Running this file as a user will generate the required xml files, install   #
# the mime types and then update the local mime type database.                #
#                                                                             #
###############################################################################

# Print each command before it is run
# set -x

# Exit immediately on non-zero return value
set -e

# Display an error and exit if an unset variable is used.
set -u

# Create a temporary directory for the required XML files
TMPDIR="$(mktemp --directory)"

cleanup ()
{
    status="$?"
    printf -- 'Script finished: exit status %s\n' "${status}"

    [ -d "$TMPDIR" ] && rm -r "$TMPDIR"
}
trap cleanup EXIT

# Make sure the current user is not root
if [ "$(id -u)" -eq 0 ]
then
    echo 'Do not run this file as the root user'
    exit 1
fi

# create mime type 'application/x-font-otf' for tumbler
OTFXML="$TMPDIR/user-font-otf.xml"
cat << EOF > "$OTFXML"
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
 <mime-type type="application/x-font-otf">
  <comment>OpenType Font</comment>
  <glob pattern="*.otf"/>
 </mime-type>
</mime-info>
EOF

# create mime type 'application/x-font-ttf' for tumbler
TTFXML="$TMPDIR/user-font-ttf.xml"
cat << EOF > "$TTFXML"
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
 <mime-type type="application/x-font-ttf">
  <comment>TrueType Font</comment>
  <glob pattern="*.ttf"/>
 </mime-type>
</mime-info>
EOF

# Register these mime types for the current user
xdg-mime install "$OTFXML"
xdg-mime install "$TTFXML"
update-mime-database ~/.local/share/mime/

Last edited by Pheeble (2026-08-15 06:25:36)

Offline

Registered users online in this topic: 0, guests: 0

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.011 seconds, 7 queries executed - Memory usage: 530.95 KiB (Peak: 553.55 KiB) ]