在我的网站上,我有一个使用"⌙“字符作为内容的::after
css伪元素:
.tags_checks label::after{
content:"⌙"
}
现在它在mac chrome上运行得很好。但是当它显示在windows chrome上时,它是水平翻转的(就像在源代码中一样):
Mac (Chrome DevTools):
Windows (Chrome DevTools):
为什么会这样?我怎样才能让它同时在mac和windows上运行?
发布于 2021-10-27 03:41:58
我写了一个Python脚本用于测试,结果如下(Windows10上的FontGlyphsHtml.py 0x2319
,默认浏览器Chrome)
脚本(在注释中有部分文档):
import unicodedata
import sys
import os
from fontTools.ttLib import TTFont, TTCollection
def char_in_font(unicode_char, font):
for cmap in font['cmap'].tables:
if cmap.isUnicode() or cmap.getEncoding() == 'utf_16_be':
if ord(unicode_char) in cmap.cmap:
auxcn = cmap.cmap[ord(unicode_char)]
return auxcn if auxcn != '' else '<nil>'
return ''
def checkfont(char,font,fontdict,fontpath):
nameID_index = 1 # works generally (not always)
for i,f in enumerate(font['name'].names):
# An Introduction to TrueType Fonts: A look inside the TTF format
# https://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=IWS-Chapter08
# 1 = Font Family name, 2 = Font SubFamily name, 4 = Full font name
if f.nameID == 1:
nameID_index = i
break
fontname = font['name'].names[nameID_index].toStr()
if fontname not in fontdict.keys():
aux = char_in_font(char, font)
if aux != '':
fontdict[fontname] = "{} ({}) {} [{}] '{}'".format(
char,
'0x{:04x}'.format(ord(char)),
unicodedata.name(char, '???'),
aux,
fontname
)
def testfont(char):
fontdict = {}
for fontpath in fontsPaths:
font = TTFont(fontpath) # specify the path to the font
checkfont(char,font,fontdict,fontpath)
for fontpath in fontcPaths: # specify the path to the font collection
fonts = TTCollection(fontpath)
for ii in range(len(fonts)):
font = TTFont(fontpath, fontNumber=ii) # fontfile and index
checkfont(char,font,fontdict,fontpath)
return fontdict
def testprint(char):
chardesc = '0x{:04x}'.format(ord(char)), unicodedata.name(char, '???')
charline = '{} {} '.format( char, chardesc)
print('') # empty line for better readability
print(charline)
outfile.write('\n' + htmchar.format(char, chardesc) + '\n')
fontarray = testfont(char)
for x in fontarray.keys():
print(fontarray[x])
outfile.write(htmline.format(x, fontarray[x]) + '\n')
### if __name__ == '__main__':
fontsPaths = []
fontcPaths = []
fontsdirs = [ os.path.join( os.getenv('SystemRoot'), 'Fonts')
, r"D:\Downloads\MathJax-TeX-fonts-otf"
, r"D:\Downloads\Fonty"
# , r"D:\Downloads\Fonty\KrutiDev010\k010"
# , os.path.join( os.getenv('LOCALAPPDATA'), r'Microsoft\Windows\Fonts')
# , os.path.join( os.getenv('ProgramFiles'), r'WindowsApps\Microsoft.WindowsTerminal_1.4.3243.0_x64__8wekyb3d8bbwe')
]
print(fontsdirs, file=sys.stderr)
for fontsdir in fontsdirs:
for root,dirs,files in os.walk( fontsdir ):
for file in files:
if file.endswith(".ttf") or file.endswith(".otf") or file.endswith(".ttc"):
tfile = os.path.join(root,file)
if file.endswith(".ttc"):
fontcPaths.append(tfile)
else:
fontsPaths.append(tfile)
htmfile = 'CharGlyphs.html' ### ### ### ###
htmpref = '''
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="generator" content="{}"><title></title>
</head><body>
'''.format(os.path.basename(__file__))
htmchar = '<BR>{} <font color="Red">{}</font><BR>' # line
# htmchar = '<BR>{}<BR>' # line
htmline = '<font face="{}">{}</font><BR>' # font, line
htmsuff = '</body></html>'
outfile = open(htmfile, 'w', encoding='utf-8')
outfile.write(htmpref + '\n')
if len(sys.argv) == 1:
testprint(u"अ") # अ 0x0905 Devanagari Letter A
# testprint(u"") # 0x1f63a SMILING CAT FACE WITH OPEN MOUTH
# testprint(u"") # 0x1f408 CAT
# surprising results (characters from the `Private Use` area)
# testprint("\uf0a3")# 0xf0a3 ???
# testprint("\uf098")# 0xf098 ???
# testprint("\uEE79\uED5F") # [uniEE79] 'Segoe MDL2 Assets'
else:
for i in range( 1, len(sys.argv) ):
if len(sys.argv[i]) >=2:
try:
chars = chr(int(sys.argv[i])) # 0x042F or 1071
except:
try:
chars = chr(int(sys.argv[i],16)) # 042F
except:
chars = (sys.argv[i].
encode('raw_unicode_escape').
decode('unicode_escape')) # ➕\U00010A30\u042F\xFE
else:
chars = sys.argv[i] # Я (Cyrillic Capital Letter Ya)
for char in chars:
testprint(char)
outfile.write(htmsuff)
outfile.close()
os.startfile(htmfile)
您可以对自己进行全部签名测试,而不是对摘自UnicodeData.Txt的进行签名。
Char CodePoint Category Description
---- --------- -------- -----------
¬ U+00AC Sm-MathSymbol Not Sign
⌐ U+2310 So-OtherSymbol Reversed Not Sign
⌙ U+2319 So-OtherSymbol Turned Not Sign
⫬ U+2AEC Sm-MathSymbol Double Stroke Not Sign
⫭ U+2AED Sm-MathSymbol Reversed Double Stroke Not Sign
¬ U+FFE2 Sm-MathSymbol Fullwidth Not Sign
https://stackoverflow.com/questions/69734914
复制