r-lib / marquee

Markdown Parser and Renderer for R Graphics
https://marquee.r-lib.org
Other
85 stars 1 forks source link

font looks slightly different, particularly when article is a github website #29

Closed davidhodge931 closed 5 months ago

davidhodge931 commented 5 months ago

Does the font (or font spacing) change when using element_marquee()?

Maybe it looks ever-so-slightly different in the console and in a Rmd article - but it looks very different when the article is pushed to github.

Console without marquee

image

Console with marquee

image

pkdown Rmd article in local with marquee

image

pkdown Rmd article on github built website with marquee

image

I noticed this in this blog as well https://nrennie.rbind.io/blog/coloured-text-legend-ggplot-ggtext-marquee/

thomasp85 commented 5 months ago

Thanks for this. It is somewhat expected and impossible to guard against. Marquee uses textshaping and systemfonts to find and place glyphs which may be different from how the graphics device works for regular text.

Can you tell me which graphics devices are in effect in the above plots?

davidhodge931 commented 5 months ago

Thanks for the explanation.

If that is the case, it'd be cool to have a function to convert all element_text elements in a theme to element_marquee, so the font within the plot looked 100% consistent.

The global settings had Cairo png

thomasp85 commented 5 months ago

yes, especially Cairo will look a bit different. Emphasised if you are using the font aliases as these may map to a different font entirely. If you use the ragg devices it should all look pretty similar

thomasp85 commented 5 months ago

There is now a marquefy_theme() function as well as a bunch of fixes to make justification and margins of element_marquee more in line with element_text

davidhodge931 commented 5 months ago

Awesome, thanks!!

davidhodge931 commented 5 months ago

Something that just came to mind.. I wonder whether it'll get slightly confusing, if you spell marquefy with one e here.

A couple of other ideas are:

This function will be super useful, thanks!

teunbrand commented 5 months ago

Wouldn't it more ideal if + theme(text = element_marquee()) would just work?

thomasp85 commented 5 months ago

I'm not sure that is possible... How would you, as user, then have a root level marquee element but set a specific element to element_text()

teunbrand commented 5 months ago

For sure it isn't currently possible. But I think you could either add an inherit.class argument or have an element_placeholder() that just adopts the parent's class.

thomasp85 commented 5 months ago

We can muse about this in the ggplot2 repo - this isn't really up to marquee :-)