Font API and object-level shaping - #16
Merged
Merged
Conversation
- Added `Font` class for loading and managing font data, including methods for creating instances from file paths and byte arrays. - Introduced `GlyphBuffer`, `GlyphInfo`, and `GlyphPosition` classes to handle glyph shaping and positioning, providing a structured way to access glyph information. - Updated `__init__.py` to include new classes in the module's public API. - Enhanced `Buffer` class with methods for handling glyph data and serialization. - Added comprehensive tests for the new font and glyph functionalities, ensuring correct behavior and integration with existing components.
- Updated `test_glyph_info_fields` to assert additional properties of glyph information, including cluster values for multiple glyphs. - Introduced `test_from_bytes_matches_from_path` to verify that font data loaded from bytes matches that loaded from a file path. - Adjusted error handling in `test_features_wrong_type` to ensure proper feature validation.
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
This PR adds the object-oriented shaping API: load fonts from path or bytes, configure axis variations and point size, shape a
Buffer, and work with the resultingGlyphInfo/GlyphPositiondata. Buffers can be recycled throughGlyphBuffer.clear(), and serialized output can be matched to the high-levelshape()helper for the cases we cover in tests.What’s included
Font— load via path (Font(path)) orFont.from_bytes, optionalface_index,units_per_em,set_variations(string orVariationlist),set_point_size, andshape(buffer, features=…)with string orFeaturelist.GlyphBuffer,GlyphInfo,GlyphPosition— length, index access, iteration as(info, pos)pairs,glyph_infos/glyph_positionsgetters, andserialize(font)for HarfRust-style glyph strings.Buffer(aftershape) andGlyphBuffer(afterclear()) to match the owned-container design.pyharfrust.shape, and buffer consumption / recycling.