Skip to content
This repository was archived by the owner on Mar 30, 2019. It is now read-only.

Commit e388915

Browse files
authored
Merge pull request #1017 from mrvux/dwrite_colorfix
Try API for TranslateColorGlyphRun
2 parents 3ca7ebf + d3cd680 commit e388915

2 files changed

Lines changed: 89 additions & 1 deletion

File tree

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel
2+
//
3+
// Permission is hereby granted, free of charge, to any person obtaining a copy
4+
// of this software and associated documentation files (the "Software"), to deal
5+
// in the Software without restriction, including without limitation the rights
6+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
// copies of the Software, and to permit persons to whom the Software is
8+
// furnished to do so, subject to the following conditions:
9+
//
10+
// The above copyright notice and this permission notice shall be included in
11+
// all copies or substantial portions of the Software.
12+
//
13+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
// THE SOFTWARE.
20+
21+
using System;
22+
23+
namespace SharpDX.DirectWrite
24+
{
25+
/// <summary>
26+
/// <p>Creates a rendering parameters object with the specified properties.</p>
27+
/// </summary>
28+
/// <include file='..\Documentation\CodeComments.xml' path="/comments/comment[@id='IDWriteFactory1']/*"/>
29+
/// <msdn-id>Hh780402</msdn-id>
30+
/// <unmanaged>IDWriteFactory2</unmanaged>
31+
/// <unmanaged-short>IDWriteFactory2</unmanaged>
32+
public partial class Factory2
33+
{
34+
35+
/// <summary>
36+
/// <p>This method is called on a glyph run to translate it in to multiple color glyph runs.</p>
37+
/// </summary>
38+
/// <param name = "baselineOriginX"><dd> <p>The horizontal baseline origin of the original glyph run.</p> </dd></param>
39+
/// <param name = "baselineOriginY"><dd> <p>The vertical baseline origin of the original glyph run.</p> </dd></param>
40+
/// <param name = "glyphRun"><dd> <p>Original glyph run containing monochrome glyph IDs.</p> </dd></param>
41+
/// <param name = "glyphRunDescription"><dd> <p>Optional glyph run description.</p> </dd></param>
42+
/// <param name = "measuringMode"><dd> <p>Measuring mode used to compute glyph positions if the run contains color glyphs.</p> </dd></param>
43+
/// <param name = "worldToDeviceTransform"><dd> <p> World transform multiplied by any DPI scaling. This is needed to compute glyph positions if the run contains color glyphs and the measuring mode is not <strong>DWRITE_MEASURING_MODE_NATURAL</strong>. If this parameter is <strong><c>null</c></strong>, and identity transform is assumed. </p> </dd></param>
44+
/// <param name = "colorPaletteIndex"><dd> <p> Zero-based index of the color palette to use. Valid indices are less than the number of palettes in the font, as returned by <strong>IDWriteFontFace2::GetColorPaletteCount</strong>. </p> </dd></param>
45+
/// <param name = "colorLayers"><dd> <p> If the original glyph run contains color glyphs, this parameter receives a reference to an <strong><see cref = "SharpDX.DirectWrite.ColorGlyphRunEnumerator"/></strong> interface. The client uses the returned interface to get information about glyph runs and associated colors to render instead of the original glyph run. If the original glyph run does not contain color glyphs, this method returns <strong>DWRITE_E_NOCOLOR</strong> and the output reference is <strong><c>null</c></strong>. </p> </dd></param>
46+
/// <returns><p>If this method succeeds, it returns <strong><see cref = "SharpDX.Result.Ok"/></strong>. Otherwise, it returns an <strong><see cref = "SharpDX.Result"/></strong> error code.</p></returns>
47+
/// <remarks>
48+
/// <p> If the code calls this method with a glyph run that contains no color information, the method returns <strong>DWRITE_E_NOCOLOR</strong> to let the application know that it can just draw the original glyph run. If the glyph run contains color information, the function returns an object that can be enumerated through to expose runs and associated colors. The application then calls <strong>DrawGlyphRun</strong> with each of the returned glyph runs and foreground colors. </p>
49+
/// </remarks>
50+
/// <msdn-id>dn280451</msdn-id>
51+
/// <unmanaged>HRESULT IDWriteFactory2::TranslateColorGlyphRun([In] float baselineOriginX,[In] float baselineOriginY,[In] const DWRITE_GLYPH_RUN* glyphRun,[In, Optional] const DWRITE_GLYPH_RUN_DESCRIPTION* glyphRunDescription,[In] DWRITE_MEASURING_MODE measuringMode,[In, Optional] const DWRITE_MATRIX* worldToDeviceTransform,[In] unsigned int colorPaletteIndex,[Out] IDWriteColorGlyphRunEnumerator** colorLayers)</unmanaged>
52+
/// <unmanaged-short>IDWriteFactory2::TranslateColorGlyphRun</unmanaged-short>
53+
public void TranslateColorGlyphRun(System.Single baselineOriginX, System.Single baselineOriginY, SharpDX.DirectWrite.GlyphRun glyphRun, SharpDX.DirectWrite.GlyphRunDescription glyphRunDescription, SharpDX.Direct2D1.MeasuringMode measuringMode, SharpDX.Mathematics.Interop.RawMatrix3x2? worldToDeviceTransform, System.Int32 colorPaletteIndex, out SharpDX.DirectWrite.ColorGlyphRunEnumerator colorLayers)
54+
{
55+
var result = TryTranslateColorGlyphRun(baselineOriginX, baselineOriginY, glyphRun, glyphRunDescription, measuringMode, worldToDeviceTransform, colorPaletteIndex, out colorLayers);
56+
result.CheckError();
57+
}
58+
59+
60+
/// <summary>
61+
/// <p>This method is called on a glyph run to translate it in to multiple color glyph runs.</p>
62+
/// </summary>
63+
/// <param name = "baselineOriginX"><dd> <p>The horizontal baseline origin of the original glyph run.</p> </dd></param>
64+
/// <param name = "baselineOriginY"><dd> <p>The vertical baseline origin of the original glyph run.</p> </dd></param>
65+
/// <param name = "glyphRun"><dd> <p>Original glyph run containing monochrome glyph IDs.</p> </dd></param>
66+
/// <param name = "glyphRunDescription"><dd> <p>Optional glyph run description.</p> </dd></param>
67+
/// <param name = "measuringMode"><dd> <p>Measuring mode used to compute glyph positions if the run contains color glyphs.</p> </dd></param>
68+
/// <param name = "worldToDeviceTransform"><dd> <p> World transform multiplied by any DPI scaling. This is needed to compute glyph positions if the run contains color glyphs and the measuring mode is not <strong>DWRITE_MEASURING_MODE_NATURAL</strong>. If this parameter is <strong><c>null</c></strong>, and identity transform is assumed. </p> </dd></param>
69+
/// <param name = "colorPaletteIndex"><dd> <p> Zero-based index of the color palette to use. Valid indices are less than the number of palettes in the font, as returned by <strong>IDWriteFontFace2::GetColorPaletteCount</strong>. </p> </dd></param>
70+
/// <returns><dd> <p> If the original glyph run contains color glyphs, this parameter receives a reference to an <strong><see cref = "SharpDX.DirectWrite.ColorGlyphRunEnumerator"/></strong> interface. The client uses the returned interface to get information about glyph runs and associated colors to render instead of the original glyph run. If the original glyph run does not contain color glyphs, this method returns <strong>DWRITE_E_NOCOLOR</strong> and the output reference is <strong><c>null</c></strong>. </p> </dd></returns>
71+
/// <remarks>
72+
/// <p> If the code calls this method with a glyph run that contains no color information, the method returns <strong>DWRITE_E_NOCOLOR</strong> to let the application know that it can just draw the original glyph run. If the glyph run contains color information, the function returns an object that can be enumerated through to expose runs and associated colors. The application then calls <strong>DrawGlyphRun</strong> with each of the returned glyph runs and foreground colors. </p>
73+
/// </remarks>
74+
/// <msdn-id>dn280451</msdn-id>
75+
/// <unmanaged>HRESULT IDWriteFactory2::TranslateColorGlyphRun([In] float baselineOriginX,[In] float baselineOriginY,[In] const DWRITE_GLYPH_RUN* glyphRun,[In, Optional] const DWRITE_GLYPH_RUN_DESCRIPTION* glyphRunDescription,[In] DWRITE_MEASURING_MODE measuringMode,[In, Optional] const DWRITE_MATRIX* worldToDeviceTransform,[In] unsigned int colorPaletteIndex,[Out] IDWriteColorGlyphRunEnumerator** colorLayers)</unmanaged>
76+
/// <unmanaged-short>IDWriteFactory2::TranslateColorGlyphRun</unmanaged-short>
77+
public SharpDX.DirectWrite.ColorGlyphRunEnumerator TranslateColorGlyphRun(System.Single baselineOriginX, System.Single baselineOriginY, SharpDX.DirectWrite.GlyphRun glyphRun, SharpDX.DirectWrite.GlyphRunDescription glyphRunDescription, SharpDX.Direct2D1.MeasuringMode measuringMode, SharpDX.Mathematics.Interop.RawMatrix3x2? worldToDeviceTransform, System.Int32 colorPaletteIndex)
78+
{
79+
SharpDX.DirectWrite.ColorGlyphRunEnumerator colorLayers;
80+
TranslateColorGlyphRun(baselineOriginX, baselineOriginY, glyphRun, glyphRunDescription, measuringMode, worldToDeviceTransform, colorPaletteIndex, out colorLayers);
81+
return colorLayers;
82+
}
83+
}
84+
}

Source/SharpDX.Direct2D1/DirectWrite/Mapping.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,12 @@
222222

223223
<map param="IDWriteRemoteFontFileStream::BeginDownload::asyncResult" return="true" />
224224
<map method="IDWriteAsyncResult::GetResult" check="false"/>
225+
226+
<!-- Factory 2 -->
227+
<map method="IDWriteFactory2::TranslateColorGlyphRun" hresult="true" check="false" visibility="public" name="TryTranslateColorGlyphRun" />
225228

226-
<!--
229+
230+
<!--
227231
// *****************************************************************
228232
// DWrite Functions
229233
// *****************************************************************

0 commit comments

Comments
 (0)