Skip to content

appstream: Add metainfo xml to all font packages #449

@joebonrichie

Description

@joebonrichie

Add appstream metainfo to all font packages so font previews show up in Software Centers.

Please see font-clear-sans-ttf in the Solus Software Center as an example.

Screenshot from 2023-10-06 12-18-13

Please see this commit for liberation-fonts-ttf on how to add appstream metainfo to a package

8b48034

Finding fonts to update

Originally, all of our fonts except font-clear-sans-ttf and liberation-fonts-ttf were missing appstream data.
To search for fonts that have no metainfo.xml file:

Method 1: Run this (substitute solus-builds for the directory you have on your system):

cd solus-builds/packages/packages

find . -maxdepth 2 -type d -iname "font-*" -a ! -iname "*-manager" ! -exec sh -c 'test -e "$1"/files/*metainfo.xml' sh {} \; -print

Also check t/texlive/files for the texlive fonts

Note: Make sure the package is actually a font. The above commands are provided for convenience.

Method 2: Run this to find all desktop font packages:

eopkg info -c desktop.font

Then pick a font and check its info in the repo. Pick one that has no metadata file to add appstream data to.

Create the metainfo file

Create a file fontname.metainfo.xml in the files subdirectory (for the liberation-fonts-ttf font this file is named files/liberation.metainfo.xml because the font name is liberation)
It should contain

<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2023 Solus Developers <copyright@getsol.us -->
  <component type="font">
  <id>packagename</id>
  <metadata_license>CC0-1.0</metadata_license>
  <name>fontname</name>
  <url type="homepage">https://fontwebpage.com/</url>
  <summary>Some summary of the fonts provided</summary>
</component>

You will need a few pieces of data for the file for the placeholders.

  • The font package name from eopkg info fontname | grep Name for id
  • The font name. You can get this by looking at the install section of its package.yml file. The font name is the last part of the directory in the install directive.
  • The homepage (if one exists). This is usually in package.yml, if not please add it as part of your commit.
  • The summary should be brief, one short one sentence. It can be gotten from the font's website or you can create it yourself. It may be different than the eopkg description if that is longer.
  • The metadata_license needs to be CC0-1.0

If the font provides translations for the name, add them like this:

<summary>This is SARASA GOTHIC, a CJK programming font based on Iosevka and Source Han Sans.</summary>
<summary xml:lang="ja">更紗ゴシック</summary>
<summary xml:lang="kr">사라사 고딕</summary>
<summary xml:lang="zh">更纱黑体</summary>

See this PR for reference.

Then install it via package.yml

install    : |
    install -Dm00644 $pkgfiles/somefont.metainfo.xml $installdir/usr/share/metainfo/somefont.metainfo.xml

Build and test

To test the appstream metainfo is valid; after building the package with the appstream data included

Install appstream-glib then run appstream-builder --packages-dir=. --include-failed -v

Finally, check that the package doesn't show up in the example-failed.xml.gz file. The font preview will then show up in the software center when appstream-data is next refreshed.

To cleanup after running appstream-builder, run: rm -fr example* tmp/ cache/.

If a font package provides more than one font

appstream-builder requires a 1:1 mapping between appstream data and packages. If a package provides several different families of fonts, it must also be sub-packaged if providing more than one appstream metainfo xml file.

If a font is sub-packaged you can use the extends field in its metadata file so that one font extends another e.g.

<component type="font">
  <id>some-font-subpackage</id>
  <metadata_license>CC0-1.0</metadata_license>
  <extends>some-font</extends>
</component>

In the package.yml file only use one install directive for the metainfo file for the parent. Use patterns to put the sub-package metainfo.xml files in the right place.
Example from noto-sans, which has noto-serif as a sub-package:

    install -Dm00644 $pkgfiles/noto-sans-ttf.metainfo.xml $installdir/usr/share/metainfo/noto-sans-ttf.metainfo.xml
patterns   :
    - ^noto-serif-ttf :
      - /usr/share/fonts/truetype/noto-sans-ttf/NotoSerif*
      - /usr/share/metainfo/noto-serif-ttf.metainfo.xml

Further information

Reference: The Freedesktop font metadata spec

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good First IssueIssue that is good for someone new to the Solus project to try to tackleType: ChoreNot a feature or a bug

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions