关于css中 font-金年会app官方网
请问为什么css中设置的字体consolas无效?
- 此前在一部电脑上字体正常显示,回家之后用另一部电脑打开就无法生效了
- 已经检查系统安装了此字体,修改为其他字体也无法生效;
- 请教了前端朋友也看不出问题在哪
- 是否与浏览器兼容性有关?该如何修改?
<html lang="en">
<head>
<meta charset="utf-8">
<title>test filetitle>
<link rel="stylesheet" href="./csshighlight.css">
head>
<body>
<pre class="code-block"><code>
;;
procedure(y_getheight(vianame @optional d_tech(techgettechfile(ddgetobj(gegeteditcellview()->libname))) outcutparam(nil) "tdg")
let((viaparam cutlppw maxenc height)
viaparam = car(setof(x d_tech->viadefs x->name == vianame))->params
unless(viaparam error("* cannot get via params - %a of %s from %s \n" viaparam vianame d_tech->libname))
cutlppw = nth(1 viaparam)
maxenc = max(car(nth(6 viaparam)) car(nth(7 viaparam)))
if(outcutparam then
list(height = cutlppw 2*maxenc list(cutlppw car(nth(5 viaparam))))
else
height = cutlppw 2*maxenc
)
);end let
);end proc
code>pre>
<script src="lisp_highlighter.js">script>
body>
html>
/* lisp-highlight.css */
.code-block {
background-color: rgba(244, 244, 244, 0.2);
border: 1px solid rgb(221, 221, 221);
border-radius: 8px;
padding: 10px;
font-family: "consolas", monospace !important;
font-size: 18px;
white-space: pre;
overflow-x: auto;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
}
.lisp-keyword {
color: rgb(158, 24, 232);
}
.lisp-function {
color: rgb(223, 150, 135);
}
.lisp-string {
color: rgb(36, 187, 105);
}
.lisp-comment {
color: rgb(187, 38, 37);
}
// lisp-highlighter.js
document.addeventlistener('domcontentloaded', function() {
// 定义lisp关键字和函数名
const lispkeywordsandfunctions = ['procedure', 'let', 'if', 'then', 'else', 'cond', 'prog', 'car', 'cdr', 'nth',
'techgettechfile', 'ddgetobj', 'setof', 'unless', 'max', 'min', 'when', 'while', 'for', 'case', 'list',
'optional', 'gegeteditcellview', 'gegetselset', 'error', 'warn', 'abs', 'centerbox', 'rexmatchp', 'foreach',
'mapcar', 'sort', 'artmakestring', 'evenp', 'oddp', 'nthelem', 'lessp', 'ciutilsmakeunique', 'maketable',
'dbgettrueoverlaps', 'cadr', 'xcoord', 'ycoord', 'cons', 'append', 'append1', 'dbtransformbbox', 'apply',
'uppercase', 'lowercase', 'dbcreaterect', 'dbcreatevia', 'techfindviadefbyname', 'fix', 'infile', 'outfile',
'gets', 'print', 'printf', 'println', 'sprintf', 'fprintf', 'isfile', 'isfilename', 'isdir', 'close',
'parsestring', 'symboltostring', 'stringtosymbol', 'substring', 'index', 'strcat', 'last', 'xcons', 'remove', 'member',
'stringp', 'blankstrp', 'artblankstring', 'buildstring', 'parsestring', 'evalstring', 'atof', 'atoi', 'artmakestring', 'symboltostring', 'stringtosymbol', 'substring', 'index', 'nindex', 'rindex', 'strcmp', 'strncmp', 'getchar', 'strcat', 'strncat', 'strlen', 'strpbrk', 'aelnumber',
];
// 创建用于匹配的正则表达式
const keywordandfunctionregex = new regexp('\\b(' lispkeywordsandfunctions.join('|') ')\\b', 'g');
const singlelinecommentregex = /;.*/g; // 匹配分号开始到行尾的任何字符
const multilinecommentregex = /\/\*[\s\s]*?\*\//g; // 匹配/* */之间的任何字符,包括换行
const stringregex = /"(?:\\.|[^"\\])*"/g; // 匹配双引号内的字符串,考虑转义字符
// 选择所有需要高亮的代码块
const codeblocks = document.queryselectorall('pre.code-block code');
codeblocks.foreach(block => {
let code = block.textcontent;
// 替换多行注释
// code = code.replace(multilinecommentregex, '$&');
// 替换单行注释
// code = code.replace(singlelinecommentregex, '$&');
// 替换字符串
code = code.replace(stringregex, '$&');
// 替换关键字和函数名
code = code.replace(keywordandfunctionregex, '$&');
block.innerhtml = code;
});
});