dwrite: Added a stub for IDWriteTextAnalyzer.

This commit is contained in:
Nikolay Sivov 2012-10-28 17:58:10 -04:00 committed by Alexandre Julliard
parent 419a1f45f9
commit 45c7798c36
6 changed files with 207 additions and 9 deletions

View file

@ -3,6 +3,7 @@ IMPORTLIB = dwrite
IMPORTS = user32 gdi32
C_SRCS = \
analyzer.c \
font.c \
gdiinterop.c \
layout.c \

144
dlls/dwrite/analyzer.c Normal file
View file

@ -0,0 +1,144 @@
/*
* Text analyzer
*
* Copyright 2012 Nikolay Sivov for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define COBJMACROS
#include "dwrite.h"
#include "dwrite_private.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(dwrite);
static HRESULT WINAPI dwritetextanalyzer_QueryInterface(IDWriteTextAnalyzer *iface, REFIID riid, void **obj)
{
TRACE("(%s %p)\n", debugstr_guid(riid), obj);
if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDWriteTextAnalyzer))
{
*obj = iface;
return S_OK;
}
*obj = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI dwritetextanalyzer_AddRef(IDWriteTextAnalyzer *iface)
{
return 2;
}
static ULONG WINAPI dwritetextanalyzer_Release(IDWriteTextAnalyzer *iface)
{
return 1;
}
static HRESULT WINAPI dwritetextanalyzer_AnalyzeScript(IDWriteTextAnalyzer *iface,
IDWriteTextAnalysisSource* source, UINT32 position, UINT32 length, IDWriteTextAnalysisSink* sink)
{
FIXME("(%p %u %u %p): stub\n", source, position, length, sink);
return E_NOTIMPL;
}
static HRESULT WINAPI dwritetextanalyzer_AnalyzeBidi(IDWriteTextAnalyzer *iface,
IDWriteTextAnalysisSource* source, UINT32 position, UINT32 length, IDWriteTextAnalysisSink* sink)
{
FIXME("(%p %u %u %p): stub\n", source, position, length, sink);
return E_NOTIMPL;
}
static HRESULT WINAPI dwritetextanalyzer_AnalyzeNumberSubstitution(IDWriteTextAnalyzer *iface,
IDWriteTextAnalysisSource* source, UINT32 position, UINT32 length, IDWriteTextAnalysisSink* sink)
{
FIXME("(%p %u %u %p): stub\n", source, position, length, sink);
return E_NOTIMPL;
}
static HRESULT WINAPI dwritetextanalyzer_AnalyzeLineBreakpoints(IDWriteTextAnalyzer *iface,
IDWriteTextAnalysisSource* source, UINT32 position, UINT32 length, IDWriteTextAnalysisSink* sink)
{
FIXME("(%p %u %u %p): stub\n", source, position, length, sink);
return E_NOTIMPL;
}
static HRESULT WINAPI dwritetextanalyzer_GetGlyphs(IDWriteTextAnalyzer *iface,
WCHAR const* text, UINT32 length, IDWriteFontFace* font_face, BOOL is_sideways,
BOOL is_rtl, DWRITE_SCRIPT_ANALYSIS const* analysis, WCHAR const* locale,
IDWriteNumberSubstitution* substitution, DWRITE_TYPOGRAPHIC_FEATURES const** features,
UINT32 const* feature_range_len, UINT32 feature_ranges, UINT32 max_glyph_count,
UINT16* clustermap, DWRITE_SHAPING_TEXT_PROPERTIES* text_props, UINT16* glyph_indices,
DWRITE_SHAPING_GLYPH_PROPERTIES* glyph_props, UINT32* actual_glyph_count)
{
FIXME("(%s:%u %p %d %d %p %s %p %p %p %u %u %p %p %p %p %p): stub\n", debugstr_wn(text, length),
length, font_face, is_sideways, is_rtl, analysis, debugstr_w(locale), substitution, features, feature_range_len,
feature_ranges, max_glyph_count, clustermap, text_props, glyph_indices, glyph_props, actual_glyph_count);
return E_NOTIMPL;
}
static HRESULT WINAPI dwritetextanalyzer_GetGlyphPlacements(IDWriteTextAnalyzer *iface,
WCHAR const* text, UINT16 const* clustermap, DWRITE_SHAPING_TEXT_PROPERTIES* props,
UINT32 text_len, UINT16 const* glyph_indices, DWRITE_SHAPING_GLYPH_PROPERTIES const* glyph_props,
UINT32 glyph_count, IDWriteFontFace * font_face, FLOAT fontEmSize, BOOL is_sideways, BOOL is_rtl,
DWRITE_SCRIPT_ANALYSIS const* analysis, WCHAR const* locale, DWRITE_TYPOGRAPHIC_FEATURES const** features,
UINT32 const* feature_range_len, UINT32 feature_ranges, FLOAT* glyph_advances, DWRITE_GLYPH_OFFSET* glyph_offsets)
{
FIXME("(%s %p %p %u %p %p %u %p %f %d %d %p %s %p %p %u %p %p): stub\n", debugstr_w(text),
clustermap, props, text_len, glyph_indices, glyph_props, glyph_count, font_face, fontEmSize, is_sideways,
is_rtl, analysis, debugstr_w(locale), features, feature_range_len, feature_ranges, glyph_advances, glyph_offsets);
return E_NOTIMPL;
}
static HRESULT WINAPI dwritetextanalyzer_GetGdiCompatibleGlyphPlacements(IDWriteTextAnalyzer *iface,
WCHAR const* text, UINT16 const* clustermap, DWRITE_SHAPING_TEXT_PROPERTIES* props,
UINT32 text_len, UINT16 const* glyph_indices, DWRITE_SHAPING_GLYPH_PROPERTIES const* glyph_props,
UINT32 glyph_count, IDWriteFontFace * font_face, FLOAT fontEmSize, FLOAT pixels_per_dip,
DWRITE_MATRIX const* transform, BOOL use_gdi_natural, BOOL is_sideways, BOOL is_rtl,
DWRITE_SCRIPT_ANALYSIS const* analysis, WCHAR const* locale, DWRITE_TYPOGRAPHIC_FEATURES const** features,
UINT32 const* feature_range_lengths, UINT32 feature_ranges, FLOAT* glyph_advances, DWRITE_GLYPH_OFFSET* glyph_offsets)
{
FIXME("(%s %p %p %u %p %p %u %p %f %f %p %d %d %d %p %s %p %p %u %p %p): stub\n", debugstr_w(text),
clustermap, props, text_len, glyph_indices, glyph_props, glyph_count, font_face, fontEmSize, pixels_per_dip,
transform, use_gdi_natural, is_sideways, is_rtl, analysis, debugstr_w(locale), features, feature_range_lengths,
feature_ranges, glyph_advances, glyph_offsets);
return E_NOTIMPL;
}
static const struct IDWriteTextAnalyzerVtbl textanalyzervtbl = {
dwritetextanalyzer_QueryInterface,
dwritetextanalyzer_AddRef,
dwritetextanalyzer_Release,
dwritetextanalyzer_AnalyzeScript,
dwritetextanalyzer_AnalyzeBidi,
dwritetextanalyzer_AnalyzeNumberSubstitution,
dwritetextanalyzer_AnalyzeLineBreakpoints,
dwritetextanalyzer_GetGlyphs,
dwritetextanalyzer_GetGlyphPlacements,
dwritetextanalyzer_GetGdiCompatibleGlyphPlacements
};
static IDWriteTextAnalyzer textanalyzer = { &textanalyzervtbl };
HRESULT get_textanalyzer(IDWriteTextAnalyzer **ret)
{
*ret = &textanalyzer;
return S_OK;
}

View file

@ -71,8 +71,9 @@ extern HRESULT create_font_from_logfont(const LOGFONTW*, IDWriteFont**) DECLSPEC
extern HRESULT create_textformat(const WCHAR*,IDWriteFontCollection*,DWRITE_FONT_WEIGHT,DWRITE_FONT_STYLE,DWRITE_FONT_STRETCH,
FLOAT,const WCHAR*,IDWriteTextFormat**) DECLSPEC_HIDDEN;
extern HRESULT create_textlayout(const WCHAR*,UINT32,IDWriteTextFormat*,IDWriteTextLayout**) DECLSPEC_HIDDEN;
extern HRESULT create_gdiinterop(IDWriteGdiInterop**) DECLSPEC_HIDDEN;
extern HRESULT get_gdiinterop(IDWriteGdiInterop**) DECLSPEC_HIDDEN;
extern HRESULT create_localizedstrings(IDWriteLocalizedStrings**) DECLSPEC_HIDDEN;
extern HRESULT add_localizedstring(IDWriteLocalizedStrings*,const WCHAR*,const WCHAR*) DECLSPEC_HIDDEN;
extern HRESULT get_system_fontcollection(IDWriteFontCollection**) DECLSPEC_HIDDEN;
extern void release_system_fontcollection(void) DECLSPEC_HIDDEN;
extern HRESULT get_textanalyzer(IDWriteTextAnalyzer**) DECLSPEC_HIDDEN;

View file

@ -275,7 +275,7 @@ static const struct IDWriteGdiInteropVtbl gdiinteropvtbl = {
static IDWriteGdiInterop gdiinterop = { &gdiinteropvtbl };
HRESULT create_gdiinterop(IDWriteGdiInterop **ret)
HRESULT get_gdiinterop(IDWriteGdiInterop **ret)
{
*ret = &gdiinterop;
return S_OK;

View file

@ -500,7 +500,7 @@ static HRESULT WINAPI dwritefactory_CreateTypography(IDWriteFactory *iface, IDWr
static HRESULT WINAPI dwritefactory_GetGdiInterop(IDWriteFactory *iface, IDWriteGdiInterop **gdi_interop)
{
TRACE("(%p)\n", gdi_interop);
return create_gdiinterop(gdi_interop);
return get_gdiinterop(gdi_interop);
}
static HRESULT WINAPI dwritefactory_CreateTextLayout(IDWriteFactory *iface, WCHAR const* string,
@ -532,8 +532,8 @@ static HRESULT WINAPI dwritefactory_CreateEllipsisTrimmingSign(IDWriteFactory *i
static HRESULT WINAPI dwritefactory_CreateTextAnalyzer(IDWriteFactory *iface, IDWriteTextAnalyzer **analyzer)
{
FIXME("(%p): stub\n", analyzer);
return E_NOTIMPL;
TRACE("(%p)\n", analyzer);
return get_textanalyzer(analyzer);
}
static HRESULT WINAPI dwritefactory_CreateNumberSubstitution(IDWriteFactory *iface, DWRITE_NUMBER_SUBSTITUTION_METHOD method,

View file

@ -396,10 +396,62 @@ struct sa_test {
struct script_analysis sa[10];
};
enum scriptcode {
Script_Arabic = 0,
Script_Latin = 38,
Script_Latin_Symb = 77
};
static struct sa_test sa_tests[] = {
{
{'t', 'e', 's', 't',0}, 1,
{ { 0, 4, { 38, DWRITE_SCRIPT_SHAPES_DEFAULT } }} },
{'t','e','s','t',0}, 1,
{ { 0, 4, { Script_Latin, DWRITE_SCRIPT_SHAPES_DEFAULT } }}
},
{
{' ',' ',' ',' ','!','$','[','^','{','~',0}, 1,
{ { 0, 10, { Script_Latin_Symb, DWRITE_SCRIPT_SHAPES_DEFAULT } }}
},
{
{' ',' ',' ','1','2',' ',0}, 1,
{ { 0, 6, { Script_Latin_Symb, DWRITE_SCRIPT_SHAPES_DEFAULT } }}
},
{
/* digits only */
{'1','2',0}, 1,
{ { 0, 2, { Script_Latin_Symb, DWRITE_SCRIPT_SHAPES_DEFAULT } }}
},
{
/* Arabic */
{0x064a,0x064f,0x0633,0x0627,0x0648,0x0650,0x064a,0}, 1,
{ { 0, 7, { Script_Arabic, DWRITE_SCRIPT_SHAPES_DEFAULT } }}
},
{
/* Arabic, Latin */
{'1','2','3','-','5','2',0x064a,0x064f,0x0633,0x0627,0x0648,0x0650,0x064a,'7','1','.',0}, 1,
{ { 0, 16, { 0, DWRITE_SCRIPT_SHAPES_DEFAULT } }}
},
{
/* Arabic, English */
{'A','B','C','-','D','E','F',' ',0x0621,0x0623,0x0624,0}, 2,
{ { 0, 8, { Script_Latin, DWRITE_SCRIPT_SHAPES_DEFAULT } },
{ 8, 3, { Script_Arabic, DWRITE_SCRIPT_SHAPES_DEFAULT } },
}
},
{
/* leading space, Arabic, English */
{' ',0x0621,0x0623,0x0624,'A','B','C','-','D','E','F',0}, 2,
{ { 0, 4, { Script_Arabic, DWRITE_SCRIPT_SHAPES_DEFAULT } },
{ 4, 7, { Script_Latin, DWRITE_SCRIPT_SHAPES_DEFAULT } },
}
},
{
/* English, Arabic, trailing space */
{'A','B','C','-','D','E','F',0x0621,0x0623,0x0624,' ',0}, 2,
{ { 0, 7, { Script_Latin, DWRITE_SCRIPT_SHAPES_DEFAULT } },
{ 7, 4, { Script_Arabic, DWRITE_SCRIPT_SHAPES_DEFAULT } },
}
},
{ {0} }
};
@ -433,9 +485,7 @@ static void test_AnalyzeScript(void)
HRESULT hr;
hr = IDWriteFactory_CreateTextAnalyzer(factory, &analyzer);
todo_wine
ok(hr == S_OK, "got 0x%08x\n", hr);
if (hr != S_OK) return;
while (*ptr->string)
{
@ -443,7 +493,9 @@ todo_wine
init_expected_sa(expected_seq, ptr);
hr = IDWriteTextAnalyzer_AnalyzeScript(analyzer, &analysissource, 0, lstrlenW(g_source), &analysissink);
todo_wine
ok(hr == S_OK, "got 0x%08x\n", hr);
if (hr == E_NOTIMPL) break;
ok_sequence(sequences, ANALYZER_ID, expected_seq[0]->sequence, "AnalyzeScript", FALSE);
ptr++;
}