Commit Graph

22 Commits

Author SHA1 Message Date
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
takase1121 7ecc174094
fix memory leak and wrong check in font_retrieve 2022-06-15 23:23:13 +08: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
takase1121 84a3906323
fix FontGroup __gc method 2021-12-24 15:04:52 +08:00
Adam Harrison eb9918089a Takes kivutar's changes into account, cleaning things up slightly. 2021-12-15 20:31:24 -05:00
Adam d7b6fe3d42
Merge pull request #688 from adamharrison/mono-font
Add Support for `none` Antialiasing
2021-11-23 15:59:07 -05:00
Adam Harrison 96db380c73 Manual merge of into . 2021-11-23 15:57:22 -05:00
Adam Harrison bc5be3c9b7 Support no antialiasing. 2021-11-22 18:13:43 -05:00
Adam Harrison 7575d2eee6 Fixed minor issue. 2021-10-16 23:32:17 -04:00
Adam Harrison f2488fdd8d Added in support for font groupings. 2021-10-12 23:24:52 -04:00
Francesco Abbate cb08c5cbb7 Fix dirty pixels problem on window's right side
The last column of pixel on the window's right side isn't correctly
drawn and pixels appear dirty and more noticeably when the a NagView
message was previously shown, a stripe of red pixels remains on the right.

We use now a more souding roundig scheme. Now the rectangles to clip or to
draw are passed around as Lua numbers without any rounding. In turns, when
the rect coordinates are passed to the renderer we ensure the border of the
rect are correctly snapped to the pixel's grid. It works by computing the
coordinates of the edges, round them to integers and then compute the rect's
width based on the rounded coordinates values.
2021-10-10 14:52:55 +02:00
Adam Harrison 806e4bc970 Converted all ints to floats for x coordinate purposes. 2021-09-25 00:35:55 -04:00
Adam Harrison 940db0f9c7 Added in underline as well. 2021-09-24 11:23:49 -04:00
Adam Harrison 16deedc8a3 Fixed up some naming conventions, and also added bolding and italics. 2021-09-24 11:23:49 -04:00
Adam Harrison e25f2e9c5c Removed font renderer. 2021-09-24 11:22:39 -04:00
Francesco Abbate aa0b2bb5fc Fix crash problem with rencache and font access
In some cases rencache was using a FontDesc pointer that was actually freed by
Lua giving segfaults errors.

In addition, some FontDesc object were not freed in some cases if the
rencache_end_frame was not called when performing the "restart" command.

The invalid access problem can happen because rencache keep some pointers to
FontDesc object but these are Lua userdata that Lua can dispose of. This
situation is prone to hard errors and we should avoid to keep pointers to
objects managed by Lua.

To this purpose we use luaL_ref/unref to bind the FontDesc into the Lua's
registry while rencache need them. We still keeps pointer to FontDesc object but
using luaL_ref we are assured they will not be disposed by Lua.

Since we are using luaL_ref/unref to inform the GC about when the objects are in
use we can now finalize the objects directly when Lua collects them. Previously
the GC metamethods was issuing a FREE command to rencache and the font was
actually freed only from the rencache_end_frame function.
2021-05-21 23:38:54 +02:00
Francesco Abbate 46c3bdea67 First implementation of scaling for retina display
Introduce a new approach that discriminate coordinates in
points and pixels. Now all the logic from the Lua side and in
rencache is to always use points. The coordinates are converted
to pixels only within the renderer, in the file renderer.c.
In this way the application logic does not need to care about the
scaling of the retina displays.

For non-retina display the scaling between points and pixels is
equal to one so nothing will change.

There is nevertheless a change that leak into the Lua side. The
subpixel coordinates are in sub-pixel, not sub-points so they are
scaled by the retina scaling factor. But no change in the code is
required because the subpixel scaling factor take into account the
retina scaling, when present.

Because the retina scaling factor is not know when the application
starts but only when a window is actually available we introduce a
mechanism to render the font with a given scaling factor only from
the renderer when they are needed. We use therefore FontDesc to
describe the font information but without actually rasterizing the
font at a given scale.
2021-04-26 15:16:34 +02:00
Francesco Abbate 3b040aabc7 Implement unicode character replacements
Useful to draw whitespaces with alternate characters and colors
without slowing down the text rendering.

A new API is implemented. A renderer.replacements object can be created
to list the replacements.

In turns the function renderer.draw_text and draw_text_subpixel now accept
two optional arguments for replacements.
2021-04-01 18:05:59 +02:00
Francesco Abbate 3426bc5d73 Introduce subpixel text positioning within rencache
In order to fix the issue with cursor positioning a subpixel-aware draw
text operation within rencache was required.

With this modification the cursor positioning problem is completely
resolved.

A new function renderer.draw_text_subpixel is introduced to perform
consecutive, inline, text drawings with subpixel accuracy.
2021-03-06 18:12:02 +01:00
rxi b2756d8a49 Removed xalloc.c/h 2020-05-08 13:41:39 +01:00
rxi d8c4bfa6ba Initial commit 2019-12-28 11:17:56 +00:00