daqana/tikzDevice

geom_label wrong horizontal padding for uppercase labels

inventionate opened this issue · 1 comments

When I set a label with capital letters, the horizontal spacing is calculated incorrectly:

ggplot(mpg, aes(displ, hwy, colour = class)) + 
    geom_point() +
    annotate(
        "label",
        x = 5,
        y = 30,
        size = 15,
        label = "HELLO"
    )

Leads to:

Bildschirmfoto 2021-03-01 um 17 46 58

Maybe I'm doing something wrong? Is there any way to fix this issue?

Sorry for the noise. I had an error configuring the font metrics. With these settings everything works fine:

options(tikzDefaultEngine = "luatex")

options(tikzUnicodeMetricPackages = c(
  "\\usepackage[T1]{fontenc}\n",
  "\usetikzlibrary{calc}\n", 
  "\\usepackage{fontspec}\n",
  "\setmainfont{Fira Sans Condensed}[
BoldFont = FiraSansCondensed-Medium.otf,
BoldItalicFont = FiraSansCondensed-MediumItalic.otf]\n"
  )
)

options(tikzDocumentDeclaration = "\documentclass[11pt]{article}\n")

options(tikzLualatexPackages = c(
  getOption("tikzLualatexPackages"),
  "\setmainfont{Fira Sans Condensed}[
BoldFont = FiraSansCondensed-Medium.otf,
BoldItalicFont = FiraSansCondensed-MediumItalic.otf]\n"
  )
)

Anyway, thank you for this great package!