Crates.io | fontdb |
lib.rs | fontdb |
version | 0.23.0 |
source | src |
created_at | 2020-07-02 18:05:35.286801 |
updated_at | 2024-10-09 11:41:11.308659 |
description | A simple, in-memory font database with CSS-like queries. |
homepage | |
repository | https://github.com/RazrFalcon/fontdb |
max_upload_size | |
id | 260728 |
size | 243,358 |
fontdb
is a simple, in-memory font database with CSS-like queries.
Vec<u8>
).Database::query
.Advanced font properties querying.
The database provides only storage and matching capabilities.
For font properties querying you can use ttf-parser.
A font fallback mechanism.
This library can be used to implement a font fallback mechanism, but it doesn't implement one.
Application's global database.
The database doesn't use static
, therefore it's up to the caller where it should be stored.
Font types support other than TrueType.
A font is a collection of font faces. Therefore, a font face is a subset of a font. A simple font (*.ttf/*.otf) usually contains a single font face, but a font collection (*.ttc) can contain multiple font faces.
fontdb
stores and matches font faces, not fonts.
Therefore, after loading a font collection with 5 faces (for example), the database will be
populated with 5 FaceInfo
objects, all of which will be pointing to the same file or binary data.
The database performance is largely limited by the storage itself. We are using ttf-parser, so the parsing should not be a bottleneck.
For example, on Mac Book Pro 14 with M1 Pro, it takes just ~24ms to load 1361 font faces.
The library relies on memory-mapped files, which is inherently unsafe. But since we do not keep the files open it should be perfectly safe.
If you would like to use a persistent memory mapping of the font files,
then you can use the unsafe Database::make_shared_face_data
function.
MIT