{"id":318556,"date":"2020-08-05T16:16:26","date_gmt":"2020-08-05T23:16:26","guid":{"rendered":"https:\/\/css-tricks.com\/?page_id=318556"},"modified":"2020-09-01T08:18:11","modified_gmt":"2020-09-01T15:18:11","slug":"font-synthesis","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/almanac\/properties\/f\/font-synthesis\/","title":{"rendered":"font-synthesis"},"content":{"rendered":"\n
The Let’s take Lato<\/a> from Google Fonts as an example. It says there are 10 different variations of the font.<\/p>\n\n\n\n Each one of those font variations is technically a different font file. If we want to use certain weights and styles, then we’d link those files up so the browser has something to load.<\/p>\n\n\n\n But, not all fonts include files for handling weight and style. In those cases, the browser will “synthesize” the appearance itself. The browser does the best it can, but faux bolding and style sometimes makes text less legible; that is, less legible than a truly designed version. In the mildest of cases, we may see characters overlap. In more severe cases, the text is completely unreadable or might even change the meaning \u2014 as could happen with languages like Chinese, Japanese, Korean and other logographic scripts.<\/p>\n\n\n\n That’s where In plain English, this means It’s worth noting that There may be cases where not allowing the browser to synthesize bold and oblique on an entire language makes sense because either one can obscure characters. Here’s an example pulled from the spec that disables synthesized bold and oblique font faces containing Arabic characters:<\/p>\n\n\n\nfont-systhesis<\/code> property in CSS gives the browser instructions for how to handle font bolded and italicized character when the specified
font-family<\/code> doesn’t include them.<\/p>\n\n\n\n\n\n\n\n
font-synthesis<\/code> comes in. It controls which typefaces the browser is allowed to synthesize.<\/p>\n\n\n
Syntax<\/h3>\n\n\n
.element {\n font-synthesis: none | [ weight || style ];\n}<\/code><\/pre>\n\n\n\n
font-synthesis<\/code> will accept:<\/p>\n\n\n\n
none<\/code><\/li>
weight<\/code> or
style<\/code><\/li>
weight<\/code> and
style<\/code><\/li><\/ul>\n\n\n\n
font-synthesis<\/code> is considered a shorthand property. According to the spec<\/a>, it’s a combination of
font-synthesis-weight<\/code> and
font-synthesis-style<\/code> where both accept values of
auto<\/code> or
none<\/code>. Since it’s possible to get the same effect using the shorthand, that’s probably the best way to go.<\/p>\n\n\n
Values<\/h3>\n\n\n
none<\/code>: Neither bold nor oblique may be synthesized<\/li>
weight<\/code>: Bold may be synthesized by the browser<\/li>
style<\/code>: Oblique may be synthesized by the browser<\/li><\/ul>\n\n\n\n
font-synthesis: none; \/* browser will not synthesize any font faces *\/\nfont-synthesis: style; \/* browser will not synthesize a bold font face *\/\nfont-synthesis: weight; \/* browser will not synthesize an oblique font face *\/\nfont-synthesis: weight style; \/* browser will synthesize bold and oblique faces if they are unavailable *\/<\/code><\/pre>\n\n\n
Usage<\/h3>\n\n\n
font-synthesis<\/code> may be used with all elements, including the
::first-letter<\/a><\/code> and
::first-line<\/a><\/code> pseudo-elements.<\/p>\n\n\n\n
\/* Disables synthetic bolded and obliqued characters in Arabic *\/\n*:lang(ar) { font-synthesis: none; }<\/code><\/pre>\n\n\n
Demo<\/h3>\n\n\n