Skip to content

Commit

Permalink
한글 폰트 추가
Browse files Browse the repository at this point in the history
 - NanumBarunGothic
  • Loading branch information
mr-yoo committed Jun 8, 2022
1 parent 3a734f9 commit c0f6f2e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 30 deletions.
Binary file added pykrx/NanumBarunGothic1.ttf
Binary file not shown.
36 changes: 7 additions & 29 deletions pykrx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,18 @@
import matplotlib.pyplot as plt
import matplotlib.font_manager as fm


os = platform.system()

if os == "Darwin":
family = "AppleGothic"
install_url = "https://www.download-free-fonts.com/details/89379/" \
"applegothic-regular"

elif os == "Windows":
family = "Malgun Gothic"
install_url = "https://docs.microsoft.com/ko-kr/typography/" \
"font-list/malgun-gothic"

plt.rc('font', family="AppleGothic")

else:
family = "NanumBarunGothic"
install_url = """NanumBarunGothic font is required.
1) font install
!sudo apt-get install -y fonts-nanum
!sudo fc-cache -fv
!rm ~/.cache/matplotlib -rf
2) runtime restart if colab
"""

fonts = [x.name for x in fm.fontManager.ttflist if family in x.name]
if len(fonts) == 0:
print("No Korean fonts found. Please install the font shown below"
"because Hangul can be broken on the chart.")
print(f" - {install_url}")
print("PYKRX works fine regardless of font installation.")
family = "Malgun Gothic"
fe = fm.FontEntry(
fname="pykrx/NanumBarunGothic.ttf",
name='NanumBarunGothic'
)
fm.fontManager.ttflist.insert(0, fe)
plt.rc('font', family=fe.name)

plt.rc('font', family=family)
plt.rcParams['axes.unicode_minus'] = False
2 changes: 1 addition & 1 deletion pykrx/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

__version__ = '1.0.35'
__version__ = '1.0.37'

0 comments on commit c0f6f2e

Please sign in to comment.