-
-
Save andjc/3ecb47e3d98c25a10250c99eb5ede15b to your computer and use it in GitHub Desktop.
Add thai font on Google Colaboratory notebook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!wget https://github.com/Phonbopit/sarabun-webfont/raw/master/fonts/thsarabunnew-webfont.ttf | |
# !pip install -U --pre matplotlib | |
import matplotlib as mpl | |
mpl.font_manager.fontManager.addfont('thsarabunnew-webfont.ttf') # 3.2+ | |
mpl.rc('font', family='TH Sarabun New') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!wget -q http://www.arts.chula.ac.th/ling/wp-content/uploads/TH-Sarabun_Chula1.1.zip -O font.zip | |
!unzip -qj font.zip TH-Sarabun_Chula1.1/THSarabunChula-Regular.ttf | |
# !pip install -U --pre matplotlib | |
import matplotlib as mpl | |
mpl.font_manager.fontManager.addfont('THSarabunChula-Regular.ttf') | |
mpl.rc('font', family='TH Sarabun Chula') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def font_name(filename): | |
from matplotlib.ft2font import FT2Font | |
font = FT2Font(filename) | |
return font.family_name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
plt.text(0.1, 0.8, 'อักษรไทยน้อย', {'size': 30}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment