日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

osx 字体 linux,Linux/MacOS下matplotlib能正常显示的中文字体选择

發布時間:2023/12/10 linux 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 osx 字体 linux,Linux/MacOS下matplotlib能正常显示的中文字体选择 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

下面的Python腳本可以檢測到 *nix 系統內 matplotlib 支持正常顯示的中文字體(用到了命令行工具 fc-list ):

#!/usr/bin/env python

# -*- coding: utf-8 -*-

# File Name: font_check.py

# Created Time: Thu Mar 23 16:53:59 2017

__author__ = 'minyu'

__mail__ = 'minyu7374@gmail.com'

from matplotlib.font_managerimport FontManager

import subprocess

mpl_fonts = set(f.namefor f in FontManager().ttflist)

print ('all font list get from matplotlib.font_manager:')

for f in sorted(mpl_fonts):

print('\t' + f)

# for python2

# output = subprocess.check_output('fc-list :lang=zh -f "%{family}\n"', shell=True)

# for python3

output = subprocess.check_output('fc-list :lang=zh -f "%{family}\n"', shell=True, encoding="utf8")

zh_fonts = set(f.split(',',1)[0] for f in output.split('\n'))

print('\n' +'Chinese font list get from fc-list:')

for f in sorted(zh_fonts):

print('\t' + f)

print('\n' +'the fonts we can use:')

available = set(mpl_fonts) & set(zh_fonts)

for f in available:

print('\t' + f)

在個人的 MacOS Sierra 系統下運行結果如下:

Fontconfig warning: ignoring UTF-8: not a valid region tag

all font list get from matplotlib.font_manager:

.Keyboard

.LastResort

.SF Compact Display

.SF Compact Rounded

.SF Compact Text

.SF NS Display Condensed

.SF NS Text Condensed

Andale Mono

Apple Braille

Apple Chancery

Apple Symbols

AppleGothic

AppleMyungjo

Arial

Arial Black

Arial Narrow

Arial Rounded MT Bold

Arial Unicode MS

Ayuthaya

Big Caslon

Bitstream Vera Sans

Bitstream Vera Sans Mono

Bitstream Vera Serif

Bodoni 72 Smallcaps

Bodoni Ornaments

Bradley Hand

Brush Script MT

Chalkduster

Comic Sans MS

Consolas

Courier New

DIN Alternate

DIN Condensed

DejaVu Sans

DejaVu Sans Display

DejaVu Sans Mono

DejaVu Serif

DejaVu Serif Display

Diwan Thuluth

East Syriac Adiabene

East Syriac Ctesiphon

Estrangelo Antioch

Estrangelo Edessa

Estrangelo Midyat

Estrangelo Nisibin

Estrangelo Nisibin Outline

Estrangelo Quenneshrin

Estrangelo Talada

Estrangelo TurAbdin

Farisi

Georgia

Goha-Tibeb Zemen

Gurmukhi MT

Herculanum

Hoefler Text

Impact

InaiMathi

Khmer Sangam MN

Kokonor

Krungthep

Lao Sangam MN

Luminari

Luxi Mono

Luxi Sans

Luxi Serif

Microsoft Sans Serif

Microsoft YaHei Mono

Mishafi

Mishafi Gold

Plantagenet Cherokee

STIXGeneral

STIXIntegralsD

STIXIntegralsSm

STIXIntegralsUp

STIXIntegralsUpD

STIXIntegralsUpSm

STIXNonUnicode

STIXSizeFiveSym

STIXSizeFourSym

STIXSizeOneSym

STIXSizeThreeSym

STIXSizeTwoSym

STIXVariants

Sathu

Serto Batnan

Serto Jerusalem

Serto Jerusalem Outline

Serto Kharput

Serto Malankara

Serto Mardin

Serto Urhoy

Silom

Skia

Symbol

System Font

Tahoma

Times New Roman

Trattatello

Trebuchet MS

Verdana

Webdings

Wingdings

Wingdings 2

Wingdings 3

YaHei Consolas Hybrid

Zapf Dingbats

Zapfino

cmb10

cmex10

cmmi10

cmr10

cmss10

cmsy10

cmtt10

Fontconfig warning: ignoring UTF-8: not a valid region tag

Chinese font list get from fc-list:

.Hiragino Sans GB Interface

.LastResort

.PingFang HK

.PingFang SC

.PingFang TC

Arial Unicode MS

Fixed

GB18030 Bitmap

Heiti SC

Heiti TC

Hiragino Sans GB

Microsoft YaHei Mono

PingFang HK

PingFang SC

PingFang TC

STSong

Songti SC

Songti TC

YaHei Consolas Hybrid

the fonts we can use:

.LastResort

Microsoft YaHei Mono

YaHei Consolas Hybrid

Arial Unicode MS

YaHei Consolas Hybrid 是我自己安裝的字體,其他三個都是系統默認的,

這里選擇了 YaHei Consolas Hybrid。

mpl.rcParams['font.sans-serif'] = ['YaHei Consolas Hybrid'] #指定默認字體

mpl.rcParams['axes.unicode_minus'] = False # 解決保存圖像是負號'-'顯示為方塊的問題

總結

以上是生活随笔為你收集整理的osx 字体 linux,Linux/MacOS下matplotlib能正常显示的中文字体选择的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。