What's wrong with Java FX's bold handling? - javafx

Getting a bold label in JavaFX should be as simple as:
<Label text="Some bold text" style='-fx-font-weight: bold'/>
but it seems it is not.
Looking thru some Q&A in stackoverflow i found:
Javafx font derive bold
FXML Label text bold
Using Arial Unicode MS BOLD in JavaFX
Java FX: Bold and Italic styles are not getting applied for some of the font families
which show that people get mixed mileage. There are a few thousand views on most of these questions but only a few upvotes and comments with mixed results. In some contexts things seem to run fine in others not at all. Unfortunately i am on the "not at all" side on my Mac OS High Sierra with
java version "1.8.0_152"
So i wonder what the reason is that things do not work "out of the box" and whether there is a valid platform independent work-around or we just have to put up with this unhappy situation.

Bugs:
https://bugs.openjdk.java.net/browse/JDK-8185569
https://bugs.openjdk.java.net/browse/JDK-8176835
https://bugs.openjdk.java.net/browse/JDK-8222624
to work around it set a default font that supports bold in your css e.g.
.root{
-fx-font-size: 14pt;
-fx-font-family: "Arial";
}

Related

Rendered text looks very different in Qt and Blink, although same font is set

The upper font is from a QLabel with QFont("Arial").
The lower font is rendered with QWebEngine, e.g. Chromium/Blink backend, using css
font-family: Arial, Helvetica, sans-serif;
font-size: 8pt;
Is there a way to make the blink one look as dark and sharp as the Qt one? It looks blurry and as both texts in the app are placed next to each other, it does not look good enough.
(Qt5.8 msvc 2015 on windows 8.1)
Edit
The reason is that chromium since version 52 did drop GDI support. In former version GDI rendering could be activated by disabling the DirectWrite flag. So basically I need to recompile Qt with a different chromium backend. Or perhaps with Cent Browser because it still supports that flag despite using newest chromium.
First get the font family using QFontInfo::family().
This function returns matched family name of windows system font.
QFont f("Arial");
QFontInfo info(f);
QString family = info.family();
In simple terms "QFontInfo object is used to determine the attributes of the font actually used in the window system."
Use the family name returned by QFontInfo and set the same for QWebEngine by QWebEngineSettings::setFontFamily or using CSS.
useful links:
http://doc.qt.io/qt-5/qfontinfo.html#family
http://doc.qt.io/qt-5/qwebenginesettings.html#setFontFamily

CSS Webfont not rendering missing character

I'm using the "Quicksand" font for a web project (http://www.google.com/fonts/specimen/Quicksand) and I've a problem : the ² character doesn't exist for that font. I thought that it would be rendered in other fonts (written after Quicksand in the font-family property), but it is not. When I write ², the only thing rendered is a white space.
Is there a way to render not supported characters by other fonts ?
Here's the CSS used :
font-family: "Quicksand", Helvetica, Arial, sans-serif;
There is a bug in the Quicksand font: for the Unicode code position U+00B2, SUPERSCRIPT TWO, it has an empty glyph. It is 396 units wide, so it is wider than a normal SPACE (300 units) in the font. Another character with a similar problem is U+201A SINGLE LOW-9 QUOTATION MARK “‚”, which has an empty glyph 230 units wide.
In principle, you could circumvent the bug by using unicode-range in a #font-face rule to specify that a particular character be taken from a different font. However, browser support is still too limited (and the approach would require that you host the font files instead of using them from the Google server).
Another possibility would be to edit the font. This requires a font editor and a permission from the copyright holder (and your hosting the font files of course).
A third option is to wrap each occurrence of “²” in a span element with a class and setting font-family on them suitably. Beware that this means mixing glyphs from different fonts, which should be avoided in good typography.
Finally, consider using a different font. There are several questions about rendering problems with the Quicksand font at SO.

Chrome can't estimate bold font-weight

Many fonts on Font-Squirrel (Afta Sans, etc) and Google Fonts don't include bold "specimens" of a given font set. Chrome doesn't seem to be able to estimate bold weights as Firefox, Safari, and even IE do. I've looked at this for quite a while, doubting that chrome, of all browsers, wouldn't have this capability. This seems to be quite limiting for the available fonts we can use, am I wrong?
This also seems to add unnecessary file size to font files when an estimated bold look would do.
Afta Sans, at least as distributed via Font Squirrel, does not have a bold typeface at all. That’s why there are no specimens of Afta Sans as bold.
If you still request, via HTML or CSS, a bold typeface, most browsers will synthesize bold glyphs from regular typeface glyphs by algorithmically bolding them. This is not a requirement, just what browsers tend to do. The CSS Fonts Module Level 3 CR says, in describing font-weight: “Although the practice is not well-loved by typographers, bold faces are often synthesized by user agents for faces that lack actual bold faces. For the purposes of style matching, these faces must be treated as if they exist within the family. Authors can explicitly avoid this behavior by using the ‘font-synthesis’ property.”
If you mean that some browser version on some platform does not do synthetic bolding, then that’s a decision by the browser vendor. In theory you could use the font-synthesis property to explicitly request for synthesis, but in practice it hardly affects anything; the defined initial value of the property means that synthetic bolding is allowed and, besides, most browsers do not support this property at all.
But the current version (33) Chrome on Windows does synthetic bolding.
If you are referring to the quality of synthetic bolding, then that’s inevitably browser-dependent. The page Say No to Faux Bold says: “What your users see can be better or worse depending on their browser and the fonts you start with. Some browsers, like Firefox, smear their bolds more, making a mess of display type. Other browsers, such as Chrome, smear their bolds very little, so that the distinction between bold and normal can be lost. None of these faux faces come close to what you can get from a real font.”

<strong> tag not showing up in Chrome but does show up in all other browsers

I am working for a client and have updated her site with a new font. The problem is the tag is working for all browsers except Chrome.
Any ideas why this might be happening? Site is http://passionatepennypincher.com.
I have researched it and tried several things, i.e., strong {font-weight: bold;} but this does not work. I would be grateful for any help. Thank you!
It is working (checked in Chrome on OSX).
Looks like you're using font replacement with a typeface that doesn't respond especially well to having a bold style applied to it.
To double check bold is definitely working, swap out the Inder font for a web-safe alternative (e.g. Arial), if the bold is more prominent/visible using Arial, you know it's just the Inder font.
S
I've just had a look at the site in Chrome and the text in tags is showing up for me.
The text on the homepage is 'Here are the top retail coupons available this week, thanks to Your Retail Helper! ' and I can see the tags in the source and the text is showing in a bold weight.
<p><strong>Here are the top retail coupons available this week, thanks to Your Retail Helper!</strong> Check out my favorites below, but be sure to visit Your Retail Helper for the complete list of deals:</p>
I met the same problem in my chrome. I think it is a problem of font. So i change my standard font("STHeiti") to try to improve my guess. I found when i change the font to the font-family which is without "heiti" in its names, <strong> was working. And i also change my other browser's standard font to the font family which named like "xxheiti" and "heitixx", then <strong> was working no longer.
So, i found the "heiti" font family(e.g. STheiti, Heiti SC, Heiti TC etc.) is the “criminal” of this problem, <strong> is not effective in the "heiti" font. The "heiti" is chinese pronunciation of “bold”.
In other words <strong> tag is not working in the browser which standard font is set to any "heiti" because those font families already have the meaning of "bold". It is the ultimate reason why <strong> was not showing up in your chrome.

Attempting to use Segoe font in browser

I want to render a page with fonts mostly being font-family:"Segoe" (that line goes in the appropriate class selectors which I've verified are working), however I get back a standard font (times new roman I think). Why won't it work? I am on Windows-7 64 bit so it's installed.
The name is "Segoe UI" not "Segoe". Change that and it will work.

Resources