Buffer class for text input (Phase 4) - #9
Merged
Merged
Conversation
Pythonic Buffer class backed by Option<UnicodeBuffer>, which establishes the consumption pattern for Phase 5 shape() without yet exposing a consumer. Covers the operations needed to drive shaping end-to-end: text accumulation, direction/script/language properties, guess_segment_properties, context setters, and clear.
Adds a Buffer test covering set_not_found_variation_selector_glyph, which was exposed but previously unexercised. Marks the Direction label match inside Buffer.__repr__ with a comment pointing at the equivalent (private) match in PyDirection::__repr__, so the next edit to either keeps them in sync. Expands the TestContext header to spell out why pre/post context tests only assert that the call doesn't raise.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Buffer— the Pythonic entry point for feeding text into the shaping pipeline.UnicodeBufferbehindOption<UnicodeBuffer>so the consumption pattern (ValueErroron use-after-shape) is wired in before any consumer exists. Phase 5'sFont.shape()will call thepub(crate) take_inner/restorehooks without further refactor.add_str,add(codepoint, cluster=0),clear,reset_clusters,guess_segment_properties,reserve,set_pre_context/set_post_context, anddirection/script/languageproperties.languagereturnsNonewhen unset, matching upstream.Out of scope
Font.shape()in Phase 5.Test plan
cargo fmt --all --checkcargo clippy --all -- -D warningscargo test --alluv run maturin developuv run ruff check && uv run ruff format --checkuv run pytest— 81 passed (25 new, 56 pre-existing)