-
Notifications
You must be signed in to change notification settings - Fork 85
Customize line height for headings #535
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
tomekzaw
wants to merge
30
commits into
main
Choose a base branch
from
@tomekzaw/line-height
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
4c16500
Customize line height for headings
tomekzaw 29b8bc9
Fix web tests
tomekzaw 3ccb597
Merge branch 'main' into @tomekzaw/line-height
tomekzaw 30ab8bd
Update Podfile.lock
tomekzaw 5ba3332
Merge branch 'main' into @tomekzaw/line-height
tomekzaw 579a2aa
Merge branch 'main' into @tomekzaw/line-height
tomekzaw 0c0a6dc
Update Podfile.lock
tomekzaw abf5e6b
Merge branch 'main' into @tomekzaw/line-height
tomekzaw a08da3b
Update Podfile.lock
tomekzaw 3ced129
Unify `NSMutableParagraphStyle` creation
tomekzaw 6a1a99b
Merge branch 'main' into @tomekzaw/line-height
tomekzaw 4b32ede
Merge branch 'main' into @tomekzaw/line-height
tomekzaw 06b1ef4
Merge branch 'main' into @tomekzaw/line-height
tomekzaw f0451e0
Fix line height for h1 on iOS when line height is set on text input
tomekzaw 6f9838d
Add patch for react-native
tomekzaw 16862ac
Fix heading line height in blockquote
tomekzaw 7ceeadc
Fix line height of regular lines
tomekzaw 027dbda
Merge branch 'main' into @tomekzaw/line-height
tomekzaw bae14a5
Fix cursor height in empty text input with line height set
tomekzaw 83a5feb
Merge branch 'main' into @tomekzaw/line-height
tomekzaw 65c1d45
Merge branch 'main' into @tomekzaw/line-height
tomekzaw 1850eb8
WIP
tomekzaw 9495a26
Merge branch 'main' into @tomekzaw/line-height
tomekzaw 6d91254
Merge branch 'main' into @tomekzaw/line-height
tomekzaw 11e6265
Merge branch 'main' into @tomekzaw/line-height
tomekzaw 914b5b9
Fix react-native patch
tomekzaw d47d3f7
Merge branch 'main' into @tomekzaw/line-height
tomekzaw f262fbe
Merge branch 'main' into @tomekzaw/line-height
tomekzaw 121b311
Bump react-native patch version
tomekzaw 11ef181
Add buttons for toggling text and heading line height
tomekzaw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
diff --git a/node_modules/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTAttributedTextUtils.h b/node_modules/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTAttributedTextUtils.h | ||
index 908cfc0..f693c17 100644 | ||
--- a/node_modules/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTAttributedTextUtils.h | ||
+++ b/node_modules/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTAttributedTextUtils.h | ||
@@ -41,6 +41,8 @@ NSString *RCTNSStringFromStringApplyingTextTransform(NSString *string, facebook: | ||
|
||
void RCTApplyBaselineOffset(NSMutableAttributedString *attributedText); | ||
|
||
+void RCTApplyBaselineOffsetForRange(NSMutableAttributedString *attributedText, NSRange attributedTextRange); | ||
+ | ||
/* | ||
* Whether two `NSAttributedString` lead to the same underlying displayed text, even if they are not strictly equal. | ||
* I.e. is one string substitutable for the other when backing a control (which may have some ignorable attributes | ||
diff --git a/node_modules/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTAttributedTextUtils.mm b/node_modules/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTAttributedTextUtils.mm | ||
index d08d0ba..21b32a1 100644 | ||
--- a/node_modules/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTAttributedTextUtils.mm | ||
+++ b/node_modules/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTAttributedTextUtils.mm | ||
@@ -292,11 +292,20 @@ NSMutableDictionary<NSAttributedStringKey, id> *RCTNSTextAttributesFromTextAttri | ||
} | ||
|
||
void RCTApplyBaselineOffset(NSMutableAttributedString *attributedText) | ||
+{ | ||
+ [attributedText.string enumerateSubstringsInRange:NSMakeRange(0, attributedText.length) | ||
+ options:NSStringEnumerationByLines | NSStringEnumerationSubstringNotRequired | ||
+ usingBlock:^(NSString * _Nullable substring, NSRange substringRange, NSRange enclosingRange, BOOL * _Nonnull stop) { | ||
+ RCTApplyBaselineOffsetForRange(attributedText, enclosingRange); | ||
+ }]; | ||
+} | ||
+ | ||
+void RCTApplyBaselineOffsetForRange(NSMutableAttributedString *attributedText, NSRange attributedTextRange) | ||
{ | ||
__block CGFloat maximumLineHeight = 0; | ||
|
||
[attributedText enumerateAttribute:NSParagraphStyleAttributeName | ||
- inRange:NSMakeRange(0, attributedText.length) | ||
+ inRange:attributedTextRange | ||
options:NSAttributedStringEnumerationLongestEffectiveRangeNotRequired | ||
usingBlock:^(NSParagraphStyle *paragraphStyle, __unused NSRange range, __unused BOOL *stop) { | ||
if (!paragraphStyle) { | ||
@@ -314,7 +323,7 @@ void RCTApplyBaselineOffset(NSMutableAttributedString *attributedText) | ||
__block CGFloat maximumFontLineHeight = 0; | ||
|
||
[attributedText enumerateAttribute:NSFontAttributeName | ||
- inRange:NSMakeRange(0, attributedText.length) | ||
+ inRange:attributedTextRange | ||
options:NSAttributedStringEnumerationLongestEffectiveRangeNotRequired | ||
usingBlock:^(UIFont *font, NSRange range, __unused BOOL *stop) { | ||
if (!font) { | ||
@@ -332,7 +341,7 @@ void RCTApplyBaselineOffset(NSMutableAttributedString *attributedText) | ||
|
||
[attributedText addAttribute:NSBaselineOffsetAttributeName | ||
value:@(baseLineOffset) | ||
- range:NSMakeRange(0, attributedText.length)]; | ||
+ range:attributedTextRange]; | ||
} | ||
|
||
static NSMutableAttributedString *RCTNSAttributedStringFragmentFromFragment( |
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.