Commit Graph

139 Commits

Author SHA1 Message Date
George Sokianos 5c983f10b5 Merge branch 'master' into amiga2.1 2023-12-26 13:36:13 +00:00
Jan 7b67a5d81b turn window_renderer into managed pointer (#1683)
* turn window_renderer into managed pointer
this will make it easier to move it into userdata in the future

* remove unused function, remove comment
2023-12-26 13:16:33 +00:00
Guldoman 5719f4de6f Use x offset to define render command rect in `rencache_draw_text` (#1618)
* Return x offset for the first character in `ren_font_group_get_width`

* Use x offset to define render command rect in `rencache_draw_text`
2023-12-26 13:16:33 +00:00
Guldoman 4e2f70e5ee Scale mouse coordinates by window scale (#1630)
* Update window scale on resize

* Scale mouse coordinates by window scale

* Avoid scaling mouse coordinates while using `LITE_USE_SDL_RENDERER`
2023-12-26 13:16:33 +00:00
Takase 1196bf355c fix: dim rendering when antialiasing is turned off (#1641) 2023-12-26 13:16:33 +00:00
George Sokianos 1b00045146 Added codesets support for encoding switch 2023-12-18 17:19:13 +00:00
Takase 4e5c0ed1d4 feat(src/renderer): unify fontgroup baseline (#1560)
* feat(src/renderer): unify fontgroup baseline

* fix(src/renderer): use the first font's baseline for the text run
2023-08-07 15:26:49 +01:00
Takase 60e71160b6 feat(src/renderer): stream fonts with SDL_RWops on all platforms (#1555)
* feat(src/renderer): stream fonts with SDL_RWops on all platforms

This fixes #1529 where the font itself carries the font file, which gets copied around.
This commit streams the file, so the file is not entirely in memory.

* style(src/renderer): use standard C types

* refactor(src/renderer): implement FT_Stream.close

* fix(src/renderer): fix SDL_RWops double free
2023-08-07 15:26:38 +01:00
Takase fa694ae6f8 style(src/renderer): use FreeType header names (#1554) 2023-08-07 15:26:38 +01:00
Guldoman 608ad159cd Allow setting custom glyphset size (#1542)
* Properly set glyphset size

* Rename `MAX_GLYPHSET` to `GLYPHSET_SIZE`

* Use more appropriate types for font metrics
2023-08-07 15:26:38 +01:00
Jan 0532ef1792 Attach command buffer to Renderer Window (#1472) 2023-08-07 15:26:38 +01:00
Guldoman 9328e7ae8f Increase number of loadable glyphsets (#1524)
This should be enough to load every unicode codepoint.
2023-08-07 15:26:38 +01:00
takase1121 554a4d4f48 fix(renderer): fix memory leak when freeing glyphsets 2023-08-07 15:26:38 +01:00
Guldoman 71e4adbd6f Aggregate `SDL_Surface`s and their scale in `RenSurface` (#1429) 2023-08-07 15:26:06 +01:00
Guldoman 94e2df991c Use clipping functions provided by SDL (#1426) 2023-08-07 15:26:06 +01:00
Guldoman ca29728e34 Improve text width calculation precision (#1408)
In some extreme cases (~30000 chars) text width precision takes a hit.
Using double instead of float fixes that.
2023-08-07 15:25:46 +01:00
Jan 66815b24b0 pass RenWindow by argument (#1321)
* pass RenWindow to all renderer functions that need it

* pass RenWindow to all rencache functions that need it
2023-08-07 15:02:06 +01:00
Jan 4d35dc4969 replace uses of SDL_Window with RenWindow (#1319)
Since Renwindow contains our instance of SDL_Window we can use this
to simplify future logic to create separate window instances
2023-08-07 15:01:31 +01:00
Takase 8daf7dc926 feat(src/renderer): unify fontgroup baseline (#1560)
* feat(src/renderer): unify fontgroup baseline

* fix(src/renderer): use the first font's baseline for the text run
2023-08-07 14:51:14 +01:00
Takase 8c9620aaed feat(src/renderer): stream fonts with SDL_RWops on all platforms (#1555)
* feat(src/renderer): stream fonts with SDL_RWops on all platforms

This fixes #1529 where the font itself carries the font file, which gets copied around.
This commit streams the file, so the file is not entirely in memory.

* style(src/renderer): use standard C types

* refactor(src/renderer): implement FT_Stream.close

* fix(src/renderer): fix SDL_RWops double free
2023-08-07 14:51:14 +01:00
Takase 74d9c15736 style(src/renderer): use FreeType header names (#1554) 2023-08-07 14:51:14 +01:00
Guldoman 3775032c78 Allow setting custom glyphset size (#1542)
* Properly set glyphset size

* Rename `MAX_GLYPHSET` to `GLYPHSET_SIZE`

* Use more appropriate types for font metrics
2023-08-07 14:51:14 +01:00
Jan 6e113cb15e Attach command buffer to Renderer Window (#1472) 2023-08-07 14:50:59 +01:00
Guldoman 9bb6589790 Increase number of loadable glyphsets (#1524)
This should be enough to load every unicode codepoint.
2023-08-07 14:50:59 +01:00
takase1121 363b102abc fix(renderer): fix memory leak when freeing glyphsets 2023-08-07 14:50:59 +01:00
Guldoman 1d86665b6d Aggregate `SDL_Surface`s and their scale in `RenSurface` (#1429) 2023-08-07 14:50:58 +01:00
Guldoman 4f1360a6c5 Use clipping functions provided by SDL (#1426) 2023-08-07 14:50:58 +01:00
Guldoman 7907fa785c Improve text width calculation precision (#1408)
In some extreme cases (~30000 chars) text width precision takes a hit.
Using double instead of float fixes that.
2023-08-07 14:50:58 +01:00
Jan 16182d01d8 pass RenWindow by argument (#1321)
* pass RenWindow to all renderer functions that need it

* pass RenWindow to all rencache functions that need it
2023-08-07 14:50:58 +01:00
Jan c44a3cd291 replace uses of SDL_Window with RenWindow (#1319)
Since Renwindow contains our instance of SDL_Window we can use this
to simplify future logic to create separate window instances
2023-08-07 14:50:43 +01:00
George Sokianos 65d95c7f40 Merge branch 'master' into amiga2.1 2023-01-08 21:04:04 +00:00
Julien Voisin 7133ea5419
Fix a memory leak (#1305)
`font` was not freed upon error.
2023-01-05 15:48:01 -05:00
Guldoman 2638e9636b
Allow command buffer to be expanded (#1297) 2023-01-01 21:12:14 -05:00
Guldoman c29b1c2cb9
Use Lua string length instead of relying on `strlen` (#1262)
This allows us to render `NULL` byte sequences and not truncate strings 
that contain them.
2022-12-26 13:49:07 -04:00
Guldoman 9f917052ad
Add initialization to variable in `ren_draw_text` 2022-11-27 00:45:57 +01:00
Takase 7fa51bb7ab
Windows font loading hotfix (#1205)
* add missing windows header
* hold the handle until GC so that the file can't be modified in use,
   this is a regression when we switched to CreateFile.
* set wpath to NULL to avoid double free
2022-11-17 01:09:38 -04:00
takase1121 69938c619c
add support for loading fonts with UTF-8 filenames 2022-11-14 22:01:24 +08:00
takase1121 4457f26502
use flexible structure member from C99 2022-11-14 22:00:40 +08:00
George Sokianos 2bdfd5a694 Merge branch 'master' into amiga-2.0 2022-09-26 17:27:35 +01:00
Aqil Contractor 9b1bfeacac
Added a smoothing and strikethrough option to font loading. (#1087)
* Added a smoothing option to font loading.
* Added a font strikethrough option to font loading.
* Fixed underline applying incorrectly in cases of non-underlined fallback fonts being used.

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>
2022-08-20 16:15:08 -04:00
jgmdev d2f9eeea07 renderer fonts: additions and improvements
* Allow passing font options to renderer.font:copy().
* Added renderer.font:get_path()
* Reintroduced set_size() for more faster font size changes
* Swapped copy wiht set_size on scale plugin for better performance
* Use code_font:copy() instead of renderer.font.load() on language_md to
  properly match user font now that font options are supported on copy.
* Added new changes to renderer docs
2022-06-23 18:08:04 -04:00
George Sokianos 69bd81188b Merged MOS and OS4 code. Did some more fixes before the 2.0.3r2 release. 2022-06-18 18:17:07 +01:00
takase1121 73cd768a19
load space metrics only instead of all metrics of the 1st 256 characters 2022-06-12 08:22:01 +08:00
Guldoman 8156836126 Fix `ren_font_group_get_tab_size` returning unexpected values
We were casting the `xadvance` to an int, so in some cases the resulting 
tab size was wrong.
2022-05-04 10:26:48 -04:00
Guldoman 1439b59d65
Improve performance of `ren_draw_rect` (#935)
We color a 1x1 `SDL_Surface` with the desired color. This surface is 
then stretched over the area we need to cover using `SDL_BlitScaled`.
This way we avoid having to do the blending ourselves.
2022-04-20 17:13:42 -04:00
Jan fff10a2612
Cleanup (#826)
* Update meson.build
- add logic to loop over more lua names (in the future more names might be discovered)
- disable warnings and errors on dependencies

* adding missing includes and checks, correct data types, pointer mess […]
- various functions from string.h were used but never defined
- logic was done across multiple different data types with different signedness, got all of them up to snuff
- give 0 sized array size of 1 (array of size 0 is illegal, but rewriting the code is out of the scope of this commit)
- add preprocessor that marks possibly unused argument as such (does not mean they will get optimized out or anything)
- correctly initialize structs with all data needed

All these were found by generating the project using `meson -Dwarning_level=3 -Dwerror=true`

* remove undefined behavior, correct data types

* Comment manual bit manipulation to be investigated

* check for more edge cases, replace multiple cleanups with goto

* remove system specific includes
2022-04-15 11:34:46 -04:00
Adam 683d23e3ba
Changed calculation to use ascender, which should work better. (#912) 2022-04-04 10:38:43 -04:00
Guldoman 5714da81f8
Always check if the beginning of the text needs to be clipped 2022-03-07 23:35:56 +01:00
Adam 61e712db12
Fixed rendering computations for y offset. (#843)
* Fixed rendering computations for y offset.

* Force monospacing if every ascii character has the same integer advance.

* Added in explanatory comment.

* Fixed issues.

* Made lines less long.
2022-02-15 15:57:07 -05:00
George Sokianos 8fe3c75339 Fixes on renderer to address wrong colors with opacity smaller than 1 and wrong surface size, like mentioned at #803 issue at lite-xl repo 2022-02-05 13:31:40 +00:00