Openlayers 4.4.0+ 文本样式无法识别可缩放单位 (Ems)

Openlayers 4.4.0+ text style not recognizing scalable units (Ems)

我们目前正在尝试将我们的应用程序从 Openlayers v4.2.0 升级到 v4.4.2,但在显示使用字体 属性 中的可缩放单位 (Ems) 的文本样式时遇到问题。下面是用于创建文本样式的代码段。

var fill = new ol.style.Fill({ color: "black" });
var textStyle = new ol.style.Text({
  text: "A",
  font: "normal 1em Lato",
  textBaseline: 'bottom',
  fill: fill
});

this CodePen中我使用的是4.3.4版本,文字与正文中指定的字体大小相匹配。

this CodePen I have used version 4.4.0 and the text is much smaller. I believe it is using the default font property value of 10px sans-serif as specified in this 文档中。

我的字体 属性 值是否有错误?还是有另一种方法可以使用 Openlayers 文本样式和更新版本来实现可扩展单元?还是不建议在这种情况下使用可缩放字体?

文本渲染系统在 v4.4.0 中完全重写,以获得更好的性能。您看到的不同之处在于,文本现在被预呈现到一个单独的 canvas,它不会从 DOM 继承任何 css。因此,无论您体内有什么 font-size(或任何影响地图容器的 css),地图上呈现的文本 em 将始终基于默认 font-size 使用的字体。