Rethink of Ligature 再思连字 #240
Replies: 3 comments 5 replies
-
Note 文章中所有的内容都是基于我个人非专业的实践经验,可能存在不准确的地方,欢迎留言并指正 背景连字是一个 OpenType 特性,它可以制定基于上下文的规则来对字符进行替换,还可以让用户自行启用或关闭部分特性(如 为什么要做这个字体我最开始接触到的连字字体,是著名的 再后来,我接触到了其他的连字字体,比如 V5 和 V6在 现状和思考在 于是,自然而然地,一个问题出现了:如何提供一个自定义能力更强的连字方案,让其他人无需直接修改字体,通过配置的方式自行编译一个属于自己的字体?目前我的一个想法:将通用的字形作为默认,将所有的个性化字形作为开关选项,供使用者启用关闭,或者通过脚本/网站编译,设置为固定开启 特性开关的选择特性开关可以是 Character Variants( 浏览器中构建由于浏览器良好的跨平台兼容性和便携性,越来越多人希望在浏览器中完成一切事情。在去年的时候,我发现了 |
Beta Was this translation helpful? Give feedback.
-
连字作为一种上下文无关的特性,在代码中确实容易出现不协调的情况。 |
Beta Was this translation helpful? Give feedback.
-
话说 连体字 什么时候打算支持 比如 == != 之类的🤗 |
Beta Was this translation helpful? Give feedback.
-
Note
All the content in the article is based on my personal non-professional practical experience, and there may be inaccuracies. Please feel free to leave comments and corrections.
中文版本
Background
Ligature is an OpenType feature that allows for context-based rules to replace characters and enables users to selectively enable or disable certain features (such as
cv01
orss01
). It possesses powerful capabilities that can greatly enhance the reading experience of code. Ligatures were also one of the main driving forces behind the creation of this font.Why Create This Font
The first ligature font I encountered was the well-known
Fira Code
. At that time, I had just started learning programming and had been using the defaultConsolas
font. The discovery ofFira Code
added a touch of novelty to my dry learning process of the C language. Seeing the final code afterAC
gave me a sense of accomplishment, especially when I noticed that people who is failed to solve the problem around me were still using sans-serif fonts. However, I have to admit that as a beginner, using fonts with significant changes like==
/!=
posed a bit of a learning curve, often causing confusion.Later on, I came across other ligature fonts such as
Jetbrains Mono
,Iosevka
,Victor Mono
, andCascadia Code
. My perspective continued to broaden, but at the same time, I was not completely satisfied with some of the glyph shapes. This dissatisfaction led me to the idea of creating my own font.Versions 5 and 6
In
Maple Mono
versions 5 and 6, the ligature rules were modified by me based on thefea
script code parsed fromFira Code Retina
in Font Creator. At that time, as I was just starting out with font development, I could only imitate the process. In the end, I managed to cobble together a font that was passable, and I posted it on v2ex.com . To my surprise and gratitude, it received enthusiastic support and feedback from the community, gaining over 1,000 stars in three days. Encouraged by this response, I quickly addressed the reported issues by releasing a fixed version and subsequently several optimized versions.Current Situation and Thoughts
In
Maple Mono
version 7, I made modifications to theJetbrains Mono
variable font source files to suit my personal preferences. I utilized the powerful font tool library @ftCLI for optimization. In terms of ligatures, a significant portion was directly reused with adjustments made for many edge cases. Due to a disruptive standardization of the ligature rules in version 6.2, I took a more conservative approach in the current version 7 Beta, sticking to the previous method: using all ligatures that align with my personal preferences by default, and using feature toggles to disable glyphs that may confuse others.As a result, a new question emerged: how can I provide a more customizable ligature solution that allows others to compile their own fonts without directly modifying them, through configuration options? One idea I have is: using common glyphs as defaults and making all personalized glyphs available as toggle options for users to enable or disable, or provide a fixed toggle setting through scripts/websites.
Selection of Ligature Features
Ligature features can be in the form of Character Variants (
cv01
-cv99
) or Stylistic Sets (ss01
-ss20
), totaling 119. Functionally, there is no difference between the two, only a distinction in naming conventions for different types of features. However, for the sake of backward compatibility, fonts likeFira Code
andJetbrains Mono
did not adhere to this convention. Currently,Maple Mono
's ligatures also do not entirely comply with this convention, so reconsideration will be needed when restructuring the feature toggles.Compile in Browser
Due to the browser's excellent cross-platform compatibility and convenience, more and more people prefer to complete tasks within the browser. Last year, I discovered
Commit Mono
, which allows for browser-based font compilation using theopentype.js
library. However, after developing and compiling with this library, I found that the resulting file size exceeded that generated usingfonttools
inPython
by more than twice. Due to my limited resources, I chose not to delve deeper into this area after trying other popular JavaScript libraries likefonteditor-core
andfontkit
. If you are keen on compiling in the browser, I recommend using fontfreeze, a tool that usesPyodide
to convertPython
code toWASM
for frontend use. However, please note that it cannot compileMaple Mono NF
.Beta Was this translation helpful? Give feedback.
All reactions