Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
89fcb115
Commit
89fcb115
authored
Oct 29, 2012
by
Nikolay Sivov
Committed by
Alexandre Julliard
Oct 29, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dwrite: Implement initial script itemization for AnalyzeScript().
parent
45c7798c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
101 additions
and
5 deletions
+101
-5
analyzer.c
dlls/dwrite/analyzer.c
+95
-2
analyzer.c
dlls/dwrite/tests/analyzer.c
+6
-3
No files found.
dlls/dwrite/analyzer.c
View file @
89fcb115
...
@@ -27,6 +27,91 @@
...
@@ -27,6 +27,91 @@
WINE_DEFAULT_DEBUG_CHANNEL
(
dwrite
);
WINE_DEFAULT_DEBUG_CHANNEL
(
dwrite
);
enum
scriptcode
{
Script_Arabic
=
0
,
Script_Latin
=
38
,
Script_Latin_Symb
=
77
,
Script_Unknown
=
(
UINT16
)
-
1
};
struct
script_range
{
UINT16
script
;
DWORD
first
;
DWORD
last
;
};
static
const
struct
script_range
script_ranges
[]
=
{
/* C0 Controls: U+0000–U+001F */
/* ASCII punctuation and symbols: U+0020–U+002F */
/* ASCII digits: U+0030–U+0039 */
/* ASCII punctuation and symbols: U+003A–U+0040 */
{
Script_Latin_Symb
,
0x00
,
0x040
},
/* Latin uppercase: U+0041–U+005A */
{
Script_Latin
,
0x41
,
0x5a
},
/* ASCII punctuation and symbols: U+005B–U+0060 */
{
Script_Latin_Symb
,
0x5b
,
0x060
},
/* Latin lowercase: U+0061–U+007A */
{
Script_Latin
,
0x61
,
0x7a
},
/* ASCII punctuation and symbols, control char DEL: U+007B–U+007F */
{
Script_Latin_Symb
,
0x7b
,
0x7f
},
/* Arabic: U+0600–U+06FF */
{
Script_Arabic
,
0x600
,
0x6ef
},
/* unsuppoted range */
{
Script_Unknown
}
};
static
UINT16
get_char_script
(
WCHAR
c
)
{
DWORD
ch
=
c
;
int
i
;
for
(
i
=
0
;
i
<
sizeof
(
script_ranges
)
/
sizeof
(
struct
script_range
);
i
++
)
{
const
struct
script_range
*
range
=
&
script_ranges
[
i
];
if
(
range
->
script
==
Script_Unknown
||
(
range
->
first
<=
ch
&&
range
->
last
>=
ch
))
return
range
->
script
;
}
return
Script_Unknown
;
}
static
HRESULT
analyze_script
(
const
WCHAR
*
text
,
UINT32
len
,
IDWriteTextAnalysisSink
*
sink
)
{
DWRITE_SCRIPT_ANALYSIS
sa
;
UINT32
pos
,
i
,
length
;
if
(
!
len
)
return
S_OK
;
sa
.
script
=
get_char_script
(
*
text
);
sa
.
shapes
=
DWRITE_SCRIPT_SHAPES_DEFAULT
;
pos
=
0
;
length
=
1
;
for
(
i
=
1
;
i
<
len
;
i
++
)
{
UINT16
script
=
get_char_script
(
text
[
i
]);
/* Script_Latin_Symb script type is ignored when preceded or followed by another script */
if
(
sa
.
script
==
Script_Latin_Symb
)
sa
.
script
=
script
;
if
(
script
==
Script_Latin_Symb
)
script
=
sa
.
script
;
/* this is a length of a sequence to be reported next */
if
(
sa
.
script
==
script
)
length
++
;
if
(
sa
.
script
!=
script
)
{
HRESULT
hr
=
IDWriteTextAnalysisSink_SetScriptAnalysis
(
sink
,
pos
,
length
,
&
sa
);
if
(
FAILED
(
hr
))
return
hr
;
pos
=
i
;
length
=
1
;
sa
.
script
=
script
;
}
}
/* 1 length case or normal completion call */
return
IDWriteTextAnalysisSink_SetScriptAnalysis
(
sink
,
pos
,
length
,
&
sa
);
}
static
HRESULT
WINAPI
dwritetextanalyzer_QueryInterface
(
IDWriteTextAnalyzer
*
iface
,
REFIID
riid
,
void
**
obj
)
static
HRESULT
WINAPI
dwritetextanalyzer_QueryInterface
(
IDWriteTextAnalyzer
*
iface
,
REFIID
riid
,
void
**
obj
)
{
{
TRACE
(
"(%s %p)
\n
"
,
debugstr_guid
(
riid
),
obj
);
TRACE
(
"(%s %p)
\n
"
,
debugstr_guid
(
riid
),
obj
);
...
@@ -55,8 +140,16 @@ static ULONG WINAPI dwritetextanalyzer_Release(IDWriteTextAnalyzer *iface)
...
@@ -55,8 +140,16 @@ static ULONG WINAPI dwritetextanalyzer_Release(IDWriteTextAnalyzer *iface)
static
HRESULT
WINAPI
dwritetextanalyzer_AnalyzeScript
(
IDWriteTextAnalyzer
*
iface
,
static
HRESULT
WINAPI
dwritetextanalyzer_AnalyzeScript
(
IDWriteTextAnalyzer
*
iface
,
IDWriteTextAnalysisSource
*
source
,
UINT32
position
,
UINT32
length
,
IDWriteTextAnalysisSink
*
sink
)
IDWriteTextAnalysisSource
*
source
,
UINT32
position
,
UINT32
length
,
IDWriteTextAnalysisSink
*
sink
)
{
{
FIXME
(
"(%p %u %u %p): stub
\n
"
,
source
,
position
,
length
,
sink
);
const
WCHAR
*
text
;
return
E_NOTIMPL
;
HRESULT
hr
;
UINT32
len
;
TRACE
(
"(%p %u %u %p)
\n
"
,
source
,
position
,
length
,
sink
);
hr
=
IDWriteTextAnalysisSource_GetTextAtPosition
(
source
,
position
,
&
text
,
&
len
);
if
(
FAILED
(
hr
))
return
hr
;
return
analyze_script
(
text
,
len
,
sink
);
}
}
static
HRESULT
WINAPI
dwritetextanalyzer_AnalyzeBidi
(
IDWriteTextAnalyzer
*
iface
,
static
HRESULT
WINAPI
dwritetextanalyzer_AnalyzeBidi
(
IDWriteTextAnalyzer
*
iface
,
...
...
dlls/dwrite/tests/analyzer.c
View file @
89fcb115
...
@@ -404,6 +404,11 @@ enum scriptcode {
...
@@ -404,6 +404,11 @@ enum scriptcode {
static
struct
sa_test
sa_tests
[]
=
{
static
struct
sa_test
sa_tests
[]
=
{
{
{
/* just 1 char string */
{
't'
,
0
},
1
,
{
{
0
,
1
,
{
Script_Latin
,
DWRITE_SCRIPT_SHAPES_DEFAULT
}
}}
},
{
{
't'
,
'e'
,
's'
,
't'
,
0
},
1
,
{
't'
,
'e'
,
's'
,
't'
,
0
},
1
,
{
{
0
,
4
,
{
Script_Latin
,
DWRITE_SCRIPT_SHAPES_DEFAULT
}
}}
{
{
0
,
4
,
{
Script_Latin
,
DWRITE_SCRIPT_SHAPES_DEFAULT
}
}}
},
},
...
@@ -451,7 +456,7 @@ static struct sa_test sa_tests[] = {
...
@@ -451,7 +456,7 @@ static struct sa_test sa_tests[] = {
{
7
,
4
,
{
Script_Arabic
,
DWRITE_SCRIPT_SHAPES_DEFAULT
}
},
{
7
,
4
,
{
Script_Arabic
,
DWRITE_SCRIPT_SHAPES_DEFAULT
}
},
}
}
},
},
/* keep this as end marker */
{
{
0
}
}
{
{
0
}
}
};
};
...
@@ -493,9 +498,7 @@ static void test_AnalyzeScript(void)
...
@@ -493,9 +498,7 @@ static void test_AnalyzeScript(void)
init_expected_sa
(
expected_seq
,
ptr
);
init_expected_sa
(
expected_seq
,
ptr
);
hr
=
IDWriteTextAnalyzer_AnalyzeScript
(
analyzer
,
&
analysissource
,
0
,
lstrlenW
(
g_source
),
&
analysissink
);
hr
=
IDWriteTextAnalyzer_AnalyzeScript
(
analyzer
,
&
analysissource
,
0
,
lstrlenW
(
g_source
),
&
analysissink
);
todo_wine
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
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
);
ok_sequence
(
sequences
,
ANALYZER_ID
,
expected_seq
[
0
]
->
sequence
,
"AnalyzeScript"
,
FALSE
);
ptr
++
;
ptr
++
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment