Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
GuangchuangYu committed Apr 1, 2019
1 parent 8c4d25d commit fce67b2
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 13 deletions.
10 changes: 7 additions & 3 deletions R/sticker.R
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ geom_pkgname <- function(package, x=1, y=1.4, color="#FFFFFF", family="Aller_Rg"
##' @importFrom sysfonts font_add
##' @importFrom showtext showtext_auto
load_font <- function(family) {
## load the font packed in the hexSticker package,
## otherwise, load system fonts
##
## google font can be supported via `showtext`,
## see https://github.com/GuangchuangYu/hexSticker#google-fonts
##
if (family == "Aller") {
family <- "Aller_Rg"
}
Expand All @@ -153,9 +159,7 @@ load_font <- function(family) {
if (any(i)) {
font_add(family, fonts[which(i)[1]])
showtext_auto()
} # else {
# sysfonts::font_add_google(name = family, family = family)
# }
}
return(family)
}

Expand Down
16 changes: 16 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,22 @@ sticker(imgurl, package="hexSticker", p_size=8, s_x=1, s_y=.75, s_width=.6,

<img src="inst/figures/imgfile.png" height="300"/>

### Google fonts

```{r eval=FALSE}
library(showtext)
## Loading Google fonts (http://www.google.com/fonts)
font_add_google("Gochi Hand", "gochi")
## Automatically use showtext to render text for future devices
showtext_auto()
## use the ggplot2 example
sticker(p, package="hexSticker", p_size=8, s_x=1, s_y=.75, s_width=1.3, s_height=1,
p_family = "gochi", filename="inst/figures/ggplot2-google-font.png")
```

<img src="inst/figures/ggplot2-google-font.png" height="300"/>


----

Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,22 @@ sticker(imgurl, package="hexSticker", p_size=8, s_x=1, s_y=.75, s_width=.6,

<img src="inst/figures/imgfile.png" height="300"/>

### Google fonts

``` r
library(showtext)
## Loading Google fonts (http://www.google.com/fonts)
font_add_google("Gochi Hand", "gochi")
## Automatically use showtext to render text for future devices
showtext_auto()

## use the ggplot2 example
sticker(p, package="hexSticker", p_size=8, s_x=1, s_y=.75, s_width=1.3, s_height=1,
p_family = "gochi", filename="inst/figures/ggplot2-google-font.png")
```

<img src="inst/figures/ggplot2-google-font.png" height="300"/>

-----

## Stickers produced by `hexSticker`
Expand Down
Binary file added inst/figures/ggplot2-google-font.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified inst/figures/ggplot2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 0 additions & 2 deletions man/reexports.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions man/sticker.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fce67b2

Please sign in to comment.