Re:Font with Built-In Syntax Highlighting
by penteract on Thursday August 15, 2024 @06:56AM
(#41254638)
I think the author has underestimated the power of the substitution rules - it looks like it should be possible to drag a state machine along, hence recognise any regular language.
Something like the following should handle quoted strings (untested and needs every character to be listed out in the definitions of @Char, @CharQuoted and @NonQuoteQuoted):
I don't know if context can be carried between different lines.
[ Parent
| on HN ]
Re:Font with Built-In Syntax Highlighting
by spease on Thursday August 15, 2024 @11:40AM
(#41257321)
How long until it runs Doom?
You may have already seen it (here on hn) but someone absolutely has made a game within a font: https://www.coderelay.io/fontemon.html
Re:Font with Built-In Syntax Highlighting
by california-og on Thursday August 15, 2024 @01:17PM
(#41258283)
That's genius, thank you!! I will have to try that tomorrow but I have a feeling it might just work : - )
Re:Font with Built-In Syntax Highlighting
by penteract on Thursday August 15, 2024 @02:42PM
(#41259124)
Here's a tested version that, given text containing only lower case letters, backslash and double quote, capitalizes the letters between quotes and handles escaping reasonably. (works with NotoSans-Regular.ttf)
@Char = [a-z quotedbl backslash];
@CharQuoted = [A-Z quotesingle slash];
@NonQuoteQuoted = [A-Z slash];
@Escaped = [asterisk dollar];
feature liga {
lookup xa {
sub quotedbl @Char' by @CharQuoted;
sub slash backslash' by dollar;
sub slash quotedbl' by asterisk;
sub [@NonQuoteQuoted asterisk dollar] @Char' by @CharQuoted;
} xa;
} liga;
feature liga {
lookup xb {
sub quotesingle' by quotedbl;
sub slash' by backslash;
sub dollar' by backslash;
sub asterisk' by quotedbl;
} xb;
} liga;
Re:Font with Built-In Syntax Highlighting
by ajudson on Thursday August 15, 2024 @03:19PM
(#41259429)
Do you know if there is a programmatic way to convert multi character to multi character without intermediate glyphs? E.G. snake -> snāk
Re:Font with Built-In Syntax Highlighting
by penteract on Thursday August 15, 2024 @03:56PM
(#41259762)
For that example, I think you could do
s n a' k e -> ā
s n ā k e' -> NULL
although that would also change "snāke" to "snāk", which is not quite what you asked for.I don't think there's a way to do many-to-many substitution in general, although it would always be possible if you create intermediate glyphs. I believe Section 5 of http://adobe-type-tools.github.io/afdko/OpenTypeFeatureFileS... gives the full list of substitution types.