Skip to content

Commit 64e7d1f

Browse files
authored
Merge pull request #107 from kas-gui/push-szwzytvuyznt
Update fontique; fix selection of fonts with differing synthesis
2 parents 554b38c + ea8d15f commit 64e7d1f

File tree

4 files changed

+37
-5
lines changed

4 files changed

+37
-5
lines changed

.github/workflows/test.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ jobs:
1515
runs-on: ubuntu-latest
1616
steps:
1717
- uses: actions/checkout@v5
18+
- name: Install dependencies
19+
run: |
20+
sudo apt-get update
21+
sudo apt-get install -y libfontconfig1-dev
1822
- name: Install toolchain
1923
uses: dtolnay/rust-toolchain@nightly
2024
with:
@@ -45,6 +49,11 @@ jobs:
4549

4650
steps:
4751
- uses: actions/checkout@v5
52+
- name: Install dependencies
53+
if: ${{ matrix.os == 'ubuntu-latest' }}
54+
run: |
55+
sudo apt-get update
56+
sudo apt-get install -y libfontconfig1-dev
4857
- name: Install toolchain
4958
uses: actions-rs/toolchain@v1
5059
with:

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ log = "0.4"
5151
serde = { version = "1.0.123", features = ["derive"], optional = true }
5252
ab_glyph = { version = "0.2.10", optional = true }
5353
swash = "0.2.4"
54-
fontique = "0.6.0"
54+
fontique = "0.7.0"
5555

5656
[dependencies.rustybuzz]
5757
version = "0.20.1"

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,22 @@ Pure-Rust alternatives for typesetting and rendering text:
4949
- [glyph_brush](https://github.com/alexheretic/glyph-brush) is a fast caching text render library using [ab_glyph].
5050

5151

52+
Crates and features
53+
-------------------
54+
55+
Significant external dependencies:
56+
57+
- [rustybuzz](https://crates.io/crates/rustybuzz): a complete harfbuzz's shaping algorithm port to Rust
58+
- [fontique](https://crates.io/crates/fontique): Font enumeration and fallback
59+
60+
### Feature flags
61+
62+
This crate has a few optional features (all are disabled by default). See [Cargo.toml](https://github.com/kas-gui/kas-text/blob/master/Cargo.toml#L21) for a full list. Highlighted features:
63+
64+
- `shaping`: enable text shaping (recommended)
65+
- `markdown`: rich text support with Markdown parsing (only supports a small subset of Markdown features)
66+
67+
5268
Contributing
5369
--------
5470

src/fonts/library.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@ pub struct FaceStore {
8686
}
8787

8888
impl FaceStore {
89-
/// Construct, given a file path, a reference to the loaded data and the face index
90-
///
91-
/// The `path` is to be stored; its contents are already loaded in `data`.
89+
/// Construct, given a data blob, face index and synthesis settings
9290
fn new(blob: Blob<u8>, index: u32, synthesis: Synthesis) -> Result<Self, FontError> {
9391
// Safety: this is a private fn used to construct a FaceStore instance
9492
// to be stored in FontLibrary which is never deallocated. This
@@ -367,13 +365,22 @@ impl FontLibrary {
367365
let mut hasher = DefaultHasher::new();
368366
qf.blob.id().hash(&mut hasher);
369367
hasher.write_u32(qf.index);
368+
// Hashing of qf.synthesis is incomplete, but we use an equality test later anyway
369+
for var in qf.synthesis.variation_settings() {
370+
var.0.hash(&mut hasher);
371+
}
372+
qf.synthesis.embolden().hash(&mut hasher);
373+
qf.synthesis.skew().is_some().hash(&mut hasher);
370374
hasher.finish()
371375
};
372376

373377
for (h, id) in face_list.source_hash.iter().cloned() {
374378
if h == source_hash {
375379
let face = &face_list.faces[id.get()];
376-
if face.blob.id() == qf.blob.id() && face.index == qf.index {
380+
if face.blob.id() == qf.blob.id()
381+
&& face.index == qf.index
382+
&& face.synthesis == qf.synthesis
383+
{
377384
faces.push(id);
378385
return QueryStatus::Continue;
379386
}

0 commit comments

Comments
 (0)