Go to file
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
.github Release v2.1.5 (#1840) 2024-06-30 07:21:35 +08:00
data add cuda 2024-07-04 13:09:00 +08:00
docs move window creation and management to Lua (#1751) 2024-06-22 15:01:39 -04:00
licenses Fix Project Scanning (#746) 2022-03-06 00:59:22 -05:00
resources macos: Add proper platform-specific icon 2024-07-12 14:56:16 +08:00
scripts resources,scripts: use gh cli to fetch the correct release tags 2024-06-30 07:19:27 +08:00
src renderer: rewrite glyph cache (#1845) 2024-07-13 02:39:49 +02:00
subprojects subprojects: update lua,pcre2,sdl2 (#1812) 2024-06-18 15:19:38 +02:00
.editorconfig Updated Meson configuration 2021-08-09 22:26:16 +02:00
.gitattributes Merge pull request #309 from redtide/git-line-endings 2021-06-30 11:13:42 -04:00
.gitignore refactor(build): use dmgbuild to create dmgs (#1664) 2023-11-10 02:44:58 +01:00
LICENSE Rectify `LICENSE` dates and owners (#1748) 2024-03-15 21:03:24 +01:00
README.md readme: add minimum supported OSes (#1711) 2024-02-06 01:49:41 +01:00
build-packages.sh refactor(build): use dmgbuild to create dmgs (#1664) 2023-11-10 02:44:58 +01:00
build.lhelper Adapt build job to lhelper-2 2022-06-30 09:42:01 +02:00
changelog.md Release v2.1.5 (#1840) 2024-06-30 07:21:35 +08:00
meson.build Release v2.1.5 (#1840) 2024-06-30 07:21:35 +08:00
meson_options.txt Use Lua wrap by default (#1481) 2023-08-24 22:33:39 -04:00

README.md

Lite XL

CI Discord Badge Image

screenshot-dark

A lightweight text editor written in Lua, adapted from lite.

Please refer to our website for the user and developer documentation, including build instructions details. A quick build guide is described below.

Lite XL has support for high DPI display on Windows and Linux and, since 1.16.7 release, it supports retina displays on macOS.

Please note that Lite XL is compatible with lite for most plugins and all color themes. We provide a separate lite-xl-plugins repository for Lite XL, because in some cases some adaptations may be needed to make them work better with Lite XL. The repository with modified plugins is https://github.com/lite-xl/lite-xl-plugins.

The changes and differences between Lite XL and rxi/lite are listed in the changelog.

Overview

Lite XL is derived from lite. It is a lightweight text editor written mostly in Lua — it aims to provide something practical, pretty, small and fast easy to modify and extend, or to use without doing either.

The aim of Lite XL compared to lite is to be more user friendly, improve the quality of font rendering, and reduce CPU usage.

Customization

Additional functionality can be added through plugins which are available in the plugins repository or in the Lite XL plugins repository.

Additional color themes can be found in the colors repository. These color themes are bundled with all releases of Lite XL by default.

Quick Build Guide

If you compile Lite XL yourself, it is recommended to use the script build-packages.sh:

bash build-packages.sh -h

The script will run Meson and create a tar compressed archive with the application or, for Windows, a zip file. Lite XL can be easily installed by unpacking the archive in any directory of your choice.

Otherwise the following is an example of basic commands if you want to customize the build:

meson setup --buildtype=release --prefix <prefix> build
meson compile -C build
DESTDIR="$(pwd)/lite-xl" meson install --skip-subprojects -C build

where <prefix> might be one of /, /usr or /opt, the default is /. To build a bundle application on macOS:

meson setup --buildtype=release --Dbundle=true --prefix / build
meson compile -C build
DESTDIR="$(pwd)/Lite XL.app" meson install --skip-subprojects -C build

Please note that the package is relocatable to any prefix and the option prefix affects only the place where the application is actually installed.

Installing Prebuilt

Head over to releases and download the version for your operating system.

The prebuilt releases supports the following OSes:

  • Windows 7 and above
  • Ubuntu 18.04 and above (glibc 2.27 and above)
  • OS X El Capitan and above (version 10.11 and above)

Some distributions may provide custom binaries for their platforms.

Windows

Lite XL comes with installers on Windows for typical installations. Alternatively, we provide ZIP archives that you can download and extract anywhere and run directly.

To make Lite XL portable (e.g. running Lite XL from a thumb drive), simply create a user folder where lite-xl.exe is located. Lite XL will load and store all your configurations and plugins in the folder.

macOS

We provide DMG files for macOS. Simply drag the program into your Applications folder.

Important Newer versions of Lite XL are signed with a self-signed certificate, so you'll have to follow these steps when running Lite XL for the first time.

  1. Find Lite XL in Finder (do not open it in Launchpad).
  2. Control-click Lite XL, then choose Open from the shortcut menu.
  3. Click Open in the popup menu.

The correct steps may vary between macOS versions, so you should refer to the macOS User Guide.

On an older version of Lite XL, you will need to run these commands instead:

# clears attributes from the directory
xattr -cr /Applications/Lite\ XL.app

Otherwise, macOS will display a very misleading error saying that the application is damaged.

Linux

Unzip the file and cd into the lite-xl directory:

tar -xzf <file>
cd lite-xl

To run lite-xl without installing:

./lite-xl

To install lite-xl copy files over into appropriate directories:

rm -rf  $HOME/.local/share/lite-xl $HOME/.local/bin/lite-xl
mkdir -p $HOME/.local/bin && cp lite-xl $HOME/.local/bin/
mkdir -p $HOME/.local/share/lite-xl && cp -r data/* $HOME/.local/share/lite-xl/

Add Lite XL to PATH

To run Lite XL from the command line, you must add it to PATH.

If $HOME/.local/bin is not in PATH:

echo -e 'export PATH=$PATH:$HOME/.local/bin' >> $HOME/.bashrc

Alternatively on recent versions of GNOME and KDE Plasma, you can add $HOME/.local/bin to PATH via ~/.config/environment.d/envvars.conf:

PATH=$HOME/.local/bin:$PATH

Note Some systems might not load .bashrc when logging in. This can cause problems with launching applications from the desktop / menu.

Add Lite XL to application launchers

To get the icon to show up in app launcher, you need to create a desktop entry and put it into /usr/share/applications or ~/.local/share/applications.

Here is an example for a desktop entry in ~/.local/share/applications/com.lite_xl.LiteXL.desktop, assuming Lite XL is in PATH:

[Desktop Entry]
Type=Application
Name=Lite XL
Comment=A lightweight text editor written in Lua
Exec=lite-xl %F
Icon=lite-xl
Terminal=false
StartupWMClass=lite-xl
Categories=Development;IDE;
MimeType=text/plain;inode/directory;

To get the icon to show up in app launcher immediately, run:

xdg-desktop-menu forceupdate

Alternatively, you may log out and log in again.

Uninstall

To uninstall Lite XL, run:

rm -f $HOME/.local/bin/lite-xl
rm -rf $HOME/.local/share/icons/hicolor/scalable/apps/lite-xl.svg \
          $HOME/.local/share/applications/com.lite_xl.LiteXL.desktop \
          $HOME/.local/share/metainfo/com.lite_xl.LiteXL.appdata.xml \
          $HOME/.local/share/lite-xl

Contributing

Any additional functionality that can be added through a plugin should be done as a plugin, after which a pull request to the Lite XL plugins repository can be made.

Pull requests to improve or modify the editor itself are welcome.

Licenses

This project is free software; you can redistribute it and/or modify it under the terms of the MIT license. See LICENSE for details.

See the licenses file for details on licenses used by the required dependencies.