Skip to content

Add italic, fontweight, and fontwidth as aesthetics for geom_text() and as arguments to element_text() #6458

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
thomasp85 opened this issue May 14, 2025 · 4 comments
Labels
feature a feature request or enhancement layers 📈 themes 💃
Milestone

Comments

@thomasp85
Copy link
Member

As we all know the fontface spec is horribly limited. I think we can figure out a way to leverage systemfonts to circumvent this, though device support will be limited (quartz, ragg, and svglite AFAIK)

However, it wouldn't impair on current behaviour so that really shouldn't be a blocker

@thomasp85 thomasp85 added this to the Editioning milestone May 14, 2025
@thomasp85 thomasp85 added feature a feature request or enhancement themes 💃 layers 📈 labels May 14, 2025
@teunbrand
Copy link
Collaborator

teunbrand commented May 29, 2025

As we're converting to S7, do we want to already add these as properties to minimise backward compatibility pain in the next release? Alternatively, should we just allow a grid::glyphFont()?

@thomasp85
Copy link
Member Author

What kind of compatibility issues do you envision by adding properties at a later point?

I don't think we should go the glyphFont route -- that would prevent us from eg scaling weight

@teunbrand
Copy link
Collaborator

teunbrand commented May 29, 2025

Say some extensions {foo} defines an element_text subclass. Their class definition is fixed upon build time. ggplot2 updates their element_text definition with new properties. The {foo} subclass is now incomplete. If we include these properties now, the {foo} subclass will not be incomplete later.

I don't think we should go the glyphFont route -- that would prevent us from eg scaling weight

Fair point

@thomasp85
Copy link
Member Author

Good point. So maybe add them to element_text() but don't have them in the constructor etc

teunbrand added a commit to teunbrand/ggplot2 that referenced this issue May 29, 2025
teunbrand added a commit that referenced this issue Jun 11, 2025
* add S7 as import

* custom properties for theme elements

* convert theme elements to S7 classes

* adapt element definitions

* convert element_grob to S7 generic

* replace merge_element by S7

* implement `$.element` for backward compatibility

* Use S7 properties

* fix `inherits()` issues

* fix misc issues

* Revert "implement `$.element` for backward compatibility"

This reverts commit b038e8f.

* don't rely on `element$prop`

* move element properties

* convert `margin` to S7

* I liked index properties as an idea but apparently they print badly

* adapt failing example

* import S7

* convert theme to S7

* Reimplement S3 <uneval> into S7 <mapping>

* convert labels to S7

* make S7 class_ggplot

* Use `@` as accessor

* double dispatch for `ggplot_add()`

* Write methods for external generics as S7

* backward compatibility for ggplot class

* Implement <ggplot_built> as S7

* implement `as.gtable` methods

* rename mapping to class_mapping

* refine class_ggplot_built and related functions

* also access ggplot_built slots with normal extractors

* resolve gnarlyness in S3/S7 method conflicts

* fix esoteric 'promise already under evaluation' error

* fix series of minor issues

* export theme as class

* export labels class

* collect classes in one place

* revert @include decisions

* Make S7 generic of `get_alt_text()`

* backport `@`

* exempt classes from pkgdown

* lol at my incompetence

* allow variant error messages

* workaround for old R versions

* update pkgdown index

* backport `@`

* S7-aware `is_theme_element()`

* utility for grabbing props

* use classic extractors and subassignment

* fallback for `register_theme_elements()`

* contingencies for `inherits(x, <S7>)` on old R versions

* use `is_theme()`

* sprinkle notes

* bump staged deprecations

* add linejoins

* Disable `ggtext::element_markdown()` example

* fix failing tests

* redocument

* fix doc links

* soft-deprecate `%+%`

* simplify logic block

* don't evaluate code temporarily in FAQ example

* run revdepcheck

* recover from S3 mappings

* enable classic subsetting for ggplot_built

* fix typo

* prevent NSE shenannigans

* avoid `%+%` in test code

* add 'meta' property to track arbitrary fields

* document new property

* fix stretchy guide bug

* backward compatibility for `ggplot_add()`

* backward compatibility for `ggplot_add()`

* notes for the future

* backward compatibility for `ggplot_gtable()`

* backwards compatibility for `element_grob()`

* keep theme class

* add news bullet

* redirect other news

* add `italic`/`fontweight`/`fontwidth` properties (#6458)

* contingencies for old elements

* left out null/blank handling to from methods to generic

* also merge s3 elements

* revdepcheck

* remove outdated duplicate

* append old element classes

* append old uneval class

* append old ggplot classes

* allow for numeric `face`

* Symmetry between `$` and `[[` methods

* Revert `ggplot()` constructor to S3

* fallback for unit margins

* repair invalid theme

* make `rotate_just()` resilient for mixed S3/S7 classes

* redocument/snapshot

* revdepcheck

* contend with vector input

* unify mapping validation

* more carefullyl extract margins

* try to prevent cyclical `+`

* include snapshots

* protection against vectorised input

* fix  typo

* add `as.list()` method

* be fussy about margin input length

* tiny version bump

* allow numeric colour

* defend against insanity

---------

Co-authored-by: Thomas Lin Pedersen <thomasp85@gmail.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
feature a feature request or enhancement layers 📈 themes 💃
Projects
None yet
Development

No branches or pull requests

2 participants