Commit Graph

63 Commits

Author SHA1 Message Date
George Sokianos 893fbfc43f Extra changes to make it compile under OS4 2022-03-27 22:11:26 +01:00
George Sokianos f363c34499 Applied all the necessary changes to make it run under AmigaOS 4.1 FE 2022-03-27 21:17:48 +01:00
Francesco Abbate d1017895eb Use new mutex in dmon to avoid possible lock-up
We rely on one variable _dmon.modify_watches shared between thread to
ensure that we don't lock with the dmon polling thread waiting indefinitely
and helding a lock.

To ensure that the polling thread sees modifications done to 'modify_watches'
we use an additional mutex that act as a memory barrier.
2022-01-24 09:14:59 +01:00
Francesco Abbate 827f3f876d Remove remaining debug code fragment 2022-01-09 23:26:11 +01:00
Francesco Abbate 648b977c1e Use a timeout in dmon thread with pending events 2022-01-09 23:26:11 +01:00
Francesco Abbate 9be22f0b8d Attempt to fix dmon critical section for windows
Should fix commit bb12f085f3.

When taking the critical section we should always send the
event to wakeup the events thread. In addition use
TryEnterCriticalSection to send the event only if needed
reducing the number of spurious events sent.
2022-01-09 23:26:11 +01:00
Francesco Abbate 19ec86d971 Do not use timeout in dmon linux select
Wait indefinitely in select and wake-up the thread when needed.
2022-01-09 23:26:11 +01:00
Francesco Abbate 44a8dc320b Fix some errors with previous commits 2022-01-09 23:26:11 +01:00
Francesco Abbate 6584bdfd33 On Windows wait indefinitely in dmon thread
Avoid waiting with a finite timeout and wait indefinitely in
dmon thread. When we need to unwatch we send a signal to a special
event meant to wakeup the waiting thread.
2022-01-09 23:26:11 +01:00
Francesco Abbate f0aea5b1a4 Report error codes from dmon_watch_add 2022-01-09 23:26:11 +01:00
Francesco Abbate 1520c12580 Remove DMON_LOG_ERROR to return an error code 2022-01-09 23:26:11 +01:00
Francesco Abbate 7473fbf32c Fix undue asserts in dmon_extra
Some asserts are placed in case that can effectively occur
so we remove the assertion and we return false. In turn we
adapt the logic accordingly so when false is returned to add
a watch we do not open that directory.
2022-01-09 23:26:11 +01:00
Francesco Abbate 9578359b2b Remove inotify recursive directory monitoring
We no longer use in Lite XL recursive directory monitoring as
it was a source of problems.

To enforce this at compile time we use the preprocessor to
remove the implementation of recursive monitoring for the Linux
implementation only.
2021-12-30 15:45:09 +01:00
Francesco Abbate 80d837b05b Fix assert with dmon on directory deleting 2021-10-23 15:47:39 +02:00
Francesco Abbate a99dd947ed Add missing meson file 2021-10-09 14:37:33 +02:00
Francesco Abbate a9f6f01ed0 Move dmon files into lib/dmon 2021-10-08 22:10:17 +02:00
Guldoman 07c23fbf17 Avoid having no `pixel_width`
On small scales `pixel_width` could become `0`. This caused the creation 
of buffers of size `0` with consequent overflows.
2021-08-28 09:59:36 +02:00
Jan200101 973acb787a use dependency fallbacks, use system reproc if available 2021-08-24 11:54:44 +02:00
Adam Harrison e144ad3271 Removed legacy build system. 2021-07-15 20:47:44 -04:00
Francesco Abbate d0d6ad8d7d Fix problem with glyph spacing in subpixel mode
One more space is needed for subpixel positioning.

Otherwise some artifacts can be present
2021-03-07 18:38:47 +01:00
Francesco Abbate 6782533ad2 Fix heuristic to find font atlas optimal width 2021-03-07 17:30:11 +01:00
Francesco Abbate 9ff6a0325e Mostly fix problem of offset with cursor positioning when using mouse
In order to get right the cursor position on text on mouse clicks it is
needed to take into account text's subpixel positioning.

This fix mostly corrects the problem but cursor positioning is still
somewhat inaccurate for long lines due to repeated commands to draw a text
along a line. Repeated draw text calls make the subpixel information
lost and small errors will add-up.
2021-03-06 16:18:24 +01:00
Francesco Abbate 7abb36e5e8 Fix error with glyphs subpixel layout 2021-03-05 22:43:15 +01:00
Francesco Abbate ffb4773a0b Merge branch 'subpixel-font-positioning' 2021-03-05 09:14:25 +01:00
Francesco Abbate e441beae83 Add missing padding pixel to avoid artifacts
Using subpixel positioning we need one empty pixel as the left of each glyph.
2021-03-04 16:54:55 +01:00
Francesco Abbate bdc473435b Fix bug causing abort when glyph count was zero
Solve github's issue https://github.com/franko/lite-xl/issues/75
2021-03-03 18:49:27 +01:00
Francesco Abbate 294f3f14fb Implement subpixel font positioning
Subpixel positioning is only by 1/3 of pixel
2021-03-03 18:36:09 +01:00
Francesco Abbate ea8a8770ea Do not use nullptr and add check 2021-02-24 09:46:48 +01:00
Francesco Abbate a23986f171 Cleanup font's note markdown file 2021-02-23 17:14:22 +01:00
Francesco Abbate 35f31c8fbc Fix font rendering artifacts bug
Seen with some fonts like FiraSans, github issue:

https://github.com/franko/lite-xl/issues/46

The fix works essentially by looking to the bounds of each glyph to
accurately ensure that there are no overlaps between the glyphs.

The construction of the font atlas was changed to make some related
improvements now that the bounds of each glyph are know. The main
changes are:

- no longer align glyph on the baseline but align them on their upper
  bounds. We ensure this way that very tall fonts do not leak in the
  upper part
- terminate the row based on x bounds of the glyph to be more accurate
- for each row keep trace of the y of the more larger along y of the
  glyph. The value is used to start a new row to be sure that the new
  now does not overlap with the previous one
- sort glyphs by y size before drawing them. In this way the space
  utilization is better. The algorithm used is the very simple insert
  sort. It behaves like O(n^2) with the number of characters but should
  be ok since n is always small, typically below 128.
- compute the optimal image width and height for the given font's atlas
  for optimal memory usage. As a bonus now the lite's code don't have to
  try and repeat to get a good image size
2021-02-23 17:14:08 +01:00
Francesco Abbate a41754b382 Fix font hinting when using subpixel rendering
Ensure we set the font's size with freetype to the intended size so that
hinting works as expected and perform subpixel scaling using affine
matrix coefficient.
2020-12-11 14:36:32 +01:00
Francesco Abbate 71db2d439a Add libagg as a subproject
No longer required to be installed, the subproject will be used if not
found.
2020-06-30 17:02:50 +02:00
Francesco Abbate 0c09419001 Fix again the problem with C++ abs function 2020-06-29 18:20:36 +02:00
Francesco Abbate bc6cdd7711 Remove spurious typename keyword in C++ code 2020-06-29 17:02:45 +02:00
Francesco Abbate 1fc6d62b14 Fix Lua subproject ofr Mac OS X 2020-06-29 17:01:14 +02:00
Francesco Abbate fa649521d2 Fix usage of abs function with C++ 2020-06-29 16:58:42 +02:00
Francesco Abbate c23ef76179 Add execution flags to build script 2020-06-18 19:28:06 +02:00
Francesco Abbate 0e04030131 Fix and improve build script 2020-06-18 15:53:31 +02:00
Francesco Abbate f5ede27e91 No longer use gamma correction
Text looks more correct without the gamma correction. With gamma correction
text looks too bold in dark mode and too light in light mode. This
behavior is a sign that gamma correction is not the right thing to do.

The problem is seen with gamma at 1.5 used previously but is even worst
if a gamma value of 2.2, the theoretical value, is used.
2020-06-16 14:43:03 +02:00
Francesco Abbate 3c3662b3ba Add option to disable X axis font's pre-scaling
If used pre-scaling along X null the effect of the font's hinting.
2020-06-12 16:06:39 +02:00
Francesco Abbate 9e996a2d87 Rename FontRenderer to FR_Renderer 2020-06-11 23:19:08 +02:00
Francesco Abbate 93a36617f9 Bring back simple grayscale rendering option 2020-06-11 23:11:40 +02:00
Francesco Abbate 00c3983da6 Rename FontRenderer* symbols as FR_* 2020-06-11 18:12:47 +02:00
Francesco Abbate 117714390a Make the FontRenderer's Bitmap struct opaque outside the library 2020-06-11 17:52:00 +02:00
Francesco Abbate ce664f85b1 Move rendering buffers pointers computations inside FontRendererBlendGammaSubpixel
The logic is to disentangle the code between renderer.c and FontRenderer
so that this latter has a simple, logical interface.
2020-06-11 17:33:57 +02:00
Francesco Abbate 18865fd32f Remove font renderer debug code 2020-06-09 16:55:26 +02:00
Francesco Abbate ba4c8dbbb5 Remove unneeded checks in get_font_vmetrics 2020-06-08 09:36:07 +02:00
Francesco Abbate bddc947b99 Fix pixel off-by-one error in subpixel font renderer hspan 2020-06-08 09:35:52 +02:00
Francesco Abbate 74de184e50 Move notes.md inside lib/font_renderer 2020-06-07 16:00:06 +02:00
Francesco Abbate e82d766c2b Add more debug information in font's bitmap images 2020-06-07 00:15:38 +02:00