Repository navigation
fix(wasm): textSetFontWeight sets the size and the weight (#14740) - #14746
Conversation
|
Caution Review failedThe pull request is closed. No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CUQanVsnitcrmYLAWWPc3p
bb6c7cb to
5b00620
Compare
) `textSetFontWeight(widget, size, weight)` was routed to the 2-argument `perry_ui_set_font_weight(h, weight)`, so on `--target web` the size became the CSS font-weight and the weight was dropped. It now has its own bridge that sets `font-size` from the size and `font-weight` from the weight; a weight in 0..1 (the native scale, `systemFont(ofSize:weight:)`) maps onto CSS 100..900 as the HarmonyOS backend maps it, and a larger value is taken as a CSS weight. The widget method `setFontWeight(weight)` keeps the 2-argument bridge. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CUQanVsnitcrmYLAWWPc3p
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CUQanVsnitcrmYLAWWPc3p
5b00620 to
863d6b3
Compare
Summary
textSetFontWeight(widget, size, weight)set CSSfont-weightto the size on--target weband dropped the weight, becauseui_method_map.rsrouted it to the 2-argumentperry_ui_set_font_weight(h, weight). It now has its own 3-argument bridge that applies both.Changes
crates/perry-codegen-wasm/src/emit/ui_method_map.rs:textSetFontWeightmaps to the newperry_ui_text_set_font_weight(the nameperry-dispatch'sui_tableuses);setFontWeight/set_font_weightkeep the 2-argumentperry_ui_set_font_weight.crates/perry-codegen-wasm/src/wasm_runtime.js:perry_ui_text_set_font_weight(h, size, weight)setsfont-size: <size>pxandfont-weight. A weight in 0..1 is the native scale (Apple'ssystemFont(ofSize:weight:), as inperry-styling'sapplyFontBold(h, size)→ weight1.0, and the docs'textSetFontWeight(bold, 20, 1.0)) and maps onto CSS 100..900 the way the HarmonyOS backend (perry-codegen-arkts/src/mutations.rs) maps it; a value above 1 (the docs'textSetFontWeight(font, 24, 700)) is used as a CSS weight, capped at 1000.crates/perry-codegen-wasm/src/emit/tests.rsthat reads the widget's DOM style. It brings theWIDGET_DOM/run_web_ui_source_thenhelpers verbatim from fix(web-ui): Toggle passes a boolean to onChange #14691 (same text as fix(web-ui): Picker(onChange) receives its callback #14692–fix(web-ui): tableUpdateRowCount re-renders the table body #14695), so whichever merges first the others conflict only trivially.Related issue
Fixes #14740
Test plan
cargo test -q -p perry-codegen-wasm --lib: 77 passed. With only the fix reverted (test kept),text_set_font_weight_applies_the_size_and_the_weightfails: left"A undefined 28\nB undefined 16\nC undefined 12", right"A 28px 700\nB 16px 900\nC 12px 500".cargo build-perry --release && scripts/gc_call_effects/sidecars.sh target/release,npm ci(one build carrying this and the wasm/web: obj.message reads "" on any non-Error object (lowered to error_message) #14739 fix), A/B against a build of main 64257c3:python3 scripts/parity.py run language/error|language/object|language/class --mode webpasses the same cases on both (5/32, 45/429, 75/571);bash tests/integration/wasm/run_wasm_tests.sh30 passed, 3 failed (04_functions, 10_higher_order, 19_ffi_imports) on both.cargo clippy -p perry-codegen-wasmreports nothing in them;BASE_SHA=upstream/main scripts/run_lint_gates.shFAIL set identical to main's.The backends disagree on the 0..1 scale (macOS passes it to
NSFontWeightdirectly, GTK and Android bold at ≥ 0.5, HarmonyOS maps it onto 100..900); this follows HarmonyOS because it is the backend that also targets a 100..900 weight. The--target jsweb runtime (perry-codegen-js) has the same 2-argument routing and is not changed here.cargo build --releaseclean#[test]in the affected crateChecklist
feat:/fix:/docs:/chore:prefix convention used in the log🤖 Generated with Claude Code
https://claude.ai/code/session_01CUQanVsnitcrmYLAWWPc3p
Summary by CodeRabbit
textSetFontWeightnow applies both the requested font size and font weight. Weight values from 0 to 1 map to CSS weights from 100 to 900; values greater than 1 are used as CSS weights, capped at 1000.