Can I use CSS “unicode-range” to specify a font across an entire (third party) page?

核能气质少年 提交于 2020-12-25 04:45:26

问题


I've never become fluent with CSS but I don't think I had this situation before.

I'm thinking of using stylish to add CSS to a third-party site over which I have no direct control. So the HTML and CSS is not really set up for the kind of customizations I want to do.

The site I wish to tweak doesn't allow good control over fonts but some of its pages (user created) make a lot of use of some exotic Unicode ranges (eg. Khmer) that my OS/browser combination choose a terrible font for:

two muppets

Can I make a CSS rule that will apply to all text in a page that falls within a certain Unicode range to set it to a known good font, without delving into the structure of the page HTML/DOM?

(Or is unicode-range only for doing something different with webfonts?


回答1:


The answer is yes in most browsers

MDN - Unicode Range

The unicode-range CSS descriptor sets the specific range of characters to be downloaded from a font defined by @font-face and made available for use on the current page.

Example:

@font-face {
  font-family: 'Ampersand';
  src: local('Times New Roman');
  unicode-range: U+26;
}

Support: CanIUse.com

Also see this Article




回答2:


unicode-range(s) can be used to specify which specific set (or range) of characters you want to be downloaded from a font in an attempt to save bandwidth. See here: Mozilla unicode-range info

Without seeing the actual CSS you could attempt to just force a different font to be used completely by doing something such as declaring

body{font-family: arial,sans-serif;}    

or adding !important (which I would avoid under any normal circumstance) if the other fonts refuse to give way e.g.

body{font-family: arial,sans-serif !important;}

If you can bypass using the original font faces then the unicode-ranges will cease to be important. Watch out for things like icon-fonts though as removing those may make certain symbols/graphics disappear.

Hope that helps.

Sorry I rather misunderstood your question - thought you wanted rid of the existing unicode fonts altogether.



来源:https://stackoverflow.com/questions/28327035/can-i-use-css-unicode-range-to-specify-a-font-across-an-entire-third-party-p

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!