multitheftauto / mtasa-blue

Multi Theft Auto is a game engine that incorporates an extendable network play element into a proprietary commercial single-player game.
https://multitheftauto.com
GNU General Public License v3.0
1.3k stars 412 forks source link

Importing custom fonts does not work in Wine #3483

Open lighterly opened 1 week ago

lighterly commented 1 week ago

Describe the bug

When I try to import any type of font for any purpose, whether using guiCreateFont or dxCreateFont, the font simply does not load when tested in MTA San Andreas. Custom fonts work IF I am only on Windows; if I am using Wine on Linux, they will not load, and if they do load, the font will be damaged and full of artifacts. image image

Example: meta.xml image client.lua image

Steps to reproduce

  1. Use any type of GNU/Linux distribution (seriously), this happens on Arch Linux and NixOS
  2. Use wine-staging
  3. Set "WINEARCH" to "win32"
  4. Install MTA San Andreas stable or nightly (it happens on both)
  5. Add a custom font to be downloaded on a server created by yourself in the meta.xml, load it on the client-side via script, and try to create a test text
  6. Encounter a font that is not loaded at all.

Version

Client: Multi Theft Auto v1.6-release-22518 Server: MTA:SA Server v1.6-release-22476

Additional context

One more detail, on the MTA San Andreas Wiki page there is a topic discussing font artifacts, but the preview image is unavailable with a link to an image on Discord, and even after following the 3 steps to create an override for the 'd3dx9_42' library selecting 'Builtin (Wine)', the game no longer opens, showing the error 'MTA client integrity violation' (it seems that this solution used to work, but over time it broke). image

Relevant log output

No response

Security Policy

lighterly commented 1 week ago

Okay, look, I have been doing some tests to try to work around and find a temporary solution for this error. From what I understand, it seems that any type of custom font loaded works correctly in Wine only if you use guiCreateFont.

However, if you use a function from the drawing functions like dxCreateFont, some fonts will display artifacts or won't load correctly (in my case, the Aharoni Bold only works with guiCreateFont. I tested with the Minecraft font, and it loaded normally with both functions). It must be a minor issue that no one has noticed, but I believe it is simple to fix.

It is worth mentioning that this problem only happens in Wine; it does not occur in Windows.

using guiCreateFont: image

using DxCreateFont: image

client/fonts.lua

fonts = {}
fonts.aharoniBold = dxCreateFont("fonts/AharoniBold.ttf", 12)

_fonts = {
    ["aharoniBold"] = guiCreateFont("fonts/AharoniBold.ttf", 12),
}

client/test.lua

local screenX, screenY = guiGetScreenSize() -- Get the screen resolution (width and height)

local onClientRender

bindKey("z", "up", function()
    onClientRender = function()
        dxDrawBorderedText(0, "This is just a test!", 0, 0, screenX, screenY * 0.8, tocolor(255, 255, 255, 255), 1, fonts.aharoniBold, "center", "bottom", false, false)
    end

    addEventHandler("onClientRender", root, onClientRender)

    local timer = setTimer(function()
        removeEventHandler("onClientRender", root, onClientRender)
    end, 1000, 1)
end)

I don't know if I can provide a link to download the font here, but it's free and from Microsoft (and is used inside GTA San Andreas, I believe). The problem doesn't occur only with this font but with others as well; just test several.