Commit Graph

403 Commits

Author SHA1 Message Date
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 4b3b8f430a Merge remote-tracking branch 'basinbaby/set-window-opacity'
Implement the suggestion and close #125.

Initial suggestion and implementation from

https://github.com/rxi/lite/pull/17
2021-03-23 07:15:18 +01:00
Francesco Abbate e160ed4e5e Add comments about unused RenFont data field 2021-03-20 23:05:09 +01:00
Francesco Abbate b33167ca4b Revert "Remove unused data field in RenFont"
This reverts commit 461266e97d.

Related to github issue #122.

The void *data field is not used but the glyphset index can
someting be equal to -1 and the unused field prevent faulty
writes before the allocated struct.
2021-03-20 21:48:04 +01:00
Francesco Abbate aee602ea2f Merge branch 'xrdb-lean' 2021-03-18 16:20:32 +01:00
Francesco Abbate 461266e97d Remove unused data field in RenFont 2021-03-18 14:05:58 +01:00
Francesco Abbate ecb9e88fdb Merge branch 'master' into xrdb-lean 2021-03-18 14:00:54 +01:00
Francesco Abbate 88bec172a1 Fix problem with tab size and subpixel positioning
Solve github issue https://github.com/franko/lite-xl/issues/109
2021-03-18 13:54:33 +01:00
Francesco Abbate a742c56ee7 Minor xrdb buffer optimization 2021-03-18 10:06:01 +01:00
Francesco Abbate 43e08b0f8e Fix problem with previous commit and remove strtol call 2021-03-18 10:00:03 +01:00
Francesco Abbate 51e7c9493f Minor change for xrdb output parsing
Use memmove to copy remaining bytes at beginning of buffer
2021-03-18 09:32:52 +01:00
Francesco Abbate ac0728d073 Check for error in pipe call 2021-03-17 18:29:50 +01:00
Francesco Abbate 30f9f20e23 Ensure xrdb code is compiled only on unix 2021-03-17 18:10:47 +01:00
Francesco Abbate dab39d3b5c Implement xrdb reading without popen
Avoid using the shell, awk and cut command
2021-03-17 16:58:44 +01:00
daubaris 27f3cb23d4
Addressing the scaling factor on linux. (#107)
Use xrdb and the Xft.dpi variable to find out DPI scaling on linux.
2021-03-14 16:13:26 +01:00
Francesco Abbate baf5aebe1c Merge remote-tracking branch 'origin/master' into subpixel-font-positioning-fix 2021-03-07 12:25:53 +01:00
Francesco Abbate 23a053e1ee Ensure error and stack trace are written to stdout
To address https://github.com/franko/lite-xl/issues/87
2021-03-07 09:48:44 +01: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
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 09332fe242 Fix problem with fatal error message
Previous implementation was broken.

Ensure the error file is always written and write its location in the error message
2021-03-05 23:46:41 +01:00
Francesco Abbate a4bc8986ff Implement fatal error message box
Used when lite-xl fails at startup
2021-03-05 10:33:50 +01:00
Francesco Abbate 636bc7ec95 More accurate EXEDIR detection
Use ony the OS path separator to parse the executable filename
2021-03-05 09:42:48 +01:00
Francesco Abbate ffb4773a0b Merge branch 'subpixel-font-positioning' 2021-03-05 09:14:25 +01:00
Francesco Abbate 1ea497deb4 Fix problem when launching from a different location
Should fix https://github.com/franko/lite-xl/issues/76 and https://github.com/franko/lite-xl/issues/67
2021-03-05 07:28:29 +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 351a772466 do not use 'portable' as a compile time option
Introduce the file core/start.lua to initialize applications variables
2021-02-24 16:29:39 +01:00
Francesco Abbate ea8a8770ea Do not use nullptr and add check 2021-02-24 09:46:48 +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 9fced84a7a Move VERSION variable into Lua code
To avoid recreating binaries if there are no changes
in the C side of the source code.
2021-02-16 14:35:02 +01:00
Francesco Abbate 882413e92d Bump 1.16 version number 2021-01-13 16:52:27 +01:00
Francesco Abbate d3686bb6f4 Bump new version number 2020-12-31 11:27:35 +01:00
Francesco Abbate 2cdf674b97 Keep memory of window's size and position and restore them on start
Fix also a problem with directory path on windows.
2020-12-31 11:25:12 +01:00
Francesco Abbate 35c87462a6 Use ~ for HOME directory in folder search 2020-12-19 16:31:42 +01:00
Francesco Abbate e50d67df85 Update readme and changelog for release 1.14 2020-12-13 13:04:29 +01:00
Francesco Abbate 1fc0409163 Merge branch 'project-manager' 2020-12-12 20:27:07 +01:00
Francesco Abbate 6409b67ea2 Add core:restart function to restart the editor 2020-12-10 12:44:01 +01:00
Francesco Abbate 1c4b8cf315 Fix documentation and behavior for 1.13 release 2020-12-06 11:23:33 +01:00
Francesco Abbate afda299fe4 Implement optional font rendering options
The user can now choose antialiasing grayscale and subpixel and hinting
non, slight or full.
2020-12-04 16:15:54 +01:00
Francesco Abbate be189fda0d Always use HOME based user's config independently from portable option 2020-12-04 12:01:49 +01:00
Francesco Abbate c41dedafad Improve the implementation of unix-like directories usage
Add a Meson option "portable" to choose between "portable" and unix-like
directories. Add information about this option in the README.

To determine the user's directory use the variable USERPROFILE only on
Windows and use HOME otherwise.

Implement the "portable" option in the package build script.
2020-12-03 16:46:18 +01:00
Francesco Abbate 277186491a Fix some problems with user's directory
To accommodate the Window's platform prefer the USERPROFILE to HOME
to set user's dir.

Fix error, user's dir was not added to the package.path.
2020-12-02 16:43:35 +01:00
Francesco Abbate a337f893d9 Implement user's config as init file and add directory into package.path
Create the user's config init file if lite user's config directory does
not exists.

No longer use the awkward package.searchers but instead add user's
config dir at the end of package path.
2020-12-02 16:03:31 +01:00
Francesco Abbate 3589d7d3c0 First implementation of unix-like data directory
It basically works by setting the data directory to

$prefix/share/lite-xl

where $prefix is determined so that $prefix/bin corresponds to EXEDIR.

The packages 'user' and 'user.*' are loaded from the directory
'$HOME/.config/lite-xl'.
2020-12-02 00:23:15 +01:00
Francesco Abbate 70412b520b Fix cursor blinking problem
The problem was that when the editor had no events the cursor was not
blinking because the event loop was blocking on wait_event.

Now we no longer calls wait_event without a timeout if the windows has
the focus. When the window has the focus the timeout is set to 1 / fps
so that the cursor can blinks.

In addition we react to the "focus lost" event to ensure the documents
are redrawn without the cursor.
2020-11-21 16:36:32 +01:00
Francesco Abbate cdcd89d6d7 Merge remote-tracking branch 'rxi/master' 2020-11-17 10:24:27 +01:00
rxi 878c94a334 Changed rencache to store font tab_width with font command
Fixes bug where text would be drawn/cached wrongly if more than one tab_width
was used in a given frame
2020-09-05 15:09:54 +01:00
Francesco Abbate 1c5767d393 Merge remote-tracking branch 'rxi/master' 2020-08-19 10:08:32 +02:00
rxi 91c43dc01e Version 1.11 2020-07-05 10:56:39 +01:00
Francesco Abbate 14ec61511d Merge remote-tracking branch 'rxi/master' 2020-07-04 22:08:25 +02:00
Francesco Abbate 77a9819f4e Fix SDL2 include directives 2020-06-29 15:24:08 +02:00
rxi 87532a4b3a Version 1.10 2020-06-28 14:40:07 +01:00
rxi 11df722162 Version 1.09 2020-06-21 19:38:42 +01:00
Francesco Abbate fe0dda8309 Merge remote-tracking branch 'rxi/master' into agg-font-renderer 2020-06-16 15:00:47 +02:00
Francesco Abbate 5c3d4163d3 Modify system.wait_event to wait indefinitely if no timeout is given 2020-06-16 14:53:01 +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
rxi 1db1f0bceb Version 1.08 2020-06-14 13:33:23 +01: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 4d3693479d Merge remote-tracking branch 'rxi/master' into agg-font-renderer 2020-06-11 23:22:49 +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
rxi 95b70b1b16 Revert "Removed __APPLE__ `#ifdef` from main.c"
This reverts commit 6a7e214d1c.
2020-06-11 15:05:39 +01:00
Francesco Abbate 18865fd32f Remove font renderer debug code 2020-06-09 16:55:26 +02:00
rxi db471c0554 Version 1.07 2020-06-07 14:02:45 +01:00
rxi 6a7e214d1c Removed __APPLE__ `#ifdef` from main.c 2020-06-07 08:57:57 +01:00
Francesco Abbate fc148d7a51 Merge remote-tracking branch 'rxi/master' into font-rendering-tests 2020-06-07 00:19:03 +02:00
Francesco Abbate e82d766c2b Add more debug information in font's bitmap images 2020-06-07 00:15:38 +02:00
Francesco Abbate 81289d651e Move font resize in a separate function 2020-06-06 19:11:14 +02:00
Francesco Abbate dcf6b06629 Cleanup debug code 2020-06-06 13:08:39 +02:00
Francesco Abbate d17fde1b13 WIP: debugging stuff 2020-06-06 10:52:50 +02:00
Francesco Abbate c5575de058 Move font renderer in a separate folder as a library 2020-06-04 18:52:01 +02:00
Francesco Abbate 2171ea17fb Add correct copyright information 2020-06-04 18:14:02 +02:00
Francesco Abbate ac36cfc59c Remove unused code files 2020-06-04 18:13:28 +02:00
Francesco Abbate a2a4668887 Add some comments and remove unused code 2020-06-04 17:23:39 +02:00
Francesco Abbate 67124de130 Add some explanatory comments 2020-06-04 17:17:10 +02:00
Francesco Abbate dc5b668389 Fix resize of bounding rectangle in BakeFontBitmap function 2020-06-04 17:08:55 +02:00
Francesco Abbate c433017d75 Fix remove unnecessary function templating 2020-06-04 16:46:37 +02:00
Francesco Abbate a0e7d16167 Implement subpixel LCD font rendering 2020-06-04 16:29:28 +02:00
Daniele Laudani 95ee03fb37
move BYPASS_COMPOSITOR near other SetHint 2020-06-03 15:05:55 +02:00
Daniele Laudani 7aa462e43d
Don't tell the system to disable compositing under X11
Fixes #123
2020-06-03 14:38:44 +02:00
U-ST\francesco abbate f61ffc4710 Add missing resource file on windows 2020-06-03 12:22:17 +02:00
Francesco Abbate 9bd4a8b9de Merge remote-tracking branch 'rxi/master' into font-rendering-tests 2020-06-02 23:28:52 +02:00
Francesco Abbate 01a4981210 Use static libgcc and libstdc++ when doing release build 2020-06-02 23:20:22 +02:00
Francesco Abbate e01ba599ba Optimize glyph set bitmap rectangles by trimming empty regions 2020-06-02 18:46:44 +02:00
Francesco Abbate d46cf80226 Adjust xadvance computation to use rounding instead of truncate 2020-06-02 17:52:02 +02:00
Francesco Abbate 39d7d49586 Reduce y padding in BakeFontBitmap 2020-06-02 17:51:26 +02:00
Francesco Abbate ae032cd185 Ember blender with gamma correction into FontRenderer 2020-06-02 17:18:52 +02:00
Francesco Abbate bc74b2860d Add gamma correct pixel blender 2020-06-02 14:47:06 +02:00
Francesco Abbate c41d6a82e1 Adjust BakeFontBitmap issues 2020-06-01 17:23:18 +02:00
Francesco Abbate c2949edcd7 Check for errors when loading fonts 2020-06-01 17:01:42 +02:00
Francesco Abbate b734390388 Use font_renderer in aGG font testing program 2020-06-01 16:57:33 +02:00
Francesco Abbate e291e7269a Hack to fix font size rendering to align with STB original rendering 2020-06-01 15:33:14 +02:00
Francesco Abbate c333425770 Remove stb from Meson dependencies for Lite 2020-06-01 15:28:07 +02:00
Francesco Abbate 98f5c16932 Remove unused variable 2020-06-01 15:16:07 +02:00
Francesco Abbate 5ca7471fc7 Cosmetic code's cleanup 2020-06-01 14:45:07 +02:00
Francesco Abbate fa06862177 Completely remove usage of stb_truetype 2020-06-01 14:43:45 +02:00
Francesco Abbate 91a82d8ae4 Add missing function to free FontRenderer 2020-06-01 14:42:57 +02:00
Francesco Abbate 0389bd000a Fix y offset in BakeFontBitmap
Compute Y offset more accurately and the way it is required in
renderer.c.

Instead of returning y offset wrt the baseline position returns it
wrt the top position (the baseline plus the font's ascent).
2020-06-01 14:33:46 +02:00
Francesco Abbate 4c6e15b66c Rename GlyphSetA to GlyphSet 2020-06-01 14:08:50 +02:00
Francesco Abbate 3a8cb05ea6 Replace stb's BakeBitmapFont with AGG based font's renderer 2020-06-01 12:56:23 +02:00
Francesco Abbate edb103716a Add function to render a single unicode codepoint 2020-06-01 11:25:22 +02:00
rxi f00d5d55df Version 1.06 2020-05-31 16:53:53 +01:00
Francesco Abbate 4ec521dd37 Add correct glyphs bitmap location rects with AGG 2020-05-31 13:53:27 +02:00
Francesco Abbate 103336945e Add pixel format to render font in bitmap format
The purpose it to add later subpixel by storing the bitmap with RGB
channels to have subpixel LCD coverage information.

The colorization and gamma blending will be done when blitting the glyph
on the destination surface.
2020-05-30 18:07:31 +02:00
Francesco Abbate 010966d60d Add correct font's height calculation using AGG
Compute the height like in renderer.c
2020-05-30 16:26:10 +02:00
Francesco Abbate 0fea5d9d25 Add in agg_font_render method to get face's units to em 2020-05-30 16:25:13 +02:00
Francesco Abbate 155e76df5f Add font vmetrics in AGG font renderer test 2020-05-30 15:19:12 +02:00
Francesco Abbate 4701c2899c Add function in agg_font_freetype to take face's height 2020-05-30 15:18:36 +02:00
Francesco Abbate a7904eba3b Fix errors in renderer lcd 2020-05-29 18:41:14 +02:00
Francesco Abbate 0e713f7692 WIP: to use AGG font renderer to create a coverage bitmap 2020-05-29 16:00:29 +02:00
rxi b96609b7b8 Removed redundant __APPLE__ case in get_scale() 2020-05-29 09:33:42 +01:00
Francesco Abbate 4a8df09829 Fix y coordinate orientation in font rendering call 2020-05-29 09:27:00 +02:00
Francesco Abbate 31d7cb5ce0 Fix LCD font rendering for BGRA32 pixel format
Now the sizing of fonts is determined by stb_truetype while the
rendering is done via AGG so they are not aligned.

There seems to be an error also about Y text positioning.
2020-05-28 16:08:48 +02:00
Francesco Abbate 23a080ca45 WIP: compiles but completely broken
AGG files imported from AGG repository, sdl-testing branch.

the pixfmt_bgra32_lcd is just implemented and is not tested.
2020-05-28 12:15:24 +02:00
Francesco Abbate 79487074c0 Add missing gui_app flag in meson build 2020-05-25 16:18:06 +02:00
Francesco Abbate 7b9def299d Add dl library because it may be needed by SDL2
Should be fixed to be added only when needed.
2020-05-25 12:23:46 +02:00
Francesco Abbate 618078829c Add meson build configuration
Currently the editor will not work if it is not installed.

There is also a caveat about the 'data' directory which is installed
in the bin directory. This may work but does not seem ok because it is
pollution a shared bin directory and the 'data' folder may not be unique
to Lite.
2020-05-25 12:22:23 +02:00
rxi 61a2a2c4e5 Version 1.05 2020-05-24 13:52:10 +01:00
rxi 61092fbb99 Changed fuzzy matching to favour matching case 2020-05-23 15:08:38 +01:00
rxi 35b642d434 Added rencache invalidation on window-exposed event
Fixes #63
2020-05-22 09:00:48 +01:00
rxi 35ce3d32a9 Fixed string quoting on windows in `system.exec()` 2020-05-22 08:11:05 +01:00
rxi 7aabfebfa0 Fixed mouse-position resolution when dropping a file 2020-05-20 10:33:08 +01:00
rxi 4ae0d477c0 Made lite set project dir to CWD; removed core.project_dir
Fixes #100
2020-05-17 17:05:56 +01:00
rxi c1f731e5a1 Fixed EXEDIR having trailing slash 2020-05-17 16:58:32 +01:00
rxi adad2a65be Version 1.04 2020-05-17 14:58:44 +01:00
rxi 1abb979490 Added null-checks for all push_command() calls in rencache.c 2020-05-17 13:18:26 +01:00
rxi 82fdc63c6a Added global EXEFILE 2020-05-17 09:36:46 +01:00
rxi 5102088aca Deferred showing window until after the first frame has rendered
Fixes #97
2020-05-14 23:06:14 +01:00
rxi 9bf0ed2419 Made rencache warn on exhausting command buffer instead of panicing 2020-05-14 08:52:07 +01:00
rxi 4c2c03ed4d Made draw_text/draw_rect not push command if result is not on-screen 2020-05-14 08:45:45 +01:00
rxi 2b32edf7f0 Added system.exec() to system api 2020-05-13 20:32:53 +01:00
rxi 2f659d5180
Merge pull request #81 from extrowerk/patch-1
Build fix
2020-05-11 13:31:33 +01:00
extrowerk a6013ff181
Build fix 2020-05-11 13:49:18 +02:00
rxi c215eff6d8 Improved idle CPU utilisation when not-focused, added system.wait_event() 2020-05-11 00:21:07 +01:00
rxi b67b680975 Changed get_scale() to always default to 1.0 on macOS 2020-05-10 19:32:01 +01:00
rxi 143f8867a1 Version 1.03 2020-05-09 16:29:34 +01:00
rxi b2756d8a49 Removed xalloc.c/h 2020-05-08 13:41:39 +01:00
rxi 774d95d800 Comment improvement in rencache.c 2020-05-07 22:24:12 +01:00
rxi e551052e91 Added icon to non-windows build 2020-05-06 19:49:34 +01:00
rxi c8980a828f Version 1.02 2020-04-26 14:41:34 +01:00
rxi c658b6f1ca Removed underscore from start of globals, added VERSION
eg. `_SCALE` => `SCALE`
prevents conflict with lua's own _NAME globals
2020-04-25 09:58:01 +01:00
rxi bd43ed3e3f Added _PLATFORM global 2020-04-23 20:03:14 +01:00
rxi 03eee86ddb Made font.gc() do null-check in case font.load() failed 2020-04-22 00:41:23 +01:00
rxi a9b4bdf602 Made system.get_file_info() and list_dir() return (nil,msg) on error 2020-04-21 23:33:04 +01:00
rxi d4284edd5c Replaced system.set_fullscreen with system.set_window_mode
Solves #24
2020-04-07 18:49:11 +01:00
rxi efed38d59c Added system.set_fullscreen() and core:toggle-fullscreen command 2020-03-25 22:44:59 +00:00
basinbaby f37f22fb5f Added set_window_opacity function 2020-02-07 13:01:56 +00:00
rxi 613f9c2ba6 Changed renderer to make tab and newline glyphs invisible
Fixes #16
2020-02-05 20:16:09 +00:00
rxi 86800281c9 Made get_exe_dir() static; removed accidental `const` 2020-01-01 13:25:04 +00:00
rxi ba86b58b80 Added better resolution of exe directory; should fix #1 2019-12-31 10:53:31 +00:00
rxi d8c4bfa6ba Initial commit 2019-12-28 11:17:56 +00:00