I'm getting the following warning message with the export_graph() function:
(process:8876): Pango-WARNING **: 19:08:04.072: couldn't load font "Arial Narrow Not-Rotated 10", falling back to "Sans Not-Rotated 10", expect ugly output.
The desired result is a PNG (or any other file) with the Arial Narrow font.
Specifically, I'm trying to use Arial Narrow, which was installed using the extrafont package. The installation is confirmed looking at the fonttable() output. I've also tried using a different font also installed with extrafont and get the same Pango warning.
Strangely, render_graph() produces the desired result on-screen. But I want to export to a PNG file.
Details below:
library(magrittr)
library(DiagrammeR)
# Confirm presence of Arial Narrow
extrafont::fonttable()$FamilyName %>% grepl("Arial Narrow", .) %>% any()
# Create graph
graph <-
create_graph() %>%
add_node(label = "Lorem", node_aes = node_aes(fontname = "Arial Narrow")) %>%
add_node(label = "Ipsum", node_aes = node_aes(fontname = "Arial Narrow")) %>%
add_edge(from = 1, to = 2)
# Renders correctly
render_graph(graph)
# Results in Pango warning, regardless of file type
# (process:8876): Pango-WARNING **: 19:08:04.072: couldn't load font "Arial Narrow Not-Rotated 10", falling back to "Sans Not-Rotated 10", expect ugly output.
export_graph(graph, file_name = "test.png", width = 600)
export_graph(graph, file_name = "test.pdf", width = 600)
export_graph(graph, file_name = "test.svg", width = 600)
export_graph(graph, file_name = "test.ps", width = 600)
Session info below
R version 4.4.0 (2024-04-24 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 10 x64 (build 19045)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.utf8
[2] LC_CTYPE=English_United States.utf8
[3] LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.utf8
time zone: America/Los_Angeles
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] DiagrammeR_1.0.11 magrittr_2.0.3
loaded via a namespace (and not attached):
[1] jsonlite_1.8.8 dplyr_1.1.4 compiler_4.4.0 tidyselect_1.2.1
[5] Rcpp_1.0.12 stringr_1.5.1 rsvg_2.6.0 yaml_2.3.8
[9] fastmap_1.1.1 R6_2.5.1 generics_0.1.3 curl_5.2.1
[13] htmlwidgets_1.6.4 visNetwork_2.1.2 tibble_3.2.1 pillar_1.9.0
[17] RColorBrewer_1.1-3 rlang_1.1.3 utf8_1.2.4 V8_4.4.2
[21] Rttf2pt1_1.3.12 stringi_1.8.3 DiagrammeRsvg_0.1 cli_3.6.2
[25] withr_3.0.0 digest_0.6.35 rstudioapi_0.16.0 lifecycle_1.0.4
[29] vctrs_0.6.5 extrafont_0.19 glue_1.7.0 extrafontdb_1.0
[33] fansi_1.0.6 purrr_1.0.2 tools_4.4.0 pkgconfig_2.0.3
[37] htmltools_0.5.8.1
I'm getting the following warning message with the
export_graph()function:The desired result is a PNG (or any other file) with the Arial Narrow font.
Specifically, I'm trying to use Arial Narrow, which was installed using the
extrafontpackage. The installation is confirmed looking at thefonttable()output. I've also tried using a different font also installed withextrafontand get the same Pango warning.Strangely,
render_graph()produces the desired result on-screen. But I want to export to a PNG file.Details below:
Session info below