diff --git a/src/newgdi/glyph-shaped.c b/src/newgdi/glyph-shaped.c index 7c4943f7..269ccf03 100644 --- a/src/newgdi/glyph-shaped.c +++ b/src/newgdi/glyph-shaped.c @@ -74,7 +74,7 @@ int DrawShapedGlyphLine(HDC hdc, const LAYOUTLINE* line, #if 0 int GUIAPI DrawShapedGlyphString(HDC hdc, LOGFONT* logfont_upright, LOGFONT* logfont_sideways, - const SHAPEDGLYPHS* shaped_glyphs, + const ShapedGlyphS* shaped_glyphs, const GLYPHPOS* glyph_pos, int nr_glyphs) { int i; diff --git a/src/newgdi/layout-ellipsize.c b/src/newgdi/layout-ellipsize.c index 59728f29..0b0584aa 100644 --- a/src/newgdi/layout-ellipsize.c +++ b/src/newgdi/layout-ellipsize.c @@ -109,7 +109,7 @@ typedef struct _LineIter LineIter; /* Keeps information about a single run */ struct _RunInfo { - GLYPHRUN *run; + GlyphRun *run; int start_offset; /* Character offset of run start */ int width; /* Width of run */ }; @@ -117,7 +117,7 @@ struct _RunInfo /* Iterator to a position within the ellipsized line */ struct _LineIter { - GlyphItemIter run_iter; + GlyphRunIter run_iter; int run_index; }; @@ -128,13 +128,13 @@ struct _EllipsizeState //PangoAttrList *attrs; /* Attributes used for itemization/shaping */ RunInfo *run_info; /* Array of information about each run */ - int n_runs; + int nr_runs; int total_width; /* Original width of line in Pango units */ int gap_center; /* Goal for center of gap */ - TEXTRUN *ellipsis_trun; /* Text run created to hold ellipsis */ - GLYPHRUN *ellipsis_grun; /* Glyph run created to hold ellipsis */ + TextRun *ellipsis_trun; /* Text run created to hold ellipsis */ + GlyphRun *ellipsis_grun; /* Glyph run created to hold ellipsis */ int ellipsis_width; /* Width of ellipsis, in Pango units */ int ellipsis_is_cjk; /* Whether the first character in the ellipsized * is wide; this triggers us to try to use a @@ -143,7 +143,7 @@ struct _EllipsizeState //PangoAttrIterator *line_start_attr; /* Cached PangoAttrIterator for the start of the run */ - LineIter gap_start_iter; /* Iteratator pointig to the first cluster in gap */ + LineIter gap_start_iter; /* Iteratator pointing to the first cluster in gap */ int gap_start_x; /* x position of start of gap, in Pango units */ //PangoAttrIterator *gap_start_attr; /* Attribute iterator pointing to a range containing the first character in gap */ @@ -161,15 +161,15 @@ static void init_state (EllipsizeState *state, LAYOUTLINE *line) state->layout = line->layout; - state->n_runs = line->nr_runs; - state->run_info = malloc(sizeof(RunInfo) * state->n_runs); + state->nr_runs = line->nr_runs; + state->run_info = malloc(sizeof(RunInfo) * state->nr_runs); start_offset = line->si; state->total_width = 0; i = 0; list_for_each (l, &line->gruns) { - GLYPHRUN *run = (GLYPHRUN*)l; + GlyphRun *run = (GlyphRun*)l; int width = __mg_glyph_string_get_width (run->gs); state->run_info[i].run = run; state->run_info[i].width = width; @@ -202,8 +202,8 @@ static void free_state (EllipsizeState *state) */ static int get_cluster_width (LineIter *iter) { - GlyphItemIter *run_iter = &iter->run_iter; - GLYPHSTRING *glyphs = run_iter->glyph_item->gs; + GlyphRunIter *run_iter = &iter->run_iter; + GlyphString *glyphs = run_iter->glyph_run->gs; int width = 0; int i; @@ -225,12 +225,12 @@ static int get_cluster_width (LineIter *iter) */ static BOOL line_iter_next_cluster (EllipsizeState *state, LineIter *iter) { - if (!__mg_glyph_item_iter_next_cluster (&iter->run_iter)) { - if (iter->run_index == state->n_runs - 1) + if (!__mg_glyph_run_iter_next_cluster (&iter->run_iter)) { + if (iter->run_index == state->nr_runs - 1) return FALSE; else { iter->run_index++; - __mg_glyph_item_iter_init_start (&iter->run_iter, + __mg_glyph_run_iter_init_start (&iter->run_iter, state->run_info[iter->run_index].run, state->layout->truninfo->ucs); } @@ -243,12 +243,12 @@ static BOOL line_iter_next_cluster (EllipsizeState *state, LineIter *iter) */ static BOOL line_iter_prev_cluster (EllipsizeState *state, LineIter *iter) { - if (!__mg_glyph_item_iter_prev_cluster (&iter->run_iter)) { + if (!__mg_glyph_run_iter_prev_cluster (&iter->run_iter)) { if (iter->run_index == 0) return FALSE; else { iter->run_index--; - __mg_glyph_item_iter_init_end (&iter->run_iter, + __mg_glyph_run_iter_init_end (&iter->run_iter, state->run_info[iter->run_index].run, state->layout->truninfo->ucs); } @@ -287,7 +287,7 @@ static BOOL ends_at_ellipsization_boundary (EllipsizeState *state, LineIter *ite { RunInfo *run_info = &state->run_info[iter->run_index]; - if (iter->run_iter.end_char == run_info->run->trun->len && iter->run_index == state->n_runs - 1) + if (iter->run_iter.end_char == run_info->run->trun->len && iter->run_index == state->nr_runs - 1) return TRUE; return state->layout->bos[run_info->start_offset + iter->run_iter.end_char + 1] & BOV_GB_CURSOR_POS; @@ -299,8 +299,8 @@ static BOOL ends_at_ellipsization_boundary (EllipsizeState *state, LineIter *ite static void shape_ellipsis (EllipsizeState *state) { Glyph32 ellipsis_gv; - TEXTRUN *text_run; - GLYPHSTRING *glyphs; + TextRun *text_run; + GlyphString *glyphs; Uchar32 ellipsis_ucs[3]; int nr_ucs = 0; int i; @@ -308,7 +308,7 @@ static void shape_ellipsis (EllipsizeState *state) /* Create/reset state->ellipsis_grun */ if (!state->ellipsis_grun) { - state->ellipsis_grun = malloc (sizeof(GlyphItem)); + state->ellipsis_grun = malloc (sizeof(GlyphRun)); state->ellipsis_grun->gs = __mg_glyph_string_new (); state->ellipsis_grun->trun = NULL; } @@ -455,8 +455,8 @@ static void update_ellipsis_shape (EllipsizeState *state) */ static void find_initial_span (EllipsizeState *state) { - GlyphItem *glyph_item; - GlyphItemIter *run_iter; + GlyphRun *glyph_run; + GlyphRunIter *run_iter; BOOL have_cluster; int i; int x; @@ -480,30 +480,29 @@ static void find_initial_span (EllipsizeState *state) /* Find the run containing the gap center */ x = 0; - for (i = 0; i < state->n_runs; i++) - { + for (i = 0; i < state->nr_runs; i++) { if (x + state->run_info[i].width > state->gap_center) break; x += state->run_info[i].width; } - if (i == state->n_runs) /* Last run is a closed interval, so back off one run */ - { + /* Last run is a closed interval, so back off one run */ + if (i == state->nr_runs) { i--; x -= state->run_info[i].width; } - /* Find the cluster containing the gap center - */ + /* Find the cluster containing the gap center */ state->gap_start_iter.run_index = i; run_iter = &state->gap_start_iter.run_iter; - glyph_item = state->run_info[i].run; + glyph_run = state->run_info[i].run; - cluster_width = 0; /* Quiet GCC, the line must have at least one cluster */ - for (have_cluster = __mg_glyph_item_iter_init_start (run_iter, glyph_item, state->layout->truninfo->ucs); + cluster_width = 0; // Quiet GCC, the line must have at least one cluster + for (have_cluster = __mg_glyph_run_iter_init_start(run_iter, glyph_run, + state->layout->truninfo->ucs); have_cluster; - have_cluster = __mg_glyph_item_iter_next_cluster (run_iter)) + have_cluster = __mg_glyph_run_iter_next_cluster (run_iter)) { cluster_width = get_cluster_width (&state->gap_start_iter); @@ -513,24 +512,22 @@ static void find_initial_span (EllipsizeState *state) x += cluster_width; } - if (!have_cluster) /* Last cluster is a closed interval, so back off one cluster */ + /* Last cluster is a closed interval, so back off one cluster */ + if (!have_cluster) x -= cluster_width; state->gap_end_iter = state->gap_start_iter; - state->gap_start_x = x; state->gap_end_x = x + cluster_width; /* Expand the gap to a full span */ - while (!starts_at_ellipsization_boundary (state, &state->gap_start_iter)) - { + while (!starts_at_ellipsization_boundary (state, &state->gap_start_iter)) { line_iter_prev_cluster (state, &state->gap_start_iter); state->gap_start_x -= get_cluster_width (&state->gap_start_iter); } - while (!ends_at_ellipsization_boundary (state, &state->gap_end_iter)) - { + while (!ends_at_ellipsization_boundary (state, &state->gap_end_iter)) { line_iter_next_cluster (state, &state->gap_end_iter); state->gap_end_x += get_cluster_width (&state->gap_end_iter); } @@ -603,8 +600,8 @@ static BOOL remove_one_span (EllipsizeState *state) */ static void fixup_ellipsis_grun (EllipsizeState *state) { - GLYPHSTRING *glyphs = state->ellipsis_grun->gs; - TEXTRUN *text_run = state->ellipsis_trun; + GlyphString *glyphs = state->ellipsis_grun->gs; + TextRun *text_run = state->ellipsis_trun; int level; int i; @@ -627,7 +624,7 @@ static void fixup_ellipsis_grun (EllipsizeState *state) text_run->el = level; - text_run->flags |= TEXTRUN_FLAG_IS_ELLIPSIS; + text_run->flags |= TextRun_FLAG_IS_ELLIPSIS; } #if 0 @@ -635,11 +632,11 @@ static void fixup_ellipsis_grun (EllipsizeState *state) */ static GSList * get_run_list (EllipsizeState *state) { - GlyphItem *partial_start_run = NULL; - GlyphItem *partial_end_run = NULL; + GlyphRun *partial_start_run = NULL; + GlyphRun *partial_end_run = NULL; GSList *result = NULL; RunInfo *run_info; - GlyphItemIter *run_iter; + GlyphRunIter *run_iter; int i; /* We first cut out the pieces of the starting and ending runs we want to @@ -651,7 +648,7 @@ static GSList * get_run_list (EllipsizeState *state) if (run_iter->end_char != run_info->run->trun->len) { partial_end_run = run_info->run; - run_info->run = pango_glyph_item_split (run_info->run, state->layout->truninfo->ucs, + run_info->run = pango_glyph_run_split (run_info->run, state->layout->truninfo->ucs, run_iter->end_index - run_info->run->trun->offset); } @@ -659,7 +656,7 @@ static GSList * get_run_list (EllipsizeState *state) run_iter = &state->gap_start_iter.run_iter; if (run_iter->start_char != 0) { - partial_start_run = pango_glyph_item_split (run_info->run, state->layout->truninfo->ucs, + partial_start_run = pango_glyph_run_split (run_info->run, state->layout->truninfo->ucs, run_iter->start_index - run_info->run->trun->offset); } @@ -676,13 +673,13 @@ static GSList * get_run_list (EllipsizeState *state) if (partial_end_run) result = g_slist_prepend (result, partial_end_run); - for (i = state->gap_end_iter.run_index + 1; i < state->n_runs; i++) + for (i = state->gap_end_iter.run_index + 1; i < state->nr_runs; i++) result = g_slist_prepend (result, state->run_info[i].run); /* And free the ones we didn't use */ for (i = state->gap_start_iter.run_index; i <= state->gap_end_iter.run_index; i++) - pango_glyph_item_free (state->run_info[i].run); + pango_glyph_run_free (state->run_info[i].run); return g_slist_reverse (result); } @@ -692,7 +689,8 @@ static GSList * get_run_list (EllipsizeState *state) */ static int current_width (EllipsizeState *state) { - return state->total_width - (state->gap_end_x - state->gap_start_x) + state->ellipsis_width; + return state->total_width - (state->gap_end_x - state->gap_start_x) + + state->ellipsis_width; } /** diff --git a/src/newgdi/layout-utils.c b/src/newgdi/layout-utils.c index b0fc99b9..8e2ff1a0 100644 --- a/src/newgdi/layout-utils.c +++ b/src/newgdi/layout-utils.c @@ -53,13 +53,13 @@ #include "unicode-ops.h" #include "layoutinfo.h" -GLYPHSTRING* __mg_glyph_string_new (void) +GlyphString* __mg_glyph_string_new (void) { - GLYPHSTRING *string = calloc(1, sizeof(GLYPHSTRING)); + GlyphString *string = calloc(1, sizeof(GlyphString)); return string; } -void __mg_glyph_string_free (GLYPHSTRING *string) +void __mg_glyph_string_free (GlyphString *string) { if (string == NULL) return; @@ -71,7 +71,7 @@ void __mg_glyph_string_free (GLYPHSTRING *string) free (string); } -void __mg_glyph_string_set_size (GLYPHSTRING* string, int new_len) +void __mg_glyph_string_set_size (GlyphString* string, int new_len) { if (new_len < 0) return; @@ -83,7 +83,7 @@ void __mg_glyph_string_set_size (GLYPHSTRING* string, int new_len) else { const unsigned int max_space = MIN (INT_MAX, - UINT_MAX / MAX (sizeof(SHAPEDGLYPH), sizeof(int))); + UINT_MAX / MAX (sizeof(ShapedGlyph), sizeof(int))); unsigned int more_space = (unsigned int)string->space * 2; @@ -100,13 +100,13 @@ void __mg_glyph_string_set_size (GLYPHSTRING* string, int new_len) } string->glyphs = realloc (string->glyphs, - string->space * sizeof (SHAPEDGLYPH)); + string->space * sizeof (ShapedGlyph)); string->log_clusters = realloc (string->log_clusters, string->space * sizeof (int)); string->nr_glyphs = new_len; } -int __mg_glyph_string_get_width(const GLYPHSTRING *glyphs) +int __mg_glyph_string_get_width(const GlyphString *glyphs) { int i; int width = 0; @@ -117,16 +117,125 @@ int __mg_glyph_string_get_width(const GLYPHSTRING *glyphs) return width; } -#define LTR(glyph_item) (((glyph_item)->trun->el & 1) == 0) +#define LTR(glyph_run) (((glyph_run)->trun->el & 1) == 0) -BOOL __mg_glyph_item_iter_next_cluster (GlyphItemIter *iter) +/** + * __mg_glyph_run_split: + * @orig: a #PangoItem + * @text: text to which positions in @orig apply + * @split_index: byte index of position to split item, relative to the start of the item + * + * Modifies @orig to cover only the text after @split_index, and + * returns a new item that covers the text before @split_index that + * used to be in @orig. You can think of @split_index as the length of + * the returned item. @split_index may not be 0, and it may not be + * greater than or equal to the length of @orig (that is, there must + * be at least one byte assigned to each item, you can't create a + * zero-length item). + * + * This function is similar in function to pango_item_split() (and uses + * it internally.) + * + * Return value: the newly allocated item representing text before + * @split_index, which should be freed + * with pango_glyph_run_free(). + * + * Since: 1.2 + **/ +GlyphRun *__mg_glyph_run_split (GlyphRun *orig, + const char *text, int split_index) +{ + GlyphRun *new_grun; + int i; + int nr_glyphs; + int num_remaining; + + if (orig == NULL) + return NULL; + if (orig->trun->len <= 0) + return NULL; + if (split_index <= 0) + return NULL; + if (split_index >= orig->trun->len) + return NULL; + + if (LTR (orig)) { + for (i = 0; i < orig->gs->nr_glyphs; i++) { + if (orig->gs->log_clusters[i] >= split_index) + break; + } + + if (i == orig->gs->nr_glyphs) + // No splitting necessary + return NULL; + + split_index = orig->gs->log_clusters[i]; + nr_glyphs = i; + } + else { + for (i = orig->gs->nr_glyphs - 1; i >= 0; i--) { + if (orig->gs->log_clusters[i] >= split_index) + break; + } + + if (i < 0) + // No splitting necessary + return NULL; + + split_index = orig->gs->log_clusters[i]; + nr_glyphs = orig->gs->nr_glyphs - 1 - i; + } + + num_remaining = orig->gs->nr_glyphs - nr_glyphs; + + new_grun = malloc (sizeof(GlyphRun)); + new_grun->trun = __mg_text_run_split (orig->trun, split_index); + + new_grun->gs = __mg_glyph_string_new (); + __mg_glyph_string_set_size (new_grun->gs, nr_glyphs); + + if (LTR (orig)) { + memcpy(new_grun->gs->glyphs, + orig->gs->glyphs, + nr_glyphs * sizeof(ShapedGlyph)); + memcpy(new_grun->gs->log_clusters, + orig->gs->log_clusters, + nr_glyphs * sizeof(int)); + + memmove (orig->gs->glyphs, + orig->gs->glyphs + nr_glyphs, + num_remaining * sizeof(ShapedGlyph)); + for (i = nr_glyphs; i < orig->gs->nr_glyphs; i++) + orig->gs->log_clusters[i - nr_glyphs] = + orig->gs->log_clusters[i] - split_index; + } + else { + memcpy (new_grun->gs->glyphs, + orig->gs->glyphs + num_remaining, + nr_glyphs * sizeof(ShapedGlyph)); + memcpy (new_grun->gs->log_clusters, + orig->gs->log_clusters + num_remaining, + nr_glyphs * sizeof(int)); + + for (i = 0; i < num_remaining; i++) + orig->gs->log_clusters[i] = + orig->gs->log_clusters[i] - split_index; + } + + __mg_glyph_string_set_size (orig->gs, + orig->gs->nr_glyphs - nr_glyphs); + + return new_grun; +} + +BOOL __mg_glyph_run_iter_next_cluster (GlyphRunIter *iter) { int glyph_index = iter->end_glyph; - GLYPHSTRING *glyphs = iter->glyph_item->gs; + GlyphString *glyphs = iter->glyph_run->gs; int cluster; - const TEXTRUN *item = iter->glyph_item->trun; + const TextRun *item = iter->glyph_run->trun; - if (LTR (iter->glyph_item)) { + if (LTR (iter->glyph_run)) { if (glyph_index == glyphs->nr_glyphs) return FALSE; } @@ -139,7 +248,7 @@ BOOL __mg_glyph_item_iter_next_cluster (GlyphItemIter *iter) iter->start_index = iter->end_index; iter->start_char = iter->end_char; - if (LTR (iter->glyph_item)) { + if (LTR (iter->glyph_run)) { cluster = glyphs->log_clusters[glyph_index]; while (TRUE) { glyph_index++; @@ -183,14 +292,14 @@ BOOL __mg_glyph_item_iter_next_cluster (GlyphItemIter *iter) return TRUE; } -BOOL __mg_glyph_item_iter_prev_cluster (GlyphItemIter *iter) +BOOL __mg_glyph_run_iter_prev_cluster (GlyphRunIter *iter) { int glyph_index = iter->start_glyph; - GLYPHSTRING *glyphs = iter->glyph_item->gs; + GlyphString *glyphs = iter->glyph_run->gs; int cluster; - const TEXTRUN *item = iter->glyph_item->trun; + const TextRun *item = iter->glyph_run->trun; - if (LTR (iter->glyph_item)) { + if (LTR (iter->glyph_run)) { if (glyph_index == 0) return FALSE; } @@ -203,7 +312,7 @@ BOOL __mg_glyph_item_iter_prev_cluster (GlyphItemIter *iter) iter->end_index = iter->start_index; iter->end_char = iter->start_char; - if (LTR (iter->glyph_item)) { + if (LTR (iter->glyph_run)) { cluster = glyphs->log_clusters[glyph_index - 1]; while (TRUE) { @@ -252,18 +361,18 @@ BOOL __mg_glyph_item_iter_prev_cluster (GlyphItemIter *iter) return TRUE; } -BOOL __mg_glyph_item_iter_init_start (GlyphItemIter *iter, - const GlyphItem *glyph_item, const Uchar32 *text) +BOOL __mg_glyph_run_iter_init_start (GlyphRunIter *iter, + const GlyphRun *glyph_run, const Uchar32 *text) { - iter->glyph_item = glyph_item; + iter->glyph_run = glyph_run; iter->text = text; - if (LTR (glyph_item)) + if (LTR (glyph_run)) iter->end_glyph = 0; else - iter->end_glyph = glyph_item->gs->nr_glyphs - 1; + iter->end_glyph = glyph_run->gs->nr_glyphs - 1; - iter->end_index = glyph_item->trun->si; + iter->end_index = glyph_run->trun->si; iter->end_char = 0; iter->start_glyph = iter->end_glyph; @@ -271,49 +380,49 @@ BOOL __mg_glyph_item_iter_init_start (GlyphItemIter *iter, iter->start_char = iter->end_char; /* Advance onto the first cluster of the glyph item */ - return __mg_glyph_item_iter_next_cluster (iter); + return __mg_glyph_run_iter_next_cluster (iter); } -BOOL __mg_glyph_item_iter_init_end (GlyphItemIter *iter, - const GlyphItem *glyph_item, const Uchar32 *text) +BOOL __mg_glyph_run_iter_init_end (GlyphRunIter *iter, + const GlyphRun *glyph_run, const Uchar32 *text) { - iter->glyph_item = glyph_item; + iter->glyph_run = glyph_run; iter->text = text; - if (LTR (glyph_item)) - iter->start_glyph = glyph_item->gs->nr_glyphs; + if (LTR (glyph_run)) + iter->start_glyph = glyph_run->gs->nr_glyphs; else iter->start_glyph = -1; - iter->start_index = glyph_item->trun->si + glyph_item->trun->len; - iter->start_char = glyph_item->trun->len; + iter->start_index = glyph_run->trun->si + glyph_run->trun->len; + iter->start_char = glyph_run->trun->len; iter->end_glyph = iter->start_glyph; iter->end_index = iter->start_index; iter->end_char = iter->start_char; /* Advance onto the first cluster of the glyph item */ - return __mg_glyph_item_iter_prev_cluster (iter); + return __mg_glyph_run_iter_prev_cluster (iter); } -void __mg_glyph_item_get_logical_widths (const GlyphItem *glyph_item, +void __mg_glyph_run_get_logical_widths (const GlyphRun *glyph_run, const Uchar32 *text, int *logical_widths) { - GlyphItemIter iter; + GlyphRunIter iter; BOOL has_cluster; int dir; - dir = glyph_item->trun->el % 2 == 0 ? +1 : -1; - for (has_cluster = __mg_glyph_item_iter_init_start (&iter, glyph_item, text); + dir = glyph_run->trun->el % 2 == 0 ? +1 : -1; + for (has_cluster = __mg_glyph_run_iter_init_start (&iter, glyph_run, text); has_cluster; - has_cluster = __mg_glyph_item_iter_next_cluster (&iter)) + has_cluster = __mg_glyph_run_iter_next_cluster (&iter)) { int glyph_index, char_index, num_chars, cluster_width = 0, char_width; for (glyph_index = iter.start_glyph; glyph_index != iter.end_glyph; glyph_index += dir) { - cluster_width += glyph_item->gs->glyphs[glyph_index].width; + cluster_width += glyph_run->gs->glyphs[glyph_index].width; } num_chars = iter.end_char - iter.start_char; @@ -334,7 +443,7 @@ void __mg_glyph_item_get_logical_widths (const GlyphItem *glyph_item, } } -void __mg_glyph_item_letter_space (const GlyphItem* glyph_item, +void __mg_glyph_run_letter_space (const GlyphRun* glyph_run, const Uchar32* ucs, const BreakOppo* bos, int letter_spacing) { } diff --git a/src/newgdi/layoutinfo.c b/src/newgdi/layoutinfo.c index ea08b10e..db6f5f8b 100644 --- a/src/newgdi/layoutinfo.c +++ b/src/newgdi/layoutinfo.c @@ -84,7 +84,7 @@ LAYOUTINFO* GUIAPI CreateLayoutInfo( return layout; } -static void release_glyph_string(GLYPHSTRING* gs) +static void release_glyph_string(GlyphString* gs) { if (gs->glyphs) free (gs->glyphs); @@ -94,7 +94,7 @@ static void release_glyph_string(GLYPHSTRING* gs) free(gs); } -static void release_run(GLYPHRUN* run) +static void release_run(GlyphRun* run) { if (run->gs) { release_glyph_string(run->gs); @@ -106,7 +106,7 @@ static void release_run(GLYPHRUN* run) static void release_line(LAYOUTLINE* line) { while (!list_empty(&line->gruns)) { - GLYPHRUN* run = (GLYPHRUN*)line->gruns.prev; + GlyphRun* run = (GlyphRun*)line->gruns.prev; list_del(line->gruns.prev); release_run(run); } @@ -154,7 +154,7 @@ struct _LayoutState { // Line of the paragraph, starting at 1 for first line int line_of_par; // Glyphs for the current glyph run - GLYPHSTRING* glyphs; + GlyphString* glyphs; // Logical widths for the current text run */ int *log_widths; // Offset into log_widths to the point corresponding @@ -168,7 +168,7 @@ struct _LayoutState { // Start index of line in layout->text int line_start_index; // Current text run - const TEXTRUN* item; + TextRun* item; // Start index of line in current item */ int start_index_in_item; // the number of not fit uchars in current text run @@ -194,12 +194,12 @@ static BOOL should_ellipsize_current_line(LAYOUTINFO *layout, return TRUE; } -static void shape_tab(LAYOUTLINE *line, GLYPHSTRING *glyphs) +static void shape_tab(LAYOUTLINE *line, GlyphString *glyphs) { } static void shape_shape(const Uchar32* ucs, int nr_ucs, - RECT* ink_rc, RECT* log_rc, GLYPHSTRING *glyphs) + RECT* ink_rc, RECT* log_rc, GlyphString *glyphs) { unsigned int i; @@ -218,8 +218,8 @@ static void shape_shape(const Uchar32* ucs, int nr_ucs, static void shape_full(const Uchar32* item_ucs, int nr_item_ucs, const Uchar32* para_ucs, int nr_para_ucs, - const TEXTRUNSINFO* truninfo, const TEXTRUN* textrun, - GLYPHSTRING* glyphs) + const TEXTRUNSINFO* truninfo, TextRun* textrun, + GlyphString* glyphs) { } @@ -235,11 +235,11 @@ static void distribute_letter_spacing (int letter_spacing, *space_right = letter_spacing - *space_left; } -static GLYPHSTRING* shape_run(LAYOUTLINE *line, LayoutState *state, - const TEXTRUN *item, int offset, int len) +static GlyphString* shape_run(LAYOUTLINE *line, LayoutState *state, + TextRun *item, int offset, int len) { LAYOUTINFO *layout = line->layout; - GLYPHSTRING *glyphs = __mg_glyph_string_new (); + GlyphString *glyphs = __mg_glyph_string_new (); if (layout->truninfo->ucs[item->si + offset] == '\t') shape_tab(line, glyphs); @@ -254,15 +254,15 @@ static GLYPHSTRING* shape_run(LAYOUTLINE *line, LayoutState *state, layout->truninfo, item, glyphs); if (layout->ls) { - GlyphItem glyph_item; + GlyphRun glyph_run; int space_left, space_right; - glyph_item.trun = item; - glyph_item.gs = glyphs; - glyph_item.so = offset; - glyph_item.len = len; + glyph_run.trun = item; + glyph_run.gs = glyphs; + glyph_run.so = offset; + glyph_run.len = len; - __mg_glyph_item_letter_space (&glyph_item, + __mg_glyph_run_letter_space (&glyph_run, layout->truninfo->ucs, layout->bos + state->start_offset, layout->ls); @@ -278,18 +278,18 @@ static GLYPHSTRING* shape_run(LAYOUTLINE *line, LayoutState *state, return glyphs; } -static void free_run (GLYPHRUN *run) +static void free_run (GlyphRun *run) { __mg_glyph_string_free(run->gs); free(run); } -static const TEXTRUN *uninsert_run (LAYOUTLINE *line) +static TextRun *uninsert_run (LAYOUTLINE *line) { - GLYPHRUN *run; - const TEXTRUN *item; + GlyphRun *run; + TextRun *item; - run = (GLYPHRUN*)&line->gruns.next; + run = (GlyphRun*)&line->gruns.next; item = run->trun; list_del(line->gruns.next); @@ -299,10 +299,10 @@ static const TEXTRUN *uninsert_run (LAYOUTLINE *line) return item; } -static GLYPHRUN* insert_run(LAYOUTLINE *line, LayoutState *state, - const TEXTRUN *text_run, int so, int len, BOOL last_run) +static GlyphRun* insert_run(LAYOUTLINE *line, LayoutState *state, + TextRun *text_run, int so, int len, BOOL last_run) { - GLYPHRUN *glyph_run = malloc(sizeof(GLYPHRUN)); + GlyphRun *glyph_run = malloc(sizeof(GlyphRun)); glyph_run->trun = text_run; glyph_run->so = so; @@ -386,7 +386,7 @@ BreakResult process_text_run(LAYOUTINFO *layout, LAYOUTLINE *line, LayoutState *state, BOOL force_fit, BOOL no_break_at_end) { - const TEXTRUN *item = state->item; + TextRun *item = state->item; BOOL shape_set = FALSE; int width; int i; @@ -447,12 +447,12 @@ BreakResult process_text_run(LAYOUTINFO *layout, if (processing_new_item) { - GlyphItem glyph_item; - glyph_item.trun = item; - glyph_item.gs = state->glyphs; + GlyphRun glyph_run; + glyph_run.trun = item; + glyph_run.gs = state->glyphs; state->log_widths = malloc (sizeof (int) * item->len); - __mg_glyph_item_get_logical_widths(&glyph_item, layout->truninfo->ucs, + __mg_glyph_run_get_logical_widths(&glyph_run, layout->truninfo->ucs, state->log_widths); } @@ -513,7 +513,7 @@ retry_break: return BREAK_EMPTY_FIT; } else { - GLYPHRUN *grun; + GlyphRun *grun; /* Add the width back, to the line, reshape, subtract the new width */ @@ -622,7 +622,7 @@ static void layout_line_reorder(LAYOUTLINE *line) */ list_for_each(i, &line->gruns) { - GLYPHRUN *grun = (GLYPHRUN*)i; + GlyphRun *grun = (GlyphRun*)i; level_or |= grun->trun->el; level_and &= grun->trun->el; @@ -643,11 +643,11 @@ static void layout_line_reorder(LAYOUTLINE *line) } static void zero_line_final_space (LAYOUTLINE *line, - LayoutState *state, GLYPHRUN *run) + LayoutState *state, GlyphRun *run) { LAYOUTINFO *layout = line->layout; - const TEXTRUN *item = run->trun; - GLYPHSTRING *glyphs = run->gs; + TextRun *item = run->trun; + GlyphString *glyphs = run->gs; int glyph = item->el % 2 ? 0 : glyphs->nr_glyphs - 1; /* if the final char of line forms a cluster, and it's @@ -666,7 +666,7 @@ static void zero_line_final_space (LAYOUTLINE *line, glyphs->glyphs[glyph].width = 0; } -static void pad_glyphstring_right (GLYPHSTRING *glyphs, +static void pad_glyphstring_right (GlyphString *glyphs, LayoutState *state, int adjustment) { int glyph = glyphs->nr_glyphs - 1; @@ -685,7 +685,7 @@ static void pad_glyphstring_right (GLYPHSTRING *glyphs, } } -static void pad_glyphstring_left (GLYPHSTRING *glyphs, +static void pad_glyphstring_left (GlyphString *glyphs, LayoutState *state, int adjustment) { int glyph = 0; @@ -701,7 +701,7 @@ static void pad_glyphstring_left (GLYPHSTRING *glyphs, glyphs->glyphs[glyph].x_off += adjustment; } -static inline BOOL is_tab_run(LAYOUTINFO *layout, GLYPHRUN *grun) +static inline BOOL is_tab_run(LAYOUTINFO *layout, GlyphRun *grun) { return (layout->truninfo->ucs[grun->trun->si] == '\t'); } @@ -722,7 +722,7 @@ static void adjust_line_letter_spacing(LAYOUTLINE *line, LayoutState *state) { LAYOUTINFO *layout = line->layout; BOOL reversed; - GLYPHRUN *last_run; + GlyphRun *last_run; int tab_adjustment; struct list_head *l; @@ -734,7 +734,7 @@ static void adjust_line_letter_spacing(LAYOUTLINE *line, LayoutState *state) reversed = FALSE; if (line->resolved_dir == GLYPH_RUN_DIR_RTL) { list_for_each(l, &line->gruns) { - if (is_tab_run (layout, (GLYPHRUN*)l)) { + if (is_tab_run (layout, (GlyphRun*)l)) { reverse_runs(line); reversed = TRUE; break; @@ -755,14 +755,14 @@ static void adjust_line_letter_spacing(LAYOUTLINE *line, LayoutState *state) last_run = NULL; tab_adjustment = 0; list_for_each(l, &line->gruns) { - GLYPHRUN *run = (GLYPHRUN*)l; - GLYPHRUN *next_run; + GlyphRun *run = (GlyphRun*)l; + GlyphRun *next_run; if (l->next == &line->gruns) { next_run = NULL; } else { - next_run = (GLYPHRUN*)l->next; + next_run = (GlyphRun*)l->next; } if (is_tab_run (layout, run)) { @@ -770,8 +770,8 @@ static void adjust_line_letter_spacing(LAYOUTLINE *line, LayoutState *state) tab_adjustment = 0; } else { - GLYPHRUN *visual_next_run = reversed ? last_run : next_run; - GLYPHRUN *visual_last_run = reversed ? next_run : last_run; + GlyphRun *visual_next_run = reversed ? last_run : next_run; + GlyphRun *visual_last_run = reversed ? next_run : last_run; int run_spacing = line->layout->ls; int space_left, space_right; @@ -828,7 +828,7 @@ static void justify_clusters (LAYOUTLINE *line, LayoutState *state) for (mode = MEASURE; mode <= ADJUST; mode++) { BOOL leftedge = TRUE; - GLYPHSTRING *rightmost_glyphs = NULL; + GlyphString *rightmost_glyphs = NULL; int rightmost_space = 0; int residual = 0; @@ -836,9 +836,9 @@ static void justify_clusters (LAYOUTLINE *line, LayoutState *state) gaps_so_far = 0; list_for_each(run_iter, &line->gruns) { - GLYPHRUN *run = (GLYPHRUN*)run_iter; - GLYPHSTRING *glyphs = run->gs; - GlyphItemIter cluster_iter; + GlyphRun *run = (GlyphRun*)run_iter; + GlyphString *glyphs = run->gs; + GlyphRunIter cluster_iter; BOOL have_cluster; int dir; int offset; @@ -857,14 +857,14 @@ static void justify_clusters (LAYOUTLINE *line, LayoutState *state) offset = state->line_start_index + run->trun->si; if ((have_cluster = (dir > 0))) - __mg_glyph_item_iter_init_start(&cluster_iter, run, text); + __mg_glyph_run_iter_init_start(&cluster_iter, run, text); else - __mg_glyph_item_iter_init_end(&cluster_iter, run, text); + __mg_glyph_run_iter_init_end(&cluster_iter, run, text); for (; have_cluster; have_cluster = dir > 0 ? - __mg_glyph_item_iter_next_cluster (&cluster_iter) : - __mg_glyph_item_iter_prev_cluster (&cluster_iter)) { + __mg_glyph_run_iter_next_cluster (&cluster_iter) : + __mg_glyph_run_iter_prev_cluster (&cluster_iter)) { int i; int width = 0; @@ -975,19 +975,19 @@ static void justify_words (LAYOUTLINE *line, spaces_so_far = 0; list_for_each(run_iter, &line->gruns) { - GLYPHRUN *run = (GLYPHRUN *)run_iter; - GLYPHSTRING *glyphs = run->gs; - GlyphItemIter cluster_iter; + GlyphRun *run = (GlyphRun *)run_iter; + GlyphString *glyphs = run->gs; + GlyphRunIter cluster_iter; BOOL have_cluster; int offset; assert(run->trun->si >= state->line_start_index); offset = state->line_start_index + run->trun->si; - for (have_cluster = __mg_glyph_item_iter_init_start (&cluster_iter, + for (have_cluster = __mg_glyph_run_iter_init_start (&cluster_iter, run, text); have_cluster; - have_cluster = __mg_glyph_item_iter_next_cluster (&cluster_iter)) + have_cluster = __mg_glyph_run_iter_next_cluster (&cluster_iter)) { int i; int dir; @@ -1045,7 +1045,7 @@ static int layout_line_get_width (LAYOUTLINE *line) struct list_head* i; list_for_each(i, &line->gruns) { - GLYPHRUN *run = (GLYPHRUN*)i; + GlyphRun *run = (GlyphRun*)i; width += __mg_glyph_string_get_width (run->gs); } @@ -1063,7 +1063,7 @@ static void layout_line_postprocess (LAYOUTLINE *line, /* The runs are in reverse order at this point, * since we prepended them to the list. * So, the first run is the last logical run. */ - zero_line_final_space (line, state, (GLYPHRUN*)&line->gruns.next); + zero_line_final_space (line, state, (GlyphRun*)&line->gruns.next); /* * Reverse the runs @@ -1141,7 +1141,7 @@ static LAYOUTLINE* check_next_line(LAYOUTINFO* layout, LayoutState* state) state->remaining_width = state->line_width; while (state->item) { - const TEXTRUN *item = state->item; + TextRun *item = state->item; BreakResult result; int old_num_chars; int old_remaining_width; @@ -1267,7 +1267,7 @@ LAYOUTLINE* GUIAPI LayoutNextLine( goto next_line; } - state.item = (TEXTRUN*)&layout->truninfo->truns.next; + state.item = (TextRun*)&layout->truninfo->truns.next; state.start_index_in_item = 0; state.left_ucs_in_item = state.item->len; } diff --git a/src/newgdi/layoutinfo.h b/src/newgdi/layoutinfo.h index b695ade5..2504fe6d 100644 --- a/src/newgdi/layoutinfo.h +++ b/src/newgdi/layoutinfo.h @@ -44,10 +44,10 @@ #include "list.h" #include "textrunsinfo.h" -typedef struct _GLYPHRUN GLYPHRUN; -typedef struct _SHAPEDGLYPH SHAPEDGLYPH; +typedef struct _GlyphRun GlyphRun; +typedef struct _ShapedGlyph ShapedGlyph; -struct _SHAPEDGLYPH { +struct _ShapedGlyph { Glyph32 gv; int x_off; int y_off; @@ -56,18 +56,18 @@ struct _SHAPEDGLYPH { Uint32 is_cluster_start:1; }; -struct _GLYPHSTRING { - SHAPEDGLYPH* glyphs; +struct _GlyphString { + ShapedGlyph* glyphs; int* log_clusters; int nr_glyphs; unsigned int space; }; -struct _GLYPHRUN { +struct _GlyphRun { struct list_head list; - const TEXTRUN* trun; // the text run to which this glyph run belongs - GLYPHSTRING* gs; // the glyph string + TextRun* trun; // the text run corresponding to the glyph run + GlyphString* gs; // the glyph string int so; // the start offset in the text run int len; // the number of the uchars }; @@ -107,11 +107,10 @@ struct _LAYOUTINFO { Uint32 is_ellipsized:1; }; -typedef GLYPHRUN GlyphItem; -typedef struct _GlyphItemIter GlyphItemIter; +typedef struct _GlyphRunIter GlyphRunIter; -struct _GlyphItemIter { - const GlyphItem *glyph_item; +struct _GlyphRunIter { + const GlyphRun *glyph_run; const Uchar32 *text; int start_glyph; @@ -127,35 +126,35 @@ struct _GlyphItemIter { extern "C" { #endif /* __cplusplus */ -void __mg_text_run_free(TEXTRUN* trun); +void __mg_text_run_free(TextRun* trun); -GLYPHSTRING* __mg_glyph_string_new(void); -void __mg_glyph_string_free(GLYPHSTRING* string); -void __mg_glyph_string_set_size(GLYPHSTRING* string, int new_len); -int __mg_glyph_string_get_width(const GLYPHSTRING* string); +GlyphString* __mg_glyph_string_new(void); +void __mg_glyph_string_free(GlyphString* string); +void __mg_glyph_string_set_size(GlyphString* string, int new_len); +int __mg_glyph_string_get_width(const GlyphString* string); -BOOL __mg_glyph_item_iter_init_start (GlyphItemIter *iter, - const GlyphItem *glyph_item, const Uchar32 *text); +BOOL __mg_glyph_run_iter_init_start (GlyphRunIter *iter, + const GlyphRun *glyph_run, const Uchar32 *text); -BOOL __mg_glyph_item_iter_init_end (GlyphItemIter *iter, - const GlyphItem *glyph_item, const Uchar32 *text); +BOOL __mg_glyph_run_iter_init_end (GlyphRunIter *iter, + const GlyphRun *glyph_run, const Uchar32 *text); -BOOL __mg_glyph_item_iter_prev_cluster (GlyphItemIter *iter); -BOOL __mg_glyph_item_iter_next_cluster (GlyphItemIter *iter); +BOOL __mg_glyph_run_iter_prev_cluster (GlyphRunIter *iter); +BOOL __mg_glyph_run_iter_next_cluster (GlyphRunIter *iter); -void __mg_glyph_item_get_logical_widths(const GlyphItem* glyph_item, +void __mg_glyph_run_get_logical_widths(const GlyphRun* glyph_run, const Uchar32* ucs, int* log_widths); -void __mg_glyph_item_letter_space (const GlyphItem* glyph_item, +void __mg_glyph_run_letter_space (const GlyphRun* glyph_run, const Uchar32* ucs, const BreakOppo* bos, int letter_spacing); BOOL __mg_layout_line_ellipsize(LAYOUTLINE *line, int goal_width); -int __mg_shape_text_run(const TEXTRUNSINFO* info, const TEXTRUN* run, - int so, int len, GLYPHSTRING* glyphs); +int __mg_shape_text_run(const TEXTRUNSINFO* info, const TextRun* run, + int so, int len, GlyphString* glyphs); void __mg_shape_utf8 (const char* text, int len, - const TEXTRUN* trun, GLYPHSTRING* gs); + const TextRun* trun, GlyphString* gs); #ifdef __cplusplus } diff --git a/src/newgdi/shape-glyphs-basic.c b/src/newgdi/shape-glyphs-basic.c index 31f414d1..2433a3e0 100644 --- a/src/newgdi/shape-glyphs-basic.c +++ b/src/newgdi/shape-glyphs-basic.c @@ -67,19 +67,19 @@ #endif -static void reverse_shaped_glyphs(SHAPEDGLYPH* glyphs, int len) +static void reverse_shaped_glyphs(ShapedGlyph* glyphs, int len) { int i; for (i = 0; i < len / 2; i++) { - SHAPEDGLYPH tmp = glyphs[i]; + ShapedGlyph tmp = glyphs[i]; glyphs[i] = glyphs[len - 1 - i]; glyphs[len - 1 - i] = tmp; } } -static BOOL shape_text_run(SEINSTANCE* inst, - const TEXTRUNSINFO* info, const TEXTRUN* run, - GLYPHSTRING* gs) +static BOOL shape_text_run(SEInstance* inst, + const TEXTRUNSINFO* info, const TextRun* run, + GlyphString* gs) { BOOL ok = FALSE; int i, j; @@ -162,7 +162,7 @@ static BOOL shape_text_run(SEINSTANCE* inst, } // generate the glyphs - gs->glyphs = malloc(sizeof(SHAPEDGLYPH) * nr_ucs); + gs->glyphs = malloc(sizeof(ShapedGlyph) * nr_ucs); if (gs->glyphs == NULL) { goto out; } diff --git a/src/newgdi/textrunsinfo.c b/src/newgdi/textrunsinfo.c index 549b4879..ce0ac49a 100644 --- a/src/newgdi/textrunsinfo.c +++ b/src/newgdi/textrunsinfo.c @@ -71,11 +71,11 @@ enum { EMOJI_CHANGED = 1 << 6, }; -typedef struct _TEXTRUNSTATE { +typedef struct _TextRunSTATE { TEXTRUNSINFO* runinfo; const Uchar32* text; const Uchar32* end; - TEXTRUN* run; + TextRun* run; const Uchar32* run_start; const Uchar32* run_end; @@ -96,9 +96,9 @@ typedef struct _TEXTRUNSTATE { LanguageCode derived_lang; -} TEXTRUNSTATE; +} TextRunSTATE; -static void update_embedding_end(TEXTRUNSTATE *state) +static void update_embedding_end(TextRunSTATE *state) { state->emb_level = state->els[state->emb_end_offset]; while (state->emb_end < state->end && @@ -111,7 +111,7 @@ static void update_embedding_end(TEXTRUNSTATE *state) state->changed |= EMBEDDING_CHANGED; } -static void update_end (TEXTRUNSTATE *state) +static void update_end (TextRunSTATE *state) { state->run_end = state->emb_end; if (state->script_iter.end < state->run_end) @@ -141,7 +141,7 @@ static LanguageCode compute_derived_language (LanguageCode lang, return derived_lang; } -static void state_update_for_new_run (TEXTRUNSTATE *state) +static void state_update_for_new_run (TextRunSTATE *state) { if (state->changed & (SCRIPT_CHANGED | WIDTH_CHANGED)) { GlyphOrient orient = state->runinfo->ort_base; @@ -166,7 +166,7 @@ static void state_update_for_new_run (TEXTRUNSTATE *state) /* Use MiniGUI resource manager to avoid duplicated logfonts */ LOGFONT* __mg_create_logfont_for_run(const TEXTRUNSINFO* runinfo, - const TEXTRUN* run) + const TextRun* run) { char fontname[LEN_LOGFONT_NAME_FULL + 1]; int orient_pos = fontGetOrientPosFromName(runinfo->fontname); @@ -207,7 +207,7 @@ LOGFONT* __mg_create_logfont_for_run(const TEXTRUNSINFO* runinfo, } void __mg_release_logfont_for_run(const TEXTRUNSINFO* runinfo, - const TEXTRUN* run) + const TextRun* run) { char fontname[LEN_LOGFONT_NAME_FULL + 1]; int orient_pos = fontGetOrientPosFromName(runinfo->fontname); @@ -239,7 +239,7 @@ void __mg_release_logfont_for_run(const TEXTRUNSINFO* runinfo, ReleaseRes(Str2Key(fontname)); } -static void state_add_character(TEXTRUNSTATE *state, +static void state_add_character(TextRunSTATE *state, BOOL no_shaping, BOOL force_break, const Uchar32* pos) { if (state->run) { @@ -252,7 +252,7 @@ static void state_add_character(TEXTRUNSTATE *state, } } - state->run = malloc(sizeof(TEXTRUN)); + state->run = malloc(sizeof(TextRun)); state->run->si = pos - state->text; state->run->len = 1; state->run->lc = state->derived_lang; @@ -295,13 +295,13 @@ static void state_add_character(TEXTRUNSTATE *state, } state->run->flags = state->centered_baseline ? - TEXTRUN_FLAG_CENTERED_BASELINE : 0; + TextRun_FLAG_CENTERED_BASELINE : 0; list_add_tail(&state->run->list, &state->runinfo->truns); state->runinfo->nr_runs++; } -static BOOL state_process_run (TEXTRUNSTATE *state) +static BOOL state_process_run (TextRunSTATE *state) { const Uchar32* p; BOOL last_was_forced_break = FALSE; @@ -332,7 +332,7 @@ static BOOL state_process_run (TEXTRUNSTATE *state) return TRUE; } -static BOOL state_next (TEXTRUNSTATE *state) +static BOOL state_next (TextRunSTATE *state) { if (state->run_end == state->end) return FALSE; @@ -367,7 +367,7 @@ static BOOL state_next (TEXTRUNSTATE *state) static BOOL create_text_runs(TEXTRUNSINFO* runinfo, BidiLevel* els) { BOOL ok = FALSE; - TEXTRUNSTATE state; + TextRunSTATE state; Uint8 local_types_buff[LOCAL_ARRAY_SIZE]; Uint8* types_buff = NULL; @@ -454,19 +454,19 @@ void* GetNextTextRunInfo(TEXTRUNSINFO* runinfo, BidiLevel* embedding_level, GlyphRunDir* run_dir, GlyphOrient* orient) { - TEXTRUN* run = NULL; + TextRun* run = NULL; if (prev == NULL) { if (list_empty(&runinfo->truns)) return NULL; - run = (TEXTRUN*)runinfo->truns.next; + run = (TextRun*)runinfo->truns.next; } else { struct list_head* list_entry = (struct list_head*)prev; if (list_entry->next == &runinfo->truns) return NULL; - run = (TEXTRUN*)list_entry->next; + run = (TextRun*)list_entry->next; } if (logfont) *logfont = run->lf; @@ -654,8 +654,8 @@ RGBCOLOR __mg_textruns_get_text_color(const TEXTRUNSINFO* runinfo, int index) struct list_head *i; list_for_each(i, &runinfo->attrs.list) { - TEXTATTRMAP* color_entry; - color_entry = (TEXTATTRMAP*)i; + TextAttrMap* color_entry; + color_entry = (TextAttrMap*)i; if (index >= color_entry->si && (index < color_entry->si + color_entry->len) && color_entry->type == TEXT_ATTR_TEXT_COLOR) { @@ -666,29 +666,62 @@ RGBCOLOR __mg_textruns_get_text_color(const TEXTRUNSINFO* runinfo, int index) return runinfo->attrs.value; } -TEXTRUN* __mg_textruns_get_by_offset(const TEXTRUNSINFO* runinfo, +TextRun* __mg_textruns_get_by_offset(const TEXTRUNSINFO* runinfo, int offset, int *start_index) { return NULL; } -TEXTRUN* __mg_text_run_new_orphan(const TEXTRUNSINFO* info, +TextRun* __mg_text_run_new_orphan(const TEXTRUNSINFO* info, const Uchar32* ucs, int nr_ucs) { - TEXTRUN* trun = malloc(sizeof(TEXTRUN)); + TextRun* trun = malloc(sizeof(TextRun)); return trun; } -void __mg_text_run_free_orphan(TEXTRUN* trun) +void __mg_text_run_free_orphan(TextRun* trun) { free(trun); } +TextRun* __mg_text_run_copy(const TextRun* trun) +{ + TextRun *result; + + if (trun == NULL) + return NULL; + + result = malloc(sizeof(TextRun)); + memcpy(result, trun, sizeof(TextRun)); + + return result; +} + +TextRun* __mg_text_run_split(TextRun *orig, int split_index) +{ + TextRun *new_run; + + if (orig == NULL) + return NULL; + if (split_index <= 0) + return NULL; + if (split_index >= orig->len) + return NULL; + + new_run = __mg_text_run_copy(orig); + new_run->len = split_index; + + orig->si += split_index; + orig->len -= split_index; + + return new_run; +} + BOOL GUIAPI SetTextColorInTextRuns(TEXTRUNSINFO* runinfo, int start_index, int length, RGBCOLOR color) { - TEXTATTRMAP* color_entry = NULL; + TextAttrMap* color_entry = NULL; if (runinfo == NULL || start_index < 0 || length < 0 || start_index > runinfo->nr_ucs || @@ -696,7 +729,7 @@ BOOL GUIAPI SetTextColorInTextRuns(TEXTRUNSINFO* runinfo, goto error; } - color_entry = calloc(1, sizeof(TEXTATTRMAP)); + color_entry = calloc(1, sizeof(TextAttrMap)); if (color_entry == NULL) { goto error; } @@ -720,13 +753,13 @@ BOOL GUIAPI DestroyTextRunsInfo(TEXTRUNSINFO* runinfo) return FALSE; while (!list_empty(&runinfo->attrs.list)) { - TEXTATTRMAP* entry = (TEXTATTRMAP*)runinfo->attrs.list.prev; + TextAttrMap* entry = (TextAttrMap*)runinfo->attrs.list.prev; list_del(runinfo->attrs.list.prev); free(entry); } while (!list_empty(&runinfo->truns)) { - TEXTRUN* run = (TEXTRUN*)runinfo->truns.prev; + TextRun* run = (TextRun*)runinfo->truns.prev; list_del(runinfo->truns.prev); if (run->lf) __mg_release_logfont_for_run(runinfo, run); diff --git a/src/newgdi/textrunsinfo.h b/src/newgdi/textrunsinfo.h index 427bb3b1..68e67c70 100644 --- a/src/newgdi/textrunsinfo.h +++ b/src/newgdi/textrunsinfo.h @@ -43,22 +43,22 @@ #include "list.h" -typedef struct _TEXTRUN TEXTRUN; -typedef struct _GLYPHSTRING GLYPHSTRING; -typedef struct _SEINSTANCE SEINSTANCE; -typedef struct _TEXTATTRMAP TEXTATTRMAP; +typedef struct _TextRun TextRun; +typedef struct _GlyphString GlyphString; +typedef struct _SEInstance SEInstance; +typedef struct _TextAttrMap TextAttrMap; -typedef BOOL (*CB_SHAPE_TEXT_RUN)(SEINSTANCE* instance, - const TEXTRUNSINFO* info, const TEXTRUN* run, - GLYPHSTRING* gs); +typedef BOOL (*CB_SHAPE_TEXT_RUN)(SEInstance* instance, + const TEXTRUNSINFO* info, const TextRun* run, + GlyphString* gs); -typedef BOOL (*CB_DESTROY_INSTANCE)(SEINSTANCE* instance); +typedef BOOL (*CB_DESTROY_INSTANCE)(SEInstance* instance); -typedef struct _SHAPINGENGINEINFO SHAPINGENGINEINFO; +typedef struct _ShapingEngineInfo ShapingEngineInfo; -struct _SHAPINGENGINEINFO { +struct _ShapingEngineInfo { /* The pointer to the shaping engine instance */ - SEINSTANCE* inst; + SEInstance* inst; /* callback to shap a text run */ CB_SHAPE_TEXT_RUN shape; @@ -67,11 +67,12 @@ struct _SHAPINGENGINEINFO { CB_DESTROY_INSTANCE free; }; -#define TEXTRUN_FLAG_CENTERED_BASELINE 0x01 -#define TEXTRUN_FLAG_IS_ELLIPSIS 0x02 +#define TextRun_FLAG_CENTERED_BASELINE 0x01 +#define TextRun_FLAG_IS_ELLIPSIS 0x02 -struct _TEXTRUN { +struct _TextRun { struct list_head list; + const char* fontname; // the logfont name for this run; NULL for default LOGFONT* lf; // the logfont for this run int si; // start index in the Unicode string @@ -92,7 +93,7 @@ struct _TEXTRUN { #define TEXT_ATTR_BACKGROUND_COLOR 0x04 -struct _TEXTATTRMAP { +struct _TextAttrMap { struct list_head list; int si; int len; @@ -105,7 +106,7 @@ struct _TEXTRUNSINFO { const Uchar32* ucs; // the uchars char* fontname; // the default logfont name specified - TEXTATTRMAP attrs; // the head of color map (list) + TextAttrMap attrs; // the head of color map (list) struct list_head truns; // the head of text runs (list) int nr_ucs; // number of uchars @@ -118,24 +119,27 @@ struct _TEXTRUNSINFO { Uint32 base_level:1; // the paragraph direction; 0 for LTR, 1 for RTL /* The following fields will be initialized by the shaping engine. */ - SHAPINGENGINEINFO sei; // the shaping engine information + ShapingEngineInfo sei; // the shaping engine information }; #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ -LOGFONT* __mg_create_logfont_for_run(const TEXTRUNSINFO* runinfo, - const TEXTRUN* run); -void __mg_release_logfont_for_run(const TEXTRUNSINFO* runinfo, - const TEXTRUN* run); - -TEXTRUN* __mg_text_run_new_orphan(const TEXTRUNSINFO* info, +TextRun* __mg_text_run_new_orphan(const TEXTRUNSINFO* info, const Uchar32* ucs, int nr_ucs); -void __mg_text_run_free_orphan(TEXTRUN* trun); +void __mg_text_run_free_orphan(TextRun* trun); + +TextRun* __mg_text_run_copy(const TextRun* trun); +TextRun* __mg_text_run_split(TextRun *orig, int split_index); + +LOGFONT* __mg_create_logfont_for_run(const TEXTRUNSINFO* runinfo, + const TextRun* run); +void __mg_release_logfont_for_run(const TEXTRUNSINFO* runinfo, + const TextRun* run); RGBCOLOR __mg_textruns_get_color(const TEXTRUNSINFO* runinfo, int index); -TEXTRUN* __mg_textruns_get_by_offset(const TEXTRUNSINFO* runinfo, +TextRun* __mg_textruns_get_by_offset(const TEXTRUNSINFO* runinfo, int offset, int *start_index); #ifdef __cplusplus