mini-arcade-native-backend 0.4.3__tar.gz → 0.4.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mini_arcade_native_backend-0.4.3 → mini_arcade_native_backend-0.4.4}/CHANGELOG.md +11 -0
- {mini_arcade_native_backend-0.4.3 → mini_arcade_native_backend-0.4.4}/PKG-INFO +1 -1
- {mini_arcade_native_backend-0.4.3 → mini_arcade_native_backend-0.4.4}/cpp/bindings.cpp +7 -1
- {mini_arcade_native_backend-0.4.3 → mini_arcade_native_backend-0.4.4}/cpp/engine.cpp +24 -0
- {mini_arcade_native_backend-0.4.3 → mini_arcade_native_backend-0.4.4}/cpp/engine.h +5 -0
- {mini_arcade_native_backend-0.4.3 → mini_arcade_native_backend-0.4.4}/pyproject.toml +1 -1
- {mini_arcade_native_backend-0.4.3 → mini_arcade_native_backend-0.4.4}/src/mini_arcade_native_backend/__init__.py +12 -0
- {mini_arcade_native_backend-0.4.3 → mini_arcade_native_backend-0.4.4}/.github/workflows/ci.yml +0 -0
- {mini_arcade_native_backend-0.4.3 → mini_arcade_native_backend-0.4.4}/.github/workflows/create-release-branch.yml +0 -0
- {mini_arcade_native_backend-0.4.3 → mini_arcade_native_backend-0.4.4}/.github/workflows/release-finalize.yml +0 -0
- {mini_arcade_native_backend-0.4.3 → mini_arcade_native_backend-0.4.4}/.github/workflows/release-publish.yml +0 -0
- {mini_arcade_native_backend-0.4.3 → mini_arcade_native_backend-0.4.4}/.gitignore +0 -0
- {mini_arcade_native_backend-0.4.3 → mini_arcade_native_backend-0.4.4}/.vscode/settings.json +0 -0
- {mini_arcade_native_backend-0.4.3 → mini_arcade_native_backend-0.4.4}/CMakeLists.txt +0 -0
- {mini_arcade_native_backend-0.4.3 → mini_arcade_native_backend-0.4.4}/LICENSE +0 -0
- {mini_arcade_native_backend-0.4.3 → mini_arcade_native_backend-0.4.4}/README.md +0 -0
- {mini_arcade_native_backend-0.4.3 → mini_arcade_native_backend-0.4.4}/examples/native_backend_demo.py +0 -0
- {mini_arcade_native_backend-0.4.3 → mini_arcade_native_backend-0.4.4}/poetry.lock +0 -0
- {mini_arcade_native_backend-0.4.3 → mini_arcade_native_backend-0.4.4}/poetry.toml +0 -0
- {mini_arcade_native_backend-0.4.3 → mini_arcade_native_backend-0.4.4}/tests/test_init.py +0 -0
|
@@ -6,6 +6,17 @@ This project adheres to [Semantic Versioning](https://semver.org/).
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.4.4] - 2025-12-16
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
- add measure_text method to Engine and expose it in NativeBackend
|
|
13
|
+
- add alpha handling methods and refactor color extraction in NativeBackend
|
|
14
|
+
- update draw_rect and draw_text methods to support alpha channel in color
|
|
15
|
+
|
|
16
|
+
### Other
|
|
17
|
+
- Merge branch 'release/0.4' of https://github.com/alexsc6955/mini-arcade-native-backend into release/0.4
|
|
18
|
+
- Merge branch 'release/0.4' of https://github.com/alexsc6955/mini-arcade-native-backend into release/0.4
|
|
19
|
+
|
|
9
20
|
## [0.4.3] - 2025-12-16
|
|
10
21
|
|
|
11
22
|
### Added
|
|
@@ -79,5 +79,11 @@ PYBIND11_MODULE(_native, m) {
|
|
|
79
79
|
.def("poll_events", &mini::Engine::poll_events)
|
|
80
80
|
|
|
81
81
|
.def("capture_frame", &mini::Engine::capture_frame,
|
|
82
|
-
py::arg("path"))
|
|
82
|
+
py::arg("path"))
|
|
83
|
+
.def(
|
|
84
|
+
"measure_text",
|
|
85
|
+
&mini::Engine::measure_text,
|
|
86
|
+
py::arg("text"),
|
|
87
|
+
py::arg("font_id") = -1
|
|
88
|
+
);
|
|
83
89
|
}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
#include <stdexcept>
|
|
4
4
|
#include <iostream>
|
|
5
|
+
#include <utility>
|
|
6
|
+
#include <cstring>
|
|
5
7
|
|
|
6
8
|
namespace mini {
|
|
7
9
|
|
|
@@ -381,4 +383,26 @@ namespace mini {
|
|
|
381
383
|
return events;
|
|
382
384
|
}
|
|
383
385
|
|
|
386
|
+
std::pair<int, int> Engine::measure_text(const char* text, int font_id)
|
|
387
|
+
{
|
|
388
|
+
if (!initialized_) return {0, 0};
|
|
389
|
+
|
|
390
|
+
int idx = (font_id >= 0) ? font_id : default_font_id_;
|
|
391
|
+
if (idx < 0 || idx >= (int)fonts_.size() || fonts_[idx] == nullptr) return {0, 0};
|
|
392
|
+
|
|
393
|
+
if (text == nullptr || text[0] == '\0') return {0, 0};
|
|
394
|
+
|
|
395
|
+
int w = 0;
|
|
396
|
+
int h = 0;
|
|
397
|
+
|
|
398
|
+
// TTF_SizeUTF8 returns 0 on success, -1 on error
|
|
399
|
+
if (TTF_SizeUTF8(fonts_[idx], text, &w, &h) != 0) {
|
|
400
|
+
// Optional: log error
|
|
401
|
+
// std::cerr << "TTF_SizeUTF8 Error: " << TTF_GetError() << std::endl;
|
|
402
|
+
return {0, 0};
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
return {w, h};
|
|
406
|
+
}
|
|
407
|
+
|
|
384
408
|
} // namespace mini
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
#include <SDL_ttf.h>
|
|
5
5
|
#include <vector>
|
|
6
6
|
#include <string>
|
|
7
|
+
#include <utility>
|
|
7
8
|
|
|
8
9
|
// A minimal 2D graphics engine binding for Python using SDL.
|
|
9
10
|
namespace mini {
|
|
@@ -89,6 +90,10 @@ namespace mini {
|
|
|
89
90
|
// Returns true on success, false on failure.
|
|
90
91
|
bool capture_frame(const char* path);
|
|
91
92
|
|
|
93
|
+
// Measure text (UTF-8) using a loaded font.
|
|
94
|
+
// Returns (width, height) in pixels. Returns (0,0) if no valid font or error.
|
|
95
|
+
std::pair<int, int> measure_text(const char* text, int font_id = -1);
|
|
96
|
+
|
|
92
97
|
private:
|
|
93
98
|
SDL_Window* window_; // The main application window.
|
|
94
99
|
SDL_Renderer* renderer_; // The renderer for drawing.
|
|
@@ -8,7 +8,7 @@ build-backend = "scikit_build_core.build"
|
|
|
8
8
|
|
|
9
9
|
[project]
|
|
10
10
|
name = "mini-arcade-native-backend"
|
|
11
|
-
version = "0.4.
|
|
11
|
+
version = "0.4.4"
|
|
12
12
|
description = "Native SDL2 backend for mini-arcade-core using SDL2 + pybind11."
|
|
13
13
|
authors = [
|
|
14
14
|
{ name = "Santiago Rincon", email = "rincores@gmail.com" },
|
|
@@ -324,3 +324,15 @@ class NativeBackend(Backend):
|
|
|
324
324
|
if path is None:
|
|
325
325
|
raise ValueError("Path must be provided to capture frame.")
|
|
326
326
|
return self._engine.capture_frame(path)
|
|
327
|
+
|
|
328
|
+
def measure_text(self, text: str) -> tuple[int, int]:
|
|
329
|
+
"""
|
|
330
|
+
Measure text size (width, height) in pixels for the active font.
|
|
331
|
+
|
|
332
|
+
Returns (0,0) if no font is loaded (matches draw_text no-op behavior).
|
|
333
|
+
"""
|
|
334
|
+
font_id = (
|
|
335
|
+
self._default_font_id if self._default_font_id is not None else -1
|
|
336
|
+
)
|
|
337
|
+
w, h = self._engine.measure_text(text, font_id)
|
|
338
|
+
return int(w), int(h)
|
{mini_arcade_native_backend-0.4.3 → mini_arcade_native_backend-0.4.4}/.github/workflows/ci.yml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|