Factorio fails to render fonts correctly when using game.rendering API to render some text with a custom font:
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.
[0.17.36] Factorio renders fonts with sharp corners incorrectly
-
- Long Handed Inserter
- Posts: 68
- Joined: Thu Jan 15, 2015 2:20 pm
- Contact:
[0.17.36] Factorio renders fonts with sharp corners incorrectly
- Attachments
-
- TuxDisplay.ttf.zip
- (2.37 KiB) Downloaded 91 times
Re: [0.17.36] Factorio renders fonts with sharp corners incorrectly
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.
-
- 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
info.json to add new font to the locale:
The prototype:
The function used to create 5 strings on top of a given entity:
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.
Code: Select all
{
"language-name": "English",
"font": {
"tux-display":
[
"__TuxControls__/fonts/TuxDisplay.ttf"
]
}
}
Code: Select all
data:extend{
{
type = "font",
name = "tux-display",
from = "tux-display",
size = 100,
},
}
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
Re: [0.17.36] Factorio renders fonts with sharp corners incorrectly
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.
-
- 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
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?
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?