linebender / linebender/resvg

Script/language-aware generic font-familiy resolving

Open
#1,035 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
4.1k
Forks
348
Avg merge
1d 14h
Merged PRs (30d)
3

Description

Currently `usvg` just naively iterates over all system fonts available and pick the first one that contains the expected character. Taking a tspan with a default generic family name `sans-serif` as an example:

```svg
你好
```

On my machine this makes usvg try to find a font that contains `你好`, ending up picking a random font `FZKTK--GBK1-0`, which it does contain the two Han characters but just, not expected. Expected way is to resolve to `Noto Sans CJK SC` or `Source Han Sans CN` or something more 'standard'.

System API integration is a way. On linux fontconfig is available. It has script-aware font matching scheme. Querying example:

```console
❯ fc-match ':charset=7424'
NotoSansCJK-Regular.ttc: "Noto Sans CJK SC" "Regular"
```

However system API integration may be bit heavy or dirty. Another way is, predefining font family names w.r.t. generic family names. As an example, here's the preferences file from Firefox: https://github.com/mozilla-firefox/firefox/blob/768652661f994d1bf533162e3c9ff8e0887d6784/modules/libpref/init/all.js#L2082-L2222.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing usvg's current generic-family font resolution and compare the script-aware charset matching described for fontconfig with Firefox's generic-family preferences. Done means generic families such as sans-serif choose an appropriate script-aware font for text like 你好 instead of an arbitrary font that merely contains the characters.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
computer-graphics
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.