首先,我非常熟悉Python/Sphinx/rinohtype。
我试图找出如何安装字体以便与rinohtype/Sphinx一起使用,rinohtype安装了一些字体,但我希望使用安装在我的Windows 10系统上的字体,就像Arial一样,我已经遍历了rinohtype文档,寻找指导,但一直无法理解这一点。
编辑:输出如下:
rinohtype 0.5.3 (2021-06-16) Copyright (c) Brecht Machiels and contributors
This program comes with ABSOLUTELY NO WARRANTY. Its use is subject
to the terms of the GNU Affero General Public License version 3.
rendering...
References cache read from C:\Users\marjohloo\Documents\Sphinx\Test\_build\rinoh\lxr.rtc
Typeface 'Arial' is not installed; searching Google Fonts.
-> not found: please check the typeface name (case-sensitive!)
Exception occurred:
File "c:\users\marjohloo\appdata\local\programs\python\python39\lib\site-packages\rinoh\resource.py", line 42, in parse_string
raise ResourceNotFound(cls, resource_name, entry_point_name)
rinoh.resource.ResourceNotFound: (<class 'rinoh.font.Typeface'>, 'ARIAL', 'arial')发布于 2021-07-09 10:43:29
rinohtype还不支持使用系统字体(第75期)。字体支持还没有适当的文档记录,不幸的是(但这是一个开始)。您的字体选项当前如下:
可以使用漂洗列出已安装的字体。
rinoh --list-fonts具体来说,对于Arial,您可以考虑使用TeX回转英雄字体。TeX回转体字体集合为许多其他流行字体提供了免费的替代品,包括“时代”、“Helvetica”(Arial)、“信使”和“巴拉蒂诺”。
如果你想要的是真实的东西,你可以为Arial创建自己的字体包。您可以使用漂洗字体-卡里托作为模板。
如果使用Sphinx,则不需要创建和安装Python包。您可以创建此fonts.py文件并将其导入到狮身人面像conf.py中(在sys.path.insert(0, os.path.abspath('.'))之后):
from pathlib import Path
from rinoh import register_typeface
from rinoh.font import Typeface
from rinoh.font.opentype import OpenTypeFont
FONTS_DIR = Path(r'C:\Windows\Fonts')
def otf(filename, **kwargs):
return OpenTypeFont(str(FONTS_DIR / filename), **kwargs)
arial = Typeface('Arial',
otf('arial.ttf'),
otf('arialbd.ttf'),
otf('ariali.ttf'),
otf('arialbi.ttf'),
)
register_typeface('arial', arial)我相信,对于不熟悉Python的人来说,这并不简单。如果你需要更多的信息,请告诉我。然而,这种情况应该随着漂洗型的成熟而改善。
https://stackoverflow.com/questions/68285411
复制相似问题