Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft implementation of wasm shaper #122

Merged
merged 26 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6053e0b
add `.vscode` to `gitignore`
asibahi Jul 2, 2024
40a8cf8
WIP : initial wasm structure
asibahi Jul 3, 2024
8deb543
typofix
asibahi Jul 3, 2024
def1128
implement some of the import functions
asibahi Jul 3, 2024
5160985
Merge branch 'RazrFalcon:master' into wasm_shaper
asibahi Jul 3, 2024
aaef802
give more flesh. plenty of todo!()s left
asibahi Jul 3, 2024
f080e29
slightly more wrangling
asibahi Jul 3, 2024
4865ba0
more fleshing out wasm work. in need of review.
asibahi Jul 3, 2024
d5ef3cf
different approach to pointers. unable to massage borrow checker yet
asibahi Jul 4, 2024
ac25191
revise assumptions about memory allocations
asibahi Jul 4, 2024
2202d8b
Added Test. Not failing but not producing the expected result
asibahi Jul 4, 2024
57da6f0
Merge branch 'RazrFalcon:master' into wasm_shaper
asibahi Jul 4, 2024
06ae9dd
fixed potential bug. test still failing
asibahi Jul 4, 2024
ef0b838
no functional changes, just make it easier to navigate.
asibahi Jul 4, 2024
4c3595d
replace many transmutes with bytemuck.
asibahi Jul 5, 2024
9b0809c
CALCULATOR WASM WORKS NOW
asibahi Jul 5, 2024
b535177
implement `shape_with` + other fixes.
asibahi Jul 6, 2024
230ea71
initial impl for `font_copy_glyph_outline` . Needs check for correctn…
asibahi Jul 6, 2024
82929f8
random fixes + added failing ruqaa font test.
asibahi Jul 6, 2024
b0845a5
fixed contours geenration. n_contours is actually the indices of the …
asibahi Jul 7, 2024
7a0da1f
everything works but test is failing for weird reasons
asibahi Jul 7, 2024
77133bd
Bookkeeping and added optional feature.
asibahi Jul 8, 2024
1da938f
wasmi, change where tests live, general cleanup
asibahi Jul 9, 2024
11a062b
added `log` dep. worked around cloning things.
asibahi Jul 10, 2024
84b9f58
found the bug. tests pass (mostly). Ruqaa works.
asibahi Jul 11, 2024
234ef56
should be done.
asibahi Jul 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ Cargo.lock
.directory
.DS_Store
/src/complex/*.ri
.vscode
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ unicode-bidi-mirroring = "0.3.0"
unicode-ccc = "0.3.0"
unicode-properties = { version = "0.1.0", default-features = false, features = ["general-category"] }
unicode-script = "0.5.2"
wasmi = { version = "0.34.0", optional = true }
log = "0.4.22"

[dependencies.ttf-parser]
version = "0.24.0"
Expand All @@ -36,6 +38,7 @@ features = [
[features]
default = ["std"]
std = ["ttf-parser/std"]
wasm-shaper = ["std", "dep:wasmi"]

[dev-dependencies]
pico-args = { version = "0.5", features = ["eq-separator"] }
Expand Down
2 changes: 1 addition & 1 deletion src/hb/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ pub struct GlyphPosition {
/// How much the glyph moves on the Y-axis before drawing it, this should
/// not affect how much the line advances.
pub y_offset: i32,
var: u32,
pub(crate) var: u32,
}

unsafe impl bytemuck::Zeroable for GlyphPosition {}
Expand Down
4 changes: 4 additions & 0 deletions src/hb/face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,13 +369,17 @@ impl<'a> hb_font_t<'a> {
}

#[derive(Clone, Copy, Default)]
#[repr(C)]
pub struct hb_glyph_extents_t {
pub x_bearing: i32,
pub y_bearing: i32,
pub width: i32,
pub height: i32,
}

unsafe impl bytemuck::Zeroable for hb_glyph_extents_t {}
unsafe impl bytemuck::Pod for hb_glyph_extents_t {}

fn find_best_cmap_subtable(face: &ttf_parser::Face) -> Option<u16> {
use ttf_parser::PlatformId;

Expand Down
2 changes: 2 additions & 0 deletions src/hb/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ mod ot_shaper_vowel_constraints;
mod paint_extents;
mod set_digest;
pub mod shape;
#[cfg(feature = "wasm-shaper")]
mod shape_wasm;
mod tag;
mod tag_table;
mod text_parser;
Expand Down
27 changes: 21 additions & 6 deletions src/hb/shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,27 @@ pub fn shape_with_plan(
if buffer.len > 0 {
// Save the original direction, we use it later.
let target_direction = buffer.direction;
shape_internal(&mut hb_ot_shape_context_t {
plan,
face,
buffer: &mut buffer,
target_direction,
});

#[cfg(feature = "wasm-shaper")]
{
super::shape_wasm::shape_with_wasm(face, plan, &mut buffer).unwrap_or_else(|| {
shape_internal(&mut hb_ot_shape_context_t {
plan,
face,
buffer: &mut buffer,
target_direction,
});
});
}
#[cfg(not(feature = "wasm-shaper"))]
{
shape_internal(&mut hb_ot_shape_context_t {
plan,
face,
buffer: &mut buffer,
target_direction,
});
}
}

GlyphBuffer(buffer)
Expand Down
Loading
Loading