Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What property in a font file makes a program decide to simulate bold?

Tags:

.net

wpf

fonts

I am looking for a property in a font file (either from WPF's System.Windows.Media.Fonts Typeface or GlyphTypeface) or directly accessing the .ttf/.otf file that will allow me to determine if a program like Write/WordPad in Windows will apply Bold to the font. Basically, some fonts that have the Bold attribute will still get an extra boldness applied to them and some won't. I'm trying to discover what the logic is that is used to make this determination.

To manually see this, copy and the paste the following into Write/WordPad (or OOo's Writer or MS Word or...) and change each line's font face to it's name (i.e. apply Arial Black to Arial Black)

  1. Arial Black
  2. Arial Rounded MT Bold
  3. Arial Narrow

Now apply bold to them. You'll see #2 and #3 change, but not #1.

With #3 though, something different is happening than the other two - a different font all together is being applied. Namely ARIALNB .TTF ('NB' appended, which is Arial Narrow Bold) in place of ARIALN.TTF ('N' appended, which is Arial Narrow). So in the case of this font, bold is not actually being applied.

Back to the list. #1 doesn't change, but #2 does. #1's weight is "Black" and #2's is "Bold". If you were to take the Bold version of #3, ARIALNB.TTF, and apply bold to it, it would act like #1 - it wouldn't change. But it has the same weight as #2, that of "Bold".

In other words, two are bold (Arial Rounded MT Bold and Arrow Narrow Bold), but only Arial Rounded MT Bold gets more bold applied. In the case of Arial Black, it doesn't have a Bold weight, but it still doesn't have a bold applied to it either.

Here's what it looks like: alt text

Interestingly, WPF doesn't exhibit this behavior (i.e adding more bold), but Silverlight does:

WPF (Note the FontFamily is "Arial Rounded MT"):

<StackPanel Orientation="Vertical">
    <TextBlock FontSize="24" Text="Arial Rounded MT Bold" FontFamily="Arial Rounded MT"/>
    <TextBlock FontSize="24" Text="Arial Rounded MT Bold" FontWeight="Black" FontFamily="Arial Rounded MT"/>
</StackPanel>

Silverlight (Note the FontFamily is "Arial Rounded MT Bold"):

<StackPanel Orientation="Vertical">
    <TextBlock  FontSize="24" FontFamily="Arial Rounded MT Bold" >Arial Rounded MT Bold</TextBlock>
    <TextBlock  FontSize="24" FontFamily="Arial Rounded MT Bold" FontWeight="Bold" >Arial Rounded MT Bold</TextBlock>
</StackPanel>

The question comes back to: What property of a font file tells a program to add more bold or not? I'm seeking a flag or a property within the font file that will tell me this logic.

Here's a list of other fonts where applying "Bold" has no effect: - Adobe Caslon Pro Bold - Adobe Garamond Pro Bold - Andy - Arial Black - Bell Gothic Std Black - Bell Gothic Light Black - Berlin Sans FB Demi - Blackoak Std - Bodoni MT Black - Charlemagne Std - Minion Pro Cond - Moire ExtraBold - Myriad Pro Light - Poplar Std - Prestige Elite Std - Rockwell Extra Bold - Script MT Bold - Segoe WP Black - Tekton Pro Ext - Stencil Std

like image 412
Todd Main Avatar asked Sep 08 '10 23:09

Todd Main


1 Answers

Through an enormous amount of trials, I've figured it out. From the OS/2 table, most programs look at 2 values:

  1. If usWeightClass has a value of 549 or below, the font will be made more bold.
  2. If fsSelection has bit 5 set, it will never be made more bold, regardless of the value in usWeightClass (#1 above).
like image 108
Todd Main Avatar answered Sep 30 '22 07:09

Todd Main