"Bold" style is not available for "Sans Serif" font on QT5 - qt

We just moved our application from QT4 to QT5. We found the "Bold" style is not avialble for "Sans Serif" font on QT5. I can tell from the QFontDialog which looks below:
I also use the following code to dump all available styles under "Sans Serif"
QFontDatabase db;
auto list = db.styles("Sans Serif");
for(auto& l : list)
std::cout << l << " ";
And I got the same list which is Normal, Italic and Oblique. However I can see the Bold and Bold Italic options on QT4.
My question is how the mapping from font to font style is implemented. Am I able to configure something to make the "Bold" avalialble for "Sans Serif" font in QT5.

Is it possible that is selects a different font? (note, Sans Serif is a general name, actual font associated may differ from system to system, from what was included into distribution of OS, from hardware, or from version to version of Qt).
At least when dealing with QSS styles, with Qt Quick and etc. it follows same rules as LaTex, where Sans Serif and Bold combinations are deprecated (actually Italic is too, it is same as just choose an Italic font). If you want an equivalent , you likely have to use Helvetica with Bold style (Helvetica is the usual typeface behind Sans Serif).
This is really depending on OS configuration.

Related

angular material typography - customisation

In customizing my angular material theme's typography. I understand that one can override the default font with their own font like so:
$custom-typography: mat-typography-config(
$font-family: 'Lato, monospace'
);
Although, I noticed that the source code shows two fonts , the default Roboto, and then Helvetica is also included in inverted commas:
$font-family: 'Roboto, "Helvetica Neue", sans-serif',
Is that a secondary font? I would like if I could choose a secondary font. If this is not a secondary font, what is it?
thanks
The font-family property can hold several font names as a "fallback" system. If the browser does not support the first font, it tries the next font.
Start with the font you want, and always end with a generic family, to let the browser pick a similar font in the generic family, if no other fonts are available.
Note: Separate each value with a comma.
Note: If a font name contains white-space, it must be quoted. Single quotes must be used when using the "style" attribute in HTML.
Copied from w3schools

How to specify the system’s default serif and sans-serif font-family?

When I learned CSS over a decade ago, the standard (and only) way to use the "default fonts" (whatever that means) was:
font-family: serif;
font-family: sans-serif;
Then, last year, Apple added a custom syntax for their new system font, and Blink did something similar if I remember correctly.
Can someone who's more up-to-date with CSS summarize how my font-family property should look like when I just want the default sans-serif or serif font? (I specifically don't want webfonts.)
The CSS Fonts Module Level 4 draft introduces new generic font families
For most languages and scripts, existing generics can be mapped to
something comparable to that script. That’s useful for the web so that
generics like serif and sans-serif map to something reasonable
independent of the language of the content. But typographic traditions
vary widely across the world and many scripts have a variety of common
typeface designs that don’t map cleanly into these existing generics.
In situations where a similar typeface is used across a wide variety
of platforms, it’s useful to extend the set of predefined CSS generic
font families to cover these type styles.
If you want to get "the font that feels the least out-of-place on the target platfom", that would be system-ui:
system-ui font family representing the default UI font on a
given platform
Here is a css snippet to default to system font, on most platforms (OSX, iOS, Windows, Windows Phone, Android):
font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto;
-apple-system — San Francisco in Safari (on Mac OS X and iOS); Neue Helvetica and Lucida Grande on older versions of Mac OS X.
system-ui — default UI font on a given platform.
BlinkMacSystemFont — equivalent of -apple-system, for Chrome on Mac OS X.
"Segoe UI" — Windows (Vista+) and Windows Phone.
Roboto — Android (Ice Cream Sandwich (4.0)+) and Chrome OS.
Snippet itself, borrowed from the following issue on github.
You can look up fonts for other OS or older versions of them in this article on css-tricks.

Setting a specific font using CSS

The Liberation Sans Narrow font is included with many versions of Microsoft Windows. It is a discrete font, defined by the file LiberationSansNarrow-Regular.ttf.
How, in CSS, can this font be specified? Simply specifying:
font-family: "Liberation Sans Narrow";
will not work.
Note that specifying:
font-family: "Liberation Sans";
will work to specify the Liberation Sans font, which is defined by a different TrueType font file.
I only need the CSS code to work in Firefox. It is perfectly acceptable (and expected) that it will only work in browsers running on systems that have that specific font installed.
Note that I don't want to approximate Liberation Sans Narrow; I want that specific font to be used due to the clarity of rendering.
I want to specify this font for modifying the chrome within Firefox using userChrome.css.
it depends on how the file has been included in the page.
1) font included through url then the file would have the font name used for it. we need to use the same font name
2) font included locally through the font-face then we need to use the name we mention to that font

Same font renders differently across FF7 and Chrome

Screenshot: http://i.imgur.com/QVBGx.png
It is pretty evident that my site renders different on Chrome and FF7 on my Win7 machine
I am using this:
h1, h2 {font-family: "Lucida Grande", "Helvetica Neue", Arial; }
Does anybody can point me how can I even these diffs? I don't want fonts with different 'feelings' on each browser.
The font, Lucida Grande is installed in my Windows machine
EDIT:
font-weight: normal !important
doesn't work either
It looks like the two browsers are rendering it with a different weight.
I can think of two possibilities, though I don't know if either are correct.
You requested a bold font, but that font is not available in bold. One browser is just showing the regular, non-bold variant unchanged, whereas the other has processed it to look bold.
You requested a particular weight of font, say "bold" or "600" but the installed fonts do not precisely match that weighting. One browser is substituting an "extra-bold" variant of font, and the other a "regular-bold", or something of this nature.
If either of these is correct you could play around with the font-weight CSS property to try and alter it. But then that may affect substitution of whichever font is chosen in the case that it is viewed on a system with no Lucida Grande font at all.
Fonts will always render slightly different from one browser to another, but that was a bit more difference than usual. Probably because the headers have font-weight: bold; as default, and the font doesn't have a bold variation so the browsers create the bold style from the regular weight in different ways.
Anyway, you might want to use more common fonts. On my Windows 7 machine there is neither Lucida Grande nor Helvetica Neue, so it would render using Arial. Still, I have the additional fonts that come with both MS Office and Photoshop, so I have a lot more fonts installed than you can expect from a standard system.
Also, you should always specify a generic font as the last resort, in this case sans serif, otherwise it would render using the default font if none of the fonts are installed, which is something like Times Roman which has a completely different look. Perhaps also adding Helvetica, which is the closest equivalent of Arial on non-Windows systems.

In Adobe Flex, why does an embedded version of a font, behave differently from the same font installed in the system

Scenario:
Flex application utilizing an #font-face declaration for embedding the font. (Embedded fonts are required to be able to rotate text.)
The application was originally developed as an English application, but during localization it became necessary to locate a unicode font capable of displaying Asian characters. The original implementation of the application uses four fonts to satisfy the various permutations of character emphasis. Bold, Bold Italic, Italic and Normal are all supplied through the corresponding Arial fonts in the Arial family.
Problem:
When trying to compile in the font as one that could be used for the bold, italic, and bold italic through something like (yes its not ideal, this was just a test to see if it could be done):
#font-face { src:url("/fonts/ArialUnicode.ttf");
fontFamily: myFamily;
fontWeight: normal;
fontStyle: normal;
advancedAntiAliasing: true; }
#font-face { src:url("/fonts/ArialUnicode.ttf");
fontFamily: myFamily;
fontWeight: bold;
fontStyle: normal;
advancedAntiAliasing: true; }
etc.
The problem is that when compiling the application Flex gets cranky and gives the following error message:
[ERROR] /dirpath/Style.css:[49,-1] exception during transcoding: Font for alias 'myFont' with italic style was not found at: file:/dirpath/fonts/ArialUnicode.ttf
So with some investigation it was determined that since Unicode supports neither Italics nor Bold, that when the Flex compiler attempts to embed the font, it gets unhappy as it cannot locate a font at the specified location that will satisfy the css requirement.
Now when the font-face declaration is taken back to its simplest form of:
#font-face { src:url("/fonts/ArialUnicode.ttf");
fontFamily: myFamily;
fontWeight: normal;
fontStyle: normal;
advancedAntiAliasing: true; }
everything compiles fine and the application displays all normal weight, normal style Asian characters fine. However when displaying things that are to be displayed in Bold or Italic in the style sheet, a box appears denoting that there is no embedded font nor any system font that can render that character in those styles.
Now here is where it gets weird.
If the exact same Unicode font is installed onto the system, it begins displaying the Asian characters in bold and italic. This makes no sense as the Bold and Italic characters are not in the font as demonstrated when Flex tried to embed that font to satisfy those css styles above. Yet it is evident that this font is being utilized to display the bold and italic characters as before they were just boxes before it was installed as a system font. Is this some kind of Flex voodoo? And if so is there some way I can programmatically invoke said voodoo as I cannot rely on the user having to go out and get the unicode font installed on their system.
Edit:
Here is some further information that may clarify the issue.
My question is not really how do we do multiple font faces and weights for roman characters, it is "How does Flex apply bolding and italics to a system font. Even more so when it says that that font does not support those when trying to embed that font."
The steps to make the issue reproducable are such:
Embed only MS Arial Unicode into the application and deploy it.
On a fresh Windows 2003 machine, open up Firefox and select Japanese language.
Navigate to the application URL and view the boxes where the bold and italics should be.
Now exit Firefox. Install the MS Arial Unicode font into the Windows 2003 system.
Open Firefox and repeat. The areas that used to be boxes, are now bold/bold italics/italics Japanese characters.
It isn't so much the how to solve this issue. There are plenty of viable solutions. However what I would really like to know is how does Flex apply bold and italics to a font that it says does not support bold or italics.
Thanks,
C
The problem is that you're specifying the same file name for all four font variants. The single ArialUnicode.ttf file contains only one variant.
Using the names from your c:\Windows\fonts directory, you want to embed arial.ttf, arialbd.ttf, arialbi.ttf, and ariali.ttf. These are the normal, bold, bold-italic and italic variants, respectively.
Beware that not all fonts can be embedded freely, both from a technical standpoint and from a legal standpoint.
The legal side is that fonts are software, and so need to be licensed just like any other third-party code you include in your program. You might want to look at the Bitstream Vera font family, as they are liberally-licensed. The family is highly capable, designed to be used as core fonts in Linux and such.
The technical side is that these rules are baked into the TTF and OTF file formats, and tools like the Flex compiler obey the license restrictions declared in the file. If the font is marked "no embed", it won't let you embed it.

Resources