dwrite: Implement AnalyzeBidi().
This commit is contained in:
parent
b2c65c296f
commit
fdd8454ef8
|
@ -4,6 +4,8 @@ IMPORTS = user32 gdi32
|
|||
|
||||
C_SRCS = \
|
||||
analyzer.c \
|
||||
bidi.c \
|
||||
bracket.c \
|
||||
font.c \
|
||||
gdiinterop.c \
|
||||
layout.c \
|
||||
|
|
|
@ -165,11 +165,6 @@ static const struct dwritescript_properties dwritescripts_properties[Script_Last
|
|||
{ /* Yiii */ { 0x69696959, 460, 1, 0x0020, 0, 0, 1, 1, 0, 0, 0 }, TRUE }
|
||||
};
|
||||
|
||||
static inline unsigned short get_table_entry(const unsigned short *table, WCHAR ch)
|
||||
{
|
||||
return table[table[table[ch >> 8] + ((ch >> 4) & 0x0f)] + (ch & 0xf)];
|
||||
}
|
||||
|
||||
static inline UINT16 get_char_script(WCHAR c)
|
||||
{
|
||||
UINT16 script = get_table_entry(wine_scripts_table, c);
|
||||
|
@ -671,8 +666,82 @@ static HRESULT WINAPI dwritetextanalyzer_AnalyzeScript(IDWriteTextAnalyzer2 *ifa
|
|||
static HRESULT WINAPI dwritetextanalyzer_AnalyzeBidi(IDWriteTextAnalyzer2 *iface,
|
||||
IDWriteTextAnalysisSource* source, UINT32 position, UINT32 length, IDWriteTextAnalysisSink* sink)
|
||||
{
|
||||
FIXME("(%p %u %u %p): stub\n", source, position, length, sink);
|
||||
return E_NOTIMPL;
|
||||
UINT8 *levels = NULL, *explicit = NULL;
|
||||
UINT8 baselevel, level, explicit_level;
|
||||
WCHAR *buff = NULL;
|
||||
const WCHAR *text;
|
||||
UINT32 len, pos, i;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("(%p %u %u %p)\n", source, position, length, sink);
|
||||
|
||||
if (length == 0)
|
||||
return S_OK;
|
||||
|
||||
/* get some, check for length */
|
||||
text = NULL;
|
||||
len = 0;
|
||||
hr = IDWriteTextAnalysisSource_GetTextAtPosition(source, position, &text, &len);
|
||||
if (FAILED(hr)) return hr;
|
||||
|
||||
if (len < length) {
|
||||
UINT32 read;
|
||||
|
||||
buff = heap_alloc(length*sizeof(WCHAR));
|
||||
if (!buff)
|
||||
return E_OUTOFMEMORY;
|
||||
memcpy(buff, text, len*sizeof(WCHAR));
|
||||
read = len;
|
||||
|
||||
while (read < length && text) {
|
||||
text = NULL;
|
||||
len = 0;
|
||||
hr = IDWriteTextAnalysisSource_GetTextAtPosition(source, read, &text, &len);
|
||||
if (FAILED(hr))
|
||||
goto done;
|
||||
memcpy(&buff[read], text, min(len, length-read)*sizeof(WCHAR));
|
||||
read += len;
|
||||
}
|
||||
|
||||
text = buff;
|
||||
}
|
||||
|
||||
levels = heap_alloc(length*sizeof(*levels));
|
||||
explicit = heap_alloc(length*sizeof(*explicit));
|
||||
|
||||
if (!levels || !explicit) {
|
||||
hr = E_OUTOFMEMORY;
|
||||
goto done;
|
||||
}
|
||||
|
||||
baselevel = IDWriteTextAnalysisSource_GetParagraphReadingDirection(source);
|
||||
hr = bidi_computelevels(text, length, baselevel, explicit, levels);
|
||||
if (FAILED(hr))
|
||||
goto done;
|
||||
|
||||
level = levels[0];
|
||||
explicit_level = explicit[0];
|
||||
pos = 0;
|
||||
for (i = 1; i < length; i++) {
|
||||
if (levels[i] != level || explicit[i] != explicit_level) {
|
||||
hr = IDWriteTextAnalysisSink_SetBidiLevel(sink, pos, i - pos, explicit_level, level);
|
||||
if (FAILED(hr))
|
||||
break;
|
||||
level = levels[i];
|
||||
explicit_level = explicit[i];
|
||||
pos = i;
|
||||
}
|
||||
|
||||
if (i == length - 1)
|
||||
hr = IDWriteTextAnalysisSink_SetBidiLevel(sink, pos, length - pos, explicit_level, level);
|
||||
}
|
||||
|
||||
done:
|
||||
heap_free(explicit);
|
||||
heap_free(levels);
|
||||
heap_free(buff);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI dwritetextanalyzer_AnalyzeNumberSubstitution(IDWriteTextAnalyzer2 *iface,
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,106 @@
|
|||
/* Unicode Bidirectional Bracket table */
|
||||
/* generated from http://www.unicode.org/Public/7.0.0/ucd/BidiBrackets.txt */
|
||||
/* DO NOT EDIT!! */
|
||||
|
||||
const unsigned short bidi_bracket_table[768] =
|
||||
{
|
||||
/* level 1 offsets */
|
||||
0x0100, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110,
|
||||
0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0120,
|
||||
0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0130, 0x0110,
|
||||
0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110,
|
||||
0x0140, 0x0110, 0x0110, 0x0150, 0x0110, 0x0110, 0x0110, 0x0160,
|
||||
0x0110, 0x0170, 0x0110, 0x0110, 0x0110, 0x0110, 0x0180, 0x0110,
|
||||
0x0190, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110,
|
||||
0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110,
|
||||
0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110,
|
||||
0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110,
|
||||
0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110,
|
||||
0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110,
|
||||
0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110,
|
||||
0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110,
|
||||
0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110,
|
||||
0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110,
|
||||
0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110,
|
||||
0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110,
|
||||
0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110,
|
||||
0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110,
|
||||
0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110,
|
||||
0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110,
|
||||
0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110,
|
||||
0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110,
|
||||
0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110,
|
||||
0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110,
|
||||
0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110,
|
||||
0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110,
|
||||
0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110,
|
||||
0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110,
|
||||
0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110,
|
||||
0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x0110, 0x01a0, 0x01b0,
|
||||
/* level 2 offsets */
|
||||
0x01c0, 0x01c0, 0x01d0, 0x01c0, 0x01c0, 0x01e0, 0x01c0, 0x01e0,
|
||||
0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0,
|
||||
0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0,
|
||||
0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0,
|
||||
0x01c0, 0x01c0, 0x01c0, 0x01f0, 0x01c0, 0x01c0, 0x01c0, 0x01c0,
|
||||
0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0,
|
||||
0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0,
|
||||
0x01c0, 0x0200, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0,
|
||||
0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x0210, 0x01c0, 0x01c0, 0x0220,
|
||||
0x0220, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0,
|
||||
0x0230, 0x01c0, 0x0240, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0,
|
||||
0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0,
|
||||
0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x0250, 0x0260,
|
||||
0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x0210, 0x01c0, 0x0270, 0x01c0,
|
||||
0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0,
|
||||
0x0280, 0x0290, 0x01c0, 0x01c0, 0x01c0, 0x0230, 0x01c0, 0x02a0,
|
||||
0x01c0, 0x01c0, 0x02b0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0,
|
||||
0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0,
|
||||
0x0250, 0x02c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0,
|
||||
0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0,
|
||||
0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x02d0, 0x01c0, 0x01c0,
|
||||
0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0,
|
||||
0x01d0, 0x01c0, 0x01c0, 0x01e0, 0x01c0, 0x02e0, 0x02f0, 0x01c0,
|
||||
0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0, 0x01c0,
|
||||
/* values */
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0001, 0x01fe, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0002, 0x0000, 0x01fd, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0001, 0x01fe, 0x0001, 0x01fe, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0001, 0x01fe, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x01fe, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x01fe, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0001, 0x01fe, 0x0001, 0x01fe, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0001, 0x01fe, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0001, 0x01fe, 0x0001, 0x01fe, 0x0001, 0x01fe, 0x0001, 0x01fe,
|
||||
0x0001, 0x01fe, 0x0001, 0x01fe, 0x0001, 0x01fe, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x01fe,
|
||||
0x0001, 0x01fe, 0x0001, 0x01fe, 0x0001, 0x01fe, 0x0001, 0x01fe,
|
||||
0x0000, 0x0000, 0x0000, 0x0001, 0x01fe, 0x0001, 0x01fe, 0x0001,
|
||||
0x01fe, 0x0001, 0x01fe, 0x0001, 0x01fe, 0x0003, 0x0101, 0x00fe,
|
||||
0x01fc, 0x0001, 0x01fe, 0x0001, 0x01fe, 0x0001, 0x01fe, 0x0001,
|
||||
0x01fe, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0001, 0x01fe, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0001, 0x01fe, 0x0001, 0x01fe, 0x0001, 0x01fe,
|
||||
0x0001, 0x01fe, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0001, 0x01fe, 0x0000, 0x0000, 0x0001, 0x01fe, 0x0001, 0x01fe,
|
||||
0x0001, 0x01fe, 0x0001, 0x01fe, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0001, 0x01fe, 0x0001, 0x01fe, 0x0001, 0x01fe, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0002, 0x0000, 0x01fd, 0x0000, 0x0001,
|
||||
0x01fe, 0x0000, 0x0001, 0x01fe, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
|
||||
};
|
|
@ -82,6 +82,11 @@ static inline const char *debugstr_range(const DWRITE_TEXT_RANGE *range)
|
|||
return wine_dbg_sprintf("%u:%u", range->startPosition, range->length);
|
||||
}
|
||||
|
||||
static inline unsigned short get_table_entry(const unsigned short *table, WCHAR ch)
|
||||
{
|
||||
return table[table[table[ch >> 8] + ((ch >> 4) & 0x0f)] + (ch & 0xf)];
|
||||
}
|
||||
|
||||
extern HRESULT create_font_from_logfont(const LOGFONTW*, IDWriteFont**) DECLSPEC_HIDDEN;
|
||||
extern HRESULT convert_fontface_to_logfont(IDWriteFontFace*, LOGFONTW*) DECLSPEC_HIDDEN;
|
||||
extern HRESULT create_textformat(const WCHAR*,IDWriteFontCollection*,DWRITE_FONT_WEIGHT,DWRITE_FONT_STYLE,DWRITE_FONT_STRETCH,
|
||||
|
@ -104,3 +109,5 @@ extern HRESULT analyze_opentype_font(const void* font_data, UINT32* font_count,
|
|||
extern HRESULT find_font_table(IDWriteFontFileStream *stream, UINT32 font_index, UINT32 tag, const void** table_data, void** table_context, UINT32 *table_size, BOOL* found) DECLSPEC_HIDDEN;
|
||||
extern VOID OpenType_CMAP_GetGlyphIndex(LPVOID data, DWORD utf32c, LPWORD pgi, DWORD flags) DECLSPEC_HIDDEN;
|
||||
extern VOID get_font_properties(LPCVOID os2, LPCVOID head, LPCVOID post, DWRITE_FONT_METRICS *metrics, DWRITE_FONT_STRETCH *stretch, DWRITE_FONT_WEIGHT *weight, DWRITE_FONT_STYLE *style) DECLSPEC_HIDDEN;
|
||||
|
||||
extern HRESULT bidi_computelevels(const WCHAR*,UINT32,UINT8,UINT8*,UINT8*);
|
||||
|
|
|
@ -2384,6 +2384,7 @@ DUMP_COMPOSE_TABLES( "libs/wine/compose.c" );
|
|||
DUMP_CTYPE_TABLES( "libs/wine/wctype.c" );
|
||||
dump_mirroring( "dlls/usp10/mirror.c" );
|
||||
dump_bracket( "dlls/usp10/bracket.c" );
|
||||
dump_bracket( "dlls/dwrite/bracket.c" );
|
||||
dump_shaping( "dlls/usp10/shaping.c" );
|
||||
dump_linebreak( "dlls/usp10/linebreak.c" );
|
||||
dump_linebreak( "dlls/dwrite/linebreak.c" );
|
||||
|
|
Loading…
Reference in New Issue