Shaper abstraction setup (#38755)

# Objective

- Reorganise Servo's shaper code in preparation for multiple shaping
backends
- Make it possible to keep https://github.com/servo/servo/pull/38707
up-to-date with `main` with minimal conflicts

## Changes made

- Split `components/fonts/shaper.rs` into
`components/fonts/shapers/mod.rs` and
`components/fonts/shapers/harfbuzz.rs`
- Add traits for generic shapers
- `ShapedGlyphData` now takes ownership of the HarfBuzz buffer
(`hb_buffer_t`). This allows it to be returned from
the`THarfShaper::shape_text` function. The buffer is now deallocated in
the `ShapedGlyphData`s `Drop` impl.
- Add traits for HarfBuzz-like shapers and move code from
`save_glyph_results` function to be generic over those traits so that it
can be shared by a future `HarfRust` backend.

---------

Signed-off-by: Nico Burns <nico@nicoburns.com>
This commit is contained in:
Nico Burns 2025-08-21 21:44:39 +01:00 committed by GitHub
parent d4757c9e9f
commit b18a65ed70
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 264 additions and 223 deletions

View file

@ -11,7 +11,7 @@ mod font_template;
mod glyph;
#[allow(unsafe_code)]
pub mod platform;
mod shaper;
mod shapers;
mod system_font_service;
pub use font::*;
@ -21,7 +21,7 @@ pub use font_template::*;
pub use fonts_traits::*;
pub use glyph::*;
pub use platform::LocalFontIdentifier;
pub use shaper::*;
pub use shapers::*;
pub use system_font_service::*;
use unicode_properties::{EmojiStatus, UnicodeEmoji, emoji};