Giter Club home page Giter Club logo

Comments (1)

RazrFalcon avatar RazrFalcon commented on August 22, 2024

I've tried to implement a simple shaper-driven itemization using fontconfig, but immediately stumbled on a lot of problems.

My algorithm is pretty simple:

  • Shape a string using harfbuzz.
  • Check for missing glyphs.
  • Detect their scripts.
  • Query fonts for each script via font-kit.

So all I need is a font-kit method like:

Source::select_by_script(script: unicode_script::Script, properties: &Properties) -> Result<Handle, SelectionError>

The problem is that fontconfig doesn't support this at all. I can query a font by lang and by charset.

lang is fontconfig's own languages/scripts/whatever list, which doesn't map on Unicode Script, or locale, or anything. Qt, for example, uses it's own Unicode Script list, that it calls WritingSystem and it matches it with fontconfig's lang manually. So if we want to match Unicode Script with lang than we have to do this ourselves.
Also, lang is a sort of simplified. For example, Han, Hiragana, and Katakana in fontconfig is just ja.

We can also use charset, which basically checks that font has the specified code point. But I'm not sure how correct it is. Also, querying fonts for each code point will be way slower than by lang/script and redundant.

I didn't look into DirectWrite and Core Text yet.

Also, I saw your attempt to add get_fallback to font-kit, but I don't understand how it works. It returns only one font, but what if a string has like 5 different scripts and needs 5 different fonts (in worst case scenario)?

from skribo.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.