[R] Monospaced font not shown correctly (Xubuntu 20.04)

Viechtbauer, Wolfgang (SP) wo||g@ng@v|echtb@uer @end|ng |rom m@@@tr|chtun|ver@|ty@n|
Wed Jan 20 10:10:18 CET 2021


Ah, nevermind. X11Fonts() is only for Xlib.

I'll see if I can figure out how to get 'fc-match Courier' to point to a otf/ttf font. I guess this is explained here: https://www.freedesktop.org/software/fontconfig/fontconfig-user.html

Best,
Wolfgang

>-----Original Message-----
>From: R-help [mailto:r-help-bounces using r-project.org] On Behalf Of Viechtbauer,
>Wolfgang (SP)
>Sent: Wednesday, 20 January, 2021 9:44
>To: Paul Murrell; r-help using r-project.org
>Subject: Re: [R] Monospaced font not shown correctly (Xubuntu 20.04)
>
>Dear Paul,
>
>Thanks for the helpful reply. Indeed:
>
>> fc-match Times
>NimbusRoman-Regular.otf: "Nimbus Roman" "Regular"
>> fc-match Helvetica
>NimbusSans-Regular.otf: "Nimbus Sans" "Regular"
>
>are OpenType fonts. Also:
>
>X11(type="Xlib", family="mono")
>plot(1)
>
>works. So does
>
>X11(family="Courier New") # type="cairo" by default
>plot(1)
>
>or
>
>X11(family="Inconsolata")
>plot(1)
>
>Can I not override what is specified under X11Fonts() with? Because this
>does not work:
>
>X11Fonts(mono="-*-inconsolata-%s-%s-*-*-%d-*-*-*-*-*-*-*")
>X11(family="mono")
>plot(1)
>
>Best,
>Wolfgang
>
>>-----Original Message-----
>>From: Paul Murrell [mailto:paul using stat.auckland.ac.nz]
>>Sent: Wednesday, 20 January, 2021 0:37
>>To: Viechtbauer, Wolfgang (SP); r-help using r-project.org
>>Subject: Re: [R] Monospaced font not shown correctly (Xubuntu 20.04)
>>
>>Hi
>>
>>The switch to XUbunutu 20.04 may mean a switch to Pango > 1.44 (it does
>>on Ubuntu 20.04), which means loss of support for Type 1 fonts (on
>>Cairo-based graphics devices).
>>
>>The Courier fonts (the default for "mono" on Cairo-based devices) that
>>you found are all Type 1 (.pfb) fonts.
>>
>>What does this give you (the matches for the default "sans" and "serif"
>>on Cairo-based devices) ... ?
>>
>>fc-match Times
>>fc-match Helvetica
>>
>>If those are .ttf or .otf fonts then that would explain why "sans" and
>>"serif" still work.
>>
>>A workaround is to specify the family name for a non-Type-1 monospaced
>>font, e.g., "Courier New" (?), or install a non-Type-1 Courier
>>replacement (and specify that).
>>
>>Hope that helps.
>>
>>Paul
>>
>>On 20/01/21 3:48 am, Viechtbauer, Wolfgang (SP) wrote:
>>> Hi all,
>>>
>>> On my system (Xubuntu 20.04), using par(family="mono") is not rendered
>>> correctly. The same issue was raised here:
>>>
>>> https://stackoverflow.com/questions/64207220/rendering-plot-in-r-with-
>>mono-spaced-family-font-does-not-display-characters-any
>>> <https://stackoverflow.com/questions/64207220/rendering-plot-in-r-with-
>>mono-spaced-family-font-does-not-display-characters-any>
>>>
>>> Using par(family="monospace") does work:
>>>
>>> par(mfrow=c(1,2))
>>> par(family="mono")
>>> plot(1)
>>> par(family="monospace")
>>> plot(1)
>>>
>>> Also, when saving to pdf, it works fine:
>>>
>>> pdf("plot.pdf"); par(family="mono"); plot(1); dev.off()
>>>
>>> I have forced a refresh of the font cache:
>>>
>>> fc-cache -r --verbose --really-force
>>>
>>> And Courier is available:
>>>
>>>  > fc-list | grep Courier
>>>
>>> /usr/share/fonts/X11/Type1/c0419bt_.pfb: Courier 10 Pitch:style=Regular
>>> /usr/share/fonts/type1/texlive-fonts-recommended/pcrb8a.pfb:
>>> Courier:style=Bold
>>> /usr/share/fonts/X11/Type1/c0611bt_.pfb: Courier 10 Pitch:style=Bold
>>Italic
>>> /usr/share/fonts/type1/texlive-fonts-recommended/pcrr8a.pfb:
>>> Courier:style=Regular
>>> /usr/share/fonts/X11/Type1/c0582bt_.pfb: Courier 10 Pitch:style=Italic
>>> /usr/share/fonts/X11/Type1/c0583bt_.pfb: Courier 10 Pitch:style=Bold
>>> /usr/share/fonts/type1/texlive-fonts-recommended/pcrro8a.pfb:
>>> Courier:style=Italic
>>> /usr/share/fonts/type1/texlive-fonts-recommended/pcrbo8a.pfb:
>>> Courier:style=Bold Italic
>>>
>>> Any other ideas how to fix this?
>>>
>>> Best,
>>> Wolfgang
>>>
>>> (happy to move this to R-SIG-Debian if this would be more appropriate)
>>>
>>>  > sessionInfo()
>>> R version 4.0.3 (2020-10-10)
>>> Platform: x86_64-pc-linux-gnu (64-bit)
>>> Running under: Ubuntu 20.04.1 LTS
>>>
>>> Matrix products: default
>>> BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
>>> LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/liblapack.so.3
>>>
>>> locale:
>>> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8
>>> [4] LC_COLLATE=C LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
>>> [7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C
>>> [10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>>>
>>> attached base packages:
>>> [1] stats graphics grDevices utils datasets methods base
>>>
>>> loaded via a namespace (and not attached):
>>> [1] compiler_4.0.3 tools_4.0.3
>>>
>>>  > X11Fonts()
>>> $serif
>>> [1] "-*-times-%s-%s-*-*-%d-*-*-*-*-*-*-*"
>>>
>>> $sans
>>> [1] "-*-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*"
>>>
>>> $mono
>>> [1] "-*-courier-%s-%s-*-*-%d-*-*-*-*-*-*-*"
>>>
>>> $Times
>>> [1] "-adobe-times-%s-%s-*-*-%d-*-*-*-*-*-*-*"
>>>
>>> $Helvetica
>>> [1] "-adobe-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*"
>>>
>>> $CyrTimes
>>> [1] "-cronyx-times-%s-%s-*-*-%d-*-*-*-*-*-*-*"
>>>
>>> $CyrHelvetica
>>> [1] "-cronyx-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*"
>>>
>>> $Arial
>>> [1] "-monotype-arial-%s-%s-*-*-%d-*-*-*-*-*-*-*"
>>>
>>> $Mincho
>>> [1] "-*-mincho-%s-%s-*-*-%d-*-*-*-*-*-*-*"
>
>______________________________________________
>R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list