在javascript中获取可用字体列表作为组合框

时间:2015-03-09 14:17:47

标签: android html css fonts

我需要获取所有可用字体的列表,以便在组合框下显示它们。 当用户选择字体时 - >所选文本应根据其选择而更改。 我的问题是我没有找到一个完整的列表,其中包含我使用chrome浏览器获得的所有字体作为示例。

我指的是我不需要下载的家庭字体,例如#34; David"," Times New Roman"等?

我应该在哪里获得这么详细的清单。

我的实施:

 var getFontsFamily = function () {
    var fonts = [];

    var cursiveFont = new ComboBoxElement("cursive", "cursive");
    fonts.push(cursiveFont);

    var fantasyFont = new ComboBoxElement("fantasy", "fantasy");
    fonts.push(fantasyFont);

    var initialFont = new ComboBoxElement("initial", "initial");
    fonts.push(initialFont);

    var monospaceFont = new ComboBoxElement("monospace", "monospace");
    fonts.push(monospaceFont);

    var sanSerifFont = new ComboBoxElement("sans-serif", "sans-serif");
    fonts.push(sanSerifFont);

    var serifFont = new ComboBoxElement("serif", "serif");
    fonts.push(serifFont);

    return fonts;
};

在我的控制器中: $ scope.fonts = helperCtrl.getFontsFamily();

在我的HTML中:

 <div class="customizedSelect">
    <select id="groupSelection" 
ng-model="selectedText.fontFamily" ng-options="font.type as font.value for font in fonts"></select>
 </div>


<div ng-class="{bold : item.isBold == true}" style="color:{{item.textColor}}; font-size:{{item.size}}pt; font-family:{{item.fontFamily}}">{{item.text}}</div>

此外,我需要这些字体将在android中显示为连接web和android之间的平台。 safeweb字体是否是跨平台的?

1 个答案:

答案 0 :(得分:0)

我找到了这个清单: http://en.wikipedia.org/wiki/Font_family_(HTML)

我希望它足够好。