|
1 |
| -// Copyright (c) Microsoft Corporation. |
| 1 | +// Copyright (c) Microsoft Corporation. |
2 | 2 | // Licensed under the MIT license.
|
3 | 3 |
|
4 | 4 | #include "Main.h"
|
@@ -221,90 +221,21 @@ HRESULT STDMETHODCALLTYPE TextRenderer::DrawGlyphRun(
|
221 | 221 | {
|
222 | 222 | try
|
223 | 223 | {
|
224 |
| - OrientationTransform orentation( |
| 224 | + OrientationTransform orientation( |
225 | 225 | this,
|
226 | 226 | orientationAngle,
|
227 | 227 | !!glyphRun->isSideways,
|
228 | 228 | D2D_POINT_2F{ baselineOriginX, baselineOriginY }
|
229 | 229 | );
|
230 | 230 |
|
231 |
| - HRESULT hr = DWRITE_E_NOCOLOR; |
232 |
| - wil::com_ptr<IDWriteColorGlyphRunEnumerator> colorLayers; |
233 |
| - |
234 |
| - wil::com_ptr<IDWriteFontFace2> fontFace2; |
235 |
| - if (SUCCEEDED(glyphRun->fontFace->QueryInterface(&fontFace2))) |
236 |
| - { |
237 |
| - uint32_t paletteCount = fontFace2->GetColorPaletteCount(); |
238 |
| - if (paletteCount > 0) |
239 |
| - { |
240 |
| - DWRITE_MATRIX transform; |
241 |
| - hr = m_renderTarget->GetCurrentTransform(&transform); |
242 |
| - if (FAILED(hr)) |
243 |
| - { |
244 |
| - return hr; |
245 |
| - } |
246 |
| - |
247 |
| - transform.m11 *= m_dpiScale; |
248 |
| - transform.m12 *= m_dpiScale; |
249 |
| - transform.m21 *= m_dpiScale; |
250 |
| - transform.m22 *= m_dpiScale; |
251 |
| - transform.dx *= m_dpiScale; |
252 |
| - transform.dy *= m_dpiScale; |
253 |
| - |
254 |
| - // Perform color translation. |
255 |
| - // Fall back to the default palette if the current palette index is out of range. |
256 |
| - hr = g_factory->TranslateColorGlyphRun( |
257 |
| - baselineOriginX, |
258 |
| - baselineOriginY, |
259 |
| - glyphRun, |
260 |
| - nullptr, |
261 |
| - measuringMode, |
262 |
| - &transform, |
263 |
| - m_colorPaletteIndex < paletteCount ? m_colorPaletteIndex : 0, |
264 |
| - & colorLayers |
265 |
| - ); |
266 |
| - } |
267 |
| - } |
268 |
| - |
269 |
| - if (hr == DWRITE_E_NOCOLOR) |
270 |
| - { |
271 |
| - THROW_IF_FAILED(m_renderTarget->DrawGlyphRun( |
272 |
| - baselineOriginX, |
273 |
| - baselineOriginY, |
274 |
| - measuringMode, |
275 |
| - glyphRun, |
276 |
| - m_renderingParams.get(), |
277 |
| - m_textColor |
278 |
| - )); |
279 |
| - } |
280 |
| - else |
281 |
| - { |
282 |
| - THROW_IF_FAILED(hr); |
283 |
| - |
284 |
| - for (;;) |
285 |
| - { |
286 |
| - BOOL haveRun; |
287 |
| - THROW_IF_FAILED(colorLayers->MoveNext(&haveRun)); |
288 |
| - if (!haveRun) |
289 |
| - { |
290 |
| - break; |
291 |
| - } |
292 |
| - |
293 |
| - DWRITE_COLOR_GLYPH_RUN const* colorRun; |
294 |
| - THROW_IF_FAILED(colorLayers->GetCurrentRun(&colorRun)); |
295 |
| - |
296 |
| - COLORREF runColor = (colorRun->paletteIndex == 0xFFFF) ? m_textColor : ToCOLORREF(colorRun->runColor); |
297 |
| - |
298 |
| - THROW_IF_FAILED(m_renderTarget->DrawGlyphRun( |
299 |
| - colorRun->baselineOriginX, |
300 |
| - colorRun->baselineOriginY, |
301 |
| - measuringMode, |
302 |
| - &colorRun->glyphRun, |
303 |
| - m_renderingParams.get(), |
304 |
| - runColor |
305 |
| - )); |
306 |
| - } |
307 |
| - } |
| 231 | + RETURN_IF_FAILED(m_renderTarget->DrawGlyphRunWithColorSupport( |
| 232 | + baselineOriginX, |
| 233 | + baselineOriginY, |
| 234 | + measuringMode, |
| 235 | + glyphRun, |
| 236 | + m_renderingParams.get(), |
| 237 | + m_textColor |
| 238 | + )); |
308 | 239 |
|
309 | 240 | return S_OK;
|
310 | 241 | }
|
|
0 commit comments