Page 1 of 1
[0.17.36] Factorio renders fonts with sharp corners incorrectly
Posted: Fri May 03, 2019 7:08 pm
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 (309.64 KiB) Viewed 2134 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.
Re: [0.17.36] Factorio renders fonts with sharp corners incorrectly
Posted: Fri May 03, 2019 7:14 pm
by Bilka
Please provide a full font prototype definition, and a command to render the font so that we know the scale etc.
Re: [0.17.36] Factorio renders fonts with sharp corners incorrectly
Posted: Fri May 03, 2019 7:20 pm
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.
Re: [0.17.36] Factorio renders fonts with sharp corners incorrectly
Posted: Fri May 03, 2019 7:21 pm
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.
Re: [0.17.36] Factorio renders fonts with sharp corners incorrectly
Posted: Fri May 03, 2019 7:27 pm
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?