From fb2b38d243b97b3a3ee300210dc584d22ec5f4fb Mon Sep 17 00:00:00 2001 From: Samuel Guerra Date: Tue, 28 May 2024 14:15:25 -0300 Subject: [PATCH 1/5] Get font name --- .github/workflows/ci.yml | 2 +- crates/zng-ext-font/src/lib.rs | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f1a2b16ec..6aac60776 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: - run: cargo check --workspace --examples --tests --release - run: cargo clean test: - runs-on: ubuntu-latest + runs-on: macos-13 needs: [check] env: ZNG_TP_LICENSES: true diff --git a/crates/zng-ext-font/src/lib.rs b/crates/zng-ext-font/src/lib.rs index 03f7d6d22..6b979841b 100644 --- a/crates/zng-ext-font/src/lib.rs +++ b/crates/zng-ext-font/src/lib.rs @@ -1094,7 +1094,14 @@ impl FontFace { } else { ColorGlyphs::load(&font)? }; - let has_ligatures = face.table_with_tag(b"GSUB").is_some(); + + // !!: TODO, debug code to get the + let has_ligatures = match std::panic::catch_unwind(|| face.table_with_tag(b"GSUB").is_some()) { + Ok(b) => b, + Err(p) => { + panic!("panic reading GSUB for {}", font.full_name()); + }, + }; let lig_carets = if has_ligatures { LigatureCaretList::empty() } else { From bf7ead66ad324774f269c7475af6dca93ccc208a Mon Sep 17 00:00:00 2001 From: Samuel Guerra Date: Tue, 28 May 2024 14:18:40 -0300 Subject: [PATCH 2/5] check --- crates/zng-ext-font/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/zng-ext-font/src/lib.rs b/crates/zng-ext-font/src/lib.rs index 6b979841b..8978527c4 100644 --- a/crates/zng-ext-font/src/lib.rs +++ b/crates/zng-ext-font/src/lib.rs @@ -1098,9 +1098,9 @@ impl FontFace { // !!: TODO, debug code to get the let has_ligatures = match std::panic::catch_unwind(|| face.table_with_tag(b"GSUB").is_some()) { Ok(b) => b, - Err(p) => { + Err(_p) => { panic!("panic reading GSUB for {}", font.full_name()); - }, + } }; let lig_carets = if has_ligatures { LigatureCaretList::empty() From 7baf45c3b1f6bf3f5ac60d2f0268ac7390d85757 Mon Sep 17 00:00:00 2001 From: Samuel Guerra Date: Tue, 28 May 2024 14:35:59 -0300 Subject: [PATCH 3/5] Panic is non-unwinding panic, print the name before line. --- crates/zng-ext-font/src/lib.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/crates/zng-ext-font/src/lib.rs b/crates/zng-ext-font/src/lib.rs index 8978527c4..25849e6ad 100644 --- a/crates/zng-ext-font/src/lib.rs +++ b/crates/zng-ext-font/src/lib.rs @@ -1095,13 +1095,8 @@ impl FontFace { ColorGlyphs::load(&font)? }; - // !!: TODO, debug code to get the - let has_ligatures = match std::panic::catch_unwind(|| face.table_with_tag(b"GSUB").is_some()) { - Ok(b) => b, - Err(_p) => { - panic!("panic reading GSUB for {}", font.full_name()); - } - }; + eprintln!("!!: table_with_tag(bGSUB) for {:?}", font.full_name()); + let has_ligatures = face.table_with_tag(b"GSUB").is_some(); let lig_carets = if has_ligatures { LigatureCaretList::empty() } else { From e5e543591740ba9d051a4ee660ff63764a44f1d5 Mon Sep 17 00:00:00 2001 From: Samuel Guerra Date: Tue, 28 May 2024 15:11:58 -0300 Subject: [PATCH 4/5] Try using font_kit to query the GSUB table. --- crates/zng-ext-font/src/lib.rs | 5 ++--- crates/zng-ext-font/src/ligature_util.rs | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/zng-ext-font/src/lib.rs b/crates/zng-ext-font/src/lib.rs index 25849e6ad..6be454a5d 100644 --- a/crates/zng-ext-font/src/lib.rs +++ b/crates/zng-ext-font/src/lib.rs @@ -1019,7 +1019,7 @@ impl FontFace { } else { ColorGlyphs::load(&font)? }; - let has_ligatures = face.table_with_tag(b"GSUB").is_some(); + let has_ligatures = font.load_font_table(GSUB).is_some(); let lig_carets = if has_ligatures { LigatureCaretList::empty() } else { @@ -1095,8 +1095,7 @@ impl FontFace { ColorGlyphs::load(&font)? }; - eprintln!("!!: table_with_tag(bGSUB) for {:?}", font.full_name()); - let has_ligatures = face.table_with_tag(b"GSUB").is_some(); + let has_ligatures = font.load_font_table(GSUB).is_some(); let lig_carets = if has_ligatures { LigatureCaretList::empty() } else { diff --git a/crates/zng-ext-font/src/ligature_util.rs b/crates/zng-ext-font/src/ligature_util.rs index 276e3a7a9..dae2df498 100644 --- a/crates/zng-ext-font/src/ligature_util.rs +++ b/crates/zng-ext-font/src/ligature_util.rs @@ -12,6 +12,7 @@ use core::cmp; use byteorder::{BigEndian, ReadBytesExt}; use zng_view_api::font::GlyphIndex; +pub const GSUB: u32 = u32::from_be_bytes(*b"GSUB"); const GDEF: u32 = u32::from_be_bytes(*b"GDEF"); #[derive(Clone)] From 5b1a8b1e8a754db1b2560dbb6f3618dfaf56faf3 Mon Sep 17 00:00:00 2001 From: Samuel Guerra Date: Tue, 28 May 2024 15:42:45 -0300 Subject: [PATCH 5/5] Add windows and macos to pull request CI --- .github/workflows/ci.yml | 48 ++++++++++++++++++++++++++++++++--- .github/workflows/release.yml | 6 ++--- CHANGELOG.md | 1 + 3 files changed, 49 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6aac60776..24469d70e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,11 +49,53 @@ jobs: - uses: Swatinem/rust-cache@v2 - run: cargo check --workspace --examples --tests --release - run: cargo clean - test: - runs-on: macos-13 + test-ubuntu: + runs-on: ubuntu-latest + needs: [check] + env: + ZNG_TP_LICENSES: true + steps: + - uses: dtolnay/rust-toolchain@stable + - name: install cargo-about + uses: baptiste0928/cargo-install@v3 + with: + crate: cargo-about + - name: install cargo-nextest + uses: taiki-e/install-action@v2 + with: + tool: cargo-nextest + - uses: actions/checkout@v4 + - uses: Swatinem/rust-cache@v2 + - run: cargo do test --nextest + - run: cargo clean + test-windows: + runs-on: windows-latest + needs: [check] + env: + ZNG_TP_LICENSES: true + NEXTEST_RETRIES: 3 + CC: 'clang-cl' + CXX: 'clang-cl' + steps: + - uses: dtolnay/rust-toolchain@stable + - name: install cargo-about + uses: baptiste0928/cargo-install@v3 + with: + crate: cargo-about + - name: install cargo-nextest + uses: taiki-e/install-action@v2 + with: + tool: cargo-nextest + - uses: actions/checkout@v4 + - uses: Swatinem/rust-cache@v2 + - run: cargo do test --nextest + - run: cargo clean + test-macos: + runs-on: macos-latest needs: [check] env: ZNG_TP_LICENSES: true + NEXTEST_RETRIES: 3 steps: - uses: dtolnay/rust-toolchain@stable - name: install cargo-about @@ -90,6 +132,6 @@ jobs: - run: cargo clean test-all: runs-on: ubuntu-latest - needs: [check-release, doc, test, test-doc, test-macro] + needs: [check-release, doc, test-ubuntu, test-windows, test-macos, test-doc, test-macro] steps: - run: exit 0 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 02d2f49db..d6a3e29a8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -78,7 +78,7 @@ jobs: - run: cargo clean if: ${{ github.event.inputs.skip_checks != 'true' }} check-macos: - runs-on: macos-13 + runs-on: macos-latest steps: - uses: actions/checkout@v4 if: ${{ github.event.inputs.skip_checks != 'true' }} @@ -225,7 +225,7 @@ jobs: name: prebuilt-windows path: crates/zng-view-prebuilt/lib/zng_view.dll prebuild-macos: - runs-on: macos-13 + runs-on: macos-latest needs: [check-macos] env: ZNG_TP_LICENSES: true @@ -392,7 +392,7 @@ jobs: - run: cargo clean if: ${{ github.event.inputs.skip_tests != 'true' }} test-macos: - runs-on: macos-13 + runs-on: macos-latest needs: [prebuild-macos] env: NEXTEST_RETRIES: 3 diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fbf93c3b..067193309 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ * Fix `Img::copy_pixels`. * Fix `view_process::default::run_same_process` exit in headless runs. * Fix `AutoGrowMode::rows` actually enabling Columns auto grow. +* Fix "unsafe precondition(s) violated" issue ([#242](https://github.com/zng-ui/zng/issues/242)). # 0.6.1