annotate src/gui_dwrite.cpp @ 12952:7fd105bfe992 v8.0.1352

patch 8.0.1352: dead URLs in the help go unnoticed commit https://github.com/vim/vim/commit/f38c86eb6b665d9fcd3d232820a48198eccac376 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Nov 28 14:19:07 2017 +0100 patch 8.0.1352: dead URLs in the help go unnoticed Problem: Dead URLs in the help go unnoticed. Solution: Add a script to check URLs in the help files. (Christian Brabandt)
author Christian Brabandt <cb@256bit.org>
date Tue, 28 Nov 2017 14:30:05 +0100
parents 2ebc3df65ca2
children 18e6f4addce9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4 noet: */
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
2 /*
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
3 * Author: MURAOKA Taro <koron.kaoriya@gmail.com>
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
4 *
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
5 * Contributors:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
6 * - Ken Takata
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
7 * - Yasuhiro Matsumoto
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
8 *
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
9 * Copyright (C) 2013 MURAOKA Taro <koron.kaoriya@gmail.com>
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
10 * THIS FILE IS DISTRIBUTED UNDER THE VIM LICENSE.
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
11 */
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
12
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
13 #define WIN32_LEAN_AND_MEAN
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
14
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
15 #ifndef DYNAMIC_DIRECTX
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
16 # if WINVER < 0x0600
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
17 # error WINVER must be 0x0600 or above to use DirectWrite(DirectX)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
18 # endif
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
19 #endif
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
20
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
21 #include <windows.h>
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
22 #include <crtdbg.h>
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
23 #include <assert.h>
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
24 #include <math.h>
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
25 #include <d2d1.h>
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
26 #include <d2d1helper.h>
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
27
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
28 // Disable these macros to compile with old VC and newer SDK (V8.1 or later).
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
29 #if defined(_MSC_VER) && (_MSC_VER < 1700)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
30 # define _COM_Outptr_ __out
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
31 # define _In_reads_(s)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
32 # define _In_reads_opt_(s)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
33 # define _Maybenull_
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
34 # define _Out_writes_(s)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
35 # define _Out_writes_opt_(s)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
36 # define _Out_writes_to_(x, y)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
37 # define _Out_writes_to_opt_(x, y)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
38 # define _Outptr_
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
39 #endif
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
40
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
41 #include <dwrite_2.h>
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
42
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
43 #include "gui_dwrite.h"
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
44
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
45 #ifdef __MINGW32__
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
46 # define __maybenull SAL__maybenull
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
47 # define __in SAL__in
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
48 # define __out SAL__out
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
49 #endif
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
50
8641
0af716a4f5d2 commit https://github.com/vim/vim/commit/cc6cf9b9f9045a7d8b5923ea0c556e9a4c2567d3
Christian Brabandt <cb@256bit.org>
parents: 8271
diff changeset
51 #if (defined(_MSC_VER) && (_MSC_VER >= 1700)) || (__cplusplus >= 201103L)
0af716a4f5d2 commit https://github.com/vim/vim/commit/cc6cf9b9f9045a7d8b5923ea0c556e9a4c2567d3
Christian Brabandt <cb@256bit.org>
parents: 8271
diff changeset
52 # define FINAL final
0af716a4f5d2 commit https://github.com/vim/vim/commit/cc6cf9b9f9045a7d8b5923ea0c556e9a4c2567d3
Christian Brabandt <cb@256bit.org>
parents: 8271
diff changeset
53 #else
0af716a4f5d2 commit https://github.com/vim/vim/commit/cc6cf9b9f9045a7d8b5923ea0c556e9a4c2567d3
Christian Brabandt <cb@256bit.org>
parents: 8271
diff changeset
54 # define FINAL
0af716a4f5d2 commit https://github.com/vim/vim/commit/cc6cf9b9f9045a7d8b5923ea0c556e9a4c2567d3
Christian Brabandt <cb@256bit.org>
parents: 8271
diff changeset
55 #endif
0af716a4f5d2 commit https://github.com/vim/vim/commit/cc6cf9b9f9045a7d8b5923ea0c556e9a4c2567d3
Christian Brabandt <cb@256bit.org>
parents: 8271
diff changeset
56
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
57 #ifdef DYNAMIC_DIRECTX
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
58 extern "C" HINSTANCE vimLoadLib(char *name);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
59
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
60 typedef int (WINAPI *PGETUSERDEFAULTLOCALENAME)(LPWSTR, int);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
61 typedef HRESULT (WINAPI *PD2D1CREATEFACTORY)(D2D1_FACTORY_TYPE,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
62 REFIID, const D2D1_FACTORY_OPTIONS *, void **);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
63 typedef HRESULT (WINAPI *PDWRITECREATEFACTORY)(DWRITE_FACTORY_TYPE,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
64 REFIID, IUnknown **);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
65
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
66 static HINSTANCE hD2D1DLL = NULL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
67 static HINSTANCE hDWriteDLL = NULL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
68
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
69 static PGETUSERDEFAULTLOCALENAME pGetUserDefaultLocaleName = NULL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
70 static PD2D1CREATEFACTORY pD2D1CreateFactory = NULL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
71 static PDWRITECREATEFACTORY pDWriteCreateFactory = NULL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
72
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
73 #define GetUserDefaultLocaleName (*pGetUserDefaultLocaleName)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
74 #define D2D1CreateFactory (*pD2D1CreateFactory)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
75 #define DWriteCreateFactory (*pDWriteCreateFactory)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
76
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
77 static void
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
78 unload(HINSTANCE &hinst)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
79 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
80 if (hinst != NULL)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
81 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
82 FreeLibrary(hinst);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
83 hinst = NULL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
84 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
85 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
86 #endif // DYNAMIC_DIRECTX
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
87
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
88 template <class T> inline void SafeRelease(T **ppT)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
89 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
90 if (*ppT)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
91 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
92 (*ppT)->Release();
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
93 *ppT = NULL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
94 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
95 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
96
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
97 static DWRITE_PIXEL_GEOMETRY
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
98 ToPixelGeometry(int value)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
99 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
100 switch (value)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
101 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
102 default:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
103 case 0:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
104 return DWRITE_PIXEL_GEOMETRY_FLAT;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
105 case 1:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
106 return DWRITE_PIXEL_GEOMETRY_RGB;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
107 case 2:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
108 return DWRITE_PIXEL_GEOMETRY_BGR;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
109 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
110 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
111
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
112 static int
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
113 ToInt(DWRITE_PIXEL_GEOMETRY value)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
114 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
115 switch (value)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
116 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
117 case DWRITE_PIXEL_GEOMETRY_FLAT:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
118 return 0;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
119 case DWRITE_PIXEL_GEOMETRY_RGB:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
120 return 1;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
121 case DWRITE_PIXEL_GEOMETRY_BGR:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
122 return 2;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
123 default:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
124 return -1;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
125 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
126 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
127
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
128 static DWRITE_RENDERING_MODE
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
129 ToRenderingMode(int value)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
130 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
131 switch (value)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
132 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
133 default:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
134 case 0:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
135 return DWRITE_RENDERING_MODE_DEFAULT;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
136 case 1:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
137 return DWRITE_RENDERING_MODE_ALIASED;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
138 case 2:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
139 return DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
140 case 3:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
141 return DWRITE_RENDERING_MODE_CLEARTYPE_GDI_NATURAL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
142 case 4:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
143 return DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
144 case 5:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
145 return DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
146 case 6:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
147 return DWRITE_RENDERING_MODE_OUTLINE;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
148 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
149 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
150
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
151 static D2D1_TEXT_ANTIALIAS_MODE
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
152 ToTextAntialiasMode(int value)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
153 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
154 switch (value)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
155 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
156 default:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
157 case 0:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
158 return D2D1_TEXT_ANTIALIAS_MODE_DEFAULT;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
159 case 1:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
160 return D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
161 case 2:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
162 return D2D1_TEXT_ANTIALIAS_MODE_GRAYSCALE;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
163 case 3:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
164 return D2D1_TEXT_ANTIALIAS_MODE_ALIASED;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
165 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
166 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
167
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
168 static int
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
169 ToInt(DWRITE_RENDERING_MODE value)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
170 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
171 switch (value)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
172 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
173 case DWRITE_RENDERING_MODE_DEFAULT:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
174 return 0;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
175 case DWRITE_RENDERING_MODE_ALIASED:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
176 return 1;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
177 case DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
178 return 2;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
179 case DWRITE_RENDERING_MODE_CLEARTYPE_GDI_NATURAL:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
180 return 3;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
181 case DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
182 return 4;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
183 case DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
184 return 5;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
185 case DWRITE_RENDERING_MODE_OUTLINE:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
186 return 6;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
187 default:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
188 return -1;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
189 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
190 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
191
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
192 class FontCache {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
193 public:
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
194 struct Item {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
195 HFONT hFont;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
196 IDWriteTextFormat* pTextFormat;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
197 DWRITE_FONT_WEIGHT fontWeight;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
198 DWRITE_FONT_STYLE fontStyle;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
199 Item() : hFont(NULL), pTextFormat(NULL) {}
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
200 };
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
201
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
202 private:
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
203 int mSize;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
204 Item *mItems;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
205
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
206 public:
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
207 FontCache(int size = 2) :
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
208 mSize(size),
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
209 mItems(new Item[size])
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
210 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
211 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
212
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
213 ~FontCache()
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
214 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
215 for (int i = 0; i < mSize; ++i)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
216 SafeRelease(&mItems[i].pTextFormat);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
217 delete[] mItems;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
218 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
219
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
220 bool get(HFONT hFont, Item &item)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
221 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
222 int n = find(hFont);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
223 if (n < 0)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
224 return false;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
225 item = mItems[n];
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
226 slide(n);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
227 return true;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
228 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
229
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
230 void put(const Item& item)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
231 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
232 int n = find(item.hFont);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
233 if (n < 0)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
234 n = mSize - 1;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
235 if (mItems[n].pTextFormat != item.pTextFormat)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
236 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
237 SafeRelease(&mItems[n].pTextFormat);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
238 item.pTextFormat->AddRef();
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
239 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
240 mItems[n] = item;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
241 slide(n);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
242 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
243
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
244 private:
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
245 int find(HFONT hFont)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
246 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
247 for (int i = 0; i < mSize; ++i)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
248 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
249 if (mItems[i].hFont == hFont)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
250 return i;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
251 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
252 return -1;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
253 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
254
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
255 void slide(int nextTop)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
256 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
257 if (nextTop == 0)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
258 return;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
259 Item tmp = mItems[nextTop];
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
260 for (int i = nextTop - 1; i >= 0; --i)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
261 mItems[i + 1] = mItems[i];
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
262 mItems[0] = tmp;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
263 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
264 };
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
265
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
266 struct DWriteContext {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
267 HDC mHDC;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
268 bool mDrawing;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
269 bool mFallbackDC;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
270
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
271 ID2D1Factory *mD2D1Factory;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
272
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
273 ID2D1DCRenderTarget *mRT;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
274 ID2D1SolidColorBrush *mBrush;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
275
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
276 IDWriteFactory *mDWriteFactory;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
277 IDWriteFactory2 *mDWriteFactory2;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
278
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
279 IDWriteGdiInterop *mGdiInterop;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
280 IDWriteRenderingParams *mRenderingParams;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
281
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
282 FontCache mFontCache;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
283 IDWriteTextFormat *mTextFormat;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
284 DWRITE_FONT_WEIGHT mFontWeight;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
285 DWRITE_FONT_STYLE mFontStyle;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
286
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
287 D2D1_TEXT_ANTIALIAS_MODE mTextAntialiasMode;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
288
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
289 // METHODS
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
290
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
291 DWriteContext();
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
292
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
293 virtual ~DWriteContext();
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
294
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
295 HRESULT CreateTextFormatFromLOGFONT(const LOGFONTW &logFont,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
296 IDWriteTextFormat **ppTextFormat);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
297
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
298 HRESULT SetFontByLOGFONT(const LOGFONTW &logFont);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
299
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
300 void SetFont(HFONT hFont);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
301
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
302 void BindDC(HDC hdc, RECT *rect);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
303
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
304 void AssureDrawing();
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
305
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
306 ID2D1Brush* SolidBrush(COLORREF color);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
307
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
308 void DrawText(const WCHAR* text, int len,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
309 int x, int y, int w, int h, int cellWidth, COLORREF color,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
310 UINT fuOptions, CONST RECT *lprc, CONST INT * lpDx);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
311
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
312 void FillRect(RECT *rc, COLORREF color);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
313
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
314 void Flush();
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
315
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
316 void SetRenderingParams(
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
317 const DWriteRenderingParams *params);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
318
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
319 DWriteRenderingParams *GetRenderingParams(
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
320 DWriteRenderingParams *params);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
321 };
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
322
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
323 class AdjustedGlyphRun : public DWRITE_GLYPH_RUN
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
324 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
325 private:
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
326 FLOAT &mAccum;
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
327 FLOAT mDelta;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
328 FLOAT *mAdjustedAdvances;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
329
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
330 public:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
331 AdjustedGlyphRun(
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
332 const DWRITE_GLYPH_RUN *glyphRun,
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
333 FLOAT cellWidth,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
334 FLOAT &accum) :
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
335 DWRITE_GLYPH_RUN(*glyphRun),
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
336 mAccum(accum),
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
337 mDelta(0.0f),
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
338 mAdjustedAdvances(new FLOAT[glyphRun->glyphCount])
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
339 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
340 assert(cellWidth != 0.0f);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
341 for (UINT32 i = 0; i < glyphRun->glyphCount; ++i)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
342 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
343 FLOAT orig = glyphRun->glyphAdvances[i];
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
344 FLOAT adjusted = adjustToCell(orig, cellWidth);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
345 mAdjustedAdvances[i] = adjusted;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
346 mDelta += adjusted - orig;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
347 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
348 glyphAdvances = mAdjustedAdvances;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
349 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
350
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
351 ~AdjustedGlyphRun()
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
352 {
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
353 mAccum += mDelta;
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
354 delete[] mAdjustedAdvances;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
355 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
356
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
357 static FLOAT adjustToCell(FLOAT value, FLOAT cellWidth)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
358 {
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
359 int cellCount = int(floor(value / cellWidth + 0.5f));
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
360 if (cellCount < 1)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
361 cellCount = 1;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
362 return cellCount * cellWidth;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
363 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
364 };
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
365
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
366 struct TextRendererContext {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
367 // const fields.
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
368 COLORREF color;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
369 FLOAT cellWidth;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
370
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
371 // working fields.
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
372 FLOAT offsetX;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
373 };
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
374
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
375 class TextRenderer FINAL : public IDWriteTextRenderer
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
376 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
377 public:
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
378 TextRenderer(
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
379 DWriteContext* pDWC) :
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
380 cRefCount_(0),
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
381 pDWC_(pDWC)
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
382 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
383 AddRef();
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
384 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
385
8271
770774e66011 commit https://github.com/vim/vim/commit/edb4f2b3601b0abd47091606269c0ac3244a805b
Christian Brabandt <cb@256bit.org>
parents: 7547
diff changeset
386 // add "virtual" to avoid a compiler warning
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
387 virtual ~TextRenderer()
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
388 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
389 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
390
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
391 IFACEMETHOD(IsPixelSnappingDisabled)(
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
392 __maybenull void* clientDrawingContext,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
393 __out BOOL* isDisabled)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
394 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
395 *isDisabled = FALSE;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
396 return S_OK;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
397 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
398
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
399 IFACEMETHOD(GetCurrentTransform)(
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
400 __maybenull void* clientDrawingContext,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
401 __out DWRITE_MATRIX* transform)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
402 {
8271
770774e66011 commit https://github.com/vim/vim/commit/edb4f2b3601b0abd47091606269c0ac3244a805b
Christian Brabandt <cb@256bit.org>
parents: 7547
diff changeset
403 // forward the render target's transform
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
404 pDWC_->mRT->GetTransform(
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
405 reinterpret_cast<D2D1_MATRIX_3X2_F*>(transform));
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
406 return S_OK;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
407 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
408
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
409 IFACEMETHOD(GetPixelsPerDip)(
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
410 __maybenull void* clientDrawingContext,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
411 __out FLOAT* pixelsPerDip)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
412 {
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
413 float dpiX, unused;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
414 pDWC_->mRT->GetDpi(&dpiX, &unused);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
415 *pixelsPerDip = dpiX / 96.0f;
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
416 return S_OK;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
417 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
418
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
419 IFACEMETHOD(DrawUnderline)(
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
420 __maybenull void* clientDrawingContext,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
421 FLOAT baselineOriginX,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
422 FLOAT baselineOriginY,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
423 __in DWRITE_UNDERLINE const* underline,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
424 IUnknown* clientDrawingEffect)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
425 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
426 return E_NOTIMPL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
427 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
428
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
429 IFACEMETHOD(DrawStrikethrough)(
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
430 __maybenull void* clientDrawingContext,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
431 FLOAT baselineOriginX,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
432 FLOAT baselineOriginY,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
433 __in DWRITE_STRIKETHROUGH const* strikethrough,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
434 IUnknown* clientDrawingEffect)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
435 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
436 return E_NOTIMPL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
437 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
438
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
439 IFACEMETHOD(DrawInlineObject)(
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
440 __maybenull void* clientDrawingContext,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
441 FLOAT originX,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
442 FLOAT originY,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
443 IDWriteInlineObject* inlineObject,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
444 BOOL isSideways,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
445 BOOL isRightToLeft,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
446 IUnknown* clientDrawingEffect)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
447 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
448 return E_NOTIMPL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
449 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
450
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
451 IFACEMETHOD(DrawGlyphRun)(
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
452 __maybenull void* clientDrawingContext,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
453 FLOAT baselineOriginX,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
454 FLOAT baselineOriginY,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
455 DWRITE_MEASURING_MODE measuringMode,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
456 __in DWRITE_GLYPH_RUN const* glyphRun,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
457 __in DWRITE_GLYPH_RUN_DESCRIPTION const* glyphRunDescription,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
458 IUnknown* clientDrawingEffect)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
459 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
460 TextRendererContext *context =
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
461 reinterpret_cast<TextRendererContext*>(clientDrawingContext);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
462
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
463 AdjustedGlyphRun adjustedGlyphRun(glyphRun, context->cellWidth,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
464 context->offsetX);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
465
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
466 if (pDWC_->mDWriteFactory2 != NULL)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
467 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
468 IDWriteColorGlyphRunEnumerator *enumerator = NULL;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
469 HRESULT hr = pDWC_->mDWriteFactory2->TranslateColorGlyphRun(
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
470 baselineOriginX + context->offsetX,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
471 baselineOriginY,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
472 &adjustedGlyphRun,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
473 NULL,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
474 DWRITE_MEASURING_MODE_GDI_NATURAL,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
475 NULL,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
476 0,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
477 &enumerator);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
478 if (SUCCEEDED(hr))
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
479 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
480 // Draw by IDWriteFactory2 for color emoji
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
481 BOOL hasRun = TRUE;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
482 enumerator->MoveNext(&hasRun);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
483 while (hasRun)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
484 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
485 const DWRITE_COLOR_GLYPH_RUN* colorGlyphRun;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
486 enumerator->GetCurrentRun(&colorGlyphRun);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
487
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
488 pDWC_->mBrush->SetColor(colorGlyphRun->runColor);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
489 pDWC_->mRT->DrawGlyphRun(
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
490 D2D1::Point2F(
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
491 colorGlyphRun->baselineOriginX,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
492 colorGlyphRun->baselineOriginY),
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
493 &colorGlyphRun->glyphRun,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
494 pDWC_->mBrush,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
495 DWRITE_MEASURING_MODE_NATURAL);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
496 enumerator->MoveNext(&hasRun);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
497 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
498 SafeRelease(&enumerator);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
499 return S_OK;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
500 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
501 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
502
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
503 // Draw by IDWriteFactory (without color emoji)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
504 pDWC_->mRT->DrawGlyphRun(
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
505 D2D1::Point2F(
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
506 baselineOriginX + context->offsetX,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
507 baselineOriginY),
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
508 &adjustedGlyphRun,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
509 pDWC_->SolidBrush(context->color),
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
510 DWRITE_MEASURING_MODE_NATURAL);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
511 return S_OK;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
512 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
513
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
514 public:
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
515 IFACEMETHOD_(unsigned long, AddRef) ()
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
516 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
517 return InterlockedIncrement(&cRefCount_);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
518 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
519
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
520 IFACEMETHOD_(unsigned long, Release) ()
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
521 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
522 long newCount = InterlockedDecrement(&cRefCount_);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
523
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
524 if (newCount == 0)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
525 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
526 delete this;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
527 return 0;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
528 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
529 return newCount;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
530 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
531
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
532 IFACEMETHOD(QueryInterface)(
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
533 IID const& riid,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
534 void** ppvObject)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
535 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
536 if (__uuidof(IDWriteTextRenderer) == riid)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
537 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
538 *ppvObject = this;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
539 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
540 else if (__uuidof(IDWritePixelSnapping) == riid)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
541 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
542 *ppvObject = this;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
543 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
544 else if (__uuidof(IUnknown) == riid)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
545 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
546 *ppvObject = this;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
547 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
548 else
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
549 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
550 *ppvObject = NULL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
551 return E_FAIL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
552 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
553
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
554 return S_OK;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
555 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
556
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
557 private:
6120
f62b2e76dd80 updated for version 7.4.398
Bram Moolenaar <bram@vim.org>
parents: 6110
diff changeset
558 long cRefCount_;
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
559 DWriteContext* pDWC_;
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
560 };
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
561
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
562 DWriteContext::DWriteContext() :
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
563 mHDC(NULL),
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
564 mDrawing(false),
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
565 mFallbackDC(false),
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
566 mD2D1Factory(NULL),
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
567 mRT(NULL),
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
568 mBrush(NULL),
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
569 mDWriteFactory(NULL),
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
570 mDWriteFactory2(NULL),
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
571 mGdiInterop(NULL),
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
572 mRenderingParams(NULL),
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
573 mFontCache(8),
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
574 mTextFormat(NULL),
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
575 mFontWeight(DWRITE_FONT_WEIGHT_NORMAL),
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
576 mFontStyle(DWRITE_FONT_STYLE_NORMAL),
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
577 mTextAntialiasMode(D2D1_TEXT_ANTIALIAS_MODE_DEFAULT)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
578 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
579 HRESULT hr;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
580
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
581 hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
582 __uuidof(ID2D1Factory), NULL,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
583 reinterpret_cast<void**>(&mD2D1Factory));
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
584 _RPT2(_CRT_WARN, "D2D1CreateFactory: hr=%p p=%p\n", hr, mD2D1Factory);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
585
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
586 if (SUCCEEDED(hr))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
587 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
588 D2D1_RENDER_TARGET_PROPERTIES props = {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
589 D2D1_RENDER_TARGET_TYPE_DEFAULT,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
590 { DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_IGNORE },
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
591 0, 0,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
592 D2D1_RENDER_TARGET_USAGE_NONE,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
593 D2D1_FEATURE_LEVEL_DEFAULT
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
594 };
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
595 hr = mD2D1Factory->CreateDCRenderTarget(&props, &mRT);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
596 _RPT2(_CRT_WARN, "CreateDCRenderTarget: hr=%p p=%p\n", hr, mRT);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
597 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
598
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
599 if (SUCCEEDED(hr))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
600 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
601 hr = mRT->CreateSolidColorBrush(
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
602 D2D1::ColorF(D2D1::ColorF::Black),
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
603 &mBrush);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
604 _RPT2(_CRT_WARN, "CreateSolidColorBrush: hr=%p p=%p\n", hr, mBrush);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
605 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
606
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
607 if (SUCCEEDED(hr))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
608 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
609 hr = DWriteCreateFactory(
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
610 DWRITE_FACTORY_TYPE_SHARED,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
611 __uuidof(IDWriteFactory),
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
612 reinterpret_cast<IUnknown**>(&mDWriteFactory));
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
613 _RPT2(_CRT_WARN, "DWriteCreateFactory: hr=%p p=%p\n", hr,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
614 mDWriteFactory);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
615 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
616
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
617 if (SUCCEEDED(hr))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
618 {
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
619 DWriteCreateFactory(
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
620 DWRITE_FACTORY_TYPE_SHARED,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
621 __uuidof(IDWriteFactory2),
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
622 reinterpret_cast<IUnknown**>(&mDWriteFactory2));
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
623 _RPT1(_CRT_WARN, "IDWriteFactory2: %s\n", SUCCEEDED(hr) ? "available" : "not available");
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
624 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
625
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
626 if (SUCCEEDED(hr))
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
627 {
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
628 hr = mDWriteFactory->GetGdiInterop(&mGdiInterop);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
629 _RPT2(_CRT_WARN, "GetGdiInterop: hr=%p p=%p\n", hr, mGdiInterop);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
630 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
631
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
632 if (SUCCEEDED(hr))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
633 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
634 hr = mDWriteFactory->CreateRenderingParams(&mRenderingParams);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
635 _RPT2(_CRT_WARN, "CreateRenderingParams: hr=%p p=%p\n", hr,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
636 mRenderingParams);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
637 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
638 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
639
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
640 DWriteContext::~DWriteContext()
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
641 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
642 SafeRelease(&mTextFormat);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
643 SafeRelease(&mRenderingParams);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
644 SafeRelease(&mGdiInterop);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
645 SafeRelease(&mDWriteFactory);
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
646 SafeRelease(&mDWriteFactory2);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
647 SafeRelease(&mBrush);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
648 SafeRelease(&mRT);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
649 SafeRelease(&mD2D1Factory);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
650 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
651
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
652 HRESULT
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
653 DWriteContext::CreateTextFormatFromLOGFONT(const LOGFONTW &logFont,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
654 IDWriteTextFormat **ppTextFormat)
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
655 {
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
656 // Most of this function is copied from: https://github.com/Microsoft/Windows-classic-samples/blob/master/Samples/Win7Samples/multimedia/DirectWrite/RenderTest/TextHelpers.cpp
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
657 HRESULT hr = S_OK;
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
658 IDWriteTextFormat *pTextFormat = NULL;
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
659
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
660 IDWriteFont *font = NULL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
661 IDWriteFontFamily *fontFamily = NULL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
662 IDWriteLocalizedStrings *localizedFamilyNames = NULL;
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
663 float fontSize = 0;
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
664
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
665 if (SUCCEEDED(hr))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
666 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
667 hr = mGdiInterop->CreateFontFromLOGFONT(&logFont, &font);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
668 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
669
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
670 // Get the font family to which this font belongs.
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
671 if (SUCCEEDED(hr))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
672 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
673 hr = font->GetFontFamily(&fontFamily);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
674 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
675
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
676 // Get the family names. This returns an object that encapsulates one or
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
677 // more names with the same meaning but in different languages.
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
678 if (SUCCEEDED(hr))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
679 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
680 hr = fontFamily->GetFamilyNames(&localizedFamilyNames);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
681 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
682
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
683 // Get the family name at index zero. If we were going to display the name
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
684 // we'd want to try to find one that matched the use locale, but for
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
685 // purposes of creating a text format object any language will do.
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
686
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
687 wchar_t familyName[100];
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
688 if (SUCCEEDED(hr))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
689 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
690 hr = localizedFamilyNames->GetString(0, familyName,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
691 ARRAYSIZE(familyName));
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
692 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
693
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
694 if (SUCCEEDED(hr))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
695 {
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
696 // Use lfHeight of the LOGFONT as font size.
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
697 fontSize = float(logFont.lfHeight);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
698
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
699 if (fontSize < 0)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
700 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
701 // Negative lfHeight represents the size of the em unit.
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
702 fontSize = -fontSize;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
703 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
704 else
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
705 {
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
706 // Positive lfHeight represents the cell height (ascent +
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
707 // descent).
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
708 DWRITE_FONT_METRICS fontMetrics;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
709 font->GetMetrics(&fontMetrics);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
710
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
711 // Convert the cell height (ascent + descent) from design units
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
712 // to ems.
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
713 float cellHeight = static_cast<float>(
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
714 fontMetrics.ascent + fontMetrics.descent)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
715 / fontMetrics.designUnitsPerEm;
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
716
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
717 // Divide the font size by the cell height to get the font em
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
718 // size.
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
719 fontSize /= cellHeight;
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
720 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
721 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
722
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
723 // The text format includes a locale name. Ideally, this would be the
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
724 // language of the text, which may or may not be the same as the primary
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
725 // language of the user. However, for our purposes the user locale will do.
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
726 wchar_t localeName[LOCALE_NAME_MAX_LENGTH];
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
727 if (SUCCEEDED(hr))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
728 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
729 if (GetUserDefaultLocaleName(localeName, LOCALE_NAME_MAX_LENGTH) == 0)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
730 hr = HRESULT_FROM_WIN32(GetLastError());
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
731 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
732
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
733 if (SUCCEEDED(hr))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
734 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
735 // Create the text format object.
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
736 hr = mDWriteFactory->CreateTextFormat(
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
737 familyName,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
738 NULL, // no custom font collection
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
739 font->GetWeight(),
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
740 font->GetStyle(),
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
741 font->GetStretch(),
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
742 fontSize,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
743 localeName,
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
744 &pTextFormat);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
745 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
746
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
747 if (SUCCEEDED(hr))
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
748 hr = pTextFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_LEADING);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
749
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
750 if (SUCCEEDED(hr))
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
751 hr = pTextFormat->SetParagraphAlignment(
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
752 DWRITE_PARAGRAPH_ALIGNMENT_CENTER);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
753
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
754 if (SUCCEEDED(hr))
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
755 hr = pTextFormat->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
756
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
757 SafeRelease(&localizedFamilyNames);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
758 SafeRelease(&fontFamily);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
759 SafeRelease(&font);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
760
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
761 if (SUCCEEDED(hr))
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
762 *ppTextFormat = pTextFormat;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
763 else
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
764 SafeRelease(&pTextFormat);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
765
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
766 return hr;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
767 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
768
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
769 HRESULT
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
770 DWriteContext::SetFontByLOGFONT(const LOGFONTW &logFont)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
771 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
772 HRESULT hr = S_OK;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
773 IDWriteTextFormat *pTextFormat = NULL;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
774
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
775 hr = CreateTextFormatFromLOGFONT(logFont, &pTextFormat);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
776
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
777 if (SUCCEEDED(hr))
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
778 {
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
779 SafeRelease(&mTextFormat);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
780 mTextFormat = pTextFormat;
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
781 mFontWeight = static_cast<DWRITE_FONT_WEIGHT>(logFont.lfWeight);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
782 mFontStyle = logFont.lfItalic ? DWRITE_FONT_STYLE_ITALIC
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
783 : DWRITE_FONT_STYLE_NORMAL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
784 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
785
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
786 return hr;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
787 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
788
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
789 void
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
790 DWriteContext::SetFont(HFONT hFont)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
791 {
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
792 FontCache::Item item;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
793 if (mFontCache.get(hFont, item))
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
794 {
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
795 if (item.pTextFormat != NULL)
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
796 {
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
797 item.pTextFormat->AddRef();
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
798 SafeRelease(&mTextFormat);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
799 mTextFormat = item.pTextFormat;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
800 mFontWeight = item.fontWeight;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
801 mFontStyle = item.fontStyle;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
802 mFallbackDC = false;
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
803 }
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
804 else
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
805 mFallbackDC = true;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
806 return;
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
807 }
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
808
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
809 HRESULT hr = E_FAIL;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
810 LOGFONTW lf;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
811 if (GetObjectW(hFont, sizeof(lf), &lf))
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
812 hr = SetFontByLOGFONT(lf);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
813
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
814 item.hFont = hFont;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
815 if (SUCCEEDED(hr))
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
816 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
817 item.pTextFormat = mTextFormat;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
818 item.fontWeight = mFontWeight;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
819 item.fontStyle = mFontStyle;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
820 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
821 mFontCache.put(item);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
822 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
823
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
824 void
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
825 DWriteContext::BindDC(HDC hdc, RECT *rect)
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
826 {
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
827 Flush();
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
828 mRT->BindDC(hdc, rect);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
829 mRT->SetTransform(D2D1::IdentityMatrix());
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
830 mHDC = hdc;
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
831 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
832
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
833 void
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
834 DWriteContext::AssureDrawing()
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
835 {
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
836 if (mDrawing == false)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
837 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
838 mRT->BeginDraw();
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
839 mDrawing = true;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
840 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
841 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
842
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
843 ID2D1Brush*
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
844 DWriteContext::SolidBrush(COLORREF color)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
845 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
846 mBrush->SetColor(D2D1::ColorF(UINT32(GetRValue(color)) << 16 |
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
847 UINT32(GetGValue(color)) << 8 | UINT32(GetBValue(color))));
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
848 return mBrush;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
849 }
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
850
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
851 void
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
852 DWriteContext::DrawText(const WCHAR* text, int len,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
853 int x, int y, int w, int h, int cellWidth, COLORREF color,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
854 UINT fuOptions, CONST RECT *lprc, CONST INT * lpDx)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
855 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
856 if (mFallbackDC)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
857 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
858 Flush();
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
859 ExtTextOutW(mHDC, x, y, fuOptions, lprc, text, len, lpDx);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
860 return;
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
861 }
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
862
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
863 AssureDrawing();
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
864
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
865 HRESULT hr;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
866 IDWriteTextLayout *textLayout = NULL;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
867
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
868 hr = mDWriteFactory->CreateTextLayout(text, len, mTextFormat,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
869 FLOAT(w), FLOAT(h), &textLayout);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
870
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
871 if (SUCCEEDED(hr))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
872 {
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
873 DWRITE_TEXT_RANGE textRange = { 0, UINT32(len) };
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
874 textLayout->SetFontWeight(mFontWeight, textRange);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
875 textLayout->SetFontStyle(mFontStyle, textRange);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
876
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
877 TextRenderer renderer(this);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
878 TextRendererContext context = { color, FLOAT(cellWidth), 0.0f };
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
879 textLayout->Draw(&context, &renderer, FLOAT(x), FLOAT(y));
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
880 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
881
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
882 SafeRelease(&textLayout);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
883 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
884
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
885 void
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
886 DWriteContext::FillRect(RECT *rc, COLORREF color)
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
887 {
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
888 AssureDrawing();
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
889 mRT->FillRectangle(
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
890 D2D1::RectF(FLOAT(rc->left), FLOAT(rc->top),
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
891 FLOAT(rc->right), FLOAT(rc->bottom)),
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
892 SolidBrush(color));
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
893 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
894
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
895 void
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
896 DWriteContext::Flush()
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
897 {
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
898 if (mDrawing)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
899 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
900 mRT->EndDraw();
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
901 mDrawing = false;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
902 }
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
903 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
904
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
905 void
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
906 DWriteContext::SetRenderingParams(
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
907 const DWriteRenderingParams *params)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
908 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
909 if (mDWriteFactory == NULL)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
910 return;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
911
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
912 IDWriteRenderingParams *renderingParams = NULL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
913 D2D1_TEXT_ANTIALIAS_MODE textAntialiasMode =
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
914 D2D1_TEXT_ANTIALIAS_MODE_DEFAULT;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
915 HRESULT hr;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
916 if (params != NULL)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
917 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
918 hr = mDWriteFactory->CreateCustomRenderingParams(params->gamma,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
919 params->enhancedContrast, params->clearTypeLevel,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
920 ToPixelGeometry(params->pixelGeometry),
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
921 ToRenderingMode(params->renderingMode), &renderingParams);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
922 textAntialiasMode = ToTextAntialiasMode(params->textAntialiasMode);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
923 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
924 else
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
925 hr = mDWriteFactory->CreateRenderingParams(&renderingParams);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
926 if (SUCCEEDED(hr) && renderingParams != NULL)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
927 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
928 SafeRelease(&mRenderingParams);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
929 mRenderingParams = renderingParams;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
930 mTextAntialiasMode = textAntialiasMode;
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
931
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
932 Flush();
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
933 mRT->SetTextRenderingParams(mRenderingParams);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
934 mRT->SetTextAntialiasMode(mTextAntialiasMode);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
935 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
936 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
937
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
938 DWriteRenderingParams *
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
939 DWriteContext::GetRenderingParams(
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
940 DWriteRenderingParams *params)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
941 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
942 if (params != NULL && mRenderingParams != NULL)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
943 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
944 params->gamma = mRenderingParams->GetGamma();
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
945 params->enhancedContrast = mRenderingParams->GetEnhancedContrast();
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
946 params->clearTypeLevel = mRenderingParams->GetClearTypeLevel();
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
947 params->pixelGeometry = ToInt(mRenderingParams->GetPixelGeometry());
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
948 params->renderingMode = ToInt(mRenderingParams->GetRenderingMode());
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
949 params->textAntialiasMode = mTextAntialiasMode;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
950 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
951 return params;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
952 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
953
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
954 ////////////////////////////////////////////////////////////////////////////
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
955 // PUBLIC C INTERFACES
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
956
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
957 void
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
958 DWrite_Init(void)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
959 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
960 #ifdef DYNAMIC_DIRECTX
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
961 // Load libraries.
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
962 hD2D1DLL = vimLoadLib(const_cast<char*>("d2d1.dll"));
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
963 hDWriteDLL = vimLoadLib(const_cast<char*>("dwrite.dll"));
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
964 if (hD2D1DLL == NULL || hDWriteDLL == NULL)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
965 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
966 DWrite_Final();
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
967 return;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
968 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
969 // Get address of procedures.
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
970 pGetUserDefaultLocaleName = (PGETUSERDEFAULTLOCALENAME)GetProcAddress(
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
971 GetModuleHandle("kernel32.dll"), "GetUserDefaultLocaleName");
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
972 pD2D1CreateFactory = (PD2D1CREATEFACTORY)GetProcAddress(hD2D1DLL,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
973 "D2D1CreateFactory");
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
974 pDWriteCreateFactory = (PDWRITECREATEFACTORY)GetProcAddress(hDWriteDLL,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
975 "DWriteCreateFactory");
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
976 #endif
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
977 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
978
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
979 void
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
980 DWrite_Final(void)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
981 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
982 #ifdef DYNAMIC_DIRECTX
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
983 pGetUserDefaultLocaleName = NULL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
984 pD2D1CreateFactory = NULL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
985 pDWriteCreateFactory = NULL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
986 unload(hDWriteDLL);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
987 unload(hD2D1DLL);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
988 #endif
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
989 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
990
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
991 DWriteContext *
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
992 DWriteContext_Open(void)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
993 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
994 #ifdef DYNAMIC_DIRECTX
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
995 if (pGetUserDefaultLocaleName == NULL || pD2D1CreateFactory == NULL
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
996 || pDWriteCreateFactory == NULL)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
997 return NULL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
998 #endif
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
999 return new DWriteContext();
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1000 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1001
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1002 void
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1003 DWriteContext_BindDC(DWriteContext *ctx, HDC hdc, RECT *rect)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1004 {
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1005 if (ctx != NULL)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1006 ctx->BindDC(hdc, rect);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1007 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1008
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1009 void
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1010 DWriteContext_SetFont(DWriteContext *ctx, HFONT hFont)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1011 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1012 if (ctx != NULL)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1013 ctx->SetFont(hFont);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1014 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1015
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1016 void
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1017 DWriteContext_DrawText(
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1018 DWriteContext *ctx,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1019 const WCHAR* text,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1020 int len,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1021 int x,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1022 int y,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1023 int w,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1024 int h,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1025 int cellWidth,
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1026 COLORREF color,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1027 UINT fuOptions,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1028 CONST RECT *lprc,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1029 CONST INT * lpDx)
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1030 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1031 if (ctx != NULL)
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1032 ctx->DrawText(text, len, x, y, w, h, cellWidth, color,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1033 fuOptions, lprc, lpDx);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1034 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1035
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1036 void
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1037 DWriteContext_FillRect(DWriteContext *ctx, RECT *rc, COLORREF color)
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1038 {
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1039 if (ctx != NULL)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1040 ctx->FillRect(rc, color);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1041 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1042
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1043 void
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1044 DWriteContext_Flush(DWriteContext *ctx)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1045 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1046 if (ctx != NULL)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 8641
diff changeset
1047 ctx->Flush();
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1048 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1049
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1050 void
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1051 DWriteContext_Close(DWriteContext *ctx)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1052 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1053 delete ctx;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1054 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1055
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1056 void
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1057 DWriteContext_SetRenderingParams(
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1058 DWriteContext *ctx,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1059 const DWriteRenderingParams *params)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1060 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1061 if (ctx != NULL)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1062 ctx->SetRenderingParams(params);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1063 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1064
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1065 DWriteRenderingParams *
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1066 DWriteContext_GetRenderingParams(
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1067 DWriteContext *ctx,
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1068 DWriteRenderingParams *params)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1069 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1070 if (ctx != NULL)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1071 return ctx->GetRenderingParams(params);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1072 else
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1073 return NULL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents:
diff changeset
1074 }