Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Style ignores bold font #352

Closed
holgersindbaek opened this Issue · 6 comments

2 participants

@holgersindbaek

I'm using 2 font families with DTCoreText. One of them (DINPro) works fine and will show bold text as well, but the other (Charter ITC) won't show bold text.

So if I style the font like this, it stays regular:

p {
    font-family:"Charter ITC";
    font-weight: bold;
}

It's the second version of this font family I've tried it with, but with no luck.

I checked the font to see if it was a registered bold like below and it was:

CTFontRef font = CTFontCreateWithName((CFStringRef)@"CharterITC-Bold", 10, NULL);
CTFontSymbolicTraits traits = CTFontGetSymbolicTraits(font);
BOOL isItalic = ((traits & kCTFontItalicTrait) == kCTFontItalicTrait);
BOOL isBold = ((traits & kCTFontBoldTrait) == kCTFontBoldTrait);
NSLog(@"Italic: %i Bold: %i", isItalic, isBold);

Here are the fonts - http://ge.tt/2NMjlKb - if you need them to replicate the issue.

@Cocoanetics
Owner
@holgersindbaek

Sounds good.

I can't find where to put them though?

Can't find any examples in the example app.

@Cocoanetics
Owner

I inspected these fonts and replicated your issue. The root cause is that the regular font face CharterITC-Regu also has the bold trait set. This is a mistake in the font, IMHO.

I recommend any way that you register your custom fonts in the global override table. This way DTCoreTextFontDescriptor can do a quick lookup of the face name from the combination of family, bold and italic flags instead of having to search font tables.

Add this at the launch of your app:

[DTCoreTextFontDescriptor setOverrideFontName:@"CharterITC-Bold" forFontFamily:@"Charter ITC" bold:YES italic:NO];
[DTCoreTextFontDescriptor setOverrideFontName:@"CharterITC-BoldItal" forFontFamily:@"Charter ITC" bold:YES italic:YES];

With this setup the following test came out correctly.

Screen Shot 2013-03-20 at 14 47 32

I explained all this in more detail in a blog post

@holgersindbaek

Thanks for checking.

I ended up using Fontographer for Mac to change the font trait set (regular font was set to medium). Thanks for he tip anyway!

@Cocoanetics
Owner

You should still use the overrides for performance

@holgersindbaek
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.