带有空格的字体在CKEditor中未正确应用

问题描述 投票:1回答:3

由于这篇文章How can I add(programatically) google fonts to ckeditor,我能够将Google字体添加到我的ckeditor中。但是,我想添加字体“ Goudy Bookletter 1911”,并且此字体显示不正确。我检查了元素,并将其更改为font-family: goudy bookletter 1911时,其样式为font-family: 'goudy bookletter 1911'。谁知道我该如何编辑ckeditor,以便在应用字体样式时添加引号?谢谢!

javascript css ckeditor google-webfonts
3个回答
1
投票

http://ckeditor.com/forums/CKEditor-3.x/Ckeditor-external-fonts-problem

ckeditor网站上的这篇文章可能会解决您的问题...


0
投票

由于我无法确定如何在config.font_names列表中添加引号而不会导致js错误,并且我只对字体Goudy Bookletter 1911有问题,因此我通过在列表中添加camelCased名称来解决此问题,因此它看起来像这个:

config.font_names = "Arial/Arial, Helvetica, sans-serif;Glass Antiqua;Goudy Bookletter 1911/GoudyBookletter1911;"

我无法将每个带有空格的Google字体都更改为camelCase,因为Google会在字体名称后加上“ -Regular”之类的名称,但这暂时解决了我的问题。如果您有更好的主意,请告诉我!


0
投票

对于CkEditor 5:fontFamily / utils中的normalizeFontNameForCSS添加了额外的引号。您可以通过创建自定义版本来更改它,但是如果仅出于此目的,则很耗时

function normalizeFontNameForCSS( fontName ) {
    fontName = fontName.trim();

    // Compound font names should be quoted.
    if ( fontName.indexOf( ' ' ) > 0 ) {
        fontName = `'${ fontName }'`; // ==> fontName = `${ fontName }`
    }

    return fontName;
}
© www.soinside.com 2019 - 2024. All rights reserved.