So script inside web page is bad, but script inside font is good? That's interesting definition of bloat. I'd prefer ordinary webpage using locally installed fonts with explicit JavaScript snippet to highlight keywords.
Well someone else mentioned llama.ttf which is a font that embeds an llm, using Harfbuzz's WASM engine.
So, you could absolutely write a WASM Z80 emulator and embed it in a font. Whether or not you could make it do anything useful, or how strong your grip on reality would remain after? I don't know.
But it wasn't like you were doing anything else on the days between Christmas and New Year, right?
I view stuff like this kind of like code that fits into a bootloader or whatever. It’s really more of the technical challenge than to actually solve a problem. The result is much better if you just run a script on your hand-coded file to add syntax highlighting as DOM elements. Still, love seeing stuff like this.
Has anyone tried this with PowerPoint yet? Our org is very PowerPoint centric and always struggle a bit with the workflow for code.
Copy pasting from IntelliJ does give colours but none of the other niceties such as kerning or litigation. Screenshots are nice visually but a pain to maintain.
> It only works where OpenType is supported. Fortunately, that's all major browsers and most modern programs. However, something like PowerPoint doesn't support OpenType.
Yes, ligatures. No idea where “litigations” came from.
I think there is still some kerning going on where the individual letters are placed closer together and the entire word has the same width so more spacing in between words.
> Works in <textarea> and <input>! Syntax highlighting inside <textarea> has been previously impossible, because textareas and inputs can only contain plain text. This is where the interesting
Interesting indeed! This bit feels like a neat bit of hackery to keep in my back pocket for sure.
I have yet to see a good web based text editor with syntax highlighting. They all mess with the native search functionality of the browser. Because they can't just use a textarea for the edit area. With this approach, it would be possible.
I wonder how usable a Python version of this would be?
Contenteditable plus the CSS Custom Highlight API (which highlights ranges instead of elements) might indeed allow for a good solution. But I have not yet seen an editor that does that.
I have yet to see a good web based text editor with syntax highlighting.
I slightly expect you to pull a "no true Scotsman" here and suggest it's actually no good because it doesn't really support mobile browsers very well, but Microsoft's Monaco editor that's driven from VS Code is quite good. https://microsoft.github.io/monaco-editor/
It seems to have the same problems all of the web based editors I have seen have. Either they capture ctrl+f and take away the native search experience. Or they have a broken search experience. This one is in the latter category.
When I hit ctrl+f on that page and type "export":
First it says "1 of 4 matches" but nothing is highlighted.
When I hit enter, it says "2 of 4 matches" and again, nothing is highlighted.
When I hit enter again, it says "3 of 4 matches" and the first match is highlighted.
When I hit enter again, it says "4 of 4 matches" and the second match is highlighted.
This is a curious sort of hazy modern mirror image of the world of Sinclair computers, that embedded their BASIC parsing in the keyboard driver — that is to say, it essentially wasn't possible to type a syntactically incorrect BASIC program.
Then you need to curl the URL, pipe it to an .html file, and then search the resulting file for "@font-face". The only place that has the @font-face rule for this fancy font is inside <template> syntax, meaning it will do nothing (template content is inert) until JS clones that template into the DOM as active content.
Correct. The code editor that has the subscript: "The colors in the HTML snippet above comes from within the font itself, the code is plain text, and requires no JavaScript."
Which doesn't work without JS. So adding the @font-face to the page itself, so that things works even without JS, would be lovely.
vbezhenar | a day ago
benrutter | a day ago
I took it to be along the lines of an "easier to work with" type motivation, rather than reducing package sizes.
WesolyKubeczek | a day ago
zappchance | a day ago
https://fuglede.github.io/llama.ttf
blauditore | a day ago
Gracana | a day ago
https://github.com/nevesnunes/z80-sans
koct9i | a day ago
ErroneousBosh | a day ago
So, you could absolutely write a WASM Z80 emulator and embed it in a font. Whether or not you could make it do anything useful, or how strong your grip on reality would remain after? I don't know.
But it wasn't like you were doing anything else on the days between Christmas and New Year, right?
zX41ZdbW | a day ago
This is a blocker for my applications.
cyanmagenta | a day ago
michaelsshaw | a day ago
balou23 | 7 hours ago
[1] https://fuglede.github.io/llama.ttf/
spockz | a day ago
Copy pasting from IntelliJ does give colours but none of the other niceties such as kerning or litigation. Screenshots are nice visually but a pain to maintain.
Sayrus | a day ago
> It only works where OpenType is supported. Fortunately, that's all major browsers and most modern programs. However, something like PowerPoint doesn't support OpenType.
spockz | a day ago
layer8 | a day ago
Is kerning a thing for monospace fonts?
spockz | a day ago
I think there is still some kerning going on where the individual letters are placed closer together and the entire word has the same width so more spacing in between words.
mock-possum | a day ago
Interesting indeed! This bit feels like a neat bit of hackery to keep in my back pocket for sure.
cluckindan | a day ago
mg | a day ago
I have yet to see a good web based text editor with syntax highlighting. They all mess with the native search functionality of the browser. Because they can't just use a textarea for the edit area. With this approach, it would be possible.
I wonder how usable a Python version of this would be?
gethly | a day ago
mg | a day ago
hyperhello | a day ago
onion2k | a day ago
I slightly expect you to pull a "no true Scotsman" here and suggest it's actually no good because it doesn't really support mobile browsers very well, but Microsoft's Monaco editor that's driven from VS Code is quite good. https://microsoft.github.io/monaco-editor/
mg | a day ago
When I hit ctrl+f on that page and type "export":
First it says "1 of 4 matches" but nothing is highlighted.
When I hit enter, it says "2 of 4 matches" and again, nothing is highlighted.
When I hit enter again, it says "3 of 4 matches" and the first match is highlighted.
When I hit enter again, it says "4 of 4 matches" and the second match is highlighted.
exasperaited | a day ago
TheRealPomax | a day ago
But then why does the color disappear if I disallow scripts on this page? Instead of your font, now it uses Consolas.
Are you using JS to load the font in? (if so... web fonts don't need JS to load =)
[OP] california-og | a day ago
TheRealPomax | 21 hours ago
[OP] california-og | 20 hours ago
TheRealPomax | 19 hours ago
[OP] california-og | 18 hours ago
TheRealPomax | 18 hours ago
Which doesn't work without JS. So adding the @font-face to the page itself, so that things works even without JS, would be lovely.
[OP] california-og | 17 hours ago
eviks | 16 hours ago
The whole post proves the opposite is true!
jasonjmcghee | 15 hours ago
665 points | 137 comments
https://news.ycombinator.com/item?id=41245159