Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Win32 GUIで)Typographic Featuresを指定したい #1382

Open
Bakudankun opened this issue Nov 30, 2021 · 0 comments
Open

(Win32 GUIで)Typographic Featuresを指定したい #1382

Bakudankun opened this issue Nov 30, 2021 · 0 comments

Comments

@Bakudankun
Copy link

内容

Cascadia CodeFira Code など、いくつかのプログラミングフォントは対応するエディタで Font Features を指定することでいくつかの字形を変えることができます。

gVimも対応していただけると嬉しいです。Win32 GUIでDirectWrite有効な状態(set rop=type:directxのとき)なら実現可能だろうと思います。

Pros 良くなる点

フォントに用意されているより好みの字形を選んで使うことができます。

実現方法

とりあえず下のようにすることで、 ss19 を指定して例えばCascadia Codeではドットゼロの代わりにスラッシュゼロを表示することができましたがわしにできるのはここまでじゃ

diff --git a/src/gui_dwrite.cpp b/src/gui_dwrite.cpp
index 83acdab1a..80c34cebf 100644
--- a/src/gui_dwrite.cpp
+++ b/src/gui_dwrite.cpp
@@ -1033,6 +1033,19 @@ DWriteContext::DrawText(const WCHAR *text, int len,
 	textLayout->SetFontWeight(mFontWeight, textRange);
 	textLayout->SetFontStyle(mFontStyle, textRange);
 
+	IDWriteTypography *typography;
+	hr = mDWriteFactory->CreateTypography(&typography);
+	if (SUCCEEDED(hr))
+	{
+	    DWRITE_FONT_FEATURE fontFeature = {
+		DWRITE_MAKE_FONT_FEATURE_TAG('s', 's', '1', '9'),
+		1
+	    };
+	    typography->AddFontFeature(fontFeature);
+	    textLayout->SetTypography(typography, textRange);
+	    SafeRelease(&typography);
+	}
+
 	TextRenderer renderer(this);
 	TextRendererContext context = { color, FLOAT(cellWidth), 0.0f };
 	textLayout->Draw(&context, &renderer, FLOAT(x), FLOAT(y));

Vimのバージョン

8.2.3640

OSの種類/ディストリ/バージョン

  • Windows 10 Pro 64bit (10.0.19043)

その他

オプション guifontfxxxx のようなオプションを並べて指定できるようにすると良いかと思います。
例:set guifont=Cascadia\ Code:fcalt:fss01:fss19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants