Skip to main content
View on YouTube to comment and like!

Syntax Video

This Font Has Built-in Syntax Highlighting

Chapter 1 00:00

Transcript

syntax highlighting sucks and if you've ever tried to implement it on your own website you know that it's a giant pain sometimes to get going there's JavaScript there's CSS there's all the different languages you have to support but all of that could be going away with this incredible new technique I saw this tweet from Adam argal today about no pain syntax highlighting using a font and variable fonts this is incredible now I'm going to link this Post in the description of this video but hakey linin has figured out something truly incredible here leveraging open type features they were able to build syntax highlighting built into a font and this thing is wild you're going to want to read this entire blog post because it's a trip but basically they're able to take advantage of something called open type color and contextual Alternatives

inside of a font to be able to color a font and there are some caveats here but again you don't have to use JavaScript you don't have to use CSS and not only that it actually takes care of some of the weird things that we weren't able to do with syntax highlighting before and many of you know that if you've done syntax highlighting it's wrapping your text in a bunch of HTML elements applying classes and then applying color with this we don't have that you just have straight up text and that's so cool because then you you can do syntax highlighting inside of things like inputs and text areas those were completely impossible before because instead you had a whole bunch of markup to get your syntax highlighting I think this is one of the most wild techniques that I've seen and to be honest I'm so incredibly excited about this now what about the cons why might you want not want to use this well as you can see

here making modifications to the syntax highlighter like changing a color palette adding more language support and changing the look of the font requires modifying the font file now if somebody's really dedicated to getting this up and working you could make a tool online to potentially uh create a new font automatically program those types of things but like they mention here they used glyphs to modify the font and it only works on Mac and cost €300 that's not to say that you couldn't develop something uh to make this easier but you know right now uh just have having a font with syntax highlighting is pretty much what you're going to get and having it be tuned into your theme and all that stuff might be something for the future another it only works where open type is supported now all major browsers do support this but other applications like they mentioned PowerPoint right uh does not support open type hey but hey I'm using this for websites so that doesn't really that

doesn't matter to me personally but it might to you but lastly there's kind of some weird things like JavaScript keywords inside of bra brackets and tags like that will be highlighted uh you can't highlight comment blocks or strings between quotes those types of things but again no JavaScript or HTML modifications or css to get this working I I mean you got to weigh your Alternatives here so they go deep into how this is accomplished including all the different letter and character variations all of the different ways but not only that how the open type color attributes actually work and in depth about what exactly is going on here so I think you should take your time and read through this blog post give this a look but let me know what you think about this technique is this something you would use is this incredible or is this incredibly lame what do you think me personally I'm stoked about this I can't imagine where this is going to go but I think this is potentially the start of something really interesting so leave

your comments down below let me know what you think and I'll see you in the next one

Quote it with credit and a link. Quoting Syntax