在字符串大胆中键入一个单词
给定以下代码(从此答案中:如何在pygame中显示文本? ):
pygame.font.init() # you have to call this at the start,
# if you want to use this module.
my_font = pygame.font.SysFont('Comic Sans MS', 30)
text_surface = my_font.render('Some Text', False, (0, 0, 0))
是否可以在保留“某个”一词的同时使“文本”一词大胆?
(没有多次渲染)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,这是不可能的。您必须使用字体的“粗体”版本。 “ Bold”不是标志或属性,而是一种不同的字体。因此,您需要用一个字体和另一种字体渲染单词“文本”和“ some”一词。
您可以使用
pygame.font.font.match_font()
找到特定字体文件的路径。最小示例:
使用 Modle文本可以用不同的样式呈现,例如
style_default
和style_strong
。但是,文本只能一次使用一种样式渲染。因此,您仍然必须分别渲染每个单词:See also
No it is not possible. You must use the "bold" version of the font. "bold" isn't a flag or attribute, it's just a different font. So you need to render the word "Text" with one font and the word "Some" with another font.
You can use
pygame.font.match_font()
to find the path to a specific font file.Minimal example:
With the
pygame.freetype
modle the text can be rendered with different styles likeSTYLE_DEFAULT
andSTYLE_STRONG
. However, the text can only be rendered with one style at a time. So you still have to render each word separately:See also Text and font