Skip to content

Commit

Permalink
Use monospace font for RCTRedBox.mm message (#34780)
Browse files Browse the repository at this point in the history
Summary:
The format is crunching spaces:

![Simulator Screen Shot - iPhone 14 Pro Max - 2022-09-24 at 16 25 33](https://user-images.githubusercontent.com/9664363/192119593-30d5c82f-9f8c-465d-af29-6914d4111351.png)

Now it preserves the space and makes the error look a little less scary:

![Simulator Screen Shot - iPhone 14 Pro Max - 2022-09-24 at 16 25 02](https://user-images.githubusercontent.com/9664363/192119603-8214a38b-6511-413b-b999-5d2739cd0293.png)

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[iOS] [Fixed] - RedBox title font by using a monospace font on iOS +13.

Pull Request resolved: #34780

Test Plan: See pictures. You can repro by applying changes and starting a project with a misc `>` character. The first load triggers the error message.

Reviewed By: cipolleschi

Differential Revision: D39798262

Pulled By: robhogan

fbshipit-source-id: d836e50f3e95865a6482accf4aea5b0e6cf24995
  • Loading branch information
EvanBacon authored and facebook-github-bot committed Sep 27, 2022
1 parent 14c91cd commit 5933b6a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion React/CoreModules/RCTRedBox.mm
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,13 @@ - (UITableViewCell *)reuseCell:(UITableViewCell *)cell forErrorMessage:(NSString
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"msg-cell"];
cell.textLabel.accessibilityIdentifier = @"redbox-error";
cell.textLabel.textColor = [UIColor whiteColor];
cell.textLabel.font = [UIFont boldSystemFontOfSize:16];
if (@available(iOS 13.0, *)) {
// Prefer a monofont for formatting messages that were designed
// to be displayed in a terminal.
cell.textLabel.font = [UIFont monospacedSystemFontOfSize:14 weight:UIFontWeightBold];
} else {
cell.textLabel.font = [UIFont boldSystemFontOfSize:14];
}
cell.textLabel.lineBreakMode = NSLineBreakByWordWrapping;
cell.textLabel.numberOfLines = 0;
cell.detailTextLabel.textColor = [UIColor whiteColor];
Expand Down

0 comments on commit 5933b6a

Please sign in to comment.