1 string2path 팩키지1

먼저 systemfonts::system_fonts() 명령어로 폰트가 설치된 경로명을 확인한다. 그리고 나서 해당 문자를 ggplot으로 시각화한다.

# devtools::install_github("yutannihilation/string2path")
library(tidyverse)
library(string2path)

systemfonts::system_fonts() %>% 
  filter(str_detect(name, "Nanum"))
# A tibble: 26 x 9
   path            index name       family   style weight width italic monospace
   <chr>           <int> <chr>      <chr>    <chr> <ord>  <ord> <lgl>  <lgl>    
 1 "C:\\WINDOWS\\~     0 NanumGoth~ NanumGo~ Regu~ normal norm~ FALSE  TRUE     
 2 "C:\\WINDOWS\\~     0 NanumGoth~ NanumGo~ Bold  bold   norm~ FALSE  TRUE     
 3 "C:\\WINDOWS\\~     0 NanumPen   Nanum P~ Regu~ normal norm~ FALSE  FALSE    
 4 "C:\\WINDOWS\\~     0 NanumBrush Nanum B~ Regu~ normal norm~ FALSE  FALSE    
 5 "C:\\WINDOWS\\~     0 NanumBaru~ NanumBa~ Regu~ normal norm~ FALSE  FALSE    
 6 "C:\\WINDOWS\\~     0 NanumBaru~ NanumBa~ Bold  semib~ norm~ FALSE  FALSE    
 7 "C:\\WINDOWS\\~     0 NanumBaru~ NanumBa~ Light light  norm~ FALSE  FALSE    
 8 "C:\\WINDOWS\\~     0 NanumBaru~ NanumBa~ Ultr~ light  norm~ FALSE  FALSE    
 9 "C:\\WINDOWS\\~     0 NanumGoth~ NanumGo~ Regu~ normal norm~ FALSE  FALSE    
10 "C:\\WINDOWS\\~     0 NanumGoth~ NanumGo~ Bold  semib~ norm~ FALSE  FALSE    
# ... with 16 more rows
string_df <- string2path("윤영아 !!!", "C:\\WINDOWS\\Fonts\\NanumGothicCoding.ttf")

string_df <- tibble::rowid_to_column(string_df)

ggplot(string_df) +
  geom_path(aes(x, y, group = id)) +
  theme_void() +
  coord_equal()

애니메이션으로 제작해 보자.

library(gganimate)

ggplot(string_df) +
  geom_path(aes(x, y, group = id), size = 2, colour = "blue", lineend = "round") +
  theme_void() +
  coord_equal() +
  transition_reveal(rowid)

2 Seoul R Meetup 로고?

Seoul R Meetup Group의 글자를 나눔바른펜 글꼴로 시각화해보자.

seoul_df <- string2path("Seoul R Meetup", "C:\\WINDOWS\\Fonts\\NanumBarunpenB.ttf")

seoul_df <- tibble::rowid_to_column(seoul_df)

ggplot(seoul_df) +
  geom_path(aes(x, y, group = id)) +
  theme_void() +
  coord_equal()

애니메이션으로 제작해 보자.

ggplot(seoul_df) +
  geom_path(aes(x, y, group = id), size = 2, colour = "black", lineend = "round") +
  theme_void() +
  coord_equal() +
  transition_reveal(rowid)

 

데이터 과학자 이광춘 저작

kwangchun.lee.7@gmail.com