-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
[Text] Programmatically get the default font family (San Francisco vs. Helvetica Neue) #1611
Comments
Summary: Get the default font family programmatically. The default font family is hard coded as Helvetica. Closes facebook#1611
Summary: Get the default font family programmatically. The default font family is hard coded as Helvetica. Closes facebook#1611
Here are all the places where Helvetica is mentioned in code. Currently, it creates a font by name if no family is provided, it should instead modify the |
I know how can I get |
On iOS 7, on the device itself, running Anyways, it doesn't matter what font the system gives here. The point is to use |
@paramaggarwal The system font has changed to San Francisco in iOS 9. @ide I'm thinking we should add a virtual font name called "System" that defaults to whatever the current system font is. Does that work for you? I'll consider making this the default instead of Helvetica, but this may break existing apps. |
@nicklockwood I think we want the notion of a system font for a given size, which includes the font name and other typographical defaults that Apple has configured. This includes options like how colons are formatted in timestamps -- when rendering 9:45AM, the colon should be vertically raised. I haven't tested it but I believe that these options are configured when you call Additionally we'll want to expose these new options to JS. One example is the monospaced digits options -- with the new SF font, digits are no longer monospaced (instead they are naturally spaced so that "1" is thinner than "5" for example), but for UI elements like incrementing counters you want the monospaced digits. And of course there's the font name vs. font family distinction. I believe we want to encourage use of font families so that the OS picks the appropriate font for the given size. For the SF font, there's a Display cut and a Text cut, where Display is intended for larger sizes. I wasn't able to find the new font options in the prerelease docs yet but Session 804 (2015) covers most of this. |
@ide that's why I'm proposing we have a virtual "System" font name/family to specify that you want to use the system defaults for all these attributes. |
@nicklockwood Making sure I understand your idea... so |
@ide exactly. |
That sounds really good. |
👍 |
@nicklockwood @ide, great points. Linking to the WWDC talk for anyone interested in what all has changed: Introducing the New System Fonts |
Add a virtual fontName called "System" that defaults to whatever the current system font is. (@nicklockwood ) facebook#1611 It breaks all snapshot tests.
👍 I just pushed the new commit that supports a virtual fontName |
👍 |
Add a virtual fontName called "System" that defaults to whatever the current system font is. (@nicklockwood ) facebook#1611 It may break UI of existing apps.
Add a virtual fontName called "System" that defaults to whatever the current system font is. (@nicklockwood facebook#1611) It may break UI of existing apps.
@dalinaum So I'm not sure what is the correct way, to do this - so can't suggest modifications but I did watch Introducing the New System Fonts, and in it they say that fetching Again, sorry for giving feedback without being able to suggest code modifications. 😄 |
Add a virtual fontName called "System" that defaults to whatever the current system font is. (@nicklockwood facebook#1611) It may break UI of existing apps.
Fix for this already landed in master it seems. please reopen if i'm wrong. |
Yeah, this is fixed. |
…add a virtual fontName called "System" Summary: Get the system font instead of Helvetica programmatically and add a virtual fontName called "System" that defaults to whatever the current system font is. #1611 Closes facebook/react-native#1635 Github Author: LYK <[email protected]>
So, is there a way to get monospaced digits now? |
@dapetcu21 I believe that's not supported -- your best bet is rendering |
@dapetcu21: For me it worked to set |
What about variants of San Francisco? https://github.com/AppleDesignResources/SanFranciscoFont |
I have the same question as @f0rr0. Is there a way to choose between Display and Text variants of the San Francisco font? |
Same here, what about using the variants or semibold.
and run
Note: If you delete font files you need to edit manually the |
Currently Helvetica is hard-coded in a couple places. We should instead get the system's font programmatically.
The text was updated successfully, but these errors were encountered: