糊了一个font features的支持

第一次这么深入地看Emacs的font跟face的实现,真是太好玩了

font-feature

11 个赞

有了这个之后连字是不是不再需要特殊设置了?有没有希望进 Emacs core?

ligature和font feature相关,但不一样

ligature在5年前加harfbuzz支持的时候有一波讨论,现在还是要set-char-table-range

font features是字体特性开关,你注意看0!==的显示效果。例如jetbrains mono提供了这些features。我之后会试试提patch,这个要改c的部分,不进core是没法用的

Prettify Symbols mode is a buffer-local minor mode that replaces certain strings with more attractive versions for display purposes. For example, in Emacs Lisp mode, it replaces the string ‘lambda’ with the Greek lambda character ‘λ’. In a TeX buffer, it will replace ‘\alpha’ … ‘\omega’ and other math macros with their Unicode characters. You may wish to use this in non-programming modes as well. You can customize the mode by adding more entries to ‘prettify-symbols-alist’. More elaborate customization is available via customizing ‘prettify-symbols-compose-predicate’ if its default value ‘prettify-symbols-default-compose-p’ is not appropriate. There is also a global version, ‘global-prettify-symbols-mode’, which enables the mode in all buffers that support it.

(info “(emacs) Misc for Programs”)

Right, pretty symbol mode is actually replacing the codepoints in the buffer, which is not ideal. The real ligature support is via harfbuzz. It generates the true glyph without changing the codepoints and send to cairo for rendering. You can enable it by using ligature.el

Eli觉得设了face之后不应该要另外设置composition table

如果做得出来的话连字就不用特别设置了,但是Emacs这个很旧的display engine可能比较难hack,因为它有一个很强的假设:一个codepoint对应一个glyph

1 个赞

这个有没有后续

后续就是我写的版本要配合composition-function-table一起用,但是Eli觉得既然设了face attribute就应该能自动配置连字,方向是在xdisp.c里绕开composition table

工作比较忙也没太多时间啃这个大部头

1 个赞