fschutt / rust-fontconfig

Pure-Rust rewrite of the Linux fontconfig library (no system dependencies) - using ttf-parser and allsorts
MIT License
39 stars 8 forks source link

Properties: doesn't detect monospace / oblique / condensed? #3

Open dhardy opened 3 years ago

dhardy commented 3 years ago

On my system this lib detects 194 fonts. Of these:

I was considering how to select fonts using CSS-like properties (as in font-kit, implemented here and here). It appears that currently not enough properties are detected to do this. Are you planning on adding selection/matching logic?

Example: the DejaVu family:

name family italic oblique bold monospace path index
DejaVu Sans DejaVu Sans FALSE DontCare FALSE DontCare /usr/share/fonts/dejavu-sans-fonts/DejaVuSans.ttf 0
DejaVu Sans Bold DejaVu Sans FALSE DontCare TRUE DontCare /usr/share/fonts/dejavu-sans-fonts/DejaVuSans-Bold.ttf 0
DejaVu Sans Bold Oblique DejaVu Sans TRUE DontCare TRUE DontCare /usr/share/fonts/dejavu-sans-fonts/DejaVuSans-BoldOblique.ttf 0
DejaVu Sans Condensed DejaVu Sans Condensed FALSE DontCare FALSE DontCare /usr/share/fonts/dejavu-sans-fonts/DejaVuSansCondensed.ttf 0
DejaVu Sans Condensed Bold DejaVu Sans Condensed FALSE DontCare TRUE DontCare /usr/share/fonts/dejavu-sans-fonts/DejaVuSansCondensed-Bold.ttf 0
DejaVu Sans Condensed Bold Oblique DejaVu Sans Condensed TRUE DontCare TRUE DontCare /usr/share/fonts/dejavu-sans-fonts/DejaVuSansCondensed-BoldOblique.ttf 0
DejaVu Sans Condensed Oblique DejaVu Sans Condensed TRUE DontCare FALSE DontCare /usr/share/fonts/dejavu-sans-fonts/DejaVuSansCondensed-Oblique.ttf 0
DejaVu Sans ExtraLight DejaVu Sans Light FALSE DontCare FALSE DontCare /usr/share/fonts/dejavu-sans-fonts/DejaVuSans-ExtraLight.ttf 0
DejaVu Sans Mono DejaVu Sans Mono FALSE DontCare FALSE DontCare /usr/share/fonts/dejavu-sans-mono-fonts/DejaVuSansMono.ttf 0
DejaVu Sans Mono Bold DejaVu Sans Mono FALSE DontCare TRUE DontCare /usr/share/fonts/dejavu-sans-mono-fonts/DejaVuSansMono-Bold.ttf 0
DejaVu Sans Mono Bold Oblique DejaVu Sans Mono TRUE DontCare TRUE DontCare /usr/share/fonts/dejavu-sans-mono-fonts/DejaVuSansMono-BoldOblique.ttf 0
DejaVu Sans Mono Oblique DejaVu Sans Mono TRUE DontCare FALSE DontCare /usr/share/fonts/dejavu-sans-mono-fonts/DejaVuSansMono-Oblique.ttf 0
DejaVu Sans Oblique DejaVu Sans TRUE DontCare FALSE DontCare /usr/share/fonts/dejavu-sans-fonts/DejaVuSans-Oblique.ttf 0
DejaVu Serif DejaVu Serif FALSE DontCare FALSE DontCare /usr/share/fonts/dejavu-serif-fonts/DejaVuSerif.ttf 0
DejaVu Serif Bold DejaVu Serif FALSE DontCare TRUE DontCare /usr/share/fonts/dejavu-serif-fonts/DejaVuSerif-Bold.ttf 0
DejaVu Serif Bold Italic DejaVu Serif TRUE DontCare TRUE DontCare /usr/share/fonts/dejavu-serif-fonts/DejaVuSerif-BoldItalic.ttf 0
DejaVu Serif Condensed DejaVu Serif Condensed FALSE DontCare FALSE DontCare /usr/share/fonts/dejavu-serif-fonts/DejaVuSerifCondensed.ttf 0
DejaVu Serif Condensed Bold DejaVu Serif Condensed FALSE DontCare TRUE DontCare /usr/share/fonts/dejavu-serif-fonts/DejaVuSerifCondensed-Bold.ttf 0
DejaVu Serif Condensed Bold Italic DejaVu Serif Condensed TRUE DontCare TRUE DontCare /usr/share/fonts/dejavu-serif-fonts/DejaVuSerifCondensed-BoldItalic.ttf 0
DejaVu Serif Condensed Italic DejaVu Serif Condensed TRUE DontCare FALSE DontCare /usr/share/fonts/dejavu-serif-fonts/DejaVuSerifCondensed-Italic.ttf 0
DejaVu Serif Italic DejaVu Serif TRUE DontCare FALSE DontCare /usr/share/fonts/dejavu-serif-fonts/DejaVuSerif-Italic.ttf 0
dhardy commented 3 years ago

In comparison, fontdb detects 220 fonts (all still under /usr/share/fonts): one .ttc file contains two faces with only one detected by this lib, otherwise I'm not quite sure where the count difference comes from.

In terms of properties, fontdb also doesn't detect any "oblique" fonts but does a better job of detecting weight and "condensed".

@RazrFalcon comparison table from fontdb for DejaVu fonts below.

name family style weight stretch monospace path index
DejaVuSans-Bold DejaVu Sans Normal Weight(700) Normal FALSE /usr/share/fonts/dejavu/DejaVuSans-Bold.ttf 0
DejaVuSans-BoldOblique DejaVu Sans Italic Weight(700) Normal FALSE /usr/share/fonts/dejavu/DejaVuSans-BoldOblique.ttf 0
DejaVuSans-ExtraLight DejaVu Sans Light Normal Weight(200) Normal FALSE /usr/share/fonts/dejavu/DejaVuSans-ExtraLight.ttf 0
DejaVuSans-Oblique DejaVu Sans Italic Weight(400) Normal FALSE /usr/share/fonts/dejavu/DejaVuSans-Oblique.ttf 0
DejaVuSans DejaVu Sans Normal Weight(400) Normal FALSE /usr/share/fonts/dejavu/DejaVuSans.ttf 0
DejaVuSansCondensed-Bold DejaVu Sans Condensed Normal Weight(700) SemiCondensed FALSE /usr/share/fonts/dejavu/DejaVuSansCondensed-Bold.ttf 0
DejaVuSansCondensed-BoldOblique DejaVu Sans Condensed Italic Weight(700) SemiCondensed FALSE /usr/share/fonts/dejavu/DejaVuSansCondensed-BoldOblique.ttf 0
DejaVuSansCondensed-Oblique DejaVu Sans Condensed Italic Weight(400) SemiCondensed FALSE /usr/share/fonts/dejavu/DejaVuSansCondensed-Oblique.ttf 0
DejaVuSansCondensed DejaVu Sans Condensed Normal Weight(400) SemiCondensed FALSE /usr/share/fonts/dejavu/DejaVuSansCondensed.ttf 0
DejaVuSansMono-Bold DejaVu Sans Mono Normal Weight(700) Normal TRUE /usr/share/fonts/dejavu/DejaVuSansMono-Bold.ttf 0
DejaVuSansMono-BoldOblique DejaVu Sans Mono Italic Weight(700) Normal TRUE /usr/share/fonts/dejavu/DejaVuSansMono-BoldOblique.ttf 0
DejaVuSansMono-Oblique DejaVu Sans Mono Italic Weight(400) Normal TRUE /usr/share/fonts/dejavu/DejaVuSansMono-Oblique.ttf 0
DejaVuSansMono DejaVu Sans Mono Normal Weight(400) Normal TRUE /usr/share/fonts/dejavu/DejaVuSansMono.ttf 0
DejaVuSerif-Bold DejaVu Serif Normal Weight(700) Normal FALSE /usr/share/fonts/dejavu/DejaVuSerif-Bold.ttf 0
DejaVuSerif-BoldItalic DejaVu Serif Italic Weight(700) Normal FALSE /usr/share/fonts/dejavu/DejaVuSerif-BoldItalic.ttf 0
DejaVuSerif-Italic DejaVu Serif Italic Weight(400) Normal FALSE /usr/share/fonts/dejavu/DejaVuSerif-Italic.ttf 0
DejaVuSerif DejaVu Serif Normal Weight(400) Normal FALSE /usr/share/fonts/dejavu/DejaVuSerif.ttf 0
DejaVuSerifCondensed-Bold DejaVu Serif Condensed Normal Weight(700) SemiCondensed FALSE /usr/share/fonts/dejavu/DejaVuSerifCondensed-Bold.ttf 0
DejaVuSerifCondensed-BoldItalic DejaVu Serif Condensed Italic Weight(700) SemiCondensed FALSE /usr/share/fonts/dejavu/DejaVuSerifCondensed-BoldItalic.ttf 0
DejaVuSerifCondensed-Italic DejaVu Serif Condensed Italic Weight(400) SemiCondensed FALSE /usr/share/fonts/dejavu/DejaVuSerifCondensed-Italic.ttf 0
DejaVuSerifCondensed DejaVu Serif Condensed Normal Weight(400) SemiCondensed FALSE /usr/share/fonts/dejavu/DejaVuSerifCondensed.ttf 0
RazrFalcon commented 3 years ago

In terms of properties, fontdb also doesn't detect any "oblique" fonts

Are you sure? Can you provide a test file, preferably on the fontdb bug tracker.

dhardy commented 3 years ago

Are you sure?

Assuming you have a Linux system, DejaVu fonts should already be installed? Several variants (see the table above) are named "oblique" and in appearance are "oblique" (just a slanted variant of the regular face), but are listed in the table above as "Italic". Also:

$ fc-list
..
/usr/share/fonts/dejavu/DejaVuSans-Oblique.ttf: DejaVu Sans:style=Oblique

Edit: posted https://github.com/RazrFalcon/fontdb/issues/10, I think you can find the font file?