Skip to content

Font Rejigging#2191

Open
adamharrison wants to merge 86 commits into
lite-xl:masterfrom
adamharrison:PR/font-rejigging
Open

Font Rejigging#2191
adamharrison wants to merge 86 commits into
lite-xl:masterfrom
adamharrison:PR/font-rejigging

Conversation

@adamharrison

@adamharrison adamharrison commented Dec 14, 2025

Copy link
Copy Markdown
Member

To be merged only after multi-windows, and virtual lines. Could likely be rewritten to only work on top of virtual lines, but does require at a minimum virtual lines. Contains many commits from other branches; but I'll try and keep to a single relevant commit that can be easily cherry-picked. Currently, that commit is 202a05a.

Changes the structure of how fonts work, by adding a lua layer in front of them.

Before, style.lua:

style.font = renderer.font.load(DATADIR .. "/fonts/FiraSans-Regular.ttf", 15 * SCALE)
style.big_font = style.font:copy(46 * SCALE)
style.icon_font = renderer.font.load(DATADIR .. "/fonts/icons.ttf", 16 * SCALE, {antialiasing="grayscale", hinting="full"})
style.icon_big_font = style.icon_font:copy(23 * SCALE)
style.code_font = renderer.font.load(DATADIR .. "/fonts/JetBrainsMono-Regular.ttf", 15 * SCALE)

Now:

style.font = font.load(DATADIR .. "/fonts/FiraSans-Regular.ttf")
style.icon_font = font.load(DATADIR .. "/fonts/icons.ttf", { size = 16, antialiasing = "grayscale", hinting = "full" })
style.code_font = font.load(DATADIR .. "/fonts/JetBrainsMono-Regular.ttf")

Where the last optional argument is simply a set of default options in the absence of specifying one, but can be overriden at draw time at any time if you wish to specify something else.


To draw, the lite-xl EmptyView before:

  local title = "Lite XL"
  local version = VERSION
  local logo_h = style.big_font:get_height(title)
  local logo_y = y - logo_h + logo_h/4
  local logo_x = logo_right_side - style.big_font:get_width(title)
  local vers_x = logo_right_side - style.font:get_width(version)
  local vers_y = y + logo_h/8
  renderer.draw_text(style.big_font, title, logo_x, logo_y, style.dim)
  renderer.draw_text(style.font, version, vers_x, vers_y, style.dim)

Now:

  local title = "Lite XL"
  local version = VERSION
  local logo_h = style.font:get_height(EmptyView.logo_size)
  local logo_y = y - logo_h + logo_h/4
  local logo_x = logo_right_side - style.font:get_width(title, EmptyView.logo_size)
  local vers_x = logo_right_side - style.font:get_width(version)
  local vers_y = y + logo_h/8
  style.font:draw(title, logo_x, logo_y, style.dim, EmptyView.logo_size)
  style.font:draw(version, vers_x, vers_y, style.dim)

Also, removes the core.add_thread stuff in language_md (and a bunch of other places that are keeping track of SCALE/theme font/color changes), and adds in a simple hinting mechanism for the tokenizer, allowing for you to simply say:

    -- bold and italic
    { pattern = { "%*%*%*%S", "%*%*%*" },   type = "keyword2", hints = { bold = true, italic = true } },
    { pattern = { "%*%*%S", "%*%*" },       type = "keyword2", hints = { bold = true } },
    -- handle edge case where asterisk can be at end of line and not close
    { pattern = { "%f[\\%*]%*[%S]", "%*%f[^%*]" }, 
                                            type = "keyword2", hints = { italic = true } },
    -- alternative bold italic formats
    { pattern = "^___[%s%p%w]+___" ,        type = "keyword2", hints = { bold = true, italic = true } },
    { pattern = "^__[%s%p%w]+__" ,          type = "keyword2", hints = { bold = true } },
    { pattern = "^_[%s%p%w]+_" ,            type = "keyword2", hints = { italic = true }  },

Which is then uptaken into the new tokenization system with virtual lines, and just properly spits out the right stuff.

Jan200101 and others added 30 commits September 3, 2025 16:26
… it between plugin and main, and we should use the command system if possible.

Streamlined language.

Unified predicates.

Fixed up some minor issues.

Readded this menu bind.

Ensured that context menu command works even without x and y.

Cleaned up treeview rework, and incoporated Guldo's comments.
Beginning moving of stuff to multi-window.

Fixed a number of bugs.

Need to do contextmenu rework first.

Fixes.

Solidified command structure.

Changing most stuff over to root_view.
Fixed some issue.

Cleaned up older multi-window stuff.

Passed window to keymap.

Fix a few things.

Treeview changes.

Fixed autocomplete and window restoration.

Fixed nag_view.

Removed all instances of core references to views.
Bumps the github-actions group with 2 updates: [actions/checkout](https://github.com/actions/checkout) and [actions/download-artifact](https://github.com/actions/download-artifact).

Updates `actions/checkout` from 4 to 5
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v4...v5)

Updates `actions/download-artifact` from 4 to 5
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](actions/download-artifact@v4...v5)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: actions/download-artifact
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Used a more correct function.

Virtual lines begins.

Initial commit of virtual lines PR.

Making it so that linewrapping also works.

Things proceed apace.

We proceed apace.

Fixed many things.

Fixed a number of bugs.

Standardizing naming conventions.

Fixed issue with resolving screen position on multi-lines.

Added in read-only mode.

Fixed selections.

Gloriously beautiful.

Uncommented modified selcetions.

Rearranged things to be more abstracted.

Fixed line length issue.

Rearchitected token storage.

Fixed invalidations.

Hooked up highlighter to syntax highlighting.

Added in rqeuest to tokenize extra lines.

Reduced size.

Bumped modversion.

Fixed issue with cache not resizing appropriately.

Changed over resolve_screen_position to new system.

Mixed up order of parameters.

Small little bug fixes.

Ensure we don't wrap over.

Removed dev statement.

More small fixes.

Fixed some codefolding and autocomplete issues.

Fixed up plugins that still use doc.

Made sure we only fold the right code.

Added in compatibility function.

Simplified functions.

Fixed some minor references to selections and inserts.

Added in safety guard for tokenize.

Fixed a few small things.

Removed unecessarily large amount of cache invalidation.

Fixed some minor bugs with linewrapping.

Slight bug fix.

Fixed reference to docview.

Added in keybinds for codefolding, and fixed some issues.

Fixed slightl typo.

Fixed some minor issues with highlighter.

Ensured that we fully clear out cache if mandated.

Updated autocomplete to work with docview.

Fixed bug.

Always treat lines as empty instead of nil.

Fixed block and line comment.

Changed over project search to also use docview.

Fixed redo stack.

Fixed commandview issue.

Added in utility function to make things easier.

Fixed small issue with invalidation of blocks in the middle of the cache.

Fixed overwrite.

Major rework of virtual lines.

Updating.

Fixed tokens not quite slotting into the vline cache.

Further updated virtual lines to improve a lot of things.

Properly annotate preivous tokens ending in newlines.

Made it so codefolding doesn't pay attention to comments or strings, and folds generally better.

Updated projectsearch to be compatible with virtual lines.

Made it so that when we close the fold, we break it.

Tightened things up.

Fixed dirmonitor.

Convert to the virtual line in question.

Fixed trimwhitespace to accomodate new virtual lines architecture.

Added in cache for get_vselections, as it's a constnatly called function. I don't like it, but performance if you have the cursor later in the line is pretty bad otherwise.

Ensured that the cache had the intra being paid attention to.

Added in extra check, and ifdef patterns.

fixed up lua a lil bit.

Fixed a folding issue.

Cleaned up vcache shrinking.

Requires a tostring, as autocomplete passes an object with a metatable that overrides __tostring; and relies on this to work with fuzzy match.

Fixed minor translation issue.

Allowed for auto-folding of long lines.

Added in some comments.

Added in resumption which was omitted, and also don't force syntaxful line to be correct until we actually tokenize.

Sped up tokenizer with utf8 patterns.

Allowed for a visible flag to be passed to token retrieval.

Added visible flag.

Added visible flag.

Fixed small issue with utf8 continuation bytes.

Removed overly aggressive cache invalidation in codefolding.

Fixing up UTF8 problems.

Added in visible parameter, and fixed some very long find stuff.

Fixed up off-by-one-error.

Deferred invlaidate_cache until after a tokenize.

Invalidate cache should be deferred during a token retrieval.

Flush deferred invalidations upon retrieve token.
The plugin loading system from lite-xl#1881 was designed to allow for negative priority plugins, however the regex was not modified accordingly.

This fixes that deficiency.
This fixes display issues when the display scaling factor is not 1.0 on
Linux Wayland.
…ew uses will be uses, which can lead to odd behaviour.
A mouse wheel event has a float value to indicate the "speed". This
value is passed to Lua as an integer. In the case of very low mouse
wheel sensitivities, the speed value can be below 1, which got converted
to zero for the lua side. This effectively disabled the mouse wheel.

The problem does not exist with X11 because the mouse wheel speed is an
integer - at least as provided by SDL3.

The fix is to pass the float value to Lua instead.
The bug was: when screen scaling was different from 1, the window size
would not be restored properly after closing and reopening. It would be
scaled by the screen scaling factor.

The fix is to make f_renwin_set_size take physical pixels as input
instead of scaled ones.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants