string2path
An experimental R package to convert string to path
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (12.0%) to scientific vocabulary
Keywords from Contributors
Repository
An experimental R package to convert string to path
Basic Info
- Host: GitHub
- Owner: yutannihilation
- License: other
- Language: Rust
- Default Branch: main
- Homepage: https://yutannihilation.github.io/string2path/
- Size: 77.7 MB
Statistics
- Stars: 99
- Watchers: 3
- Forks: 5
- Open Issues: 6
- Releases: 50
Metadata Files
README.md
string2path
The string2path R package converts a text to paths of the outlines of each glyph, based on a font data. Under the hood, this package is powered by the savvy framework to use these two Rust crates:
- ttf-parser for parsing
font data. TrueType font (
.ttf) and OpenType font (.otf) are supported. - lyon for tessellation of polygons and flattening the curves.
Installation
r
install.packages("string2path")
Development version
The development version is available on R-universe:
r
install.packages("string2path",
repos = c(
yutannihilation = "https://yutannihilation.r-universe.dev",
CRAN = "https://cloud.r-project.org"
)
)
If you want to install from source, you need to have Rust toolchain installed before trying to install this package. See https://www.rust-lang.org/tools/install for the installation instructions.
Example
string2path()
``` r library(string2path) library(ggplot2)
d <- string2path("カラテが\n高まる。", "Noto Sans JP", font_weight = "bold")
d <- tibble::rowidtocolumn(d)
ggplot(d) + geompath(aes(x, y, group = pathid, colour = factor(glyphid)), linewidth = 1.5) + thememinimal() + coordequal() + theme(legend.position = "top") + scalecolourviridisd(option = "H") ```

``` r
library(gganimate) d <- string2path("蹴", "Noto Sans JP") d <- tibble::rowidtocolumn(d)
ggplot(d) + geompath(aes(x, y, group = pathid), linewidth = 2, colour = "purple2", lineend = "round") + thememinimal() + coordequal() + transition_reveal(rowid) ```

dump_fontdb()
Note that "Noto Sans JP" above (and "Iosevka SS08" below) is the
font installed on my local machine, so the same code might not run on
your environment. You can use dump_fontdb() to see the available
combination of font family (e.g. "Arial"), weight (e.g. "bold"), and
style (e.g. "italic").
``` r dump_fontdb()
> # A tibble: 449 × 5
> source index family weight style
>
> 1 "C:\WINDOWS\Fonts\arial.ttf" 0 Arial normal normal
> 2 "C:\WINDOWS\Fonts\arialbd.ttf" 0 Arial bold normal
> 3 "C:\WINDOWS\Fonts\arialbi.ttf" 0 Arial bold italic
> 4 "C:\WINDOWS\Fonts\ariali.ttf" 0 Arial normal italic
> 5 "C:\WINDOWS\Fonts\ariblk.ttf" 0 Arial black normal
> 6 "C:\WINDOWS\Fonts\bahnschrift.ttf" 0 Bahnschrift normal normal
> 7 "C:\WINDOWS\Fonts\BIZ-UDGothicB.ttc" 0 BIZ UDGothic bold normal
> 8 "C:\WINDOWS\Fonts\BIZ-UDGothicB.ttc" 1 BIZ UDPGothic bold normal
> 9 "C:\WINDOWS\Fonts\BIZ-UDGothicR.ttc" 0 BIZ UDGothic normal normal
> 10 "C:\WINDOWS\Fonts\BIZ-UDGothicR.ttc" 1 BIZ UDPGothic normal normal
> # ℹ 439 more rows
```
You can also specify the font file directly. Pomicons is a font available on gabrielelana/pomicons, licensed under SIL OFL 1.1.
``` r pomiconsfile <- here::here("fonts", "Pomicons.ttf") if (!file.exists(pomiconsfile)) { dir.create(dirname(pomiconsfile)) curl::curldownload( "https://github.com/gabrielelana/pomicons/blob/master/fonts/Pomicons.ttf?raw=true", destfile = pomicons_file ) }
dtmp <- string2path("\uE007", pomiconsfile)
ggplot(dtmp) + geompath(aes(x, y, group = pathid), linewidth = 5, colour = "#26d1a9") + thememinimal() + coord_equal() ```
![]()
string2fill()
``` r d <- string2fill("abc", "Iosevka SS08", fontweight = "bold", fontstyle = "italic")
ggplot(d) + geompolygon(aes(x, y, group = triangleid, fill = factor(triangleid %% 7)), colour = "grey", linewidth = 0.1) + thememinimal() + coordequal() + theme(legend.position = "none") + scalefillviridisd(option = "H") ```

string2stroke()
``` r for (w in 1:9 * 0.01) { d <- string2stroke("abc","Iosevka SS08", fontweight = "bold", fontstyle = "italic", line_width = w)
p <- ggplot(d) + geompolygon(aes(x, y, group = triangleid, fill = factor(triangleid %% 2)), colour = "grey", linewidth = 0.1) + thememinimal() + coordequal() + theme(legend.position = "none") + scalefill_manual(values = c("purple", "pink")) plot(p) } ```

tolerance
tolerance controls resolution of the tessellation. You can reduce
tolerance to get higher resolutions. In most of the cases, 1e-5 ~
1e-6 should be enough. For more details, please refer to lyon’s
official
document.
``` r for (tolerance in c(1e-1, 1e-2, 1e-3, 1e-4, 1e-5, 1e-6, 1e-7)) { d <- string2fill("abc", "Iosevka SS08", fontweight = "bold", fontstyle = "italic", tolerance = tolerance)
p <- ggplot(d) + geompolygon(aes(x, y, group = triangleid), fill = "transparent", colour = "black", linewidth = 0.5) + thememinimal() + coordequal() + ggtitle(paste0("tolerance: ", tolerance)) plot(p) } ```

Owner
- Name: Hiroaki Yutani
- Login: yutannihilation
- Kind: user
- Location: Japan
- Website: https://yutannihilation.github.io/
- Repositories: 431
- Profile: https://github.com/yutannihilation
GitHub Events
Total
- Create event: 99
- Release event: 3
- Issues event: 12
- Watch event: 4
- Delete event: 86
- Issue comment event: 69
- Push event: 117
- Pull request event: 173
Last Year
- Create event: 99
- Release event: 3
- Issues event: 12
- Watch event: 4
- Delete event: 86
- Issue comment event: 69
- Push event: 117
- Pull request event: 173
Committers
Last synced: about 1 year ago
Top Committers
| Name | Commits | |
|---|---|---|
| Hiroaki Yutani | y****i@g****m | 431 |
| dependabot[bot] | 4****] | 16 |
Issues and Pull Requests
Last synced: 11 months ago
All Time
- Total issues: 35
- Total pull requests: 174
- Average time to close issues: 15 days
- Average time to close pull requests: 7 days
- Total issue authors: 4
- Total pull request authors: 2
- Average comments per issue: 0.63
- Average comments per pull request: 0.45
- Merged pull requests: 78
- Bot issues: 0
- Bot pull requests: 110
Past Year
- Issues: 7
- Pull requests: 142
- Average time to close issues: about 2 hours
- Average time to close pull requests: 9 days
- Issue authors: 1
- Pull request authors: 2
- Average comments per issue: 1.14
- Average comments per pull request: 0.54
- Merged pull requests: 48
- Bot issues: 0
- Bot pull requests: 110
Top Authors
Issue Authors
- yutannihilation (34)
- mdsumner (1)
- durraniu (1)
- mskyttner (1)
- coolbutuseless (1)
Pull Request Authors
- dependabot[bot] (135)
- yutannihilation (83)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- cran 23,762 last-month
- Total dependent packages: 0
- Total dependent repositories: 1
- Total versions: 16
- Total maintainers: 1
cran.r-project.org: string2path
Rendering Font into 'data.frame'
- Homepage: https://yutannihilation.github.io/string2path/
- Documentation: http://cran.r-project.org/web/packages/string2path/string2path.pdf
- License: MIT + file LICENSE
-
Latest release: 0.2.2
published over 1 year ago
Rankings
Maintainers (1)
Dependencies
- arrayvec 0.7.2
- autocfg 1.1.0
- cfg-if 1.0.0
- euclid 0.22.7
- float_next_after 0.1.5
- fontdb 0.9.1
- lazy_static 1.4.0
- libR-sys 0.3.0
- libc 0.2.126
- log 0.4.17
- lyon 1.0.0
- lyon_algorithms 1.0.0
- lyon_geom 1.0.1
- lyon_path 1.0.0
- lyon_tessellation 1.0.0
- memmap2 0.5.5
- num-traits 0.2.15
- once_cell 1.13.0
- paste 1.0.7
- proc-macro2 1.0.38
- quote 1.0.18
- syn 1.0.94
- ttf-parser 0.15.0
- unicode-xid 0.2.3
- winapi 0.3.9
- winapi-i686-pc-windows-gnu 0.4.0
- winapi-x86_64-pc-windows-gnu 0.4.0
- fontdb 0.9.1
- lyon 1.0
- once_cell 1.13.0
- ttf-parser 0.15
- R >= 4.1 depends
- cli * imports
- tibble * imports
- testthat >= 3.0.0 suggests
- actions/checkout v3 composite
- actions/checkout v2 composite
- dtolnay/rust-toolchain master composite
- r-lib/actions/check-r-package v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
- JamesIves/github-pages-deploy-action 4.1.4 composite
- actions-rs/toolchain v1 composite
- actions/checkout v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
- actions/checkout v4 composite
- yutannihilation/r-wasm-actions/build-rwasm main composite