“在Rcairo_set_font中找不到任何字体”

时间:2017-02-28 17:24:26

标签: r cairo

尝试使用Cairo时出现以下错误:No font found in Rcairo_set_font

这是日志:

> library(Cairo)
> Cairo.capabilities()
   png   jpeg   tiff    pdf    svg     ps    x11    win raster
  TRUE  FALSE  FALSE   TRUE   TRUE   TRUE   TRUE  FALSE   TRUE
> Cairo(600, 600, file="plot.png", type="png", bg="white")
Error in Cairo(600, 600, file = "plot.png", type = "png", bg = "white") :
  No font found in Rcairo_set_font

我在CentOS 7上使用R版本3.2.1(在Docker容器中)。

有人知道我怎么能避免这个错误吗?

我没有在网上找到任何解决此问题的内容......

1 个答案:

答案 0 :(得分:0)

我已设法通过安装using System; using Microsoft.Extensions.Caching.Memory; namespace Memcache { public class Program { private static MemoryCache _cache; private static int _cacheExpSecs; public static void Main(string[] args) { _cache = new MemoryCache(new MemoryCacheOptions()); _cacheExpSecs = 2; var cacheEntryOptions = new MemoryCacheEntryOptions() .SetSlidingExpiration(TimeSpan.FromSeconds(_cacheExpSecs)) .RegisterPostEvictionCallback(callback: EvictionCallback); _cache.Set(1, "One", cacheEntryOptions); _cache.Set(2, "Two", cacheEntryOptions); var autoEvent = new System.Threading.AutoResetEvent(false); System.Threading.Timer timer = new System.Threading.Timer(checkCache, autoEvent, 1000, 6000); Console.Read(); } private static void checkCache(Object o) { if(_cache.Get(1)!=null) { Console.WriteLine(string.Format(@"checkCache: Cache with key {0} will be removed manually and will trigger the callback.", 1)); _cache.Remove(1); } else { Console.WriteLine(string.Format("checkCache: Cache with key {0} is expired.", 1)); } if(_cache.Get(2) != null) { Console.WriteLine(string.Format("checkCache: Cache with key {0} will expire in {1} seconds, but won't trigger the callback until we check it's value again.", 2, _cacheExpSecs)); } else { Console.WriteLine(string.Format("checkCache: Cache with key {0} is expired.", 2)); } } private static void EvictionCallback(object key, object value, EvictionReason reason, object state) { Console.WriteLine(); Console.WriteLine("/*****************************************************/"); Console.WriteLine(string.Format("/* EvictionCallback: Cache with key {0} has expired. */", key)); Console.WriteLine("/*****************************************************/"); Console.WriteLine(); } } } 包来解决此问题:

xorg-x11-fonts-Type1