简体   繁体   中英

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

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?

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

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 eg

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM