R-Markdown font width unknown warning when creating svg chart but not png
I have a report were I output some ggplot-charts with device = svg in rmarkdown. Output-format is html. Unfortunently I get lots of warnings like below. I don't get any warnings if I specify device = png
## Warning in grid.Call(L_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font width unknown for character 0x53
Anybody knows why png works (or atleast doesn't give any warnings) but not svg? Session info and non-reproducible code below. I use extrafont which I guess may have something to do with it.
Sessioninfo:
R version 3.3.1 (2016-06-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
locale:
[1] LC_COLLATE=Swedish_Finland.1252 LC_CTYPE=Swedish_Finland.1252
LC_MONETARY=Swedish_Finland.1252 LC_NUMERIC=C
[5] LC_TIME=Swedish_Finland.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] extrafont_0.17 cairoDevice_2.23 Cairo_1.5-9 RODBC_1.3-13
loaded via a namespace (and not attached):
[1] magrittr_1.5 htmltools_0.3.5 tools_3.3.1 yaml_2.1.13
Rcpp_0.12.5 stringi_1.1.1 rmarkdown_1.0 extrafontdb_1.0
[9] knitr_1.13 stringr_1.0.0 digest_0.6.9 Rttf2pt1_1.3.4
evaluate_0.9
Code-chunk:
```{r plot2, echo = FALSE, fig.show='hold', out.width='50%', dev=c('svg')}
ggplot-code example:
ggplot(dt.bar2_1,
aes(x=factor(Mon), y=nsk_rel, fill =Class)) +
geom_bar(stat="identity", position = "dodge")+
scale_fill_manual(values = c("#6baed6","#3182bd"), name = "Type") +
scale_y_continuous(labels = percent,
breaks = c(0, 0.02, 0.04, 0.06, 0.08, 0.10),
limits = c(0, 0.10))+
theme(axis.text.x = element_text(size=11),
axis.text.y = element_text(size=11))+
xlab("Month") + ylab("Freq")+
ggtitle(Title.2_1) +
theme(plot.title = element_text(family = "Trebuchet MS",
color="#666666",
face="bold",
size=16,
hjust=0))
When calling fonttable()
:
r svg fonts png r-markdown
add a comment |
I have a report were I output some ggplot-charts with device = svg in rmarkdown. Output-format is html. Unfortunently I get lots of warnings like below. I don't get any warnings if I specify device = png
## Warning in grid.Call(L_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font width unknown for character 0x53
Anybody knows why png works (or atleast doesn't give any warnings) but not svg? Session info and non-reproducible code below. I use extrafont which I guess may have something to do with it.
Sessioninfo:
R version 3.3.1 (2016-06-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
locale:
[1] LC_COLLATE=Swedish_Finland.1252 LC_CTYPE=Swedish_Finland.1252
LC_MONETARY=Swedish_Finland.1252 LC_NUMERIC=C
[5] LC_TIME=Swedish_Finland.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] extrafont_0.17 cairoDevice_2.23 Cairo_1.5-9 RODBC_1.3-13
loaded via a namespace (and not attached):
[1] magrittr_1.5 htmltools_0.3.5 tools_3.3.1 yaml_2.1.13
Rcpp_0.12.5 stringi_1.1.1 rmarkdown_1.0 extrafontdb_1.0
[9] knitr_1.13 stringr_1.0.0 digest_0.6.9 Rttf2pt1_1.3.4
evaluate_0.9
Code-chunk:
```{r plot2, echo = FALSE, fig.show='hold', out.width='50%', dev=c('svg')}
ggplot-code example:
ggplot(dt.bar2_1,
aes(x=factor(Mon), y=nsk_rel, fill =Class)) +
geom_bar(stat="identity", position = "dodge")+
scale_fill_manual(values = c("#6baed6","#3182bd"), name = "Type") +
scale_y_continuous(labels = percent,
breaks = c(0, 0.02, 0.04, 0.06, 0.08, 0.10),
limits = c(0, 0.10))+
theme(axis.text.x = element_text(size=11),
axis.text.y = element_text(size=11))+
xlab("Month") + ylab("Freq")+
ggtitle(Title.2_1) +
theme(plot.title = element_text(family = "Trebuchet MS",
color="#666666",
face="bold",
size=16,
hjust=0))
When calling fonttable()
:
r svg fonts png r-markdown
add a comment |
I have a report were I output some ggplot-charts with device = svg in rmarkdown. Output-format is html. Unfortunently I get lots of warnings like below. I don't get any warnings if I specify device = png
## Warning in grid.Call(L_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font width unknown for character 0x53
Anybody knows why png works (or atleast doesn't give any warnings) but not svg? Session info and non-reproducible code below. I use extrafont which I guess may have something to do with it.
Sessioninfo:
R version 3.3.1 (2016-06-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
locale:
[1] LC_COLLATE=Swedish_Finland.1252 LC_CTYPE=Swedish_Finland.1252
LC_MONETARY=Swedish_Finland.1252 LC_NUMERIC=C
[5] LC_TIME=Swedish_Finland.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] extrafont_0.17 cairoDevice_2.23 Cairo_1.5-9 RODBC_1.3-13
loaded via a namespace (and not attached):
[1] magrittr_1.5 htmltools_0.3.5 tools_3.3.1 yaml_2.1.13
Rcpp_0.12.5 stringi_1.1.1 rmarkdown_1.0 extrafontdb_1.0
[9] knitr_1.13 stringr_1.0.0 digest_0.6.9 Rttf2pt1_1.3.4
evaluate_0.9
Code-chunk:
```{r plot2, echo = FALSE, fig.show='hold', out.width='50%', dev=c('svg')}
ggplot-code example:
ggplot(dt.bar2_1,
aes(x=factor(Mon), y=nsk_rel, fill =Class)) +
geom_bar(stat="identity", position = "dodge")+
scale_fill_manual(values = c("#6baed6","#3182bd"), name = "Type") +
scale_y_continuous(labels = percent,
breaks = c(0, 0.02, 0.04, 0.06, 0.08, 0.10),
limits = c(0, 0.10))+
theme(axis.text.x = element_text(size=11),
axis.text.y = element_text(size=11))+
xlab("Month") + ylab("Freq")+
ggtitle(Title.2_1) +
theme(plot.title = element_text(family = "Trebuchet MS",
color="#666666",
face="bold",
size=16,
hjust=0))
When calling fonttable()
:
r svg fonts png r-markdown
I have a report were I output some ggplot-charts with device = svg in rmarkdown. Output-format is html. Unfortunently I get lots of warnings like below. I don't get any warnings if I specify device = png
## Warning in grid.Call(L_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
## font width unknown for character 0x53
Anybody knows why png works (or atleast doesn't give any warnings) but not svg? Session info and non-reproducible code below. I use extrafont which I guess may have something to do with it.
Sessioninfo:
R version 3.3.1 (2016-06-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
locale:
[1] LC_COLLATE=Swedish_Finland.1252 LC_CTYPE=Swedish_Finland.1252
LC_MONETARY=Swedish_Finland.1252 LC_NUMERIC=C
[5] LC_TIME=Swedish_Finland.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] extrafont_0.17 cairoDevice_2.23 Cairo_1.5-9 RODBC_1.3-13
loaded via a namespace (and not attached):
[1] magrittr_1.5 htmltools_0.3.5 tools_3.3.1 yaml_2.1.13
Rcpp_0.12.5 stringi_1.1.1 rmarkdown_1.0 extrafontdb_1.0
[9] knitr_1.13 stringr_1.0.0 digest_0.6.9 Rttf2pt1_1.3.4
evaluate_0.9
Code-chunk:
```{r plot2, echo = FALSE, fig.show='hold', out.width='50%', dev=c('svg')}
ggplot-code example:
ggplot(dt.bar2_1,
aes(x=factor(Mon), y=nsk_rel, fill =Class)) +
geom_bar(stat="identity", position = "dodge")+
scale_fill_manual(values = c("#6baed6","#3182bd"), name = "Type") +
scale_y_continuous(labels = percent,
breaks = c(0, 0.02, 0.04, 0.06, 0.08, 0.10),
limits = c(0, 0.10))+
theme(axis.text.x = element_text(size=11),
axis.text.y = element_text(size=11))+
xlab("Month") + ylab("Freq")+
ggtitle(Title.2_1) +
theme(plot.title = element_text(family = "Trebuchet MS",
color="#666666",
face="bold",
size=16,
hjust=0))
When calling fonttable()
:
r svg fonts png r-markdown
r svg fonts png r-markdown
edited Aug 19 '16 at 8:07
ErrantBard
asked Aug 12 '16 at 7:04
ErrantBardErrantBard
7461026
7461026
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
The problem is, that the svg device does not know the font Trebucht MS. Take a look at the package extrafont
. Install it and import all system fonts with
install.packages("extrafont")
library(extrafont)
font_import()
This will take some minutes. Afterwards put these lines in your RMarkdown document:
```{r}
library(extrafont)
loadfonts(device = "pdf", quiet = T)
```
This should do the trick as long as Trebuchet MS is available on your system.
Thanks @Martin, I actually have the extrafont package loaded and fonts imported. The last line, loadfonts I haven't used though. So tried it but it didn't seem to help. I'm starting to think I should let all this slide even if it irks me that png works but not svg!
– ErrantBard
Aug 19 '16 at 5:56
And when I think about it - the titles for my charts sure look like they have trebuchet as a font, despite warning. If I don't run the theme plot-title part I get another font.
– ErrantBard
Aug 19 '16 at 6:19
@ErrantBard Interesting. It works for me though. Are you sure Trebuchet MS is registered in the extrafontdb?
– Martin Schmelzer
Aug 19 '16 at 7:37
Interesting indeed - something is weird and I don't doubt it is connected to Extrafonts as you say :) See image above, from when I call fonttable.
– ErrantBard
Aug 19 '16 at 8:09
add a comment |
I'm not sure whether you still need any help till. However I've encountered this problem today and I finally find an simple approach. I post it here in case someone need in the future.
Here's the code:
windowsFonts(myFont = windowsFont("TT Times New Rome"))
line_plot = ggplot(data = total_plot_data, aes(x = hour, y = electricity, group = type, colour = type, linetype = type)) +
geom_line(size = 0.75) +
theme(
text = element_text(family = "myFont", size = 15),
legend.text = element_text(size = 10),
);
Simply add a line as windowsFonts(myFont = windowsFont("TT Times New Rome"))
and use element_text(family = "myFont", size = 15)
solve this problem on my computer.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f38911875%2fr-markdown-font-width-unknown-warning-when-creating-svg-chart-but-not-png%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The problem is, that the svg device does not know the font Trebucht MS. Take a look at the package extrafont
. Install it and import all system fonts with
install.packages("extrafont")
library(extrafont)
font_import()
This will take some minutes. Afterwards put these lines in your RMarkdown document:
```{r}
library(extrafont)
loadfonts(device = "pdf", quiet = T)
```
This should do the trick as long as Trebuchet MS is available on your system.
Thanks @Martin, I actually have the extrafont package loaded and fonts imported. The last line, loadfonts I haven't used though. So tried it but it didn't seem to help. I'm starting to think I should let all this slide even if it irks me that png works but not svg!
– ErrantBard
Aug 19 '16 at 5:56
And when I think about it - the titles for my charts sure look like they have trebuchet as a font, despite warning. If I don't run the theme plot-title part I get another font.
– ErrantBard
Aug 19 '16 at 6:19
@ErrantBard Interesting. It works for me though. Are you sure Trebuchet MS is registered in the extrafontdb?
– Martin Schmelzer
Aug 19 '16 at 7:37
Interesting indeed - something is weird and I don't doubt it is connected to Extrafonts as you say :) See image above, from when I call fonttable.
– ErrantBard
Aug 19 '16 at 8:09
add a comment |
The problem is, that the svg device does not know the font Trebucht MS. Take a look at the package extrafont
. Install it and import all system fonts with
install.packages("extrafont")
library(extrafont)
font_import()
This will take some minutes. Afterwards put these lines in your RMarkdown document:
```{r}
library(extrafont)
loadfonts(device = "pdf", quiet = T)
```
This should do the trick as long as Trebuchet MS is available on your system.
Thanks @Martin, I actually have the extrafont package loaded and fonts imported. The last line, loadfonts I haven't used though. So tried it but it didn't seem to help. I'm starting to think I should let all this slide even if it irks me that png works but not svg!
– ErrantBard
Aug 19 '16 at 5:56
And when I think about it - the titles for my charts sure look like they have trebuchet as a font, despite warning. If I don't run the theme plot-title part I get another font.
– ErrantBard
Aug 19 '16 at 6:19
@ErrantBard Interesting. It works for me though. Are you sure Trebuchet MS is registered in the extrafontdb?
– Martin Schmelzer
Aug 19 '16 at 7:37
Interesting indeed - something is weird and I don't doubt it is connected to Extrafonts as you say :) See image above, from when I call fonttable.
– ErrantBard
Aug 19 '16 at 8:09
add a comment |
The problem is, that the svg device does not know the font Trebucht MS. Take a look at the package extrafont
. Install it and import all system fonts with
install.packages("extrafont")
library(extrafont)
font_import()
This will take some minutes. Afterwards put these lines in your RMarkdown document:
```{r}
library(extrafont)
loadfonts(device = "pdf", quiet = T)
```
This should do the trick as long as Trebuchet MS is available on your system.
The problem is, that the svg device does not know the font Trebucht MS. Take a look at the package extrafont
. Install it and import all system fonts with
install.packages("extrafont")
library(extrafont)
font_import()
This will take some minutes. Afterwards put these lines in your RMarkdown document:
```{r}
library(extrafont)
loadfonts(device = "pdf", quiet = T)
```
This should do the trick as long as Trebuchet MS is available on your system.
answered Aug 18 '16 at 21:45
Martin SchmelzerMartin Schmelzer
12.8k23561
12.8k23561
Thanks @Martin, I actually have the extrafont package loaded and fonts imported. The last line, loadfonts I haven't used though. So tried it but it didn't seem to help. I'm starting to think I should let all this slide even if it irks me that png works but not svg!
– ErrantBard
Aug 19 '16 at 5:56
And when I think about it - the titles for my charts sure look like they have trebuchet as a font, despite warning. If I don't run the theme plot-title part I get another font.
– ErrantBard
Aug 19 '16 at 6:19
@ErrantBard Interesting. It works for me though. Are you sure Trebuchet MS is registered in the extrafontdb?
– Martin Schmelzer
Aug 19 '16 at 7:37
Interesting indeed - something is weird and I don't doubt it is connected to Extrafonts as you say :) See image above, from when I call fonttable.
– ErrantBard
Aug 19 '16 at 8:09
add a comment |
Thanks @Martin, I actually have the extrafont package loaded and fonts imported. The last line, loadfonts I haven't used though. So tried it but it didn't seem to help. I'm starting to think I should let all this slide even if it irks me that png works but not svg!
– ErrantBard
Aug 19 '16 at 5:56
And when I think about it - the titles for my charts sure look like they have trebuchet as a font, despite warning. If I don't run the theme plot-title part I get another font.
– ErrantBard
Aug 19 '16 at 6:19
@ErrantBard Interesting. It works for me though. Are you sure Trebuchet MS is registered in the extrafontdb?
– Martin Schmelzer
Aug 19 '16 at 7:37
Interesting indeed - something is weird and I don't doubt it is connected to Extrafonts as you say :) See image above, from when I call fonttable.
– ErrantBard
Aug 19 '16 at 8:09
Thanks @Martin, I actually have the extrafont package loaded and fonts imported. The last line, loadfonts I haven't used though. So tried it but it didn't seem to help. I'm starting to think I should let all this slide even if it irks me that png works but not svg!
– ErrantBard
Aug 19 '16 at 5:56
Thanks @Martin, I actually have the extrafont package loaded and fonts imported. The last line, loadfonts I haven't used though. So tried it but it didn't seem to help. I'm starting to think I should let all this slide even if it irks me that png works but not svg!
– ErrantBard
Aug 19 '16 at 5:56
And when I think about it - the titles for my charts sure look like they have trebuchet as a font, despite warning. If I don't run the theme plot-title part I get another font.
– ErrantBard
Aug 19 '16 at 6:19
And when I think about it - the titles for my charts sure look like they have trebuchet as a font, despite warning. If I don't run the theme plot-title part I get another font.
– ErrantBard
Aug 19 '16 at 6:19
@ErrantBard Interesting. It works for me though. Are you sure Trebuchet MS is registered in the extrafontdb?
– Martin Schmelzer
Aug 19 '16 at 7:37
@ErrantBard Interesting. It works for me though. Are you sure Trebuchet MS is registered in the extrafontdb?
– Martin Schmelzer
Aug 19 '16 at 7:37
Interesting indeed - something is weird and I don't doubt it is connected to Extrafonts as you say :) See image above, from when I call fonttable.
– ErrantBard
Aug 19 '16 at 8:09
Interesting indeed - something is weird and I don't doubt it is connected to Extrafonts as you say :) See image above, from when I call fonttable.
– ErrantBard
Aug 19 '16 at 8:09
add a comment |
I'm not sure whether you still need any help till. However I've encountered this problem today and I finally find an simple approach. I post it here in case someone need in the future.
Here's the code:
windowsFonts(myFont = windowsFont("TT Times New Rome"))
line_plot = ggplot(data = total_plot_data, aes(x = hour, y = electricity, group = type, colour = type, linetype = type)) +
geom_line(size = 0.75) +
theme(
text = element_text(family = "myFont", size = 15),
legend.text = element_text(size = 10),
);
Simply add a line as windowsFonts(myFont = windowsFont("TT Times New Rome"))
and use element_text(family = "myFont", size = 15)
solve this problem on my computer.
add a comment |
I'm not sure whether you still need any help till. However I've encountered this problem today and I finally find an simple approach. I post it here in case someone need in the future.
Here's the code:
windowsFonts(myFont = windowsFont("TT Times New Rome"))
line_plot = ggplot(data = total_plot_data, aes(x = hour, y = electricity, group = type, colour = type, linetype = type)) +
geom_line(size = 0.75) +
theme(
text = element_text(family = "myFont", size = 15),
legend.text = element_text(size = 10),
);
Simply add a line as windowsFonts(myFont = windowsFont("TT Times New Rome"))
and use element_text(family = "myFont", size = 15)
solve this problem on my computer.
add a comment |
I'm not sure whether you still need any help till. However I've encountered this problem today and I finally find an simple approach. I post it here in case someone need in the future.
Here's the code:
windowsFonts(myFont = windowsFont("TT Times New Rome"))
line_plot = ggplot(data = total_plot_data, aes(x = hour, y = electricity, group = type, colour = type, linetype = type)) +
geom_line(size = 0.75) +
theme(
text = element_text(family = "myFont", size = 15),
legend.text = element_text(size = 10),
);
Simply add a line as windowsFonts(myFont = windowsFont("TT Times New Rome"))
and use element_text(family = "myFont", size = 15)
solve this problem on my computer.
I'm not sure whether you still need any help till. However I've encountered this problem today and I finally find an simple approach. I post it here in case someone need in the future.
Here's the code:
windowsFonts(myFont = windowsFont("TT Times New Rome"))
line_plot = ggplot(data = total_plot_data, aes(x = hour, y = electricity, group = type, colour = type, linetype = type)) +
geom_line(size = 0.75) +
theme(
text = element_text(family = "myFont", size = 15),
legend.text = element_text(size = 10),
);
Simply add a line as windowsFonts(myFont = windowsFont("TT Times New Rome"))
and use element_text(family = "myFont", size = 15)
solve this problem on my computer.
answered Dec 29 '18 at 8:45
XinzXinz
563
563
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f38911875%2fr-markdown-font-width-unknown-warning-when-creating-svg-chart-but-not-png%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown