From 2f1bbc3828689f6ace2eeea97e9dac8671d55f99 Mon Sep 17 00:00:00 2001 From: routersys Date: Fri, 3 Jul 2026 08:48:16 +0900 Subject: [PATCH] =?UTF-8?q?setfont=20=E3=81=B8=E5=9E=8B=E6=A4=9C=E6=9F=BB?= =?UTF-8?q?=E3=81=A8=E6=95=B0=E5=80=A4=E5=A4=89=E6=8F=9B=E3=82=92=E5=B0=8E?= =?UTF-8?q?=E5=85=A5=E3=81=97=20ffi=20=E5=A4=89=E6=8F=9B=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E3=82=92=E6=8E=92=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- native/worker.lua | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/native/worker.lua b/native/worker.lua index 54b5bed..a69243e 100644 --- a/native/worker.lua +++ b/native/worker.lua @@ -368,14 +368,22 @@ end local font = { family = "", size = 34, bold = false, italic = false, color = 0xFFFFFF } function obj.setfont(name, size, style, col1) - if name ~= nil then font.family = tostring(name) end - if size ~= nil then font.size = size end - if style ~= nil then - local s = math.floor(style) - font.bold = (s % 2) == 1 - font.italic = (math.floor(s / 2) % 2) == 1 + local nameType = type(name) + if nameType == "string" then + font.family = name + elseif nameType == "number" then + font.family = tostring(name) end - if col1 ~= nil then font.color = col1 end + local sizeNumber = tonumber(size) + if sizeNumber ~= nil then font.size = sizeNumber end + local styleNumber = tonumber(style) + if styleNumber ~= nil then + local flags = math.floor(styleNumber) + font.bold = (flags % 2) == 1 + font.italic = (math.floor(flags / 2) % 2) == 1 + end + local colorNumber = tonumber(col1) + if colorNumber ~= nil then font.color = colorNumber end end local function applyLoadResult()