Add public theme font and style inheritance APIs - #1612
Draft
pseudosavant wants to merge 4 commits into
Draft
pseudosavant wants to merge 4 commits into
pseudosavant wants to merge 4 commits into
Conversation
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.
Setting a heading style's
font.namecan leave its existing theme references in place. In Word, the heading can then render in the theme font instead of the requested typeface. Applying a literal font to every run also prevents later theme changes from updating that text.This adds public APIs for editing the document's Latin theme fonts and binding styles to those fonts. For example, a document can use Aptos Display for headings and Aptos for body text, with both families reflected in Word's theme settings and inherited by new paragraphs.
Proposed API
Document.theme_fontsexposes the scheme name and major/minor Latin typefaces.Font.theme_fontaccepts"major","minor", orNone. Assigning a family removes conflicting literal Latin names. AssigningNoneremoves local Latin theme references while preserving literal names. The getter reads local references and returnsNonefor absent or mixed families.Styles.default_fontexposes document-wide character defaults.Style.linked_styleexposes the linked style, allowing callers to configure the character style associated with a paragraph style.Existing
Font.nameassignment behavior is preserved. Theme edits preserve East Asian, complex-script, and supplemental fonts, colors, and effects. Access creates a complete default theme when none exists. Malformed or incomplete theme font schemes raiseValueError. Untouched theme parts retain their original bytes.Validation
Feedback requested
This is a draft for feedback on the public API shape before finalizing the contribution. In particular, feedback on the
theme_fontsentry point, thetheme_fontproperty name, string family values versus an enumeration, and the handling of missing or incomplete themes would be welcome.The branch contains the library implementation, documentation, unit tests, and acceptance coverage. It is based directly on upstream
masterand is independent of the existing hyperlink authoring PR.