Skip to content

Surface resvg font fallback warnings #50

@hukka

Description

@hukka

For some reason if text with character "₂" (subscript 2) is rendered with vg2png, the whole text is rendered as bold. vg2svg and the online vega editor do not render the text like that.

For example this document

{
  "width": 500,
  "height": 500,
  "autosize": "pad",
  "marks": [
    {
      "type": "text",
      "from": {"data": "table"},
      "encode": {
        "enter": {
          "x": {"field": {"group": "width"}, "mult": 0.5},
          "radius": {"signal": "width / 2 - 10"},
          "text": {
            "signal": "datum.id"
          },
          "fill": {"value": "#000"},
          "fontSize": {"value": 20},
          "baseline": {"value": "middle"},
          "y": {"field": {"group": "width"}, "mult": 0.5},
          "theta": {"signal": "(datum.startAngle + datum.endAngle)/2"}
        }
      }
    },
    {
      "type": "arc",
      "from": {"data": "table"},
      "encode": {
        "enter": {
          "fill": {"scale": "color", "field": "id"},
          "x": {"signal": "width / 2"},
          "y": {"signal": "width / 2"}
        },
        "update": {
          "startAngle": {"field": "startAngle"},
          "endAngle": {"field": "endAngle"},
          "innerRadius": {"value": 120},
          "outerRadius": {"value": 140}
        }
      }
    }
  ],
  "scales": [
    {
      "name": "color",
      "type": "ordinal",
      "domain": {"data": "table", "field": "id"},
      "range": {"scheme": "blueorange"}
    }
  ],
  "legends": [
    {
      "fill": "color",
      "labelFontSize": 30
    }
  ],
  "$schema": "https//vega.github.io/schema/vega/v5.json",
  "data": [
    {
      "name": "table",
      "values": [
        {
          "id": "foo₂",
          "field": 4
        },
        {
          "id": "foofoo₂",
          "field": 6
        },
        {
          "id": "bar",
          "field": 10
        }
      ],
      "transform": [
        {"type": "pie", "field": "field", "sort": true},
        {
          "type": "window",
          "groupby": [],
          "ops": ["sum"],
          "fields": ["field"],
          "as": ["total"],
          "frame": [null, null]
        }
      ]
    }
  ],
  "background": "white",
  "description": "A basic donut chart example.",
  "config": {}
}

with command vl-convert vg2png --input visualization.vg.json --output test.png will render like
image

while vl-convert vg2svg --input visualization.vg.json --output test.svg like
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions