Comments (1)
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)
- Can shaping be reused for different line breaks? HOT 10
- harfbuzz-sys build fails with cannot find input file: `test/Makefile.in' HOT 3
- Unique font id HOT 1
- Choice of font fallback API on macOS HOT 1
- layout_run function does not work correctly on ubuntu 18.04 HOT 1
- Mac font used in example: "DevanagariUI" vs. "DevanagariMT"
- Why provide Unicode functions in Rust rather than use Harfbuzz’s default? HOT 1
- Interaction with CSS font matching algorithm HOT 2
- Add CI (Travis/AppVeyor/GitHub/GitLab/etc)
- How to use Skribo for text layout HOT 4
- Should skribo provide a shaping cache? HOT 8
- HbFace leaks memory
- High level goal: render to image HOT 6
- `make_unicode_funcs` cause memory leak
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from skribo.