Commit graph

361 commits

Author SHA1 Message Date
andrewmd5 2b46565a2e fix: text measurement/rendering width mismatch in sokol_clay
The text bounding box width was incorrect because the measurement function
was using logical pixels while the rendering function was using physical
pixels (scaled by DPI). This caused a mismatch where:

- sclay_measure_text() set font size and letter spacing without DPI scaling
- sclay_render() applied DPI scaling to both font size and letter spacing
- fontstash's fonsTextBounds() returned physical pixel measurements even
  when given logical pixel sizes, leading to incorrect width calculations

The fix ensures consistent DPI scaling by:
1. Scaling font size and letter spacing by dpi_scale during measurement
2. Dividing the returned bounds by dpi_scale to convert back to logical pixels
3. This ensures Clay receives measurements in logical pixels that match what
   will actually be rendered

This was particularly noticeable with long continuous text where the
discrepancy accumulated across many characters. The issue was font-size
dependent because different font sizes have different rounding behaviors
in the underlying font rendering system.

Also adds text alignment support to properly measure and render centered/right-aligned text.
2025-08-08 17:55:32 +09:00
github-actions[bot] 91c6d05774 [bindings/odin] Update Odin bindings 2025-07-15 23:32:23 +00:00
Nic Barker 4aa3d75bef [Core] Split base ID hash from index ID hash 2025-07-16 09:30:54 +10:00
Hayden Gray 9d38edb989
[Bindings/Odin] SizingFit and SizingGrow default parameters (#462) 2025-07-09 09:07:10 +10:00
github-actions[bot] 516e85bdfe [bindings/odin] Update Odin bindings 2025-07-01 23:47:56 +00:00
Tomás Ralph 0022d12c0c
[DebugTools] Fix aspect ratio display, closes #449 (#451) 2025-07-02 09:46:12 +10:00
Nic Barker d9d0b6c37b [Core] Fix incorrect percentage sizing of floating elements 2025-07-02 09:37:38 +10:00
Hayden Gray 8dfcc944fa
[Bindings/Odin] - add CI to update binding libs (#452) 2025-06-27 15:05:13 +10:00
Mivirl a9c1f9a8a7
[Renderers/termbox2] Termbox2 renderer & examples (#419) 2025-06-27 08:26:38 +10:00
Nic Barker 281f961e3d [Bindings/Odin] Update Odin bindings 2025-06-24 13:57:15 +10:00
Nic Barker 3433a53a8e [Core] Fix an alignment bug for scrolling container contents 2025-06-24 13:55:20 +10:00
wolfee 4a91cac1b2
[Renderers/SDL3] Fix border position calculated incorrectly (#446) 2025-06-23 10:43:08 +10:00
Nic Barker ff7917798c [Core] Avoid calling measure text function with length zero 2025-06-23 10:10:13 +10:00
wolfee f97cb9ea10
[Renderers/SDL] Font sizing is ignored (#444) 2025-06-23 09:30:14 +10:00
Nic Barker 74f0ffbe26 [Renderers/Cairo] Fix outdated image API usage in cairo example 2025-06-23 09:16:41 +10:00
Nic Barker a5e212b8de [Renderers/HTML] Fix a mouse overlap bug with external scroll handling 2025-06-20 10:59:44 +10:00
Nic Barker 0835781602 [Bindings/Odin] Update Odin Bindings 2025-06-18 09:55:32 +10:00
Nic Barker 13ecd80ee5 [Renderers/SDL3] Fix up outdated API usage in SDL3 example 2025-06-18 09:54:27 +10:00
Nic Barker c524485c46 [Core] Fix case where there could be 64 extra bytes of padding between arrays in clays internal arena 2025-06-17 13:07:56 +10:00
Nic Barker b9e27178c0 [Core] Align base arena memory to 64 byte cache line 2025-06-17 10:32:30 +10:00
Nic Barker 6f10bf4b3d [Core] Remove erroneous break statement when using external scroll handling 2025-06-13 10:35:31 +10:00
Nic Barker adb1bd620a [Examples/clay-official-website] Fix links on official website example 2025-06-13 09:59:07 +10:00
Nic Barker dca9f60a6c [Core] Add objective-c support 2025-06-12 12:16:29 +10:00
Nic Barker 3ccfa0f8fa [Core] Fix a bug where extra child gap was added to the dimensions of clipped containers 2025-06-11 10:41:01 +10:00
Nic Barker 35b45d939b Fix some typos in the readme 2025-06-11 10:15:51 +10:00
Nic Barker 6b03a215b7 [Core] Fix an out of bounds access for single newline characters 2025-06-10 11:38:56 +10:00
Nic Barker b25a31c1a1 [Bindings/Odin] Update Odin Bindings to latest 2025-06-06 11:01:42 +10:00
Nic Barker 8bbe14fbcc [Documentation] Fix README typo, bump version number to 0.14 2025-06-06 10:20:37 +10:00
Alan 58491394ca
[Renderers/Raylib] Fix element float distortion (#430) 2025-06-05 10:49:26 +10:00
Nic Barker 87575cb7c3 [Core] Fix handling of letter spacing 2025-06-05 10:38:53 +10:00
Nic Barker 80659eda04 [Renderers/Web] Fix clay official website example struct definitions for web renderers 2025-06-04 10:50:35 +10:00
Rats a3003cfa12
[Bindings/Odin] Update README to better match official website example. (#422) 2025-06-02 20:26:04 +10:00
Wes Lord 5eceb52abc
Set CMake FetchContent GIT_TAG for SDL_ttf (#423) 2025-06-02 13:00:45 +10:00
Michael Tanner 149833bdc0
[Core] Fix dimension calculation that would always result in 0 (#428) 2025-06-02 12:27:28 +10:00
Nic Barker 0431f862f4 [Core] Improve handling of aspect ratio scaling 2025-06-02 12:14:09 +10:00
Nic Barker d6f3957a60
[Core] Split aspect ratio scaling into its own config (#426) 2025-06-02 10:36:58 +10:00
Boreal 89ce22e894
[Core] Fix sign comparison warning (#427) 2025-05-29 13:10:05 +10:00
Wes Lord e80736892d
[Renderers/SDL2] Indent SDL2's CMakeLists.txt consistently (#424) 2025-05-28 09:50:00 +10:00
Nic Barker ce2475ba73 [Compilers] Add missing struct name for image element config 2025-05-26 10:10:24 +10:00
Johann Muszynski 34ff7e1bea
[Compilers] Add struct names to public structs (#336) 2025-05-26 10:03:07 +10:00
Emmanuel 65e813d4df
[Renderers/Terminal] Add initial implementation of terminal renderer (#91) 2025-05-22 12:45:52 +12:00
Nic Barker 7af50d0f48 [Bindings/Odin] Update odin bindings to include floating element clipTo 2025-05-20 11:40:25 +12:00
Matt Jennings e2f94f17f6
[Renderers/Playdate] Playdate console example (#404) 2025-05-19 11:46:39 +12:00
Zordan eb1d85f2a6
[Renderers/Cairo] Fix cairo renderer and example (#416) 2025-05-19 11:36:08 +12:00
Patricio Whittingslow 76351a0999
[Documentation] Add Go rewrites of clay to README (#411) 2025-05-19 11:33:38 +12:00
Simon Oelerich efbd680685
[Core] restore compatibility with C99 (#412) 2025-05-14 13:29:12 +12:00
Patrick Doane b656dc5253
[Core] Add Clay_FloatingClipToElement (#413) 2025-05-14 13:24:42 +12:00
João Matos b78fd66da8
[Core] Add Clay_GetPointerOverIds function to the public API. (#389) 2025-05-14 12:39:56 +12:00
Jeroen van Rijn 76265e4c3c
[Bindings/Odin] Add missing border macros to Odin bindings 2025-05-09 13:25:34 +12:00
Sam El-Borai c483269295
[Documentation] Fix anchor to Clay_CustomElementConfig (#403) 2025-05-06 12:41:33 +12:00