Prevent browser from using default fonts / backups

I have a web application in which a user can change the font family of the input text area in the WSIWYG style. Now suppose the user enters some Chinese text in the text area, but selects a font that does not support Chinese characters. In my application, I would like the user to see these nasty squares (or something like that) that usually appear when the font does not support the character. Thus, the user will know that the font does not support the language and can choose another. The problem I am facing is that browsers (Firefox 17 and Chrome 23) seem to display the Chinese part of the text in fonts (like Arial) that support these Chinese characters, leading the user to believe that the font they use works fine.

Is there a way (I guess through CSS) to prevent this? Is there a way to make browsers not so “good” just this time?

Thanks in advance.

+7
source share
2 answers

You can intercept the font substitution process by throwing out the catchall font using some equivalent font-family: userChoice, yourCatchAll , where yourCatchAll is a font that has a common character for all characters.

The problem is finding such a font. The LastResort font distributed by the Unicode Consortium would be ideal, as it also visually indicates the character’s category in broad terms, but its EULA does not seem to allow modification. It is debatable whether this relates to building web font formats (e.g. .eot and .woff).

The Unicode BMP Fallback Font seems to have more liberal usage rules, but it displays the character just like its Unicode number in the field (and only supports the base multilingual plane, although it contains all the characters that most people have ever heard of).

+5
source

As another answer already explained, the solution is to use a fallback font that includes “all” unicode code points. However, the tricky part was finding or building one that doesn't weigh a few MB.

A few years later, a lighter backup font solution, Adobe's NotDef font, has now appeared. It shows a box with a cross for 1111998 Unicode code points, is only about 22Kb and uses the SIL OPEN FONT LICENSE Version 1.1 version.

If you do not want to show anything, there is also an Adobe Blank font .

+3
source

All Articles