A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
fix(native): Apple's glyphs are stored the way the atlas reads them
yhha82663f517d9
diff --git a/desktop/scripts/launch-export.mjs b/desktop/scripts/launch-export.mjsindex 1faddbd1d..1f10c90e6 100644--- a/desktop/scripts/launch-export.mjs+++ b/desktop/scripts/launch-export.mjs@@ -49,6 +49,10 @@ app.commandLine.appendSwitch('enable-unsafe-swiftshader');// capturePage pixels go through the OS display profile; pin sRGB so a colour// judgement reads the same on a wide-gamut machine as on a CI runner.app.commandLine.appendSwitch('force-color-profile', 'srgb');+// And pin the scale, for the same reason the editor's own driver does: a capture+// is in DEVICE pixels, so a scaled display returns a bigger frame than the editor+// it is compared against and parity refuses the pair for differing in size.+app.commandLine.appendSwitch('force-device-scale-factor', '1');// A desktop Chromium reports no touch hardware, so a game that only shows its// on-screen controls to a touch device shows them to nobody here. This is the// emulation a phone would make true.diff --git a/native/host/platform/apple_common.mm b/native/host/platform/apple_common.mmindex d10e90269..75974060e 100644--- a/native/host/platform/apple_common.mm+++ b/native/host/platform/apple_common.mm@@ -18,7 +18,6 @@#include "media/glyph_raster.hpp" // GLYPH_BOLD / GLYPH_ITALIC, for the font match#include "Runtime.hpp" // ESHOST_LOGE#include <vector>-#include <cstring>#include <cmath>namespace eshost {@@ -176,6 +175,9 @@ bool appleDrawGlyph(const std::string& family, u32 codepoint, int style,const int wss = w * ss;const int hss = h * ss;+ // Quartz DRAWS y-up and STORES top-down, which is the atlas' own row order —+ // so this is handed over as it lies. Flipping it here is how the first run of+ // this path put every glyph on its head while the Latin beside it stood up.std::vector<esengine::u8> canvas((size_t)wss * hss, 0);CGContextRef ctx = CGBitmapContextCreate(canvas.data(), (size_t)wss, (size_t)hss, 8,(size_t)wss, NULL, kCGImageAlphaOnly);@@ -191,12 +193,7 @@ bool appleDrawGlyph(const std::string& family, u32 codepoint, int style,CGContextRelease(ctx);CFRelease(font);- // Core Graphics counts rows from the bottom and the atlas from the top.- out.alpha.resize((size_t)wss * hss);- for (int row = 0; row < hss; ++row) {- std::memcpy(out.alpha.data() + (size_t)row * wss,- canvas.data() + (size_t)(hss - 1 - row) * wss, (size_t)wss);- }+ out.alpha = std::move(canvas);out.width = wss;out.height = hss;// The tile's top-left in pen space, y UP — the same two the stb path reports.