查看“︁CSS/字体”︁的源代码
来自康健生活
←
CSS/字体
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
== 格式 == === .otf === === .eot === === .svg === === WOFF === 桌面浏览器 === TTF === 旧版Safari,Android和iOS浏览器的后备版 == onlinefontconverter == == 组合方案 == === 字体命名 === 在中文系统中,字体拥有两种命名,如:<code>"Microsoft YaHei", "微软雅黑"</code>。所以为了避免用户在客户端的某些设置导致中文命名失效,要保守使用: <syntaxhighlight lang="css"> font-family: "Microsoft YaHei", "微软雅黑";</syntaxhighlight> === 中英区分 === 绝大多数中文字体内包含英文和数字,但展示效果不如人意,所以需要“渐进”处理,即先声明英文再声明中文。如: <syntaxhighlight lang="css"> font-family: Arial, "Microsoft YaHei"; </syntaxhighlight> === 客户端系统 === 不同的客户端系统,如 windows、linux、mac 等。 <syntaxhighlight lang="css"> font-family: Helvetica, Tahoma, Arial;</syntaxhighlight> === 向下兼容 === 旧版操作系统存在的字体。 === 补充字体族名称 === 使用字体族名称作为操作系统最后选择字体的方向。如,使用 sans-serif(非衬线体): <syntaxhighlight lang="css"> font-family: Helvetica, Tahoma, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "MicrosoftYaHei", "WenQuanYi Micro Hei", sans-serif;</syntaxhighlight> == 特殊字体解决方案 == === 字体压缩 === * https://www.font-spider.org/ * http://ecomfe.github.io/fontmin/#banner === 转换 === * https://github.com/nfroidure/ttf2woff2 * http://www.fontsquirrel.com/tools/webfont-generator * http://everythingfonts.com/ttf-to-woff2 === 转为 js === * http://cufon.shoqolate.com/generate/ * https://github.com/sorccu/cufon === 异步加载 === == 判断客户端字体 == <syntaxhighlight lang="javascript"> var isSupportFontFamily=function(f){if(typeof f!="string"){return false}var h="Arial";if(f.toLowerCase()==h.toLowerCase()){return true}var e="a";var d=100;var a=100,i=100;var c=document.createElement("canvas");var b=c.getContext("2d");c.width=a;c.height=i;b.textAlign="center";b.fillStyle="black";b.textBaseline="middle";var g=function(j){b.clearRect(0,0,a,i);b.font=d+"px "+j+", "+h;b.fillText(e,a/2,i/2);var k=b.getImageData(0,0,a,i).data;return[].slice.call(k).filter(function(l){return l!=0})};return g(h).join("")!==g(f).join("")};</syntaxhighlight> <syntaxhighlight lang="javascript"> isSupportFontFamily(fontFamily);</syntaxhighlight> == 字体大小 == <syntaxhighlight lang="css"> font: 12px/1.5 Arial; font-family:Arial; font-size:12px; line-height:1.5em; </syntaxhighlight> == 单位 == === px === === pt === 计算公式 <blockquote><pre> pt = 1/72(英寸), px = 1/dpi(英寸) </pre></blockquote> 如果按照 window 的 96dpi 来计算,转换之后是: <blockquote><pre> 1 pt = px * 96/72 = px * 4/3 </pre></blockquote> === Ubuntu dpi === 使用命令: {{shc_out|<syntaxhighlight lang="bash"> xdpyinfo | grep dots</syntaxhighlight>|<syntaxhighlight lang="bash"> resolution: 96x96 dots per inch </syntaxhighlight>|$}} {{shc_out|<syntaxhighlight lang="bash"> xrdb -query | grep dpi</syntaxhighlight>|<syntaxhighlight lang="bash"> Xft.dpi: 96 </syntaxhighlight>|$}} {{shc_out|<syntaxhighlight lang="bash"> xrandr | grep -w connected</syntaxhighlight>|<syntaxhighlight lang="bash"> HDMI-1 connected primary 1920x1080+1920+0 (normal left inverted right x axis y axis) 527mm x 296mm DP-3 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 527mm x 296mm </syntaxhighlight>|$}} 查找监视器尺寸的另一种方法是直接读取其EDID。 安装read-edid软件包并<code>sudo get-edid | parse-edid | grep DisplaySize</code>在终端中运行命令。它的输出将为您提供显示器的实际大小(以毫米为单位)。如果不是,请使用标尺。 == fallback 机制 == == 字体子集化 == * 腾讯:font-spider * 百度:font-min * 阿里巴巴:icon-font font-carrier == error == === 垂直居中偏移问题 === ==== line-height ==== * 可能是使用了奇数字号。 * 可能是字号小于12px。 ==== align-items ==== ==== inline-block段落间有缝隙 ====
此页面嵌入的页面:
模板:Shc out
(
查看源代码
)
模板:Shc out/style.css
(
查看源代码
)
模板:Unknown
(
查看源代码
)
返回
CSS/字体
。
导航菜单
康健生活
搜索
user-page
通知
user-interface-preferences
个人工具
登录
五一
多读书,多运动,多到远处走走,再看看不一样的世界。