如何解决在Linux/Fedora 31上的R中无法正确显示度数符号的问题 [英] How to fix degree symbol not showing correctly in R on Linux/Fedora 31

查看:187
本文介绍了如何解决在Linux/Fedora 31上的R中无法正确显示度数符号的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作的任何地图:

ggplot()+ geom_sf()

ggplot() + geom_sf()

产生预期的地图,但不能正确显示度数,如下图所示.

produces the expected map, but does not show the degree sign correctly, as appears from the following picture.

此答案中关于SO的答案-度数符号在地图轴中不正确标签-没有帮助,我看到一个不同的标志,所以我要发布一个单独的问题.

The answer given in this answer on SO - degree symbol incorrect in map axis labels - does not help, and I am posting a separate question as I see a different sign.

更改字体无济于事.

我也尝试过使用renv在单独的项目中从Github安装当前版本的sf(0.9),但结果相同.

I've also tried installing the current version of sf (0.9) from Github in a separate project with renv, but have the same result.

我在Linux上使用Fedora 31.

I'm on Linux, Fedora 31.

要复制:

library("ggplot2")
library("sf")
nc <- st_read(system.file("shape/nc.shp", package="sf"))

ggplot() +
  geom_sf(data = nc)

2019-03-15更新

问题并非特定于ggplot/geom_sf;如评论中所建议,我遇到与plot.new(); text(0.5,0.5, bquote(120*degree*N), cex=5)相同的问题

The issue is not specific to ggplot/geom_sf; as suggested in the comments, I get the same issue with plot.new(); text(0.5,0.5, bquote(120*degree*N), cex=5)

此外,为了澄清,我没有在?X11()的帮助下详细介绍过Wine的问题.如果我在终端fc-match Symbol中运行,则会得到:

Also, to clarify, I have not the issue related to Wine detailed in the help of ?X11(). If I run in my terminal, fc-match Symbol, I get:

StandardSymbolsPS.t1:标准符号PS"常规"

StandardSymbolsPS.t1: "Standard Symbols PS" "Regular"

更新2019-03-19

在全新的Fedora 31和Fedora 32 Beta安装中得到确认.可能是Fedora问题.

Confirmed on a fresh Fedora 31 and Fedora 32 beta install. Probably a Fedora issue.

我尝试了不同的语言环境(例如"en_US.UTF-8"或德语")和设备(例如cairo_pdf()cairo_ps()),结果相同.

I tried with different locales (including e.g. "en_US.UTF-8" or "German") and devices (e.g. cairo_pdf(), cairo_ps()) with the same result.

X11.options()将"cairo"显示为类型(将其更改为Xlib或dbcairo不会更改结果).

X11.options() shows "cairo" as type (changing it to Xlib, or dbcairo does not change the result).

使用dww在下面的答案中建议的TestChars()函数显示以下内容:

Using the TestChars() function proposed by dww in the answer below shows the following:

但是,如果我用knitr编织成pdf,我会得到大多数符号,包括°.

However, if I knit to pdf with knitr, I get most symbols, including °.

如果我编织成html,就会得到通常的乱码.

If I knit to html, I get the usual garbled signs.

2020-03-20更新

如@ jpmam1所建议,这似乎与pango中的回归有关,可以通过降级pango暂时修复该回归.但是,对pango进行Dowgrading会破坏操作系统的其他核心部分,例如nautilus.

As suggested by @jpmam1, this seems to be related to a regression in pango, that can be temporarily fixed by downgrading pango. Dowgrading pango however, breaks other core parts of the OS, such as nautilus.

我在Fedora上打开了一个错误: https://bugzilla.redhat.com/show_bug.cgi?id = 1815128

I opened a bug on Fedora: https://bugzilla.redhat.com/show_bug.cgi?id=1815128

推荐答案

事实证明,这种不当行为是由R本身对符号的旧式使用引起的.

As it turns out, this misbehaviour is caused by legacy use of symbols in R itself.

这可能会在R本身的上游修复: https://bugs.r-project.org/bugzilla/show_bug. cgi?id = 17748 收到我对这个问题的反馈后,它引用了我为Fedora打开的下游问题: https://bugzilla.redhat.com/show_bug.cgi?id=1815128

This will likely be fixed upstream in R itself: https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17748 which references the downstream issue I opened for Fedora after the feedback I received to this question: https://bugzilla.redhat.com/show_bug.cgi?id=1815128

IñakiUcar在R邮件列表中发布了一种有效的解决方法: https://stat.ethz.ch/pipermail/r- devel/2020-March/079185.html

A functioning workaround has been published by Iñaki Ucar on the R mailing list: https://stat.ethz.ch/pipermail/r-devel/2020-March/079185.html

我将其复制到此处以供参考:

I copy it here for reference:

$ sudo dnf install gdouros-symbola-fonts

然后将以下内容添加到/etc/fonts/local.conf(系统范围)或 〜/.fonts.conf(仅适用于您的用户):

Then add the following to /etc/fonts/local.conf (system-wide) or ~/.fonts.conf (just for your user):

<fontconfig>
<match target="pattern">
 <test name="family"><string>Symbol</string></test>
 <edit name="family" mode="prepend" binding="same">
   <string>Symbola</string>
 </edit>
</match>
</fontconfig>

现在您应该看到以下内容:

Now you should see this:

$ fc-match Symbol
Symbola.ttf: "Symbola" "Regular"

和符号应正确呈现.

同样,该解决方案归功于IñakiUcar.

Again, credit for this solution goes to Iñaki Ucar.

谢谢所有提供此问题答案的人,以帮助您进行故障排除和简化此过程.希望这将在R核心本身的上游修复.

Thank you all who provided answers to this question for assistance in troubleshooting and facilitating this process. Hopefully, this will be fixed upstream in R core itself.

这篇关于如何解决在Linux/Fedora 31上的R中无法正确显示度数符号的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆