... | ... | @@ -11,7 +11,8 @@ Using fonts with ligatures support adds extra beauty to your syntax highlighted |
|
|
|
|
|
- [About Font Ligatures](#about-font-ligatures)
|
|
|
- [Using Ligatures With Highlight](#using-ligatures-with-highlight)
|
|
|
- [Font Supporting Ligatures](#font-supporting-ligatures)
|
|
|
- [The Ligature Fonts Plugin](#the-ligature-fonts-plugin)
|
|
|
- [List of Fonts Supporting Ligatures](#list-of-fonts-supporting-ligatures)
|
|
|
|
|
|
<!-- /MarkdownTOC -->
|
|
|
|
... | ... | @@ -32,8 +33,39 @@ Here's an animated screenshot showing an Elixir code example being highlighted i |
|
|
|
|
|
All that was required to enable ligatures in the GUI was to select a font that supports them (in the above example, [Fira Code]). Since the font settings in Highlight GUI are carried over to the converted HTML document, ligatures will also be available in the output document.
|
|
|
|
|
|
## The Ligature Fonts Plugin
|
|
|
|
|
|
# Font Supporting Ligatures
|
|
|
Since v3.45, Highlight ships with a plugin to enable font ligatures in HTML/XHTML output:
|
|
|
|
|
|
- [`plugins/outhtml_ligature_fonts.lua`][outhtml_ligature_fonts.lua]
|
|
|
|
|
|
The plugin injects in the final document various font families that support ligatures:
|
|
|
|
|
|
```lua
|
|
|
--[[
|
|
|
Adds ligature fonts
|
|
|
]]
|
|
|
|
|
|
Description="Adds ligature fonts in HTML output"
|
|
|
|
|
|
function themeUpdate()
|
|
|
|
|
|
if (HL_OUTPUT == HL_FORMAT_HTML or HL_OUTPUT == HL_FORMAT_XHTML) then
|
|
|
Injections[#Injections+1]="pre.hl, ol.hl { font-family: Monoid,\"Fira Code\",\"DejaVu Sans Code\",monospace;}"
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
Plugins={
|
|
|
|
|
|
{ Type="theme", Chunk=themeUpdate }
|
|
|
|
|
|
}
|
|
|
```
|
|
|
|
|
|
So, you'll still have to install on your system the required fonts to enable ligatures support in monospaced fonts ([Monoid], [Fira Code] and/or [DejaVu Sans Code]).
|
|
|
|
|
|
# List of Fonts Supporting Ligatures
|
|
|
|
|
|
Here's a list of free and open source monospaced code fonts that support ligatures:
|
|
|
|
... | ... | @@ -57,6 +89,9 @@ So, you should always test your source code against various ligatures fonts befo |
|
|
|
|
|
[screenshot Ligatures]: Ligatures-Example-Elixir.gif "Screenshot of Elixir code in Highlight GUI with and without ligatures"
|
|
|
|
|
|
|
|
|
[outhtml_ligature_fonts.lua]: https://gitlab.com/saalen/highlight/blob/master/plugins/outhtml_ligature_fonts.lua "View source of 'outhtml_ligature_fonts.lua' plugin"
|
|
|
|
|
|
<!-- fonts links -->
|
|
|
|
|
|
[Fira Code]: https://github.com/tonsky/FiraCode
|
... | ... | |