From c6efc4a93e56d317ad344534083a51b244b43b1f Mon Sep 17 00:00:00 2001 From: Xenolphthalein <21215869+Xenolphthalein@users.noreply.github.com> Date: Thu, 3 Dec 2026 11:40:44 +0100 Subject: [PATCH 1/2] fix(pico4-monado): the pairing's title keeps clear of the hand pills, and no page's texts overlap in any language In Arabic the controllers' pairing (the setup's first page and the panel in front) drew its title under the left and right pills: a right-to-left title starts at the top bar's right edge, where the pills are. The top bar now keeps the pills' room, a pill gives its words only their own width, and bold text is measured bold, as it is drawn (a button's English "Continue" was cut short without Steam's fonts). Both panels' --render records where each text lands and fails when two of a page's texts overlap; the recipe renders every page in each of our 31 languages with it. For overpressure/phoenix#179 --- phoenix/pico4-monado/PKGBUILD | 18 +++-- .../pico4-monado/overpressure-settings.cpp | 9 ++- phoenix/pico4-monado/pico4-onboarding.cpp | 10 ++- phoenix/pico4-monado/pico4_pair_ui.hpp | 7 +- phoenix/pico4-monado/pico4_text.hpp | 77 +++++++++++++++++++ phoenix/pico4-monado/pico4_ui.hpp | 17 ++-- 6 files changed, 116 insertions(+), 22 deletions(-) diff --git a/phoenix/pico4-monado/PKGBUILD b/phoenix/pico4-monado/PKGBUILD index a3ed9a8..12aaa41 100644 --- a/phoenix/pico4-monado/PKGBUILD +++ b/phoenix/pico4-monado/PKGBUILD @@ -94,20 +94,20 @@ sha256sums=(SKIP '07e474ecbbb1e3a629735c123fe83cb1c9ca7c4dedf34392e1f99e06bdbf37c2' 'de4add87e8b087f7e1edfaa0212b052b435e94fde9cce0a28e8e410bcfeb6264' 'bb6561e792bdbcb7ec78eeb8b0a275fc138d930a3cde818ad34f2e56536a893d' - '03974180cb098b1b5c5d6fc48324a6e44c1fac26ad21e99cde7ec218e68f341f' + '00dd55716c855258ce2e3f6c247b7d80e3128d64a9fc466a5eb74e03dc028d0a' '0fe74dbd8f72c6e0763952a3e602771aa4d3c4b9c84871909fb4355d9b3b3756' '5cbe37ce8152ace06a53c6f0bec5b9fb6b639d9d2b86c6eb47864594112f87ab' '6b0d8e8479f4282bcaaaa46d0090417fa5e1ca72a03600a9b2da95cdf71f28d5' '8564f2babbd92aa89f26d448c6c6a9d2e9c7c07ac52c1fc9424f09fe11b226ed' '82cb589128b7047e28c19267ab579abe4033e8003b0560841bbf7ea90bd79c8c' - '68f3ed1ca637c979193aa095819b5b27ebf80087f262488b1d752daf10248975' + 'd3f62fedbea156a82c296430fdae6c89139f18de54c5228ab97bd4a0f37a39c0' '57b052998c5df61a691e163e4e43191e4f4994e610ea95a01ceb6a774b850be3' - 'f7419b19ba4a01f570420760a91c74183acc252eded0585dc212c542ba136e0d' + '701f01563714bcd689e70a2af608d66fe331b073620513907f6ec0136690c113' '80948b181cd55b1194842f7c4b284299ed4cf91c5ee9978fa31d1938e5c97501' - '94c45d48bfe6d226b56d10088ae7fc31839f50612db412800c9fb5e566a5797a' + '5ba1862d71710d477172eabcad5f9dba055bb3c90c3e218a7187ded2da20cea2' '4b58a623d5ebe53c2a30ed6710f25c66da8c96b2c014525fd08b479a8abbcd83' 'ccb6d333b26d172ac07fc2de3234883afccb2ae5ce0419cf3b067fe971d12372' - '4104d15d75e3dff32b8edf5779b9a73cacd85e5a36d6bd1a8c23f928889a3cc6' + '7cc922f7215fd73bf1a1d7b209d2796299698ba9fe114343f3c56e97a770b25f' '374bd56d373143725b3a6db79f284a40350a1017eb631f63d4e8d3cd41ef20b2' '88f2c74f8fb72878f7ba98d5c5007e6c639fe8ef7a078a546c1101e5b48c26ca' 'cc727edbad724f50656255313d81ebc56dc6c168bbe05f10f8c57cfecd3829a4' @@ -263,6 +263,14 @@ build() { ${CXX:-c++} -std=c++17 -O2 -Wall -Wextra -Werror -Wno-unused-parameter -Wno-missing-field-initializers -isystem monado/src/external/openvr_includes \ $(pkg-config --cflags pangocairo fontconfig librsvg-2.0) -o pico4-onboarding pico4-onboarding.cpp \ $(pkg-config --libs pangocairo fontconfig librsvg-2.0) -lcairo -lvulkan -ldl -lm + # Every page of both in every language of ours: a render fails where two of a page's texts overlap. + local lang pages + pages=$(mktemp -d) + for lang in $(sed -n 's/^\[\([a-z_]*\)\]$/\1/p' pico4-onboarding.strings); do + PICO4_ONBOARDING_STRINGS=pico4-onboarding.strings HOME="$pages" ./overpressure-settings --render "$pages" "$lang" + PICO4_ONBOARDING_STRINGS=pico4-onboarding.strings HOME="$pages" ./pico4-onboarding --render "$pages" "$lang" + done + rm -rf "$pages" ${CXX:-c++} -std=c++17 -O2 -Wall -Wextra -Werror -Wno-unused-parameter -Wno-missing-field-initializers -isystem monado/src/external/openvr_includes \ -o pico4-steamvr-switch pico4-steamvr-switch.cpp -lcairo -lvulkan -ldl -lm ${CXX:-c++} -std=c++17 -O2 -Wall -Wextra -Werror -isystem /usr/include/eigen3 -o pico4-ctrack-replay \ diff --git a/phoenix/pico4-monado/overpressure-settings.cpp b/phoenix/pico4-monado/overpressure-settings.cpp index 9e0d2ce..388e8ed 100644 --- a/phoenix/pico4-monado/overpressure-settings.cpp +++ b/phoenix/pico4-monado/overpressure-settings.cpp @@ -30,7 +30,8 @@ * * overpressure-settings [--render DIR [LANGUAGE]] * - * --render draws the pages into DIR as PNG files, without SteamVR, in LANGUAGE (Steam's name). + * --render draws the pages into DIR as PNG files, without SteamVR, in LANGUAGE (Steam's name), and + * fails when two of a page's texts overlap. */ #include "pico4_pair_ui.hpp" #include "pico4_pairing.h" @@ -849,8 +850,8 @@ draw_front(cairo_surface_t *surface, State &s, const Texts &t, double now) p.pairing = s.ctl.pairing; p.listen_left = std::max(0.0, PICO4_PAIRING_LISTEN_S - (now - s.ctl.pairing_at)); p.message = s.ctl.message != nullptr ? t.our(s.ctl.message) : ""; - topbar(c, f, t.our("controllers_title"), "", PICO4_HIT_NONE, kIcons, ""); - pico4_pair_ui::hand_pills(c, f, t, p); + const double pills = pico4_pair_ui::hand_pills(c, f, t, p); + topbar(c, f, t.our("controllers_title"), "", PICO4_HIT_NONE, kIcons, "", -1, pills + 24); pico4_pair_ui::content(c, f, t, p, true, false); footer(c, f); const std::string close = t.our("close"); @@ -893,7 +894,9 @@ render(const char *dir, const char *language) auto save = [&](cairo_surface_t *surface, const char *name) { const std::string file = std::string(dir) + "/" + name + ".png"; r |= cairo_surface_write_to_png(surface, file.c_str()) != CAIRO_STATUS_SUCCESS; + r |= pico4_text::overlaps(name) > 0; }; + pico4_text::recording() = true; State s; s.about = {"2026.12.0b1", "2026.12.0b0-13-g8b9e107", "2026.12.0b1", "steamos", "2026.12.0b1", "2026.12.1", "phoenix/7.2-11", "7.2.0-phoenix", "2.9.4-1", "26.1.6-1", "25.1.0-23", 0}; diff --git a/phoenix/pico4-monado/pico4-onboarding.cpp b/phoenix/pico4-monado/pico4-onboarding.cpp index 068c133..8032bea 100644 --- a/phoenix/pico4-monado/pico4-onboarding.cpp +++ b/phoenix/pico4-monado/pico4-onboarding.cpp @@ -23,7 +23,8 @@ * * pico4-onboarding [--render DIR [LANGUAGE]] * - * --render draws every page into DIR as PNG files, without SteamVR, in LANGUAGE (Steam's name). + * --render draws every page into DIR as PNG files, without SteamVR, in LANGUAGE (Steam's name), and + * fails when two of a page's texts overlap. */ #include "pico4_lens_panel.h" #include "pico4_onboarding.h" @@ -411,8 +412,9 @@ draw_controllers(cairo_t *c, const Frame &f, const State &s, const Texts &t) p.pairing = s.pairing; p.listen_left = std::max(0.0, PICO4_PAIRING_LISTEN_S - (f.now - s.pairing_at)); p.message = s.message; - topbar(c, f, t.our("controllers_title"), "", PICO4_HIT_NONE, kIcons, "", (u.page + 1.0) / PICO4_SETUP_PAGES); - pico4_pair_ui::hand_pills(c, f, t, p); + const double pills = pico4_pair_ui::hand_pills(c, f, t, p); + topbar(c, f, t.our("controllers_title"), "", PICO4_HIT_NONE, kIcons, "", (u.page + 1.0) / PICO4_SETUP_PAGES, + pills + 24); const bool one = (s.left || s.right) && !(s.left && s.right); pico4_pair_ui::content(c, f, t, p, one, true); if (one) { @@ -681,10 +683,12 @@ render(const char *dir, const char *language) t.load(language != nullptr ? language : "english"); cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, PICO4_TOUR_W, PICO4_TOUR_H); int r = 0; + pico4_text::recording() = true; auto save = [&](State &s, const char *name, double now = 0) { draw(surface, s, t, now); const std::string file = std::string(dir) + "/" + name + ".png"; r |= cairo_surface_write_to_png(surface, file.c_str()) != CAIRO_STATUS_SUCCESS; + r |= pico4_text::overlaps(name) > 0; }; // The first page as each pairing leaves it: none (listening for the left), one, both. State s; diff --git a/phoenix/pico4-monado/pico4_pair_ui.hpp b/phoenix/pico4-monado/pico4_pair_ui.hpp index 65b146d..8463bc5 100644 --- a/phoenix/pico4-monado/pico4_pair_ui.hpp +++ b/phoenix/pico4-monado/pico4_pair_ui.hpp @@ -35,14 +35,15 @@ struct Pairing std::string message; //!< a failure, in red where the page's words are }; -//! The left and right pills on the top bar's right, as the driver reports them. -inline void +//! The left and right pills on the top bar's right, as the driver reports them; returns their width. +inline double hand_pills(cairo_t *c, const Frame &f, const pico4_panels::Texts &t, const Pairing &p) { const double mid = kTopbarH / 2; double x = f.w - 32; x -= pill(c, t.our("hand_right"), x, mid, p.right ? kGood : kNeutral, true) + 12; - pill(c, t.our("hand_left"), x, mid, p.left ? kGood : kNeutral, true); + x -= pill(c, t.our("hand_left"), x, mid, p.left ? kGood : kNeutral, true); + return f.w - 32 - x; } /*! diff --git a/phoenix/pico4-monado/pico4_text.hpp b/phoenix/pico4-monado/pico4_text.hpp index c869cdf..21662fc 100644 --- a/phoenix/pico4-monado/pico4_text.hpp +++ b/phoenix/pico4-monado/pico4_text.hpp @@ -13,7 +13,10 @@ #include #include +#include +#include #include +#include namespace pico4_text { @@ -44,6 +47,77 @@ add_steam_fonts(const std::string &steam) return added; } +/*! + * Where the texts drawn while recording lie, in the surface's pixels: the renders check that no two + * overlap, as a long translation would make them. + */ +struct Inked +{ + double x0, y0, x1, y1; + std::string text; +}; + +inline bool & +recording() +{ + static bool on = false; + return on; +} + +inline std::vector & +inked() +{ + static std::vector boxes; + return boxes; +} + +//! Note where @p layout's ink lies, drawn at (@p x, @p y), inside the clip. +inline void +note(cairo_t *c, PangoLayout *layout, double x, double y, const std::string &text) +{ + if (!recording()) { + return; + } + PangoRectangle ink; + pango_layout_get_pixel_extents(layout, &ink, nullptr); + if (ink.width <= 0 || ink.height <= 0) { + return; + } + double cx0, cy0, cx1, cy1; + cairo_clip_extents(c, &cx0, &cy0, &cx1, &cy1); + double x0 = std::max(x + ink.x, cx0), y0 = std::max(y + ink.y, cy0); + double x1 = std::min(x + ink.x + ink.width, cx1), y1 = std::min(y + ink.y + ink.height, cy1); + if (x1 <= x0 || y1 <= y0) { + return; // all of it outside the clip: not shown + } + cairo_user_to_device(c, &x0, &y0); + cairo_user_to_device(c, &x1, &y1); + inked().push_back({std::min(x0, x1), std::min(y0, y1), std::max(x0, x1), std::max(y0, y1), text}); +} + +/*! + * Print the texts recorded since the last call that overlap one another by more than a pixel, on + * @p page; returns how many pairs, and starts the next record. + */ +inline int +overlaps(const char *page) +{ + int n = 0; + const std::vector &b = inked(); + for (size_t i = 0; i < b.size(); i++) { + for (size_t j = i + 1; j < b.size(); j++) { + const double w = std::min(b[i].x1, b[j].x1) - std::max(b[i].x0, b[j].x0); + const double h = std::min(b[i].y1, b[j].y1) - std::max(b[i].y0, b[j].y0); + if (w > 1 && h > 1) { + fprintf(stderr, "%s: \"%s\" overlaps \"%s\"\n", page, b[i].text.c_str(), b[j].text.c_str()); + n++; + } + } + } + inked().clear(); + return n; +} + enum Align { kStart, //!< left, or right in a right-to-left language @@ -73,6 +147,7 @@ draw(cairo_t *c, const std::string &text, double x, double y, double width, doub if (!measure) { cairo_move_to(c, x, y); pango_cairo_show_layout(c, layout); + note(c, layout, x, y, text); } pango_font_description_free(font); g_object_unref(layout); @@ -98,6 +173,7 @@ line(cairo_t *c, const std::string &text, double x, double y, double width, doub pango_layout_set_text(layout, text.c_str(), -1); cairo_move_to(c, x, y); pango_cairo_show_layout(c, layout); + note(c, layout, x, y, text); pango_font_description_free(font); g_object_unref(layout); } @@ -124,6 +200,7 @@ field(cairo_t *c, const std::string &text, double x, double y, double width, dou cairo_clip(c); cairo_move_to(c, x - shift, y); pango_cairo_show_layout(c, layout); + note(c, layout, x - shift, y, text); cairo_restore(c); pango_font_description_free(font); g_object_unref(layout); diff --git a/phoenix/pico4-monado/pico4_ui.hpp b/phoenix/pico4-monado/pico4_ui.hpp index 29c993f..d146862 100644 --- a/phoenix/pico4-monado/pico4_ui.hpp +++ b/phoenix/pico4-monado/pico4_ui.hpp @@ -287,7 +287,7 @@ text_width(cairo_t *c, const std::string &text, double size, bool bold) PangoLayout *layout = pango_cairo_create_layout(c); PangoFontDescription *font = pango_font_description_from_string(pico4_text::kFamilies); pango_font_description_set_absolute_size(font, size * PANGO_SCALE); - pango_font_description_set_weight(font, bold ? PANGO_WEIGHT_SEMIBOLD : PANGO_WEIGHT_NORMAL); + pango_font_description_set_weight(font, bold ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL); // as drawn pango_layout_set_font_description(layout, font); pango_layout_set_text(layout, text.c_str(), -1); int w, h; @@ -338,11 +338,11 @@ background(cairo_t *c, const Frame &f) /*! * The top bar: with @p back_id a way back (an arrow), @p crumb before the @p title ("Overpressure * Settings › Updates"), @p hint on the right with its icon, and the setup's progress (0 to 1, -1 - * none) as a line under it. + * none) as a line under it. @p reserve keeps room on the right for what the page draws there itself. */ inline void topbar(cairo_t *c, const Frame &f, const std::string &title, const std::string &crumb, int back_id, Icon hint_icon, - const std::string &hint, double progress = -1) + const std::string &hint, double progress = -1, double reserve = 0) { set(c, kLine); cairo_rectangle(c, 0, kTopbarH - 1, f.w, 1); @@ -363,10 +363,11 @@ topbar(cairo_t *c, const Frame &f, const std::string &title, const std::string & pico4_hits_add(f.hits, back_id, bx - 8, 0, s + 16, kTopbarH); x = bx + s + 12; } + const double right = f.w - 32 - reserve; double hint_w = 0; if (!hint.empty()) { hint_w = text_width(c, hint, kSmall, false); - const double hx = f.w - 32 - hint_w; + const double hx = right - hint_w; line_mid(c, hint, hx, mid, hint_w + 2, kSmall, false, kMuted); if (hint_icon != kIcons) { icon(c, hint_icon, hx - 36, mid - 13, 26, kMuted); @@ -374,7 +375,7 @@ topbar(cairo_t *c, const Frame &f, const std::string &title, const std::string & } hint_w += 24; } - const double room = f.w - 32 - hint_w - x; + const double room = right - hint_w - x; if (!crumb.empty()) { const double cw = std::min(text_width(c, crumb, kTopText, false), room * 0.6); line_mid(c, crumb, x, mid, cw + 2, kTopText, false, kMuted); @@ -382,7 +383,7 @@ topbar(cairo_t *c, const Frame &f, const std::string &title, const std::string & line_mid(c, "\xE2\x80\xBA", x, mid, 20, kTopText, false, kMuted); // › x += 26; } - line_mid(c, title, x, mid, f.w - 32 - hint_w - x, kTopText, true, kText); + line_mid(c, title, x, mid, right - hint_w - x, kTopText, true, kText); } //! The footer's line over its row of buttons. @@ -531,7 +532,7 @@ inline double pill(cairo_t *c, const std::string &text, double x, double mid, Tone tone, bool right_aligned = false) { const double size = 20, pad = 14, dot = tone == kGood ? 18 : 0; - const double w = text_width(c, text, size, true) + 2 * pad + dot, h = 36; + const double tw = text_width(c, text, size, true), w = tw + 2 * pad + dot, h = 36; if (right_aligned) { x -= w; } @@ -543,7 +544,7 @@ pill(cairo_t *c, const std::string &text, double x, double mid, Tone tone, bool set(c, ink); cairo_fill(c); } - line_mid(c, text, x + pad + dot, mid, w, size, true, ink); + line_mid(c, text, x + pad + dot, mid, tw + 2, size, true, ink); // its own width: a right-to-left one starts right return w; } From b784df9dafc52173a25c77a4b02f4883dc97668c Mon Sep 17 00:00:00 2001 From: Xenolphthalein <21215869+Xenolphthalein@users.noreply.github.com> Date: Thu, 3 Dec 2026 11:42:00 +0100 Subject: [PATCH 2/2] chore(pico4-monado): 25.1.0-24 --- phoenix/pico4-monado/PKGBUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phoenix/pico4-monado/PKGBUILD b/phoenix/pico4-monado/PKGBUILD index 12aaa41..71839b7 100644 --- a/phoenix/pico4-monado/PKGBUILD +++ b/phoenix/pico4-monado/PKGBUILD @@ -19,7 +19,7 @@ # overlays (Overpressure Settings' dashboard tab, the first-run setup). pkgname=pico4-monado pkgver=25.1.0 -pkgrel=23 +pkgrel=24 arch=(aarch64) url="https://monado.freedesktop.org" license=(BSL-1.0)