天宫鹤

Python-pptx正确设置中文字体

使用pptx_ea_font库设置中文字体:

1.安装pptx_ea_font库:pip install pptx-ea-font

2.p = text_frame.paragraphs[0] # 取文本段落

 run = p.runs[0] # 取文本运行对象,该对象为段落的子元素

pptx_ea_font.set_font(run, '微软雅黑')
#以下方法只能修改数字和英文 #run.font.name = new_font

参考:
(1)https://blog.csdn.net/A41915460/article/details/134104431
(2)https://zhuanlan.zhihu.com/p/548039429

posted on 2024-05-31 20:03  GoGrid  阅读(125)  评论(1编辑  收藏  举报

导航