禁用字体连字CSS(字母组合)

时间:2016-09-15 06:57:02

标签: css google-chrome fonts

现代浏览器会自动将一些字母组​​合在一起,最常见的是“f”和“i”组合成一个称为连字的单个字符。这通常可以优化易读性(即更容易阅读),但有时这可能不是设计师想要的。

就个人而言,我只在 Chrome (版本53.0.2785.101)中遇到此问题,我虽然无法确定,但我认为此问题在所有其他版本的Chrome中仍然存在。

Sample text in Chrome 多次合并 f i

Sample text in Edge

IE11 Sample text in IE

在这种情况下,我正在寻找一种方法来关闭它。

3 个答案:

答案 0 :(得分:9)

事实证明,这绝对是可能的,它只需要一些挖掘。正如MDN, you can turn off common ligatures所述:

font-feature-settings: "liga" 0;

然而,这是通过使用一个不起眼的css属性来完成的。相反,您应该使用font-variant-ligatures,如下所示:

font-variant-ligatures: none;

这两个属性完全相同,但建议使用后者。

MDN:

  

注意:Web作者应尽可能使用font-variant速记属性或关联的longhand属性,font-variant-ligatures,font-variant-caps,font-variant-east-asian,font-variant-alternates, font-variant-numeric或font-variant-position。

     

此属性是一个低级功能,旨在处理无法启用或访问OpenType字体功能的特殊情况。

     

特别是,这个CSS属性不应该用于启用小型上限。

答案 1 :(得分:2)

我遇到了类似的问题,并由Google执导。 我从不想在任何网页上使用连字。 (当我将网页打印为PDF并在我的PDF阅读器上使用文字转语音引擎时,它会跳过讲述连字。) 这是一个适合我的解决方案:

在Chrome / linux上打开网页(也可以在其他桌面操作系统上运行)。 安装Google Chrome的StyleBot扩展程序。然后,在其选项中,单击"样式"然后编辑全局样式表"。输入以下内容(基于@AwesomeGuy的答案)。

body {
font-variant-ligatures: none;
font-feature-settings: "liga" 0;
}

点击"启用全局样式表"。瞧,Chrome似乎再也不会渲染连字(它会分别渲染字符)。 此外,当我要求Chrome将网页打印为PDF时,字符会单独呈现。

答案 2 :(得分:0)

将其添加为书签,并在打印时单击一次。

javascript: void(function () {
    var css = `
    * {
        font-variant-ligatures: none!important;
        font-feature-settings: "liga" 0!important;
    }
    `;
    var head = document.head || document.getElementsByTagName('head')[0];
    var style = document.createElement('style');
    style.type = 'text/css';
    if (style.styleSheet) {
        /*This is required for IE8 and below.*/
        style.styleSheet.cssText = css;
    } else {
        style.appendChild(document.createTextNode(css));
    }
    head.appendChild(style);
    /*It is not necessary to set a delay.*/
    setTimeout(function () {
        window.print();
    }, 2000);
})()

将Javascript小程序添加到Chrome的书签

https://clicknathan.com/2010/07/12/how-to-add-javascript-applets-to-as-google-chrome-bookmarks/

Open a New Tab in Chrome. Command+T on a Mac, Ctrl+T on a Windows.
Google Toolbar as seen in Chrome's New TabRight click on the Bookmarks Toolbar. It’s a gray colored box like the one pictured here.
Select “Add Page” from the contextual menu that appears.
Give the Bookmark a name. You could Google “Baby Names” if you can’t come up with one. I like Shepherd or Samson or even Samsonite if you have aspirations of a career in luggage design, sales or airport security.
Paste the Javascript applet into the URL field.
Save that son of a gun and you’re on your way to finishing this tutorial!
相关问题