--- tags: R_NTU --- # R 畫畫遇到的問題大整理 ## 中文字體超級難調 以mac電腦為例 ### 解法1 :::danger 但我自己操作這個方法是失敗的 ::: > source1: https://hackmd.io/@LHB-0222/set_ggplot2#%E6%9B%B4%E6%94%B9%E5%AD%97%E9%AB%94%E9%85%8D%E7%BD%AE ```r= library(extrafont) library(remotes) remotes::install_version("Rttf2pt1", version = "1.3.8") # 要加上面這句是因為直接跑的話會顯示「font family 'XXXX' not found」 font_import("/System/Library/Fonts/") # 要找一下你的字體檔存在哪裡,這句要跑一陣子,如果字體很多的話 #loadfonts() fonts() # 查看字體列表 th <- theme(title = element_text(family="HanaMinA"), text = element_text(family="jf-openhuninn-1.1"), axis.text.y = element_text(family="jf-openhuninn-1.1"), axis.text.x = element_text(family="jf-openhuninn-1.1"), legend.text = element_text(family="jf-openhuninn-1.1"), plot.title = element_text(family="GenYoMin TW TTF SemiBold") ) ``` ### 解法2 :::success 我測試成功~ ::: 金萱粉圓體下載連結: https://free.com.tw/justfont-huninn/ ```r= library(showtext) showtext.auto(enable = TRUE) font_add("jf-openhuninn", "jf-openhuninn-1.1.ttf") # 金萱粉圓體是開源的 th <- theme(title = element_text(family="jf-openhuninn"), text = element_text(family="jf-openhuninn"), axis.text.y = element_text(family="jf-openhuninn"), axis.text.x = element_text(family="jf-openhuninn"), legend.text = element_text(family="jf-openhuninn"), plot.title = element_text(family="jf-openhuninn") ) ``` 備註:主要是mac有個基本的問題(我的猜測),可能設定**bold(粗體)**、*italic(斜體)* 可能會有問題的原因是因為它們可能都被存放在不同的字型檔案之中(?), 所以建議如果要用粗體,就直接把抓該粗體的字型檔案,如下圖示意: 
×
Sign in
Email
Password
Forgot password
or
Sign in via Google
Sign in via Facebook
Sign in via X(Twitter)
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
Continue with a different method
New to HackMD?
Sign up
By signing in, you agree to our
terms of service
.