python库Kivy中文乱码问题
来源:互联网 发布:石膏板隔音墙数据 编辑:程序博客网 时间:2024/06/06 12:36
(1)以下摘自Kivy安装目录下label.py源代码的注释,可以给我们启发:
font_name = StringProperty('Roboto')
'''Filename of the font to use. The path can be absolute or relative.
Relative paths are resolved by the :func:`~kivy.resources.resource_find`
function.
.. warning::
Depending of your text provider, the font file can be ignored. However,
you can mostly use this without problems.
If the font used lacks the glyphs for the particular language/symbols
you are using, you will see '[]' blank box characters instead of the
actual glyphs. The solution is to use a font that has the glyphs you
need to display. For example, to display |unicodechar|, use a font such
as freesans.ttf that has the glyph.
.. |unicodechar| image:: images/unicode-char.png
:attr:`font_name` is a :class:`~kivy.properties.StringProperty` and
defaults to 'Roboto'.
2)Font字体文件默认搜索目录:
运行kivy.resources.resource_paths,
Out[17]:
['.',
'D:/MyData',(python的working directory)
'C:\\Anaconda3\\lib\\site-packages\\kivy',
'C:\\Anaconda3\\lib\\site-packages\\kivy\\data\\..',
'C:\\Windows\\Fonts',
'C:\\Anaconda3\\lib\\site-packages\\kivy\\data\\fonts']
该目录可以自己修改。
3)关键步骤
修改Kivy默认字体
打开label.py文件,文件位于Anaconda3\\lib\\site-packages\\kivy目录;
在437行可看到如下语句:
font_name = StringProperty('Roboto')
把'Roboto'替换成中文字体,例如
'msyh', 表示微软雅黑msyh.ttf
'simsun.ttc', 表示宋体simsun.ttc
kivy会自动在(2)中的目录去搜索该字体文件
4)后面用到.kv文件时,这一部很关键,花了很长时间才自己探索出来解决办法
如图,在lang.py文件中添加红框中的语句,然后保存。
- python库Kivy中文乱码问题
- kivy显示中文问题
- python中文乱码问题
- python中文乱码问题
- python中文乱码问题
- python 中文乱码问题
- python 中文乱码问题
- 【python】中文乱码问题
- Python 中文乱码问题
- python 中文乱码问题
- python中文乱码问题
- python 中文乱码问题
- python 中文乱码问题
- python 中文乱码问题
- python中文乱码问题
- Python中文乱码问题
- python 中文乱码问题
- Python 中文乱码问题
- HTTP基础:URL格式、 HTTP请求、响应、消息
- JDK、J2EE、J2SE、J2ME的区别
- Mac下Lua Sublime Text2 开发环境搭建
- 3.2语法分析-上下文无关文法
- 便捷的宏定义
- python库Kivy中文乱码问题
- Structural Patterns Part 2/7: Bridge Pattern
- 大数据架构
- 工具网站
- java dom4j解析XML读取数据源配置的代码实例
- 解决DataNode Volume Failures故障
- 实例讲解基于 React+Redux 的前端开发流程
- HDOJ/HDU 1984 Mispelling4(删除第n个字符~)
- CF 开车找房子