Skip to content

Initial implementation of autoAdjustsFontSize #2327

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

Closed
wants to merge 1,061 commits into from

Conversation

MattFoley
Copy link

Comments? Concerns? This shouldn't break anything for anyone. Fingers Crossed

@MattFoley
Copy link
Author

Resolves #728.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 13, 2015
@MattFoley MattFoley force-pushed the feature-adjustFontSizeToFit branch from 1f7db56 to e3a448d Compare August 13, 2015 20:57
NSRange glyphRange = [layoutManager glyphRangeForTextContainer:textContainer];

CGRect textFrame = UIEdgeInsetsInsetRect(self.bounds, _contentInset);
if (_adjustsFontSizeToFit) {
textFrame = [self updateToFitFrame:textFrame];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't want to run this on every drawRect call, it's too expensive

@MattFoley
Copy link
Author

Note: This will only work if you specify either a height for your style, or numberOfLines. Otherwise RCTText will happily make your text node large enough to fit the titanic. :)

@MattFoley
Copy link
Author

I can't be 100% sure, but I don't think the CI failure is due to this PR. Seems to be failing on npm install?

@MattFoley
Copy link
Author

Now that I'm starting to use this in a lot of different places, this still doesn't seem to be working as well as I'd like. Does anyone else have any thoughts on improvements?

@MattFoley MattFoley force-pushed the feature-adjustFontSizeToFit branch 2 times, most recently from 9a8dbeb to 47b0495 Compare August 27, 2015 22:15
@MattFoley
Copy link
Author

This has been rebased and squashed, still looking for feedback on this.

@jjshammas
Copy link

Any movement on this? Would love to have it implemented soon.

@facebook-github-bot
Copy link
Contributor

@MattFoley updated the pull request.

@MattFoley
Copy link
Author

@jjshammas I would love some help from another developer on this. So far it seems to still have a few small issues. I believe the binary search in RCTText.m needs to be limited to just width and not height.

@facebook-github-bot
Copy link
Contributor

@MattFoley updated the pull request.

1 similar comment
@facebook-github-bot
Copy link
Contributor

@MattFoley updated the pull request.

@MattFoley MattFoley force-pushed the feature-adjustFontSizeToFit branch 2 times, most recently from 67dceab to 5be3480 Compare November 9, 2015 23:49
@facebook-github-bot
Copy link
Contributor

@MattFoley updated the pull request.

Martin Konicek and others added 7 commits November 9, 2015 15:57
We don't need these files anymore, the sync from the internal
fb repo to github is working now.

This reverts commit 746ebc6.
Summary: This adds the moduleNameMapper config which corresponds to the same config in flow.

public

Reviewed By: voideanvalue

Differential Revision: D2582879

fb-gh-sync-id: f116b86a7d4196c39faa366a521fe8401769b173
Differential Revision: D2584243

fb-gh-sync-id: 50dece06820aa754741b560cae5eb3318c1926bd
Differential Revision: D2582624

fb-gh-sync-id: b04b4c90ee478d995968cab4364e1ab0964b6ebe
Summary: Added missing file RCTRootViewInternal.h
Closes facebook#3708

Reviewed By: svcscm

Differential Revision: D2585196

Pulled By: tadeuzagallo

fb-gh-sync-id: 2d69e706fb7920063380c1dedc8ef4deb6801ee5
Differential Revision: D2581548

fb-gh-sync-id: 4cf9e0bbb494047c927cef8602101a9d000eb076
Reviewed By: kukulski

Differential Revision: D2483597

fb-gh-sync-id: 003592b55b98af7a350f4789f3199b4e6d5f2c22
tadeuzagallo and others added 20 commits November 9, 2015 15:58
Summary: public

As jspahrsumemrs pointed out, `int` could overflow pretty easy, since it was static,
change it to an NSUInteger and downcast it when need to interop.

Reviewed By: jspahrsummers

Differential Revision: D2625902

fb-gh-sync-id: 2052be47a7b0ed81484da004fa18d6ef5baf26f7
Summary: Fixes regression in bf59864

Closes facebook#3773
Closes facebook#3954

Reviewed By: svcscm

Differential Revision: D2631180

Pulled By: kmagiera

fb-gh-sync-id: 09a1a2e48fd6fff37d1491c120a28221cdc1b163
there is no screenshot above
Differential Revision: D2631505

fb-gh-sync-id: a7a21f114e521ca4ffff9fe9f8408cda70ad5ff3
Reviewed By: andreicoman11

Differential Revision: D2631186

fb-gh-sync-id: 8f898b11be31b253780474d1cf328d7d109decbb
Summary: public

Added support for #rgba and #rrggbbaa colors, which are now officially recognized in the css spec, and supported by WebKit:

http://trac.webkit.org/changeset/192023

Reviewed By: davidaurelio

Differential Revision: D2631386

fb-gh-sync-id: 207a14f77f94bac8088568dc1bbe2bb29f0176c3
Summary: public

Use OSAtomicBarrier to write the flags rather than using OSAtomic to read *and* write.

Reviewed By: jspahrsummers

Differential Revision: D2625915

fb-gh-sync-id: 2ed357ae408b2afe5ef2689582585bf4f9edd8a7
Summary: public

Rename it to `RCT_PROFILE_(BEGIN|END)_EVENT` to make it clearer that it's a macro,
since it has special behaviours.

Reviewed By: jspahrsummers

Differential Revision: D2631542

fb-gh-sync-id: 629c139462c4aa3582f719b14482017d13676e33
Summary: public

`RCTProfileTrampoline` (and consequently `RCTProfileTrampoline(Start|End)`) should be as lightweight
as possible, since it's called for every BridgeModule's method invocation, so
avoid doing any string processing there by dispatching it to Profiler queue.

Reviewed By: jspahrsummers

Differential Revision: D2625918

fb-gh-sync-id: 86a98d4cf727c3be20eebee0bf8437c502c6a42a
Reviewed By: swarr

Differential Revision: D2631395

fb-gh-sync-id: cf59a290a4b447122c36ec20176b563a38bee630
Reviewed By: martinbigio

Differential Revision: D2619364

fb-gh-sync-id: 7947388c8041e5d6cbc1e20c8eb9fc7325dc46e0
…cyResolver`

Reviewed By: martinbigio

Differential Revision: D2619690

fb-gh-sync-id: 04ca68a1fa2dc7b77a49c38ea1515d7afbdee603
Reviewed By: martinbigio

Differential Revision: D2619798

fb-gh-sync-id: ddc58233c06899017dbb98b3d8258eb0fe61cda3
Reviewed By: davidaurelio

Differential Revision: D2628366

fb-gh-sync-id: 8d849e2deb038842475e66ef641fa1d4f7b78d8f
Reviewed By: davidaurelio

Differential Revision: D2628885

fb-gh-sync-id: f8b96c483eb7deb52a7ca4897801e2d0ef9e4f4c
Reviewed By: davidaurelio

Differential Revision: D2629211

fb-gh-sync-id: ade0bf4e486b58ecbc9a29eb3bdb61286eebb3d5
Reviewed By: AaaChiuuu

Differential Revision: D2633573

fb-gh-sync-id: c47bec903d54c12f4d9e576ad1aaf16d4bd68f30
Rounding using RCTRoundPixelValue, and improve performance. (Call less often.)

binary search tests

Adding example to movies app, adding bail out, updating error margin handling, granularity and fixing default value to actually work.

Reverse package change.

Better name for checkScale.

Remove height from calculation

Remove constant.
@facebook-github-bot
Copy link
Contributor

@MattFoley updated the pull request.

@MattFoley
Copy link
Author

I'm closing this and reopening from a separate branch, it's been far to long.

@MattFoley MattFoley closed this Nov 10, 2015
@MattFoley MattFoley deleted the feature-adjustFontSizeToFit branch November 10, 2015 00:03
@MattFoley MattFoley restored the feature-adjustFontSizeToFit branch November 10, 2015 00:05
@MattFoley MattFoley deleted the feature-adjustFontSizeToFit branch November 10, 2015 00:06
@facebook-github-bot
Copy link
Contributor

@MattFoley updated the pull request.

gabrieldonadel pushed a commit to gabrieldonadel/react-native that referenced this pull request Feb 22, 2025
<!-- Thanks for submitting a pull request! We appreciate you spending
the time to work on these changes. Please provide enough information so
that others can review your pull request. The four fields below are
mandatory. -->

<!-- This fork of react-native provides React Native for macOS for the
community. It also contains some changes that are required for usage
internal to Microsoft. We are working on reducing the diff between
Facebook's public version of react-native and our
microsoft/react-native-macos fork. Long term, we want this fork to only
contain macOS concerns and have the other iOS and Android concerns
contributed upstream.

If you are making a new change then one of the following should be done:
- Consider if it is possible to achieve the desired behavior without
making a change to microsoft/react-native-macos. Often a change can be
made in a layer above in facebook/react-native instead.
- Create a corresponding PR against
[facebook/react-native](https://github.com/facebook/react-native)
**Note:** Ideally you would wait for Facebook feedback before submitting
to Microsoft, since we want to ensure that this fork doesn't deviate
from upstream.
-->

## Summary:

Problem: Setting the accessible prop to false on RN Image does not
remove the image from the accessibility tree on macOS. This is because
the accessible prop is mapped to the accessibilityElement property but
is set on NSImageView which has no effect. Instead, the
accessibilityElement prop should be set on NSImageCell.

Solution: Add a way to retrieve NSImageCell from NSImageView and map
RN's accessible prop to the accessibilityElement property on it.

## Test Plan:

Added a toggle to the 'Accessibility' test example in ImageExamples.js
to test the value of the accessible prop. Hovered over the image with
Accessibility Inspector and verified that the image is not found when
accessible is false. Also verified by turning on VoiceOver and confirmed
the image did not get read when the accessible prop is false.

accessible prop is true:
<img width="1279" alt="Screenshot 2025-01-07 at 11 19 22 AM"
src="https://github.com/user-attachments/assets/5b5abe39-f671-4f63-8931-fb0b454ecb3a"
/>

accessible prop is false:
<img width="1277" alt="Screenshot 2025-01-07 at 11 20 29 AM"
src="https://github.com/user-attachments/assets/f5704a5f-1416-4559-89d1-b11d80b43b48"
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.