[英]Replace Android Default Font File
Most solutions I read for a over-all app custom-font, is to make a custom class to be used. 我阅读的有关整体应用程序自定义字体的大多数解决方案是使自定义类被使用。 like this [Question Link] 像这样[问题链接]
I'm not looking forward for that fancy solution, but rather I want to know how can I replace the fonts used by android. 我不希望有这个花哨的解决方案,而是想知道如何替换android使用的字体。 I am currently using 我目前正在使用
<item name="android:fontFamily">sans-serif-condensed</item>
to select a font, where there are only few options as default by Android SDK. 选择字体,Android SDK默认只有很少的选项。 I want to replace the file where that sans-serif-condensed
are located so my the new font I placed would be the one to be parsed by android on runtime. 我想替换掉sans-serif-condensed
所在的文件,因此我放置的新字体将是android在运行时解析的字体。 I suspect it's on the jar file created when I created my project or maybe somwhere else since I don't really know how. 我怀疑它在我创建项目时创建的jar文件中,或者可能在其他地方,因为我真的不知道怎么做。
How can I replace an android default font file? 如何替换android默认字体文件? also where would it be? 还会在哪里?
I would be grateful for guide or instructions provided, specially if you tried it. 我将不胜感激所提供的指南或指示,特别是如果您尝试过的话。 Thanks! 谢谢! :] :]
There is a file fonts.xml which controls the mapping of font families to the actual files. 有一个文件fonts.xml ,它控制字体系列到实际文件的映射。 The font files usually reside in the folder /system/fonts
. 字体文件通常位于/system/fonts
文件夹中。
Neither is really something you can control without root though, so if you want to use custom fonts in your application, custom views are still your best bet. 但是,没有root用户也无法控制任何事情,因此,如果要在应用程序中使用自定义字体,自定义视图仍然是最好的选择。
SOLUTION 解
I think it would be helpful to post this, though it's already been a long time. 我认为将其发布会有所帮助,尽管已经很长时间了。 I haven't posted this as answer since someone might actually answer a solution. 我尚未将其发布为答案,因为有人可能会实际回答解决方案。 Also see this . 另请参阅此 。
The approach in solving this problem is not the way I expected, I was about to replace font files, but as Malcolm's comment here , to do that you must replace the system's font file, which is very inefficient. 解决这个问题的方法不是我期望的那样,我将要替换字体文件,但是正如Malcolm在这里的注释所示 ,要替换字体文件,这是非常低效的。
The better approach, which is actaully solved my problem is the answer here: Is it possible to set a custom font for entire of application? 更好的方法实际上解决了我的问题,答案是 : 可以为整个应用程序设置自定义字体吗?
It's about replacing the fonts during runtime. 这是关于在运行时替换字体。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.