Condensed and expanded fonts with SCI_STYLESETSTRETCH

24 views
Skip to first unread message

Neil Hodgson

unread,
Aug 15, 2024, 8:21:02 AMAug 15
to Scintilla mailing list
SCI_STYLESETSTRETCH has been added to Scintilla to allow choosing condensed and expanded fonts. Available from current Scintilla repository.

This can be used to show more text or use a narrower space by condensing text to as little as half of its normal width. Text can also be expanded horizontally to as much as twice the normal width for clarity.

It is similar to the font-stretch property in Cascading Style Sheets which specifies 9 values from Ultra-Condensed (1) through Normal (5) to Ultra-Expanded (9). The extreme values are likely too strong for many uses with Condensed (3) 75% and Expanded (7) 125% more reasonable values.

Most fonts do not support different stretch values and those that do may only support a couple of values. However, the Inconsolata font supports all 9 values so is useful for experimenting. The 'variable-font' version of Inconsolata uses a single file to provide all these stretch values on Win32, macOS and Linux.

Platform implementations differ in capabilities. The current implementation for Cocoa (macOS) uses a simplified API that only handles 3 possibilities with Normal as a base and any value less than normal condensing the font and any greater value expanding the font. There is a more complex Cocoa API that uses a floating point stretch value that may be implemented later.

Some APIs provide a null or don't-care value as well but its unclear if this can be supported with portable semantics.

Attaching an image with several examples with different platforms. In front is DirectWrite on Win32 with GTK+ on Linux underneath and with Qt on Win32 to the right (3 stretches: condensed for keywords, normal for identifiers, and expanded for string literals). For once, Linux font rendering looks better to me than DirectWrite.

SciTE adds a 'stretch' style attribute that uses SCI_STYLESETSTRETCH.

Neil
FontStretch.png
Reply all
Reply to author
Forward
0 new messages