lite-xl/src
Takase 27d95f63cb
renderer: rewrite glyph cache (#1845)
* renderer: rewrite glyph cache

This commit splits the current GlyphSet-based system into 2 caches,
CharMap and GlyphMap, which maps codepoints -> glyph IDs and glyph IDs -> glyphs respectively.
Each GlyphMap contains a number of GlyphAtlas mapped by their width,
and each GlyphAtlas has a list of surfaces with the same width.
Surfaces within the GlyphAtlas acts like a bump allocator, but is flexible
enough to allow older GlyphAtlas surfaces to be recycled.

GlyphMetric now contains atlas_idx and surface_idx, which points to the correct surface.
Since GlyphAtlas supports rudimentary packing & allocation, we no longer render whole
GlyphSets and this speeds up rendering in most cases.

Tab width is no longer set with the hacky "modify the GlyphMetric" hack.

* renderer: set natlas to 0 after freeing

* renderer: fix printf warning

* renderer: fix memory leak

* renderer: better whitespace rendering

* renderer: fix ubsan warning when casting ints

* renderer: fix tab handling

There's a bug with inconsistent tab widths caused by fontgroups.

* renderer: fix glyphs being loaded over and over

* renderer: add glyphmap size

* renderer: store per-surface offset_y and use it to find best-fitting surface

* renderer: fix MSVC compiler error

* renderer: remove return value from ren_font_glyph

* renderer: refactor xadvance calculation

* renderer: fix double free SDL_RWops if FT_Set_Pixel_Size fail

* renderer: always try .notdef before U+25A1

* renderer: disable ren_font_dump yet again

Accidentally commited this change.

* renderer: remove unused imports

* renderer: fix double free with FT_Open_Face

* renderer: return SDL_Surface in font_find_glyph_surface

* renderer: bring back metric flags for future extension

* renderer: refactor xadvance calculation into macro

* renderer: fix comment

* renderer: store GlyphMetric directly in the surface

* renderer: remove duplicated comment

* renderer: rename font_find_glyph_surface to font_allocate_glyph_surface

* renderer: refactor glyphmetric retrieval into an inline function

* renderer: do not render glyphs with bitmap set to null

This is a weird edge case, but at least it shouldn't crash

* renderer: refactor face metric code into its own function

* renderer: actually check if glyph fits in surface

* renderer: rudimentary support for non-scalable faces

At least it won't render nothing on the screen

* renderer: check for font_surface instead of metric directly

This is safe and shorter

* renderer: fix indentation

* renderer: rename GLYPH_PER_ATLAS to GLYPHS_PER_ATLAS

* renderer: rename all GLYPH_PER_ATLAS correctly

* renderer: make utf8_to_codepoint slightly more durable

* renderer: fix compiler unsigned cast warning
2024-07-13 02:39:49 +02:00
..
api api/system: check if a window is created when firing DND events 2024-07-04 22:25:36 +08:00
bundle_open.m Takes kivutar's changes into account, cleaning things up slightly. 2021-12-15 20:31:24 -05:00
main.c move window creation and management to Lua (#1751) 2024-06-22 15:01:39 -04:00
meson.build move window creation and management to Lua (#1751) 2024-06-22 15:01:39 -04:00
rencache.c move window creation and management to Lua (#1751) 2024-06-22 15:01:39 -04:00
rencache.h Attach command buffer to Renderer Window (#1472) 2023-06-16 16:19:52 +02:00
renderer.c renderer: rewrite glyph cache (#1845) 2024-07-13 02:39:49 +02:00
renderer.h refactor(mac): adapt `LITE_USE_SDL_RENDERER` scaling to new windowing system 2024-06-25 13:42:17 +08:00
renwindow.c src/renwindow: correctly free texture and renderer 2024-07-04 21:57:33 +08:00
renwindow.h Scale mouse coordinates by window scale (#1630) 2023-11-29 10:21:58 -05:00
unidata.h Update unidata to version 15.0 (#1122) 2022-09-19 21:27:54 -04:00
utfconv.h fix utfconv.h duplicate functions 2022-11-14 21:59:32 +08:00