I’ve got two fonts, SourceHanSans-Bold.otf and SourceHanSans-Regular.otf. I use the ‘regular’ variant for all my text. Some of my text uses a bold style, either via the rich text bold tag or via the bold setting on the text. However, Unity isn’t using the bold font to render this text; instead it looks like it’s trying to bold it itself somehow.
How does Unity decide what font to use for bold text? I also have OpenSans-Bold.ttf and OpenSans-Regular.ttf and in that case the correct font is selected. I don’t know what the difference is (aside from the fact that Open Sans is a ttf file and Source Han Sans is an otf file).
This bug report seems like the same issue. It looks like it was resolved but other people have reported it as still occurring on more recent versions of Unity (I’m on 5.4.3f1 and can’t upgrade right now).
Using FontForge I extracted just the characters I needed from the otf fonts and generated ttf fonts (which are not CID fonts - I was thinking it might be because they are CID fonts). That didn’t help. Then I changed the font information to match the Open Sans fonts (the font family for “SourceHanSans-Bold” was “Source Han Sans Bold” but for “Open Sans Bold” it was just “Open Sans”). Still no luck. I now have two really simple fonts that I expected to work, but aren’t.
Ok I’m pretty sure that the issue is because Unity is not correctly matching up the font family between regular and bold. Source Han Sans is a CID OpenType font, and if you read the OpenType CID font information for the regular and bold variants (e.g. in FontForge) you can see that the family name is correct (“Source Han Sans”) and the weight is correctly set. But if you look at the non-CID font info (Element → Font Info) or the basic font names in Font Lab Studio you can see for the “regular” font the family name is “Source Han Sans Regular” and for the “bold” font the family name is “Source Han Sans Bold”. So based on that font family name, they are two entirely separate fonts.
I also see the same thing happen in Word 2013. If I install those two fonts in Windows 8.1, in the fonts folder they show up as one font with bold and regular variants, but in Word 2013 they show up as two separate fonts, and if I bold the “regular” font it doesn’t look anything like the real bold version.
So check your font family names!
Hi, it has worked for me. With the fontforge change the name of the family and put them the same. I have seen that sometimes the name of the family changes.
I have also had to call them the same name of the file and in unity in the properties of the source to change them too. In my case I added a 2 to the original name and it worked! (google translate sorry)
That’s great, thanks for letting me know! Sounds like fonts are a bit of a mess just generally!