-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Under iOS13 (Beta 7) TimesNewRomanPSMT will be used instead of SFUI #1168
Comments
same problem here |
What is the correct post script font name for San Francisco? This is the one you should use. |
if we use
it log above error message and get error TimesNewRoman. When changing to follow method
then we can return correct result. is there way to use fontDescriptor?
|
@odrobnik The following is the feedback from apple. Maybe we should provide a way to pass because we are adopting dynamic font, it's not suitable to hardcode the font name
|
Why don't you specify the proper family name for San Francisco? |
I used the PostScript Names |
because we want to follow dynamic font or Dynamic Type. setting such as it's ok for us to manually maintain an mapping table from ".SFUI-Regular"->"SFProDisplay-Regular" and Semibold etc and for different languages. But it just no pretty enough. |
I have the same problem as @yichengchen with supporting dynamic fonts. Is providing the postscript name also working for < iOS 13? |
Have you come out with any solutions? I found that font would be different default font on different language. E.g: the PingFang in Chinese. also i can't find the postscript name of San Francisco @jcaccavale-mdsol I tried
look likes any wrong font name not start with a dot would return |
I found we set |
Yeah I thought the post script names would solve the issue but we also noticed that it's actually Helvetica that's being rendered... For now we manually copied the font in our bundle and reference it by our custom name :( |
Well, the problem is that we have no API that would allow you to set the font instance itself, but only to set a name. In DTHTMLAttributedStringBuilder.m:229 the _defaultFontDescriptor is initialized with the font name only. Then while parsing it keeps attaching updated versions of this font descriptor to tags. What you need instead is to be able to provide a default font descriptor and make sure that the extra attributes which dynamic text adds to that are also preserved. Then to use CTFontCreateWithFontDescriptor to get the font. There are two kinds of font creation, a fast or a slow one and except for some exceptions, like Chinese characters. But the options of default font or default font family omit these extra parameters that dynamic text adds. If somebody were to sponsor the creation of this functionality, I'd be happy to add it. You can email me at oliver@cocoanetics.com to inquire. |
PS: Of course you can also implement this functionality yourself and provide a PR. |
iOS 13 not support UIWebView |
@phamanhvan24 please see #1169 - already addressed by a PR |
for those who are wondering, here's a temporary workaround for this issue until there's fix in the library. What I did was to use method swizzling and overwrite the library method with my own implementation.
|
Any ways to work around this without swizzling? Totally blocking me from using DTCoreText on iOS 13. The swizzling method also doesn't work if you have bold, italic, etc fonts. |
I think you should also be able to specify a font name override for a combination of family and bold/italic flags:
|
I believe that this has been addressed by a different way of finding a matching font. |
…uilder * See Cocoanetics#1168 for reference * Basically, using system fonts will yield a font family name that we cannot directly instantiate from. * Instead, we need to use the font descriptor and create using that. This should be mutually exclusive with font family/name
…uilder * See Cocoanetics#1168 for reference * Basically, using system fonts will yield a font family name that we cannot directly instantiate from. * Instead, we need to use the font descriptor and create using that. This should be mutually exclusive with font family/name
@avium were you able that the PR doesn't break anything else? If I can find some time to verify that then I could try to merge it. |
I've made two changes for this...
|
If you set
DTDefaultFontFamily
andDTDefaultFontName
to iOS13 system font (family: .AppleSystemUIFont name: .SFUI-Regular) e.g. ininitWithHTMLData
:NSAttributedString *attributedString = [[NSAttributedString alloc] initWithHTMLData:data options:@{ DTUseiOS6Attributes: @YES, DTDefaultFontFamily: [UIFont systemFontOfSize:[UIFont systemFontSize]].familyName, DTDefaultFontName : [UIFont systemFontOfSize:[UIFont systemFontSize]].fontName, DTDefaultFontSize : @([UIFont systemFontSize])} documentAttributes:nil];
you will get the following message:
CoreText performance note: Client called CTFontCreateWithName() using name ".SFUI-Regular" and got font with PostScript name "TimesNewRomanPSMT". For best performance, only use PostScript names when calling this API.
The text was updated successfully, but these errors were encountered: