font = r'D:\BaiduSyncdisk\PycharmProjects\通用-字体\微软雅黑.ttf' txt_clip = TextClip(info['server_filename'], fontsize=24, color='white', bg_color='#c91414', font=font) txt_clip = txt_clip.set_position('center').set_duration(3).crossfadein(1).crossfadeout(1)
无论我怎么用网上的方案改,什么编码格式啊,什么imagemagick版本啊,什么字体路径啊,什么字体右键安全名称啊,统统不管用。
解决方案:
print(TextClip.list("font")) # 列出支持的字体
哈哈,你看看你选的字体是不是在列表里面没有?我kao,微软雅黑居然没有?
即使你自定义了微软雅黑的路径也不行… 好吧。看看打印出来的字体列表:
[‘Arial’, ‘Arial-Black’, ‘Arial-Bold’, ‘Arial-Bold-Italic’, ‘Arial-Italic’, ‘Arial-Narrow’, ‘Arial-Narrow-Bold’, ‘Arial-Narrow-Bold-Italic’, ‘Arial-Narrow-Italic’, ‘Bahnschrift’, ‘Book-Antiqua’, ‘Book-Antiqua-Bold’, ‘Book-Antiqua-Bold-Italic’, ‘Book-Antiqua-Italic’, ‘Bookman-Old-Style’, ‘Bookman-Old-Style-Bold’, ‘Bookman-Old-Style-Bold-Italic’, ‘Bookman-Old-Style-Italic’, ‘Bookshelf-Symbol-7’, ‘Calibri’, ‘Calibri-Bold’, ‘Calibri-Bold-Italic’, ‘Calibri-Italic’, ‘Calibri-Light’, ‘Calibri-Light-Italic’, ‘Cambria-&-Cambria-Math’, ‘Cambria-Bold’, ‘Cambria-Bold-Italic’, ‘Cambria-Italic’, ‘Candara’, ‘Candara-Bold’, ‘Candara-Bold-Italic’, ‘Candara-Italic’, ‘Candara-Light’, ‘Candara-Light-Italic’, ‘Century’, ‘Century-Gothic’, ‘Century-Gothic-Bold’, ‘Century-Gothic-Bold-Italic’, ‘Century-Gothic-Italic’, ‘Comic-Sans-MS’, ‘Comic-Sans-MS-Bold’, ‘Comic-Sans-MS-Bold-Italic’, ‘Comic-Sans-MS-Italic’, ‘Consolas’, ‘Consolas-Bold’, ‘Consolas-Bold-Italic’, ‘Consolas-Italic’, ‘Constantia’, ‘Constantia-Bold’, ‘Constantia-Bold-Italic’, ‘Constantia-Italic’, ‘Corbel’, ‘Corbel-Bold’, ‘Corbel-Bold-Italic’, ‘Corbel-Italic’, ‘Corbel-Light’, ‘Corbel-Light-Italic’, ‘Courier-New’, ‘Courier-New-Bold’, ‘Courier-New-Bold-Italic’, ‘Courier-New-Italic’, ‘DengXian’, ‘DengXian-Bold’, ‘DengXian-Light’, ‘Dubai-Bold’, ‘Dubai-Light’, ‘Dubai-Medium’, ‘Dubai-Regular’, ‘Ebrima’, ‘Ebrima-Bold’, ‘FangSong’, ‘Franklin-Gothic-Medium’, ‘Franklin-Gothic-Medium-Italic’, ‘Gabriola’, ‘Gadugi’, ‘Gadugi-Bold’, ‘Garamond’, ‘Garamond-Bold’, ‘Garamond-Italic’, ‘Georgia’, ‘Georgia-Bold’, ‘Georgia-Bold-Italic’, ‘Georgia-Italic’, ‘Holo-MDL2-Assets’, ‘Impact’, ‘Ink-Free’, ‘Javanese-Text’, ‘KaiTi’, ‘Leelawadee’, ‘Leelawadee-Bold’, ‘Leelawadee-UI’, ‘Leelawadee-UI-Bold’, ‘Leelawadee-UI-Semilight’, ‘Lucida-Console’, ‘Lucida-Sans-Unicode’, ‘Malgun-Gothic’, ‘Malgun-Gothic-Bold’, ‘Malgun-Gothic-SemiLight’, ‘Microsoft-Himalaya’, ‘Microsoft-JhengHei-&-Microsoft-JhengHei-UI’, ‘Microsoft-JhengHei-Bold-&-Microsoft-JhengHei-UI-Bold’, ‘Microsoft-JhengHei-Light-&-Microsoft-JhengHei-UI-Light’, ‘Microsoft-New-Tai-Lue’, ‘Microsoft-New-Tai-Lue-Bold’, ‘Microsoft-PhagsPa’, ‘Microsoft-PhagsPa-Bold’, ‘Microsoft-Sans-Serif’, ‘Microsoft-Tai-Le’, ‘Microsoft-Tai-Le-Bold’, ‘Microsoft-Uighur’, ‘Microsoft-Uighur-Bold’, ‘Microsoft-YaHei-&-Microsoft-YaHei-UI’, ‘Microsoft-YaHei-Bold-&-Microsoft-YaHei-UI-Bold’, ‘Microsoft-YaHei-Light-&-Microsoft-YaHei-UI-Light’, ‘Microsoft-Yi-Baiti’, ‘MingLiU-ExtB-&-PMingLiU-ExtB-&-MingLiU_HKSCS-ExtB’, ‘Mongolian-Baiti’, ‘Monotype-Corsiva’, ‘MS-Gothic-&-MS-UI-Gothic-&-MS-PGothic’, ‘MS-Reference-Sans-Serif’, ‘MS-Reference-Specialty’, ‘MT-Extra’, ‘MV-Boli’, ‘Myanmar-Text’, ‘Myanmar-Text-Bold’, ‘Nirmala-UI’, ‘Nirmala-UI-Bold’, ‘Nirmala-UI-Semilight’, ‘Palatino-Linotype’, ‘Palatino-Linotype-Bold’, ‘Palatino-Linotype-Bold-Italic’, ‘Palatino-Linotype-Italic’, ‘Sans-Serif-Collection’, ‘Segoe-Fluent-Icons’, ‘Segoe-MDL2-Assets’, ‘Segoe-Print’, ‘Segoe-Print-Bold’, ‘Segoe-Script’, ‘Segoe-Script-Bold’, ‘Segoe-UI’, ‘Segoe-UI-Black’, ‘Segoe-UI-Black-Italic’, ‘Segoe-UI-Bold’, ‘Segoe-UI-Bold-Italic’, ‘Segoe-UI-Emoji’, ‘Segoe-UI-Historic’, ‘Segoe-UI-Italic’, ‘Segoe-UI-Light’, ‘Segoe-UI-Light-Italic’, ‘Segoe-UI-Semibold’, ‘Segoe-UI-Semibold-Italic’, ‘Segoe-UI-Semilight’, ‘Segoe-UI-Semilight-Italic’, ‘Segoe-UI-Symbol’, ‘Segoe-UI-Variable’, ‘SimHei’, ‘SimSun-&-NSimSun’, ‘SimSun-ExtB’, ‘Sitka-Text’, ‘Sitka-Text-Italic’, ‘Sylfaen’, ‘Symbol’, ‘Tahoma’, ‘Tahoma-Bold’, ‘Times-New-Roman’, ‘Times-New-Roman-Bold’, ‘Times-New-Roman-Bold-Italic’, ‘Times-New-Roman-Italic’, ‘Trebuchet-MS’, ‘Trebuchet-MS-Bold’, ‘Trebuchet-MS-Bold-Italic’, ‘Trebuchet-MS-Italic’, ‘Verdana’, ‘Verdana-Bold’, ‘Verdana-Bold-Italic’, ‘Verdana-Italic’, ‘Webdings’, ‘Wingdings’, ‘Wingdings-2’, ‘Wingdings-3’, ‘Yu-Gothic-Bold-&-Yu-Gothic-UI-Semibold-&-Yu-Gothic-UI-Bold’, ‘Yu-Gothic-Light-&-Yu-Gothic-UI-Light’, ‘Yu-Gothic-Medium-&-Yu-Gothic-UI-Regular’, ‘Yu-Gothic-Regular-&-Yu-Gothic-UI-Semilight’, ‘华文中宋’, ‘华文仿宋’, ‘华文宋体’, ‘华文彩云’, ‘华文新魏’, ‘华文楷体’, ‘华文琥珀’, ‘华文细黑’, ‘华文行楷’, ‘华文隶书’, ‘幼圆’, ‘方正姚体’, ‘方正舒体’, ‘隶书’]
看到了吧,我加粗加红的部分,原来微软雅黑不叫微软雅黑,我最后选择中间的“华文细黑”好了。一切清净了。
发表评论