extrafont: Tools for using fonts

標準以外のフォントを使うためのツール

> library(extrafont)

バージョン: 0.17


関数名 概略
choose_font Choose an installed font from a list
embed_fonts Embeds fonts that are listed in the local Fontmap
extrafont extrafont package
font_addpackage Add font from an installed package to fonts database
font_import Import system fonts
font_install Install a font package and register it in the fonts database
fonts Show the fonts that are registered in the font table (and available for embedding)
fonttable Returns the full font table
loadfonts Reads the fonttable database and registers those fonts with R
ttf_import Imports all TrueType fonts in a directory and all subdirectories

font_import

システムにあるフォントを専用のデータベース(extrafontdb)に追加する

> font_install()

fonts

埋め込み可能なフォント一覧を表示する

> fonts()
  [1] ".Keyboard"               "Andale Mono"            
  [3] "Aozora Mincho Heavy"     "Aozora Mincho Light"    
  [5] "Aozora Mincho Medium"    "Aozora Mincho Regular"  
  [7] "Apple Braille"           "AppleMyungjo"           
  [9] "Arial Black"             "Arial"                  
 [11] "Arial Narrow"            "Arial Rounded MT Bold"  
 [13] "Arial Unicode MS"        "Brush Script MT"        
 [15] "cinecaption"             "Comic Sans MS"          
 [17] "Courier New"             "DIN Alternate"          
 [19] "DIN Condensed"           "Georgia"                
 [21] "Impact"                  "IPAMonaGothic"          
 [23] "IPAMonaMincho"           "IPAMonaPGothic"         
 [25] "IPAMonaUIGothic"         "JNR-SB-Font"            
 [27] "Khmer Sangam MN"         "Lao Sangam MN"          
 [29] "mac-icon-standard"       "Microsoft Sans Serif"   
 [31] "Migu 1M"                 "Myanmar Sangam MN"      
 [33] "Ricty"                   "Tahoma"                 
 [35] "Times New Roman"         "TradeGothic"            
 [37] "Trebuchet MS"            "Verdana"                
 [39] "Webdings"                "Wingdings"              
 [41] "Wingdings 2"             "Wingdings 3"            
 [43] "Batang"                  "Bodoni Ornaments"       
 [45] "Bodoni 72 Smallcaps"     "Bookshelf Symbol 7"     
 [47] ""                        "Calibri"                
 [49] "Calibri Light"           "Cambria"                
 [51] "Cambria Math"            "Candara"                
 [53] "Consolas"                "Constantia"             
 [55] "Corbel"                  "DejaVu Sans"            
 [57] "DejaVu Sans Light"       "DejaVu Sans Condensed"  
 [59] "DejaVu Sans Mono"        "DejaVu Serif"           
 [61] "DejaVu Serif Condensed"  "DOCKER ONE"             
 [63] "DOCKER THREE"            "DOCKER TWO"             
 [65] "FontAwesome"             "Franklin Gothic Book"   
 [67] "Franklin Gothic Medium"  "Gabriola"               
 [69] "Gill Sans MT"            "Gulim"                  
 [71] "HGMaruGothicMPRO"        "IPAexGothic"            
 [73] "IPAexMincho"             "IPAGothic"              
 [75] "Lucida Console"          "Lucida Sans Unicode"    
 [77] "Luminari"                "Marlett"                
 [79] "Meiryo"                  "Microsoft Yi Baiti"     
 [81] "Microsoft Himalaya"      "Microsoft Tai Le"       
 [83] "MingLiU_HKSCS-ExtB"      "MingLiU_HKSCS"          
 [85] "MingLiU"                 "MingLiU-ExtB"           
 [87] "Mongolian Baiti"         "MS Gothic"              
 [89] "MS Mincho"               "MS PGothic"             
 [91] "MS PMincho"              "MS Reference Sans Serif"
 [93] "MS Reference Specialty"  "octicons"               
 [95] "Palatino Linotype"       "Perpetua"               
 [97] "PMingLiU"                "PMingLiU-ExtB"          
 [99] "SimHei"                  "SimSun"                 
[101] "SimSun-ExtB"             "Trattatello"            
[103] "Tw Cen MT"               "xkcd"

fonttable

dbに登録されたフォントの情報を表示する

> fonttable() %>% {
+   str(.)
+   head(., 3)
+ }
'data.frame':    184 obs. of  10 variables:
 $ package   : logi  NA NA NA NA NA NA ...
 $ afmfile   : chr  "Keyboard.afm.gz" "Andale Mono.afm.gz" "AozoraMinchoHeavy.afm.gz" "AozoraMinchoLight.afm.gz" ...
 $ fontfile  : chr  "/System/Library/Fonts/Keyboard.ttf" "/Library/Fonts/Andale Mono.ttf" "/Users/uri/Library/Fonts/AozoraMinchoHeavy.ttf" "/Users/uri/Library/Fonts/AozoraMinchoLight.ttf" ...
 $ FullName  : chr  ".Keyboard" "Andale Mono" "Aozora Mincho Heavy" "Aozora Mincho Light" ...
 $ FamilyName: chr  ".Keyboard" "Andale Mono" "Aozora Mincho Heavy" "Aozora Mincho Light" ...
 $ FontName  : chr  "-Keyboard" "AndaleMono" "AozoraMinchoHeavy" "AozoraMinchoLight" ...
 $ Bold      : logi  FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ Italic    : logi  FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ Symbol    : logi  FALSE FALSE FALSE FALSE FALSE FALSE ...
 $ afmsymfile: logi  NA NA NA NA NA NA ...
  package                  afmfile
1      NA          Keyboard.afm.gz
2      NA       Andale Mono.afm.gz
3      NA AozoraMinchoHeavy.afm.gz
                                        fontfile            FullName
1             /System/Library/Fonts/Keyboard.ttf           .Keyboard
2                 /Library/Fonts/Andale Mono.ttf         Andale Mono
3 /Users/uri/Library/Fonts/AozoraMinchoHeavy.ttf Aozora Mincho Heavy
           FamilyName          FontName  Bold Italic Symbol afmsymfile
1           .Keyboard         -Keyboard FALSE  FALSE  FALSE         NA
2         Andale Mono        AndaleMono FALSE  FALSE  FALSE         NA
3 Aozora Mincho Heavy AozoraMinchoHeavy FALSE  FALSE  FALSE         NA