Giter Site home page Giter Site logo

Comments (8)

yixuan avatar yixuan commented on September 14, 2024 2

OK, now I know the problem. The fact is not that the spacing is doubled, but that the font sizes are made smaller. ggsave() has a default dpi = 300 argument, while showtext_opts() has dpi = 96. Simply add the following line will fix the issue.

showtext_opts(dpi = 300)

The same reason applies to Rmarkdown. You need to make sure the dpi knitr option is consistent with the one in showtext.

from showtext.

larmarange avatar larmarange commented on September 14, 2024

Same issue observed

from showtext.

yixuan avatar yixuan commented on September 14, 2024

I'll take a look some time later this week.

from showtext.

yixuan avatar yixuan commented on September 14, 2024

I was trying to investigate this issue today, but I couldn't reproduce it. The spacing seems correct for the minimal example below. Can someone give me a (runnable) example that has double spacing?

library(showtext)
library(ggplot2)

showtext_auto()

dat = data.frame(x = c("AAA\nAAA", "BBB\nBBB", "CCC\nCCC"), y = 1:3)
x11()
ggplot(dat, aes(x = x, y = y)) +
    geom_bar(stat = "identity") +
    ggtitle("First Line\nsecond line") +
    theme_grey(base_family = "sans")

image

from showtext.

PDjupe avatar PDjupe commented on September 14, 2024

from showtext.

larmarange avatar larmarange commented on September 14, 2024

The issue is also observed when using showtext within a Rmarkdown document.

from showtext.

larmarange avatar larmarange commented on September 14, 2024

Would it be possible to find a way in Rmarkdown for showtext to detect automatically the dpi used by knitr?

from showtext.

yixuan avatar yixuan commented on September 14, 2024

@larmarange I find that adding the following option to the document header automatically solves the problem. Can you confirm this?

---
output:
    html_document:
        fig_retina: 1
---

from showtext.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.