[0.17.36] Factorio renders fonts with sharp corners incorrectly

Things that we don't consider worth fixing at this moment.
tux_mark_5
Long Handed Inserter
Long Handed Inserter
Posts: 68
Joined: Thu Jan 15, 2015 2:20 pm
Contact:

[0.17.36] Factorio renders fonts with sharp corners incorrectly

Post by tux_mark_5 »

Factorio fails to render fonts correctly when using game.rendering API to render some text with a custom font:
Screenshot_20190503_215839.png
Screenshot_20190503_215839.png (309.64 KiB) Viewed 1802 times
All of these round-ish things seen in the screenshot should be rectangles. I'm attaching sample font that exhibits issue. I've observed this problem with several different fonts.
Attachments
TuxDisplay.ttf.zip
(2.37 KiB) Downloaded 91 times
Bilka
Factorio Staff
Factorio Staff
Posts: 3309
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: [0.17.36] Factorio renders fonts with sharp corners incorrectly

Post by Bilka »

Please provide a full font prototype definition, and a command to render the font so that we know the scale etc.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
tux_mark_5
Long Handed Inserter
Long Handed Inserter
Posts: 68
Joined: Thu Jan 15, 2015 2:20 pm
Contact:

Re: [0.17.36] Factorio renders fonts with sharp corners incorrectly

Post by tux_mark_5 »

info.json to add new font to the locale:

Code: Select all

{
  "language-name": "English",
  "font": {
    "tux-display":
    [
      "__TuxControls__/fonts/TuxDisplay.ttf" 
    ]
  }
}
The prototype:

Code: Select all

data:extend{
  {
    type = "font",
    name = "tux-display",
    from = "tux-display",
    size = 100,
  },
}
The function used to create 5 strings on top of a given entity:

Code: Select all

function create_chars(entity)
  local num_chars = 5
  local step_x = (100 + 1) * 0.5 / 32
  local origin_x = 0 - (num_chars - 1) * (step_x / 2)

  for i = 1, num_chars do
    local delta_x = origin_x + (i - 1) * step_x

    local char = rendering.draw_text{
      text = "U\x7FC\x7FU",
      surface = entity.surface,
      target = entity,
      target_offset = {delta_x, -4/32},
      color = {1.0, 1.0, 1.0},
      scale = 0.5,
      font = "tux-display",
      alignment = "center",
      scale_with_zoom = false,
    }
  end
end
I've tried different size/scale combos to see if that somehow increases "the internal resolution" of a font, but that seems to have no effect.
posila
Factorio Staff
Factorio Staff
Posts: 5344
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: [0.17.36] Factorio renders fonts with sharp corners incorrectly

Post by posila »

Thanks for the report. The game uses SDF (signed distance field) for rendering fonts, so it doesn't need to raster glyphs for different scales all the time. This could be probably fixed by using MSDF (multichannel signed distance field), but at the moment we don't plan to implement that.
tux_mark_5
Long Handed Inserter
Long Handed Inserter
Posts: 68
Joined: Thu Jan 15, 2015 2:20 pm
Contact:

Re: [0.17.36] Factorio renders fonts with sharp corners incorrectly

Post by tux_mark_5 »

That's what I was afraid of (signed distance fields for font rendering); I've dabbled with font rendering myself a bit before.

Would it be possible to add an additional parameter to the font prototype as a workaround to control internal resolution of the distance field for a specific font?
Post Reply

Return to “Won't fix.”