mirror of
https://github.com/VincentWei/MiniGUI.git
synced 2026-09-30 06:23:22 +08:00
Tune the TextRunsInfo and LayoutInfo related APIs
This commit is contained in:
+41
-35
@@ -386,21 +386,27 @@ ScriptType GUIAPI NormalizeScriptType(LanguageCode cl,
|
||||
return ws;
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
HORIZONTAL_DIRECTION_LTR,
|
||||
HORIZONTAL_DIRECTION_RTL,
|
||||
HORIZONTAL_DIRECTION_WEAK,
|
||||
} HorizontalDirection;
|
||||
|
||||
typedef enum {
|
||||
VERTICAL_DIRECTION_NONE,
|
||||
VERTICAL_DIRECTION_TTB,
|
||||
VERTICAL_DIRECTION_BTT
|
||||
VERTICAL_DIRECTION_BTT,
|
||||
} VerticalDirection;
|
||||
|
||||
typedef struct {
|
||||
/* GlyphRunDir */
|
||||
Uint8 horiz_dir; /* Orientation in horizontal context */
|
||||
|
||||
/* PangoVerticalDirection */
|
||||
/* VerticalDirection */
|
||||
Uint8 vert_dir; /* Orientation in vertical context */
|
||||
|
||||
/* GlyphOrient */
|
||||
Uint8 preferred_orient; /* Preferred context orientation */
|
||||
/* LayoutGravity */
|
||||
Uint8 preferred_gravity; /* Preferred context gravity */
|
||||
|
||||
/* BOOL */
|
||||
Uint8 wide; /* Whether script is mostly wide.
|
||||
@@ -412,13 +418,13 @@ typedef struct {
|
||||
#define TTB VERTICAL_DIRECTION_TTB
|
||||
#define BTT VERTICAL_DIRECTION_BTT
|
||||
|
||||
#define LTR GLYPH_RUN_DIR_LTR
|
||||
#define RTL GLYPH_RUN_DIR_RTL
|
||||
#define WEAK GLYPH_RUN_DIR_WEAK_LTR
|
||||
#define LTR HORIZONTAL_DIRECTION_LTR
|
||||
#define RTL HORIZONTAL_DIRECTION_RTL
|
||||
#define WEAK HORIZONTAL_DIRECTION_WEAK
|
||||
|
||||
#define S GLYPH_ORIENT_UPRIGHT
|
||||
#define E GLYPH_ORIENT_SIDEWAYS
|
||||
#define W GLYPH_ORIENT_SIDEWAYS_LEFT
|
||||
#define S LAYOUT_GRAVITY_SOUTH
|
||||
#define E LAYOUT_GRAVITY_EAST
|
||||
#define W LAYOUT_GRAVITY_WEST
|
||||
|
||||
#define UNKNOWN_SCRIPT_PROPERTY \
|
||||
{LTR, NONE, S, FALSE}
|
||||
@@ -627,61 +633,61 @@ static inline ScriptTypeProperties get_script_properties (ScriptType script)
|
||||
return script_properties[script];
|
||||
}
|
||||
|
||||
GlyphOrient ScriptGetGlyphOrientation (ScriptType script,
|
||||
GlyphOrient base_orient, GlyphOrientPolicy hint)
|
||||
LayoutGravity ScriptGetLayoutGravity (ScriptType script,
|
||||
LayoutGravity base_gravity, LayoutGravityPolicy hint)
|
||||
{
|
||||
ScriptTypeProperties props = get_script_properties (script);
|
||||
|
||||
if (base_orient == GLYPH_ORIENT_AUTO)
|
||||
base_orient = props.preferred_orient;
|
||||
if (base_gravity == LAYOUT_GRAVITY_AUTO)
|
||||
base_gravity = props.preferred_gravity;
|
||||
|
||||
return GetWideGlyphOrientationForScript (script, props.wide,
|
||||
base_orient, hint);
|
||||
return ScriptGetLayoutGravityForWide (script, props.wide,
|
||||
base_gravity, hint);
|
||||
}
|
||||
|
||||
GlyphOrient GetWideGlyphOrientationForScript (ScriptType script,
|
||||
BOOL wide, GlyphOrient base_orient, GlyphOrientPolicy hint)
|
||||
LayoutGravity ScriptGetLayoutGravityForWide (ScriptType script,
|
||||
BOOL wide, LayoutGravity base_gravity, LayoutGravityPolicy hint)
|
||||
{
|
||||
ScriptTypeProperties props = get_script_properties (script);
|
||||
BOOL vertical;
|
||||
|
||||
if (base_orient == GLYPH_ORIENT_AUTO)
|
||||
base_orient = props.preferred_orient;
|
||||
if (base_gravity == LAYOUT_GRAVITY_AUTO)
|
||||
base_gravity = props.preferred_gravity;
|
||||
|
||||
vertical = GLYPH_ORIENT_IS_VERTICAL(base_orient);
|
||||
vertical = LAYOUT_GRAVITY_IS_VERTICAL(base_gravity);
|
||||
|
||||
/* Everything is designed such that a system with no vertical support
|
||||
* renders everything correctly horizontally. So, if not in a vertical
|
||||
* orientation, base and resolved gravities are always the same.
|
||||
* gravity, base and resolved gravities are always the same.
|
||||
*
|
||||
* Wide characters are always upright.
|
||||
*/
|
||||
if (!vertical || wide)
|
||||
return base_orient;
|
||||
return base_gravity;
|
||||
|
||||
/* If here, we have a narrow character in a vertical orientation setting.
|
||||
/* If here, we have a narrow character in a vertical gravity setting.
|
||||
* Resolve depending on the hint.
|
||||
*/
|
||||
switch (hint) {
|
||||
default:
|
||||
case GLYPH_ORIENT_POLICY_NATURAL:
|
||||
case LAYOUT_GRAVITY_POLICY_NATURAL:
|
||||
if (props.vert_dir == VERTICAL_DIRECTION_NONE)
|
||||
return GLYPH_ORIENT_UPRIGHT;
|
||||
if ((base_orient == GLYPH_ORIENT_SIDEWAYS) ^
|
||||
return LAYOUT_GRAVITY_SOUTH;
|
||||
if ((base_gravity == LAYOUT_GRAVITY_EAST) ^
|
||||
(props.vert_dir == VERTICAL_DIRECTION_BTT))
|
||||
return GLYPH_ORIENT_UPRIGHT;
|
||||
return LAYOUT_GRAVITY_SOUTH;
|
||||
else
|
||||
return GLYPH_ORIENT_UPSIDE_DOWN;
|
||||
return LAYOUT_GRAVITY_NORTH;
|
||||
|
||||
case GLYPH_ORIENT_POLICY_STRONG:
|
||||
return base_orient;
|
||||
case LAYOUT_GRAVITY_POLICY_STRONG:
|
||||
return base_gravity;
|
||||
|
||||
case GLYPH_ORIENT_POLICY_LINE:
|
||||
if ((base_orient == GLYPH_ORIENT_SIDEWAYS) ^
|
||||
case LAYOUT_GRAVITY_POLICY_LINE:
|
||||
if ((base_gravity == LAYOUT_GRAVITY_EAST) ^
|
||||
(props.horiz_dir == GLYPH_RUN_DIR_RTL))
|
||||
return GLYPH_ORIENT_UPRIGHT;
|
||||
return LAYOUT_GRAVITY_SOUTH;
|
||||
else
|
||||
return GLYPH_ORIENT_UPSIDE_DOWN;
|
||||
return LAYOUT_GRAVITY_NORTH;
|
||||
}
|
||||
}
|
||||
#endif /* _MGCHARSET_UNICODE */
|
||||
|
||||
@@ -19,7 +19,7 @@ SRC_FILES = gdi.c attr.c clip.c map.c coor.c rect.c \
|
||||
simple-glyph-renderer.c glyph-shaped.c \
|
||||
textrunsinfo.c \
|
||||
shape-glyphs-basic.c shape-glyphs-complex.c \
|
||||
layout-utils.c layout-ellipsize.c layoutinfo.c
|
||||
layoutinfo.c layout-utils.c layout-ellipsize.c
|
||||
endif
|
||||
|
||||
HDR_FILES = glyph.h drawtext.h mi.h midc.h mistruct.h miwideline.h \
|
||||
|
||||
@@ -93,7 +93,7 @@ int GUIAPI DrawShapedGlyphString(HDC hdc,
|
||||
Glyph32 gv = shaped_glyphs->cb_get_glyph_info(
|
||||
shaped_glyphs->shaping_engine, shaped_glyphs->glyph_infos,
|
||||
i, NULL);
|
||||
if (glyph_pos[i].orientation == GLYPH_ORIENTATION_UPRIGHT) {
|
||||
if (glyph_pos[i].orientation == GLYPH_ORIENT_UPRIGHT) {
|
||||
if (logfont_upright)
|
||||
SelectFont(hdc, logfont_upright);
|
||||
else
|
||||
|
||||
@@ -339,7 +339,7 @@ static void shape_ellipsis (EllipsizeState *state)
|
||||
ellipsis_ucs = _ellipsis_baseline;
|
||||
}
|
||||
|
||||
text_run = __mg_text_run_get_by_offset(state->layout->truninfo,
|
||||
text_run = __mg_text_run_get_by_offset_const(state->layout->truninfo,
|
||||
state->gap_start_iter.run_iter.start_index, NULL);
|
||||
|
||||
layout_run = __mg_layout_run_new_ellipsis (state->layout, text_run,
|
||||
@@ -384,7 +384,7 @@ static void update_ellipsis_shape (EllipsizeState *state)
|
||||
BOOL is_cjk;
|
||||
const TextRun* text_run;
|
||||
|
||||
text_run = __mg_text_run_get_by_offset(state->layout->truninfo,
|
||||
text_run = __mg_text_run_get_by_offset_const(state->layout->truninfo,
|
||||
state->gap_start_iter.run_iter.start_index, NULL);
|
||||
|
||||
if (state->fontname != text_run->fontname) {
|
||||
|
||||
+83
-11
@@ -124,6 +124,72 @@ void __mg_release_logfont_for_layout(const LAYOUTINFO* layout,
|
||||
ReleaseRes(Str2Key(my_fontname));
|
||||
}
|
||||
|
||||
static GlyphOrient resolve_glyph_orient(const LAYOUTINFO* layout,
|
||||
const TextRun* trun)
|
||||
{
|
||||
LayoutGravity gravity;
|
||||
|
||||
if (layout->grv_plc == LAYOUT_GRAVITY_POLICY_STRONG) {
|
||||
return layout->orient;
|
||||
}
|
||||
|
||||
gravity = ScriptGetLayoutGravityForWide(trun->st,
|
||||
trun->flags & TEXTRUN_FLAG_UPRIGHT,
|
||||
layout->grv_base, layout->grv_plc);
|
||||
switch (gravity) {
|
||||
case LAYOUT_GRAVITY_SOUTH:
|
||||
return GLYPH_ORIENT_UPRIGHT;
|
||||
case LAYOUT_GRAVITY_EAST:
|
||||
return GLYPH_ORIENT_SIDEWAYS;
|
||||
case LAYOUT_GRAVITY_NORTH:
|
||||
return GLYPH_ORIENT_SIDEWAYS_LEFT;
|
||||
case LAYOUT_GRAVITY_WEST:
|
||||
return GLYPH_ORIENT_UPSIDE_DOWN;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return GLYPH_ORIENT_UPRIGHT;
|
||||
}
|
||||
|
||||
static void resolve_layout_run_dir(const LAYOUTINFO* layout,
|
||||
LayoutRun* lrun)
|
||||
{
|
||||
/* The level vs. gravity dance:
|
||||
* If gravity is SOUTH, leave level untouched.
|
||||
* If gravity is NORTH, step level one up, to
|
||||
* not get mirrored upside-down text.
|
||||
* If gravity is EAST, step up to an even level, as
|
||||
* it's a clockwise-rotated layout, so the rotated
|
||||
* top is unrotated left.
|
||||
* If gravity is WEST, step up to an odd level, as
|
||||
* it's a counter-clockwise-rotated layout, so the rotated
|
||||
* top is unrotated right.
|
||||
*/
|
||||
switch (layout->grv_base) {
|
||||
case LAYOUT_GRAVITY_SOUTH:
|
||||
default:
|
||||
lrun->dir = (lrun->el & 1) ? GLYPH_RUN_DIR_RTL : GLYPH_RUN_DIR_LTR;
|
||||
break;
|
||||
case LAYOUT_GRAVITY_NORTH:
|
||||
lrun->el++;
|
||||
lrun->dir = (lrun->el & 1) ? GLYPH_RUN_DIR_RTL : GLYPH_RUN_DIR_LTR;
|
||||
break;
|
||||
case LAYOUT_GRAVITY_EAST:
|
||||
lrun->el += 1;
|
||||
lrun->el &= ~1;
|
||||
lrun->dir = (lrun->el & 1) ? GLYPH_RUN_DIR_TTB : GLYPH_RUN_DIR_BTT;
|
||||
break;
|
||||
case LAYOUT_GRAVITY_WEST:
|
||||
lrun->el |= 1;
|
||||
lrun->dir = (lrun->el & 1) ? GLYPH_RUN_DIR_TTB : GLYPH_RUN_DIR_BTT;
|
||||
break;
|
||||
}
|
||||
|
||||
if (LAYOUT_GRAVITY_IS_VERTICAL(layout->grv_base))
|
||||
lrun->flags |= LAYOUTRUN_FLAG_CENTERED_BASELINE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Not like Pango, we simply use the properties of the referenced TextRun
|
||||
* for the new orphan LayoutRun, including the direction, the orientation,
|
||||
@@ -136,10 +202,12 @@ void __mg_release_logfont_for_layout(const LAYOUTINFO* layout,
|
||||
LayoutRun* __mg_layout_run_new_ellipsis(const LAYOUTINFO* layout,
|
||||
const TextRun* trun, const Uchar32* ucs, int nr_ucs)
|
||||
{
|
||||
GlyphOrient ort;
|
||||
LOGFONT* lf;
|
||||
LayoutRun* lrun;
|
||||
|
||||
lf = __mg_create_logfont_for_layout(layout, trun->fontname, trun->ort);
|
||||
ort = resolve_glyph_orient(layout, trun);
|
||||
lf = __mg_create_logfont_for_layout(layout, trun->fontname, ort);
|
||||
if (lf == NULL)
|
||||
return NULL;
|
||||
|
||||
@@ -151,20 +219,22 @@ LayoutRun* __mg_layout_run_new_ellipsis(const LAYOUTINFO* layout,
|
||||
lrun->lc = trun->lc;
|
||||
lrun->st = UCharGetScriptType(ucs[0]);
|
||||
lrun->el = trun->el;
|
||||
lrun->dir = trun->dir;
|
||||
lrun->ort = trun->ort;
|
||||
lrun->ort = ort;
|
||||
lrun->flags = trun->flags | LAYOUTRUN_FLAG_ELLIPSIS;
|
||||
|
||||
resolve_layout_run_dir(layout, lrun);
|
||||
return lrun;
|
||||
}
|
||||
|
||||
LayoutRun* __mg_layout_run_new_from(const LAYOUTINFO* layout,
|
||||
const TextRun* trun)
|
||||
{
|
||||
GlyphOrient ort;
|
||||
LOGFONT* lf;
|
||||
LayoutRun* lrun;
|
||||
|
||||
lf = __mg_create_logfont_for_layout(layout, trun->fontname, trun->ort);
|
||||
ort = resolve_glyph_orient(layout, trun);
|
||||
lf = __mg_create_logfont_for_layout(layout, trun->fontname, ort);
|
||||
if (lf == NULL)
|
||||
return NULL;
|
||||
|
||||
@@ -176,26 +246,28 @@ LayoutRun* __mg_layout_run_new_from(const LAYOUTINFO* layout,
|
||||
lrun->lc = trun->lc;
|
||||
lrun->st = trun->st;
|
||||
lrun->el = trun->el;
|
||||
lrun->dir = trun->dir;
|
||||
lrun->ort = trun->ort;
|
||||
lrun->ort = ort;
|
||||
lrun->flags = trun->flags;
|
||||
|
||||
resolve_layout_run_dir(layout, lrun);
|
||||
return lrun;
|
||||
}
|
||||
|
||||
LayoutRun* __mg_layout_run_new_from_offset(const LAYOUTINFO* layout,
|
||||
const TextRun* trun, int offset)
|
||||
{
|
||||
GlyphOrient ort;
|
||||
LOGFONT* lf;
|
||||
LayoutRun* lrun;
|
||||
|
||||
if (offset >= trun->len) {
|
||||
_DBG_PRINTF("%s: offset(%d) >= trun->len(%p, %d)\n",
|
||||
__FUNCTION__, offset, trun, trun->len);
|
||||
_WRN_PRINTF("offset(%d) >= trun->len(%p, %d)",
|
||||
offset, trun, trun->len);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
lf = __mg_create_logfont_for_layout(layout, trun->fontname, trun->ort);
|
||||
ort = resolve_glyph_orient(layout, trun);
|
||||
lf = __mg_create_logfont_for_layout(layout, trun->fontname, ort);
|
||||
if (lf == NULL)
|
||||
return NULL;
|
||||
|
||||
@@ -208,10 +280,10 @@ LayoutRun* __mg_layout_run_new_from_offset(const LAYOUTINFO* layout,
|
||||
lrun->lc = trun->lc;
|
||||
lrun->st = trun->st;
|
||||
lrun->el = trun->el;
|
||||
lrun->dir = trun->dir;
|
||||
lrun->ort = trun->ort;
|
||||
lrun->ort = ort;
|
||||
lrun->flags = trun->flags;
|
||||
|
||||
resolve_layout_run_dir(layout, lrun);
|
||||
return lrun;
|
||||
}
|
||||
|
||||
|
||||
+60
-17
@@ -106,6 +106,49 @@ LAYOUTINFO* GUIAPI CreateLayoutInfo(
|
||||
INIT_LIST_HEAD(&layout->lines);
|
||||
layout->nr_left_ucs = truninfo->nr_ucs;
|
||||
|
||||
switch (render_flags & GRF_WRITING_MODE_MASK) {
|
||||
default:
|
||||
case GRF_WRITING_MODE_HORIZONTAL_TB:
|
||||
layout->grv_base = LAYOUT_GRAVITY_SOUTH;
|
||||
break;
|
||||
case GRF_WRITING_MODE_HORIZONTAL_BT:
|
||||
layout->grv_base = LAYOUT_GRAVITY_NORTH;
|
||||
break;
|
||||
case GRF_WRITING_MODE_VERTICAL_RL:
|
||||
layout->grv_base = LAYOUT_GRAVITY_WEST;
|
||||
break;
|
||||
case GRF_WRITING_MODE_VERTICAL_LR:
|
||||
layout->grv_base = LAYOUT_GRAVITY_EAST;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (render_flags & GRF_TEXT_ORIENTATION_MASK) {
|
||||
case GRF_TEXT_ORIENTATION_AUTO:
|
||||
layout->grv_plc = LAYOUT_GRAVITY_POLICY_NATURAL;
|
||||
layout->orient = GLYPH_ORIENT_UPRIGHT;
|
||||
break;
|
||||
case GRF_TEXT_ORIENTATION_MIXED:
|
||||
layout->grv_plc = LAYOUT_GRAVITY_POLICY_LINE;
|
||||
layout->orient = GLYPH_ORIENT_UPRIGHT;
|
||||
break;
|
||||
case GRF_TEXT_ORIENTATION_UPRIGHT:
|
||||
layout->grv_plc = LAYOUT_GRAVITY_POLICY_STRONG;
|
||||
layout->orient = GLYPH_ORIENT_UPRIGHT;
|
||||
break;
|
||||
case GRF_TEXT_ORIENTATION_SIDEWAYS:
|
||||
layout->grv_plc = LAYOUT_GRAVITY_POLICY_STRONG;
|
||||
layout->orient = GLYPH_ORIENT_SIDEWAYS;
|
||||
break;
|
||||
case GRF_TEXT_ORIENTATION_UPSIDE_DOWN:
|
||||
layout->grv_plc = LAYOUT_GRAVITY_POLICY_STRONG;
|
||||
layout->orient = GLYPH_ORIENT_UPSIDE_DOWN;
|
||||
break;
|
||||
case GRF_TEXT_ORIENTATION_SIDEWAYS_LEFT:
|
||||
layout->grv_plc = LAYOUT_GRAVITY_POLICY_STRONG;
|
||||
layout->orient = GLYPH_ORIENT_SIDEWAYS_LEFT;
|
||||
break;
|
||||
}
|
||||
|
||||
layout->persist = persist_lines ? 1 : 0;
|
||||
|
||||
return layout;
|
||||
@@ -165,7 +208,7 @@ struct _LayoutState {
|
||||
|
||||
/* maintained per paragraph */
|
||||
// Current resolved base direction
|
||||
GlyphRunDir base_dir;
|
||||
ParagraphDir base_dir;
|
||||
// Line of the paragraph, starting at 1 for first line
|
||||
int line_of_par;
|
||||
// Glyphs for the current glyph run
|
||||
@@ -536,7 +579,7 @@ static inline void print_line_runs(const LAYOUTLINE* line, const char* func)
|
||||
_DBG_PRINTF(" LENGHT: %d\n", run->lrun->len);
|
||||
_DBG_PRINTF(" EMBEDDING LEVEL:%d\n", run->lrun->el);
|
||||
_DBG_PRINTF(" NO SHAPING :%s\n",
|
||||
(run->lrun->flags & LAYOUTRUN_FLAG_NO_SHAPING) ? "YES" : "NO");
|
||||
(run->lrun->noshape) ? "YES" : "NO");
|
||||
_DBG_PRINTF(" NR GLYPHS: %d\n", run->gstr->nr_glyphs);
|
||||
j++;
|
||||
}
|
||||
@@ -861,17 +904,17 @@ static LAYOUTLINE *layout_line_new(LAYOUTINFO *layout)
|
||||
/* The resolved direction for the line is always one
|
||||
* of LTR/RTL; not a week or neutral directions
|
||||
*/
|
||||
static void line_set_resolved_dir(LAYOUTLINE *line, GlyphRunDir direction)
|
||||
static void line_set_resolved_dir(LAYOUTLINE *line, ParagraphDir direction)
|
||||
{
|
||||
switch (direction) {
|
||||
default:
|
||||
case GLYPH_RUN_DIR_LTR:
|
||||
case GLYPH_RUN_DIR_WEAK_LTR:
|
||||
case GLYPH_RUN_DIR_NEUTRAL:
|
||||
case BIDI_PGDIR_LTR:
|
||||
case BIDI_PGDIR_WLTR:
|
||||
case BIDI_PGDIR_ON:
|
||||
line->resolved_dir = GLYPH_RUN_DIR_LTR;
|
||||
break;
|
||||
case GLYPH_RUN_DIR_RTL:
|
||||
case GLYPH_RUN_DIR_WEAK_RTL:
|
||||
case BIDI_PGDIR_RTL:
|
||||
case BIDI_PGDIR_WRTL:
|
||||
line->resolved_dir = GLYPH_RUN_DIR_RTL;
|
||||
break;
|
||||
}
|
||||
@@ -889,20 +932,20 @@ static void line_set_resolved_dir(LAYOUTLINE *line, GlyphRunDir direction)
|
||||
* A similar dance is performed in textrunsinfo.c:
|
||||
* state_add_character(). Keep in sync.
|
||||
*/
|
||||
switch (line->layout->truninfo->ort_rsv) {
|
||||
switch (line->layout->grv_base) {
|
||||
default:
|
||||
case GLYPH_GRAVITY_AUTO:
|
||||
case GLYPH_GRAVITY_SOUTH:
|
||||
case LAYOUT_GRAVITY_AUTO:
|
||||
case LAYOUT_GRAVITY_SOUTH:
|
||||
break;
|
||||
case GLYPH_GRAVITY_NORTH:
|
||||
case LAYOUT_GRAVITY_NORTH:
|
||||
line->resolved_dir = GLYPH_RUN_DIR_LTR
|
||||
+ GLYPH_RUN_DIR_RTL
|
||||
- line->resolved_dir;
|
||||
break;
|
||||
case GLYPH_GRAVITY_EAST:
|
||||
case LAYOUT_GRAVITY_EAST:
|
||||
line->resolved_dir = GLYPH_RUN_DIR_LTR;
|
||||
break;
|
||||
case GLYPH_GRAVITY_WEST:
|
||||
case LAYOUT_GRAVITY_WEST:
|
||||
line->resolved_dir = GLYPH_RUN_DIR_RTL;
|
||||
break;
|
||||
}
|
||||
@@ -1609,7 +1652,7 @@ static LAYOUTLINE* check_next_line(LAYOUTINFO* layout, LayoutState* state)
|
||||
state->remaining_width = break_remaining_width;
|
||||
|
||||
/* determine start text run again */
|
||||
state->trun = __mg_text_run_get_by_offset(layout->truninfo,
|
||||
state->trun = __mg_text_run_get_by_offset_const(layout->truninfo,
|
||||
state->start_offset, &state->start_index_in_trun);
|
||||
if (state->start_index_in_trun > 0) {
|
||||
state->lrun = __mg_layout_run_new_from_offset(layout,
|
||||
@@ -1744,7 +1787,7 @@ LAYOUTLINE* GUIAPI LayoutNextLine(
|
||||
//state.shape_ink_rect;
|
||||
//state.shape_logical_rect;
|
||||
|
||||
state.base_dir = layout->truninfo->run_dir;
|
||||
state.base_dir = layout->truninfo->base_dir;
|
||||
state.line_of_par = 1;
|
||||
state.glyphs = NULL;
|
||||
state.log_widths = NULL;
|
||||
@@ -1766,7 +1809,7 @@ LAYOUTLINE* GUIAPI LayoutNextLine(
|
||||
state.line_start_index = layout->truninfo->nr_ucs - layout->nr_left_ucs;
|
||||
state.start_offset = state.line_start_index;
|
||||
state.start_index_in_trun = 0;
|
||||
state.trun = __mg_text_run_get_by_offset(layout->truninfo,
|
||||
state.trun = __mg_text_run_get_by_offset_const(layout->truninfo,
|
||||
state.line_start_index, &state.start_index_in_trun);
|
||||
|
||||
_DBG_PRINTF("%s: line_start_index: %d, start_index_in_trun: %d(%p)\n",
|
||||
|
||||
+15
-11
@@ -65,22 +65,23 @@ struct _GlyphString {
|
||||
unsigned int space;
|
||||
};
|
||||
|
||||
#define LAYOUTRUN_FLAG_CENTERED_BASELINE TEXTRUN_FLAG_CENTERED_BASELINE
|
||||
#define LAYOUTRUN_FLAG_NO_SHAPING TEXTRUN_FLAG_NO_SHAPING
|
||||
#define LAYOUTRUN_FLAG_UPRIGHT TEXTRUN_FLAG_UPRIGHT
|
||||
#define LAYOUTRUN_FLAG_ELLIPSIS 0x04
|
||||
#define LAYOUTRUN_FLAG_CENTERED_BASELINE 0x08
|
||||
|
||||
struct _LayoutRun {
|
||||
LOGFONT* lf; // the logfont for this run
|
||||
const Uchar32* ucs; // the uchar string
|
||||
LOGFONT* lf; // the logfont for this run
|
||||
const Uchar32* ucs; // the uchar string
|
||||
|
||||
int si; // the start index of this run
|
||||
int len; // the length of the uchar string
|
||||
Uint32 lc:8; // language code
|
||||
Uint32 st:8; // script type
|
||||
Uint32 el:8; // the bidi embedding level
|
||||
Uint32 dir:2; // the run direction; value rage: [0, 3]
|
||||
Uint32 ort:2; // the glyph orientation; value range: [0, 3]
|
||||
Uint32 flags:4;// other flags
|
||||
int si; // the start index of this run
|
||||
int len; // the length of the uchar string
|
||||
Uint32 lc:8; // language code
|
||||
Uint32 st:8; // script type
|
||||
Uint32 el:8; // the bidi embedding level
|
||||
Uint32 dir:2; // the run direction; value rage: [0, 3]
|
||||
Uint32 ort:2; // the glyph orientation; value range: [0, 3]
|
||||
Uint32 flags:4; // other flags
|
||||
};
|
||||
|
||||
struct _GlyphRun {
|
||||
@@ -127,6 +128,9 @@ struct _LAYOUTINFO {
|
||||
int nr_left_ucs;// the number of chars not laied out
|
||||
int nr_lines; // the number of lines
|
||||
|
||||
Uint32 grv_base:4; // the base gravity
|
||||
Uint32 grv_plc:2; // the gravity policy specified
|
||||
Uint32 orient:2; // the glyph orientation specified
|
||||
Uint32 persist:1; // persist lines?
|
||||
Uint32 single_paragraph:1;
|
||||
};
|
||||
|
||||
@@ -536,14 +536,14 @@ static void adjust_glyph_position(MYGLYPHARGS* args,
|
||||
{
|
||||
switch (args->rf & GRF_WRITING_MODE_MASK) {
|
||||
case GRF_WRITING_MODE_VERTICAL_RL:
|
||||
if (gi->orientation == GLYPH_ORIENTATION_UPRIGHT) {
|
||||
if (gi->orientation == GLYPH_ORIENT_UPRIGHT) {
|
||||
x -= (args->lw + ge->bbox_w) / 2;
|
||||
x -= ge->bbox_x;
|
||||
}
|
||||
break;
|
||||
|
||||
case GRF_WRITING_MODE_VERTICAL_LR:
|
||||
if (gi->orientation == GLYPH_ORIENTATION_SIDEWAYS) {
|
||||
if (gi->orientation == GLYPH_ORIENT_SIDEWAYS) {
|
||||
x += args->lfsw->size;
|
||||
}
|
||||
else {
|
||||
@@ -858,7 +858,7 @@ static void init_glyph_info(MYGLYPHARGS* args, int i,
|
||||
gi->whitespace = 0;
|
||||
gi->suppressed = 0;
|
||||
gi->hanged = GLYPH_HANGED_NONE;
|
||||
gi->orientation = GLYPH_ORIENTATION_UPRIGHT;
|
||||
gi->orientation = GLYPH_ORIENT_UPRIGHT;
|
||||
}
|
||||
|
||||
static inline int shrink_total_extent(MYGLYPHARGS* args, int total_extent,
|
||||
@@ -899,13 +899,13 @@ static int get_glyph_extent_info(MYGLYPHARGS* args, Glyph32 gv,
|
||||
== GRF_TEXT_ORIENTATION_MIXED) {
|
||||
if (is_horizontal_only_script(gi->uc)) {
|
||||
logfont = args->lfsw;
|
||||
gi->orientation = GLYPH_ORIENTATION_SIDEWAYS;
|
||||
gi->orientation = GLYPH_ORIENT_SIDEWAYS;
|
||||
}
|
||||
}
|
||||
else if ((args->rf & GRF_TEXT_ORIENTATION_MASK)
|
||||
== GRF_TEXT_ORIENTATION_SIDEWAYS) {
|
||||
logfont = args->lfsw;
|
||||
gi->orientation = GLYPH_ORIENTATION_SIDEWAYS;
|
||||
gi->orientation = GLYPH_ORIENT_SIDEWAYS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1364,7 +1364,7 @@ int GUIAPI DrawGlyphStringEx(HDC hdc,
|
||||
|
||||
for (i = 0; i < nr_glyphs; i++) {
|
||||
if (glyph_pos[i].suppressed == 0 && glyph_pos[i].whitespace == 0) {
|
||||
if (glyph_pos[i].orientation == GLYPH_ORIENTATION_UPRIGHT) {
|
||||
if (glyph_pos[i].orientation == GLYPH_ORIENT_UPRIGHT) {
|
||||
if (logfont_upright)
|
||||
SelectFont(hdc, logfont_upright);
|
||||
else
|
||||
|
||||
+283
-108
File diff suppressed because it is too large
Load Diff
+30
-28
@@ -47,7 +47,7 @@ typedef struct _LayoutRun LayoutRun;
|
||||
typedef struct _TextRun TextRun;
|
||||
typedef struct _GlyphString GlyphString;
|
||||
typedef struct _SEInstance SEInstance;
|
||||
typedef struct _TextAttrMap TextAttrMap;
|
||||
typedef struct _TextColorMap TextColorMap;
|
||||
|
||||
typedef BOOL (*CB_SHAPE_LAYOUT_RUN)(SEInstance* instance,
|
||||
const TEXTRUNSINFO* info, const LayoutRun* run,
|
||||
@@ -68,36 +68,31 @@ struct _ShapingEngineInfo {
|
||||
CB_DESTROY_INSTANCE free;
|
||||
};
|
||||
|
||||
#define TEXTRUN_FLAG_CENTERED_BASELINE 0x01
|
||||
#define TEXTRUN_FLAG_NO_SHAPING 0x02
|
||||
#define TEXTRUN_FLAG_NO_SHAPING 0x01
|
||||
#define TEXTRUN_FLAG_UPRIGHT 0x02
|
||||
|
||||
struct _TextRun {
|
||||
struct list_head list;
|
||||
char* fontname; // the logfont name for this run; NULL for default
|
||||
|
||||
int si; // start index in the uchar string
|
||||
int len; // the length in uchars
|
||||
int si; // start index in the uchar string
|
||||
int len; // the length in uchars
|
||||
|
||||
Uint32 lc:8; // language code
|
||||
Uint32 st:8; // script type
|
||||
Uint32 el:8; // the bidi embedding level
|
||||
Uint32 lc:8; // language code
|
||||
Uint32 st:8; // script type
|
||||
Uint32 el:8; // the bidi embedding level
|
||||
Uint32 flags:2; // other flags
|
||||
#if 0
|
||||
Uint32 dir:2; // the run direction; value range: [0, 3]
|
||||
Uint32 ort:2; // the glyph orientation; value range: [0, 3]
|
||||
Uint32 flags:4;// other flags
|
||||
#endif
|
||||
};
|
||||
|
||||
#define TEXT_ATTR_TEXT_COLOR 0x00
|
||||
#define TEXT_ATTR_UNDERLINE_COLOR 0x01
|
||||
#define TEXT_ATTR_STRIKETHROUGH_COLOR 0x02
|
||||
#define TEXT_ATTR_OUTLINE_COLOR 0x03
|
||||
#define TEXT_ATTR_BACKGROUND_COLOR 0x04
|
||||
|
||||
struct _TextAttrMap {
|
||||
struct _TextColorMap {
|
||||
struct list_head list;
|
||||
int si;
|
||||
int len;
|
||||
int type; // attribute type
|
||||
Uint32 value; // attribute value
|
||||
RGBCOLOR value; // attribute value
|
||||
};
|
||||
|
||||
struct _TEXTRUNSINFO {
|
||||
@@ -105,17 +100,22 @@ struct _TEXTRUNSINFO {
|
||||
const Uchar32* ucs; // the uchars
|
||||
char* fontname; // the default logfont name specified
|
||||
|
||||
TextAttrMap attrs; // the head of color map (list)
|
||||
TextColorMap fg_colors; // the head of foreground color map (list)
|
||||
TextColorMap bg_colors; // the head of background color map (list)
|
||||
struct list_head truns; // the head of text runs (list)
|
||||
|
||||
int nr_ucs; // number of uchars
|
||||
int nr_runs; // number of runs
|
||||
int nr_ucs; // number of uchars
|
||||
int nr_runs; // number of runs
|
||||
LanguageCode lc; // language code specified
|
||||
ParagraphDir base_dir; // paragraph base direction
|
||||
|
||||
#if 0
|
||||
Uint32 lc:8; // language code specified
|
||||
Uint32 ort_base:3; // the glyph orientation specified
|
||||
Uint32 ort_rsv:3; // the glyph orientation resolved
|
||||
Uint32 ort_plc:2; // the glyph orientation policy specified
|
||||
Uint32 run_dir:4; // the run direction specified
|
||||
Uint32 grv_base:4; // the gravity specified
|
||||
Uint32 grv_plc:2; // the gravity policy specified
|
||||
Uint32 grv_rsv:4; // the gravity resolved
|
||||
Uint32 base_level:1; // the paragraph direction; 0 for LTR, 1 for RTL
|
||||
#endif
|
||||
|
||||
/* The following fields will be initialized by the shaping engine. */
|
||||
ShapingEngineInfo sei; // the shaping engine information
|
||||
@@ -125,9 +125,11 @@ struct _TEXTRUNSINFO {
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
RGBCOLOR __mg_textruns_get_text_color(const TEXTRUNSINFO* runinfo, int index);
|
||||
|
||||
const TextRun* __mg_text_run_get_by_offset(const TEXTRUNSINFO* runinfo,
|
||||
TextRun* __mg_text_run_copy(const TextRun *orig);
|
||||
TextRun* __mg_text_run_split(TextRun *orig, int split_index);
|
||||
TextRun* __mg_text_run_get_by_offset(TEXTRUNSINFO* runinfo,
|
||||
int index, int *start_offset);
|
||||
const TextRun* __mg_text_run_get_by_offset_const(const TEXTRUNSINFO* runinfo,
|
||||
int index, int *start_offset);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user