Skip to content

Commit 18cb55a

Browse files
author
Jerry Lin
committed
Provide mapping to IDWriteFontFallback::MapCharacters method
1 parent 1ab7aa9 commit 18cb55a

File tree

2 files changed

+82
-11
lines changed

2 files changed

+82
-11
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// Copyright (c) 2010-2013 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+
namespace SharpDX.DirectWrite
22+
{
23+
public partial class FontFallback
24+
{
25+
/// <summary>
26+
/// <p>Determines an appropriate font to use to render the beginning range of text.</p>
27+
/// </summary>
28+
/// <param name="analysisSource"><dd> <p>The text source implementation holds the text and locale.</p> </dd></param>
29+
/// <param name="textPosition"><dd> <p>Starting position to analyze.</p> </dd></param>
30+
/// <param name="textLength"><dd> <p>Length of the text to analyze.</p> </dd></param>
31+
/// <param name="baseFontCollection"><dd> <p>Default font collection to use.</p> </dd></param>
32+
/// <param name="baseFamilyName"><dd> <p>Family name of the base font. If you pass null, no matching will be done against the family.</p> </dd></param>
33+
/// <param name="baseWeight"><dd> <p>The desired weight.</p> </dd></param>
34+
/// <param name="baseStyle"><dd> <p>The desired style.</p> </dd></param>
35+
/// <param name="baseStretch"><dd> <p>The desired stretch.</p> </dd></param>
36+
/// <param name="mappedLength"><dd> <p>Length of text mapped to the mapped font. This will always be less than or equal to the text length and greater than zero (if the text length is non-zero) so the caller advances at least one character.</p> </dd></param>
37+
/// <param name="mappedFont"><dd> <p>The font that should be used to render the first <em>mappedLength</em> characters of the text. If it returns <c>null</c>, that means that no font can render the text, and <em>mappedLength</em> is the number of characters to skip (rendered with a missing glyph).</p> </dd></param>
38+
/// <param name="scale"><dd> <p>Scale factor to multiply the em size of the returned font by.</p> </dd></param>
39+
public void MapCharacters(
40+
TextAnalysisSource analysisSource,
41+
int textPosition,
42+
int textLength,
43+
FontCollection baseFontCollection,
44+
string baseFamilyName,
45+
FontWeight baseWeight,
46+
FontStyle baseStyle,
47+
FontStretch baseStretch,
48+
out int mappedLength,
49+
out Font mappedFont,
50+
out float scale
51+
)
52+
{
53+
MapCharacters_(
54+
TextAnalysisSourceShadow.ToIntPtr(analysisSource),
55+
textPosition,
56+
textLength,
57+
baseFontCollection,
58+
baseFamilyName,
59+
baseWeight,
60+
baseStyle,
61+
baseStretch,
62+
out mappedLength,
63+
out mappedFont,
64+
out scale
65+
);
66+
}
67+
}
68+
}

Source/SharpDX.Direct2D1/DirectWrite/Mapping.xml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!--
33
// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel
4-
//
4+
//
55
// Permission is hereby granted, free of charge, to any person obtaining a copy
66
// of this software and associated documentation files (the "Software"), to deal
77
// in the Software without restriction, including without limitation the rights
88
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
99
// copies of the Software, and to permit persons to whom the Software is
1010
// furnished to do so, subject to the following conditions:
11-
//
11+
//
1212
// The above copyright notice and this permission notice shall be included in
1313
// all copies or substantial portions of the Software.
14-
//
14+
//
1515
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1616
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1717
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -26,14 +26,14 @@
2626

2727
<namespace>SharpDX.DirectWrite</namespace>
2828
<assembly>SharpDX.Direct2D1</assembly>
29-
29+
3030
<include file="dwrite.h" attach="true" output="DirectWrite"/>
3131
<include file="dwrite_1.h" attach="true" output="DirectWrite"/>
3232
<include file="dwrite_2.h" attach="true" output="DirectWrite"/>
3333
<include file="dwrite_3.h" attach="true" output="DirectWrite"/>
3434

3535
<naming />
36-
36+
3737
<extension>
3838
<create class="DWrite" />
3939
</extension>
@@ -124,7 +124,7 @@
124124

125125
<map param="IDWriteFont::HasCharacter::exists" return="true" />
126126
<map param="IDWriteFont::GetInformationalStrings::exists" return="true" />
127-
127+
128128
<map method="IDWriteFontFace::GetFiles" visibility="internal" />
129129
<map method="IDWriteFontFace::GetDesignGlyphMetrics" visibility="internal" />
130130
<map method="IDWriteFontFace::GetGdiCompatibleGlyphMetrics" visibility="internal" />
@@ -133,6 +133,9 @@
133133
<map param="IDWriteFontFace::GetRecommendedRenderingMode::renderingMode" return="true" />
134134
<map method="IDWriteFontFace::TryGetFontTable" visibility="internal" />
135135
<map method="IDWriteFontFace::GetType" name="GetFaceType" />
136+
137+
<map param="IDWriteFontFallback::MapCharacters::mappedLength" attribute="out" />
138+
136139
<map param="IDWriteFontList::GetFont::font" return="true" />
137140
<map param="IDWriteFontFamily::GetFirstMatchingFont::matchingFont" return="true" />
138141
<map param="IDWriteFontFamily::GetMatchingFonts::matchingFonts" return="true" />
@@ -141,7 +144,7 @@
141144
<map param="IDWriteFontCollection::GetFontFromFontFace::font" return="true" />
142145
<map interface="IDWriteFontCollectionLoader" callback="true" callback-dual="false" />
143146
<map method="IDWriteFontFile::GetLoader" visibility="internal" property="false" />
144-
147+
145148
<map interface="IDWriteFontFileLoader" callback-visibility="public" callback="true" callback-dual="true" />
146149

147150
<map interface="IDWriteFontFileEnumerator" callback="true" callback-dual="false" />
@@ -152,7 +155,7 @@
152155
<map param="logFont" type="void" attribute="in" />
153156
<map param="IDWriteGdiInterop::CreateBitmapRenderTarget::renderTarget" return="true" />
154157
<map param="IDWriteGdiInterop::CreateFontFaceFromHdc::fontFace" return="true" />
155-
158+
156159
<map method="IDWriteGdiInterop1::.*?LOGFONT" visibility="internal" />
157160
<map param="logFont" type="void" attribute="in" />
158161
<map param="IDWriteGdiInterop1::CreateBitmapRenderTarget::renderTarget" return="true" />
@@ -208,14 +211,14 @@
208211
<map method="IDWriteTextLayout::GetLineMetrics" check="false"/>
209212
<map method="IDWriteTextLayout::HitTestTextRange" check="false"/>
210213
<map method="IDWriteTextLayout::GetClusterMetrics" check="false"/>
211-
214+
212215
<map method="IDWriteLocalFontFileLoader::GetFilePath.*" visibility="internal"/>
213216
<map method="IDWriteLocalFontFileLoader::GetLastWriteTimeFromKey" visibility="internal"/>
214217

215218
<map method="IDWriteBitmapRenderTarget::DrawGlyphRun" visibility="private"/>
216219
<map param="IDWriteBitmapRenderTarget::DrawGlyphRun::textColor" type="int"/>
217-
218-
220+
221+
219222
<map param="IDWriteRemoteFontFileStream::BeginDownload::asyncResult" return="true" />
220223
<map method="IDWriteAsyncResult::GetResult" check="false"/>
221224

0 commit comments

Comments
 (0)