mirror of
https://github.com/VincentWei/MiniGUI.git
synced 2026-09-24 00:54:18 +08:00
CreateTextRunsInfo and CreateLayoutInfo passed test cases
This commit is contained in:
+10
-3
@@ -12773,13 +12773,20 @@ MG_EXPORT LAYOUTLINE* GUIAPI LayoutNextLine(LAYOUTINFO* layout_info,
|
||||
int x, int y, int max_extent, BOOL last_line, SIZE* line_size,
|
||||
CB_GLYPH_LAID_OUT cb_laid_out, GHANDLE ctxt);
|
||||
|
||||
/**
|
||||
* Get layout line information
|
||||
*/
|
||||
#ifdef _MGDEVEL_MODE
|
||||
void* GetNextTextRunInfo(TEXTRUNSINFO* runinfo,
|
||||
void* prev,
|
||||
const char** fontname, int* start_index, int* length,
|
||||
LanguageCode* lang_code, ScriptType* script,
|
||||
BidiLevel* embedding_level, GlyphRunDir* run_dir,
|
||||
GlyphOrient* orient, Uint8* flags);
|
||||
|
||||
/* Get layout line information */
|
||||
MG_EXPORT BOOL GUIAPI GetLayoutLineInfo(LAYOUTLINE* line,
|
||||
int* line_no, int* max_extent, int* nr_chars, int* nr_glyphs,
|
||||
int** log_widths, int* width, int* height,
|
||||
BOOL* is_ellipsized, BOOL* is_wrapped);
|
||||
#endif
|
||||
|
||||
MG_EXPORT BOOL DrawShapedGlyph(HDC hdc, LOGFONT* lf, RGBCOLOR color,
|
||||
Glyph32 gv, const GLYPHPOS* pos);
|
||||
|
||||
+22
-5
@@ -1734,6 +1734,13 @@ BidiLevel GUIAPI UBidiGetParagraphEmbeddingLevelsAlt(
|
||||
BidiBracketType local_brk_ts[LOCAL_ARRAY_SIZE];
|
||||
BidiBracketType *brk_ts = NULL;
|
||||
|
||||
/* NOTE:
|
||||
* BIDI_IS_ISSOLATE, BIDI_IS_NUMBER, and BIDI_IS_LETTER
|
||||
* can not be applied to ored_types */
|
||||
BOOL have_isolate = FALSE;
|
||||
BOOL have_number = FALSE;
|
||||
BOOL have_letter = FALSE;
|
||||
|
||||
if (!els) {
|
||||
_DBG_PRINTF("%s: Embedding levels is NULL.\n",
|
||||
__FUNCTION__);
|
||||
@@ -1766,6 +1773,14 @@ BidiLevel GUIAPI UBidiGetParagraphEmbeddingLevelsAlt(
|
||||
BidiType bidi_type;
|
||||
bidi_ts[i] = bidi_type = UCharGetBidiType(ucs[i]);
|
||||
ored_types |= bidi_type;
|
||||
|
||||
if (BIDI_IS_ISOLATE(bidi_type) || BIDI_IS_EXPLICIT(bidi_type))
|
||||
have_isolate = TRUE;
|
||||
if (BIDI_IS_NUMBER(bidi_type))
|
||||
have_number = TRUE;
|
||||
if (BIDI_IS_LETTER(bidi_type))
|
||||
have_letter = TRUE;
|
||||
|
||||
if (BIDI_IS_STRONG (bidi_type))
|
||||
anded_strongs &= bidi_type;
|
||||
|
||||
@@ -1784,14 +1799,16 @@ BidiLevel GUIAPI UBidiGetParagraphEmbeddingLevelsAlt(
|
||||
* o base_dir doesn't have an RTL taste.
|
||||
* o there are letters, and base_dir is weak.
|
||||
*/
|
||||
if (!BIDI_IS_ISOLATE (ored_types) &&
|
||||
if (!have_isolate /* BIDI_IS_ISOLATE (ored_types) */ &&
|
||||
!BIDI_IS_RTL (ored_types) &&
|
||||
!BIDI_IS_ARABIC (ored_types) &&
|
||||
(!BIDI_IS_RTL (base_dir) ||
|
||||
(BIDI_IS_WEAK (base_dir) &&
|
||||
BIDI_IS_LETTER (ored_types))
|
||||
have_letter /* BIDI_IS_LETTER (ored_types) */)
|
||||
))
|
||||
{
|
||||
_DBG_PRINTF("%s: have_isolate: %s, ored_types, base_dir: ");
|
||||
|
||||
/* all LTR */
|
||||
base_dir = BIDI_PGDIR_LTR;
|
||||
memset (els, 0, nr_ucs);
|
||||
@@ -1804,12 +1821,12 @@ BidiLevel GUIAPI UBidiGetParagraphEmbeddingLevelsAlt(
|
||||
* o base_dir has an RTL taste (may be weak).
|
||||
* o there are letters, and base_dir is weak.
|
||||
*/
|
||||
else if (!BIDI_IS_ISOLATE (ored_types) &&
|
||||
!BIDI_IS_NUMBER (ored_types) &&
|
||||
else if (!have_isolate /* BIDI_IS_ISOLATE (ored_types) */ &&
|
||||
!have_number /* BIDI_IS_NUMBER (ored_types) */ &&
|
||||
BIDI_IS_RTL (anded_strongs) &&
|
||||
(BIDI_IS_RTL (base_dir) ||
|
||||
(BIDI_IS_WEAK (base_dir) &&
|
||||
BIDI_IS_LETTER (ored_types))
|
||||
have_letter /* BIDI_IS_LETTER (ored_types) */)
|
||||
))
|
||||
{
|
||||
/* all RTL */
|
||||
|
||||
@@ -725,5 +725,25 @@ void __mg_glyph_run_letter_space(const GlyphRun* glyph_run,
|
||||
}
|
||||
}
|
||||
|
||||
void __mg_reverse_shaped_glyphs(ShapedGlyph* glyphs, int len)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < len / 2; i++) {
|
||||
ShapedGlyph tmp = glyphs[i];
|
||||
glyphs[i] = glyphs[len - 1 - i];
|
||||
glyphs[len - 1 - i] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
void __mg_reverse_log_clusters(int* clusters, int len)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < len / 2; i++) {
|
||||
int tmp = clusters[i];
|
||||
clusters[i] = clusters[len - 1 - i];
|
||||
clusters[len - 1 - i] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* _MGCHARSET_UNICODE */
|
||||
|
||||
|
||||
+19
-12
@@ -58,7 +58,7 @@
|
||||
**
|
||||
** - We provide two shaping engines for rendering the text. One is a
|
||||
** basic shaping engine and other is the complex shaping engine based
|
||||
** on HarzBuff. The former can be used for standard scripts.
|
||||
** on HarzBuff. The former can be used for some simple applications.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -366,42 +366,47 @@ static void shape_tab(LAYOUTLINE *line, GlyphString *glyphs)
|
||||
}
|
||||
|
||||
static void shape_space(const LAYOUTINFO* layout, const LayoutRun* lrun,
|
||||
GlyphString* glyphs)
|
||||
GlyphString* gstr)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
__mg_glyph_string_set_size (glyphs, lrun->len);
|
||||
__mg_glyph_string_set_size (gstr, lrun->len);
|
||||
|
||||
for (i = 0; i < lrun->len; i++) {
|
||||
UCharGeneralCategory gc;
|
||||
|
||||
gc = UCharGetCategory(lrun->ucs[i]);
|
||||
|
||||
glyphs->glyphs[i].gv = INV_GLYPH_VALUE;
|
||||
glyphs->glyphs[i].x_off = 0;
|
||||
glyphs->glyphs[i].y_off = 0;
|
||||
gstr->glyphs[i].gv = INV_GLYPH_VALUE;
|
||||
gstr->glyphs[i].x_off = 0;
|
||||
gstr->glyphs[i].y_off = 0;
|
||||
|
||||
_ERR_PRINTF("%s: gc of uc (%04x): %d\n",
|
||||
__FUNCTION__, lrun->ucs[i], gc);
|
||||
|
||||
if (gc == UCHAR_CATEGORY_SPACE_SEPARATOR) {
|
||||
Glyph32 space_gv = GetGlyphValue(lrun->lf, UCHAR_SPACE);
|
||||
glyphs->glyphs[i].width
|
||||
gstr->glyphs[i].width
|
||||
= _font_get_glyph_log_width(lrun->lf, space_gv);
|
||||
|
||||
_ERR_PRINTF("%s: space width: %d\n",
|
||||
__FUNCTION__, glyphs->glyphs[i].width);
|
||||
__FUNCTION__, gstr->glyphs[i].width);
|
||||
|
||||
if (IsUCharWide(lrun->ucs[i])) {
|
||||
glyphs->glyphs[i].width *= 2;
|
||||
gstr->glyphs[i].width *= 2;
|
||||
}
|
||||
}
|
||||
else {
|
||||
glyphs->glyphs[i].width = 0;
|
||||
gstr->glyphs[i].width = 0;
|
||||
}
|
||||
|
||||
glyphs->glyphs[i].is_cluster_start = 1;
|
||||
glyphs->log_clusters[i] = i;
|
||||
gstr->glyphs[i].is_cluster_start = 1;
|
||||
gstr->log_clusters[i] = i;
|
||||
|
||||
if (BIDI_LEVEL_IS_RTL(lrun->el) && gstr->nr_glyphs > 1) {
|
||||
__mg_reverse_shaped_glyphs(gstr->glyphs, gstr->nr_glyphs);
|
||||
__mg_reverse_log_clusters(gstr->log_clusters, gstr->nr_glyphs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1821,6 +1826,7 @@ out:
|
||||
return next_line;
|
||||
}
|
||||
|
||||
#ifdef _MGDEVEL_MODE
|
||||
BOOL GUIAPI GetLayoutLineInfo(LAYOUTLINE* line,
|
||||
int* line_no, int* max_extent, int* nr_chars, int* nr_glyphs,
|
||||
int** log_widths, int* width, int* height,
|
||||
@@ -1851,6 +1857,7 @@ BOOL GUIAPI GetLayoutLineInfo(LAYOUTLINE* line,
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _MGCHARSET_UNICODE */
|
||||
|
||||
|
||||
@@ -196,6 +196,9 @@ BOOL __mg_layout_line_ellipsize(LAYOUTLINE *line, int goal_width);
|
||||
int __mg_shape_layout_run(const TEXTRUNSINFO* info, const LayoutRun* run,
|
||||
GlyphString* glyphs);
|
||||
|
||||
void __mg_reverse_shaped_glyphs(ShapedGlyph* glyphs, int len);
|
||||
void __mg_reverse_log_clusters(int* clusters, int len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
@@ -66,26 +66,6 @@
|
||||
# define LOCAL_ARRAY_SIZE 128
|
||||
#endif
|
||||
|
||||
static void reverse_shaped_glyphs(ShapedGlyph* glyphs, int len)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < len / 2; i++) {
|
||||
ShapedGlyph tmp = glyphs[i];
|
||||
glyphs[i] = glyphs[len - 1 - i];
|
||||
glyphs[len - 1 - i] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
static void reverse_log_clusters(int* clusters, int len)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < len / 2; i++) {
|
||||
int tmp = clusters[i];
|
||||
clusters[i] = clusters[len - 1 - i];
|
||||
clusters[len - 1 - i] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
static BOOL shape_layout_run(SEInstance* inst,
|
||||
const TEXTRUNSINFO* info, const LayoutRun* run,
|
||||
GlyphString* gs)
|
||||
@@ -241,9 +221,9 @@ static BOOL shape_layout_run(SEInstance* inst,
|
||||
}
|
||||
|
||||
// reorder glyphs
|
||||
if (BIDI_LEVEL_IS_RTL(run->el)) {
|
||||
reverse_shaped_glyphs(gs->glyphs, gs->nr_glyphs);
|
||||
reverse_log_clusters(gs->log_clusters, gs->nr_glyphs);
|
||||
if (BIDI_LEVEL_IS_RTL(run->el) && gs->nr_glyphs > 1) {
|
||||
__mg_reverse_shaped_glyphs(gs->glyphs, gs->nr_glyphs);
|
||||
__mg_reverse_log_clusters(gs->log_clusters, gs->nr_glyphs);
|
||||
}
|
||||
|
||||
ok = TRUE;
|
||||
|
||||
Reference in New Issue
Block a user