android – Html.fromHtml函数的“font”标签中有哪些字体?

android – Html.fromHtml函数的“font”标签中有哪些字体?,第1张

概述Html.fromHtml几乎没有关于它支持哪些标签的任何文档. 据说它支持许多网站上的“font”标签(如here),但在此标签中设置“face”属性时,我无法找到可用的字体. 我可以假设哪些字体始终可用?其中哪些仅来自特定的Android版本?某个地方有他们的清单吗? 编辑:似乎答案应该在“/system/etc/fonts.xml”文件中.这是Android 6.0.1上的内容: <fami Html.fromHtml几乎没有关于它支持哪些标签的任何文档.

据说它支持许多网站上的“Font”标签(如here),但在此标签中设置“face”属性时,我无法找到可用的字体.

我可以假设哪些字体始终可用?其中哪些仅来自特定的AndroID版本?某个地方有他们的清单吗?

编辑:似乎答案应该在“/system/etc/Fonts.xml”文件中.这是AndroID 6.0.1上的内容:

<familyset version="22">    <!-- first Font is default -->    <family name="sans-serif">        <Font weight="100" >Roboto-Thin.ttf</Font>        <Font weight="100" >Roboto-ThinItalic.ttf</Font>        <Font weight="300" >Roboto-light.ttf</Font>        <Font weight="300" >Roboto-lightItalic.ttf</Font>        <Font weight="400" >Roboto-Regular.ttf</Font>        <Font weight="400" >Roboto-Italic.ttf</Font>        <Font weight="500" >Roboto-Medium.ttf</Font>        <Font weight="500" >Roboto-MediumItalic.ttf</Font>        <Font weight="900" >Roboto-Black.ttf</Font>        <Font weight="900" >Roboto-BlackItalic.ttf</Font>        <Font weight="700" >Roboto-Bold.ttf</Font>        <Font weight="700" >Roboto-BoldItalic.ttf</Font>    </family>    <!-- Note that aliases must come after the Fonts they reference. -->    <alias name="sans-serif-thin" to="sans-serif" weight="100" />    <alias name="sans-serif-light" to="sans-serif" weight="300" />    <alias name="sans-serif-medium" to="sans-serif" weight="500" />    <alias name="sans-serif-black" to="sans-serif" weight="900" />    <alias name="arial" to="sans-serif" />    <alias name="helvetica" to="sans-serif" />    <alias name="tahoma" to="sans-serif" />    <alias name="verdana" to="sans-serif" />    <family name="sans-serif-condensed">        <Font weight="300" >RobotoCondensed-light.ttf</Font>        <Font weight="300" >RobotoCondensed-lightItalic.ttf</Font>        <Font weight="400" >RobotoCondensed-Regular.ttf</Font>        <Font weight="400" >RobotoCondensed-Italic.ttf</Font>        <Font weight="700" >RobotoCondensed-Bold.ttf</Font>        <Font weight="700" >RobotoCondensed-BoldItalic.ttf</Font>    </family>    <alias name="sans-serif-condensed-light" to="sans-serif-condensed" weight="300" />    <family name="serif">        <Font weight="400" >Notoserif-Regular.ttf</Font>        <Font weight="700" >Notoserif-Bold.ttf</Font>        <Font weight="400" >Notoserif-Italic.ttf</Font>        <Font weight="700" >Notoserif-BoldItalic.ttf</Font>    </family>    <alias name="times" to="serif" />    <alias name="times new roman" to="serif" />    <alias name="palatino" to="serif" />    <alias name="georgia" to="serif" />    <alias name="baskerville" to="serif" />    <alias name="goudy" to="serif" />    <alias name="fantasy" to="serif" />    <alias name="ITC Stone serif" to="serif" />    <family name="monospace">        <Font weight="400" >DroIDSansMono.ttf</Font>    </family>    <alias name="sans-serif-monospace" to="monospace" />    <alias name="monaco" to="monospace" />    <family name="serif-monospace">        <Font weight="400" >CutiveMono.ttf</Font>    </family>    <alias name="courIEr" to="serif-monospace" />    <alias name="courIEr new" to="serif-monospace" />    <family name="casual">        <Font weight="400" >ComingSoon.ttf</Font>    </family>    <family name="cursive">        <Font weight="400" >DancingScript-Regular.ttf</Font>        <Font weight="700" >DancingScript-Bold.ttf</Font>    </family>    <family name="sans-serif-smallcaps">        <Font weight="400" >CarroisGothicSC-Regular.ttf</Font>    </family>    <!-- fallback Fonts -->    <family variant="elegant">        <Font weight="400" >NotoNaskharabic-Regular.ttf</Font>        <Font weight="700" >NotoNaskharabic-Bold.ttf</Font>    </family>    <family variant="compact">        <Font weight="400" >NotoNaskharabicUI-Regular.ttf</Font>        <Font weight="700" >NotoNaskharabicUI-Bold.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansEthiopic-Regular.ttf</Font>        <Font weight="700" >NotoSansEthiopic-Bold.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansHebrew-Regular.ttf</Font>        <Font weight="700" >NotoSansHebrew-Bold.ttf</Font>    </family>    <family variant="elegant">        <Font weight="400" >NotoSansThai-Regular.ttf</Font>        <Font weight="700" >NotoSansThai-Bold.ttf</Font>    </family>    <family variant="compact">        <Font weight="400" >NotoSansThaiui-Regular.ttf</Font>        <Font weight="700" >NotoSansThaiui-Bold.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansArmenian-Regular.ttf</Font>        <Font weight="700" >NotoSansArmenian-Bold.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansGeorgian-Regular.ttf</Font>        <Font weight="700" >NotoSansGeorgian-Bold.ttf</Font>    </family>    <family variant="elegant">        <Font weight="400" >NotoSansDevanagari-Regular.ttf</Font>        <Font weight="700" >NotoSansDevanagari-Bold.ttf</Font>    </family>    <family variant="compact">        <Font weight="400" >NotoSansDevanagariui-Regular.ttf</Font>        <Font weight="700" >NotoSansDevanagariui-Bold.ttf</Font>    </family>    <!-- Gujarati should come after Devanagari -->    <family variant="elegant">        <Font weight="400" >NotoSansGujarati-Regular.ttf</Font>        <Font weight="700" >NotoSansGujarati-Bold.ttf</Font>    </family>    <family variant="compact">        <Font weight="400" >NotoSansGujaratiui-Regular.ttf</Font>        <Font weight="700" >NotoSansGujaratiui-Bold.ttf</Font>    </family>    <!-- Gurmukhi should come after Devanagari -->    <family variant="elegant">        <Font weight="400" >NotoSansGurmukhi-Regular.ttf</Font>        <Font weight="700" >NotoSansGurmukhi-Bold.ttf</Font>    </family>    <family variant="compact">        <Font weight="400" >NotoSansGurmukhiui-Regular.ttf</Font>        <Font weight="700" >NotoSansGurmukhiui-Bold.ttf</Font>    </family>    <family variant="elegant">        <Font weight="400" >NotoSansTamil-Regular.ttf</Font>        <Font weight="700" >NotoSansTamil-Bold.ttf</Font>    </family>    <family variant="compact">        <Font weight="400" >NotoSansTamilUI-Regular.ttf</Font>        <Font weight="700" >NotoSansTamilUI-Bold.ttf</Font>    </family>    <family variant="elegant">        <Font weight="400" >NotoSansMalayalam-Regular.ttf</Font>        <Font weight="700" >NotoSansMalayalam-Bold.ttf</Font>    </family>    <family variant="compact">        <Font weight="400" >NotoSansMalayalamUI-Regular.ttf</Font>        <Font weight="700" >NotoSansMalayalamUI-Bold.ttf</Font>    </family>    <family variant="elegant">        <Font weight="400" >NotoSansBengali-Regular.ttf</Font>        <Font weight="700" >NotoSansBengali-Bold.ttf</Font>    </family>    <family variant="compact">        <Font weight="400" >NotoSansBengaliui-Regular.ttf</Font>        <Font weight="700" >NotoSansBengaliui-Bold.ttf</Font>    </family>    <family variant="elegant">        <Font weight="400" >NotoSansTelugu-Regular.ttf</Font>        <Font weight="700" >NotoSansTelugu-Bold.ttf</Font>    </family>    <family variant="compact">        <Font weight="400" >NotoSansTeluguUI-Regular.ttf</Font>        <Font weight="700" >NotoSansTeluguUI-Bold.ttf</Font>    </family>    <family variant="elegant">        <Font weight="400" >NotoSansKannada-Regular.ttf</Font>        <Font weight="700" >NotoSansKannada-Bold.ttf</Font>    </family>    <family variant="compact">        <Font weight="400" >NotoSansKannadaUI-Regular.ttf</Font>        <Font weight="700" >NotoSansKannadaUI-Bold.ttf</Font>    </family>    <family variant="elegant">        <Font weight="400" >NotoSansOriya-Regular.ttf</Font>        <Font weight="700" >NotoSansOriya-Bold.ttf</Font>    </family>    <family variant="compact">        <Font weight="400" >NotoSansOriyaUI-Regular.ttf</Font>        <Font weight="700" >NotoSansOriyaUI-Bold.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansSinhala-Regular.ttf</Font>        <Font weight="700" >NotoSansSinhala-Bold.ttf</Font>    </family>    <family variant="elegant">        <Font weight="400" >NotoSansKhmer-Regular.ttf</Font>        <Font weight="700" >NotoSansKhmer-Bold.ttf</Font>    </family>    <family variant="compact">        <Font weight="400" >NotoSansKhmerUI-Regular.ttf</Font>        <Font weight="700" >NotoSansKhmerUI-Bold.ttf</Font>    </family>    <family variant="elegant">        <Font weight="400" >NotoSansLao-Regular.ttf</Font>        <Font weight="700" >NotoSansLao-Bold.ttf</Font>    </family>    <family variant="compact">        <Font weight="400" >NotoSansLaoUI-Regular.ttf</Font>        <Font weight="700" >NotoSansLaoUI-Bold.ttf</Font>    </family>    <family variant="elegant">        <Font weight="400" >NotoSansMyanmar-Regular.ttf</Font>        <Font weight="700" >NotoSansMyanmar-Bold.ttf</Font>    </family>    <family variant="compact">        <Font weight="400" >NotoSansMyanmarUI-Regular.ttf</Font>        <Font weight="700" >NotoSansMyanmarUI-Bold.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansThaana-Regular.ttf</Font>        <Font weight="700" >NotoSansThaana-Bold.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansCham-Regular.ttf</Font>        <Font weight="700" >NotoSansCham-Bold.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansBalinese-Regular.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansBamum-Regular.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansBatak-Regular.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansBUGinese-Regular.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansBuhID-Regular.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansCanadianAboriginal-Regular.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansCherokee-Regular.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSanscoptic-Regular.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansGlagolitic-Regular.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansHanunoo-Regular.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansJavanese-Regular.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansKayahli-Regular.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansLepcha-Regular.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSanslimbu-Regular.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSanslisu-Regular.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansMandaic-Regular.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansmeeteiMayek-Regular.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansNewTaiLue-Regular.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansNKo-Regular.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansolChiki-Regular.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansRejang-Regular.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansSaurashtra-Regular.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansSundanese-Regular.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansSylotiNagri-Regular.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansSyriacEstrangela-Regular.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansTagbanwa-Regular.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansTaiTham-Regular.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansTaiVIEt-Regular.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansTibetan-Regular.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansTifinagh-Regular.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansVai-Regular.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansYi-Regular.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansSymbols-Regular-Subsetted.ttf</Font>    </family>    <family lang="zh-Hans">        <Font weight="400" >NotoSansSC-Regular.otf</Font>    </family>    <family lang="zh-Hant">        <Font weight="400" >NotoSansTC-Regular.otf</Font>    </family>    <family lang="ja">        <Font weight="400" >NotoSansJP-Regular.otf</Font>    </family>    <family lang="ko">        <Font weight="400" >NotoSansKR-Regular.otf</Font>    </family>    <family>        <Font weight="400" >NanumGothic.ttf</Font>    </family>    <family>        <Font weight="400" >NotocolorEmoji.ttf</Font>    </family>    <family>        <Font weight="400" >DroIDSansFallback.ttf</Font>    </family>    <family lang="ja">        <Font weight="400" >MTLmr3m.ttf</Font>    </family>    <!--        Tai Le and Mongolian are intentionally kept last,to make sure they don't overrIDe        the East Asian punctuation for Chinese.    -->    <family>        <Font weight="400" >NotoSansTaiLe-Regular.ttf</Font>    </family>    <family>        <Font weight="400" >NotoSansMongolian-Regular.ttf</Font>    </family></familyset>
解决方法 使用“/system/etc/Fonts.xml”文件,我创建了这段代码:

textVIEw.setText(HTML.fromHTML("normal <br/>" +            "<Font face='sans-serif'>sans-serif</Font> <br/>" +            "<Font face='sans-serif-thin'>sans-serif-thin</Font> <br/>" +            "<Font face='sans-serif-light'>sans-serif-light</Font> <br/>" +            "<Font face='sans-serif-medium'>sans-serif-medium</Font> <br/>" +            "<Font face='sans-serif-black'>sans-serif-black</Font> <br/>" +            "<Font face='sans-serif-condensed'>sans-serif-condensed</Font> <br/>" +            "<Font face='sans-serif-condensed-light'>sans-serif-condensed-light</Font> <br/>" +            "<Font face='serif'>serif</Font> <br/>" +            "<Font face='monospace'>monospace</Font> <br/>" +            "<Font face='serif-monospace'>serif-monospace</Font> <br/>" +            "<Font face='casual'>casual</Font> <br/>" +            "<Font face='cursive'>cursive</Font> <br/>" +            "<Font face='sans-serif-smallcaps'>sans-serif-smallcaps</Font> <br/>" +            "<Font face='elegant'>elegant</Font> <br/>" +            "<Font face='compact'>compact</Font> <br/>"    ));

这是结果:

所以似乎所有这些都得到了支持,除了“优雅”和“紧凑”,这似乎不是真正的字体(所以也许我不明白他们的目的).

此外,这是在AndroID 6.0.1上测试的.我想知道它在旧版本上的效果如何,在那里可用,如果在AndroID N中有新的版本.

以下是在AndroID 4.0模拟器上运行此代码的结果:

似乎它没有大多数字体.

以下是我在AndroID 4.1.2中看到的Xperia J:

所以这里似乎有更多的字体可用.

总结

以上是内存溢出为你收集整理的android – Html.fromHtml函数的“font”标签中有哪些字体?全部内容,希望文章能够帮你解决android – Html.fromHtml函数的“font”标签中有哪些字体?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1128100.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-30
下一篇2022-05-30

发表评论

登录后才能评论

评论列表(0条)

    保存