• R/O
  • SSH

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqt誰得cocoapythonrubywindowsphpgameguibathyscaphec翻訳omegatframework計画中(planning stage)twitterdombtronvb.nettestarduinodirectxpreviewerゲームエンジン

K.Takata's patch queue for Vim


Commit MetaInfo

Revision460b270e52de335e07ab7579c6d0bee8d62ed343 (tree)
Zeit2022-01-21 14:50:15
AutorK.Takata <kentkt@csc....>
CommiterK.Takata

Log Message

Update ambiwidth auto patch

Ändern Zusammenfassung

Diff

diff -r 5f72cd8869fe -r 460b270e52de series
--- a/series Fri Jan 21 11:01:20 2022 +0900
+++ b/series Fri Jan 21 14:50:15 2022 +0900
@@ -29,7 +29,7 @@
2929 add-testing-option-7970.patch
3030 wip-win32-vimdir-encoding.patch #+wip
3131 win32-fix-font.patch
32-wip-win32-directwrite-charwidth-auto.patch #+wip
3332 win32-remove-casts.patch
3433 win32-use-unicode-message-api.patch
34+wip-win32-directwrite-ambiwidth-auto.patch #+wip
3535 fix-config_cache-removal.patch #+rejected
diff -r 5f72cd8869fe -r 460b270e52de wip-win32-directwrite-ambiwidth-auto.patch
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/wip-win32-directwrite-ambiwidth-auto.patch Fri Jan 21 14:50:15 2022 +0900
@@ -0,0 +1,146 @@
1+# HG changeset patch
2+# Parent 653be08b1f6a0e52b52b70ae5a0239d5a7d3f796
3+
4+diff --git a/src/gui_dwrite.cpp b/src/gui_dwrite.cpp
5+--- a/src/gui_dwrite.cpp
6++++ b/src/gui_dwrite.cpp
7+@@ -343,6 +343,8 @@ struct DWriteContext {
8+
9+ void Flush();
10+
11++ int GetCharWidth(int c);
12++
13+ void SetRenderingParams(
14+ const DWriteRenderingParams *params);
15+
16+@@ -1155,6 +1157,60 @@ DWriteContext::Flush()
17+ SetDrawingMode(DM_GDI);
18+ }
19+
20++ int
21++DWriteContext::GetCharWidth(int c)
22++{
23++ HRESULT hr;
24++ IDWriteTextLayout *textLayout = NULL;
25++ WCHAR text[3];
26++ int len, w = 0;
27++
28++ //SetDrawingMode(DM_DIRECTX);
29++
30++ if (c < 0x10000)
31++ {
32++ text[0] = (WCHAR)c;
33++ len = 1;
34++ }
35++ else
36++ {
37++ text[0] = ((c - 0x10000) >> 10) + 0xD800;
38++ text[1] = ((c - 0x10000) & 0x3ff) + 0xDC00;
39++ len = 2;
40++ }
41++ text[len] = L'\0';
42++
43++ hr = mDWriteFactory->CreateTextLayout(text, len, mTextFormat,
44++ 10.0f, 10.0f, &textLayout);
45++
46++ if (SUCCEEDED(hr))
47++ {
48++ DWRITE_TEXT_RANGE textRange = { 0, UINT32(len) };
49++ textLayout->SetFontWeight(mFontWeight, textRange);
50++ textLayout->SetFontStyle(mFontStyle, textRange);
51++
52++ UINT32 count;
53++ if (textLayout->GetClusterMetrics(NULL, 0, &count) == E_NOT_SUFFICIENT_BUFFER)
54++ {
55++ DWRITE_CLUSTER_METRICS *metrics = new DWRITE_CLUSTER_METRICS[count];
56++ textLayout->GetClusterMetrics(metrics, count, &count);
57++#ifdef DEBUG
58++ //_RPT2(_CRT_WARN, "len %d, count %d", len, count);
59++ for (UINT32 i = 0; i < count; i++)
60++ {
61++ _RPT2(_CRT_WARN, "%x (%C), [%d]: width %f", c, c, i, metrics[i].width);
62++ }
63++#endif
64++ if (count >= 1)
65++ w = (int)metrics[0].width;
66++ delete [] metrics;
67++ }
68++ }
69++
70++ SafeRelease(&textLayout);
71++ return w;
72++}
73++
74+ void
75+ DWriteContext::SetRenderingParams(
76+ const DWriteRenderingParams *params)
77+@@ -1322,6 +1378,14 @@ DWriteContext_Flush(DWriteContext *ctx)
78+ ctx->Flush();
79+ }
80+
81++ int
82++DWriteContext_GetCharWidth(DWriteContext *ctx, int c)
83++{
84++ if (ctx != NULL)
85++ return ctx->GetCharWidth(c);
86++ return 0;
87++}
88++
89+ void
90+ DWriteContext_Close(DWriteContext *ctx)
91+ {
92+diff --git a/src/gui_dwrite.h b/src/gui_dwrite.h
93+--- a/src/gui_dwrite.h
94++++ b/src/gui_dwrite.h
95+@@ -76,6 +76,7 @@ void DWriteContext_DrawLine(DWriteContex
96+ void DWriteContext_SetPixel(DWriteContext *ctx, int x, int y, COLORREF color);
97+ void DWriteContext_Scroll(DWriteContext *ctx, int x, int y, const RECT *rc);
98+ void DWriteContext_Flush(DWriteContext *ctx);
99++int DWriteContext_GetCharWidth(DWriteContext *ctx, int c);
100+ void DWriteContext_Close(DWriteContext *ctx);
101+
102+ void DWriteContext_SetRenderingParams(
103+diff --git a/src/gui_w32.c b/src/gui_w32.c
104+--- a/src/gui_w32.c
105++++ b/src/gui_w32.c
106+@@ -5182,12 +5182,12 @@ error:
107+
108+ #ifdef USE_AMBIWIDTH_AUTO
109+ # define CHARWIDE_CACHESIZE 0x20000
110+-static GuiFont last_font = NOFONT;
111+
112+ int
113+ gui_mch_get_charwidth(int c)
114+ {
115+ static int cache[CHARWIDE_CACHESIZE];
116++ static GuiFont last_font = NOFONT;
117+ GuiFont usingfont = gui.wide_font ? gui.wide_font : gui.norm_font;
118+
119+ /* Check validity of charwide cache */
120+@@ -5205,6 +5205,17 @@ gui_mch_get_charwidth(int c)
121+ {
122+ if (cache[c] >= 0)
123+ return cache[c]; /* Use cached value */
124++# if defined(FEAT_DIRECTX)
125++ else if (IS_ENABLE_DIRECTX())
126++ {
127++ int len;
128++
129++ DWriteContext_SetFont(s_dwc, (HFONT)usingfont);
130++ len = DWriteContext_GetCharWidth(s_dwc, c);
131++ cache[c] = (len + (gui.char_width >> 1)) / gui.char_width;
132++ return cache[c];
133++ }
134++# endif
135+ else
136+ {
137+ /*
138+@@ -5222,7 +5233,7 @@ gui_mch_get_charwidth(int c)
139+ cache[c] = 0;
140+ }
141+ else
142+- cache[c] = ((len + (gui.char_width >> 1)) / gui.char_width);
143++ cache[c] = (len + (gui.char_width >> 1)) / gui.char_width;
144+ SelectFont(s_hdc, hfntOld);
145+
146+ return cache[c];
diff -r 5f72cd8869fe -r 460b270e52de wip-win32-directwrite-charwidth-auto.patch
--- a/wip-win32-directwrite-charwidth-auto.patch Fri Jan 21 11:01:20 2022 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
1-# HG changeset patch
2-# Parent f4ffd8b25aa8c9706ce3ac509cef4fdcb789440c
3-
4-diff --git a/src/gui_dwrite.cpp b/src/gui_dwrite.cpp
5---- a/src/gui_dwrite.cpp
6-+++ b/src/gui_dwrite.cpp
7-@@ -1033,6 +1033,19 @@ DWriteContext::DrawText(const WCHAR *tex
8- textLayout->SetFontWeight(mFontWeight, textRange);
9- textLayout->SetFontStyle(mFontStyle, textRange);
10-
11-+ UINT32 count;
12-+ if (textLayout->GetClusterMetrics(NULL, 0, &count) == E_NOT_SUFFICIENT_BUFFER)
13-+ {
14-+ _RPT2(_CRT_WARN, "len %d, count %d", len, count);
15-+ DWRITE_CLUSTER_METRICS *metrics = new DWRITE_CLUSTER_METRICS[count];
16-+ textLayout->GetClusterMetrics(metrics, count, &count);
17-+ for (UINT32 i = 0; i < count; i++)
18-+ {
19-+ _RPT2(_CRT_WARN, "[%d]: width %f, cellWidth %d", i, metrics[i].width, cellWidth);
20-+ }
21-+ delete [] metrics;
22-+ }
23-+
24- TextRenderer renderer(this);
25- TextRendererContext context = { color, FLOAT(cellWidth), 0.0f };
26- textLayout->Draw(&context, &renderer, FLOAT(x), FLOAT(y));