mirror of
https://github.com/VincentWei/MiniGUI.git
synced 2026-09-25 11:07:54 +08:00
Tune name of structure and functions
This commit is contained in:
+22
-27
@@ -9079,7 +9079,7 @@ MG_EXPORT GlyphOrient GUIAPI ScriptGetGlyphOrientation (ScriptType script,
|
||||
GlyphOrient base_orient, GlyphOrientPolicy policy);
|
||||
|
||||
/**
|
||||
* ScriptGetWideGlyphOrientation:
|
||||
* GetWideGlyphOrientationForScript:
|
||||
* @script: #ScriptType to query
|
||||
* @wide: %TRUE for wide characters as returned by IsUCharWide()
|
||||
* @base_orient: base orientation of the paragraph
|
||||
@@ -9104,7 +9104,7 @@ MG_EXPORT GlyphOrient GUIAPI ScriptGetGlyphOrientation (ScriptType script,
|
||||
*
|
||||
* Since: 3.4.0
|
||||
*/
|
||||
GlyphOrient ScriptGetWideGlyphOrientation (ScriptType script,
|
||||
GlyphOrient GetWideGlyphOrientationForScript (ScriptType script,
|
||||
BOOL wide, GlyphOrient base_orient, GlyphOrientPolicy policy);
|
||||
|
||||
/** @} end of unicode_ops */
|
||||
@@ -12478,58 +12478,53 @@ MG_EXPORT int GUIAPI GetGlyphsExtentFromUChars(LOGFONT* logfont_upright,
|
||||
SIZE* line_size, Glyph32* glyphs, GLYPHEXTINFO* glyph_ext_info,
|
||||
GLYPHPOS* glyph_pos, LOGFONT** logfont_sideways);
|
||||
|
||||
/* The fields in the structure _GLYPHRUNINFO are invisible to users */
|
||||
typedef struct _GLYPHRUNINFO GLYPHRUNINFO;
|
||||
/* The fields in the structure _TEXTRUNSINFO are invisible to users */
|
||||
typedef struct _TEXTRUNSINFO TEXTRUNSINFO;
|
||||
|
||||
/**
|
||||
* Split a Uchar32 paragraph string into text runs according to the
|
||||
* scripts of characters.
|
||||
*
|
||||
* This function also calculates the embedding levels and the
|
||||
* breaking opportunities of the string.
|
||||
* Split a Uchar32 paragraph string into text runs.
|
||||
*/
|
||||
MG_EXPORT GLYPHRUNINFO* GUIAPI CreateGlyphRunInfo(Uchar32* ucs, int nr_ucs,
|
||||
LanguageCode lang_code, ScriptType script_type,
|
||||
ParagraphDir base_dir, GlyphRunDir run_dir,
|
||||
MG_EXPORT TEXTRUNSINFO* GUIAPI CreateTextRunsInfo(Uchar32* ucs, int nr_ucs,
|
||||
LanguageCode lang_code, ParagraphDir base_dir, GlyphRunDir run_dir,
|
||||
GlyphOrient glyph_orient, GlyphOrientPolicy orient_policy,
|
||||
LOGFONT* logfont, RGBCOLOR color);
|
||||
|
||||
/**
|
||||
* Set font of part characters. Please call this function before
|
||||
* calling ShapeGlyphRunsBaisc or ShapeGlyphRunsComplex.
|
||||
* calling ShapeTextRunsBaisc or ShapeTextRunsComplex.
|
||||
*/
|
||||
MG_EXPORT BOOL GUIAPI SetPartFontInGlyphRuns(GLYPHRUNINFO* run_info,
|
||||
MG_EXPORT BOOL GUIAPI SetPartFontInTextRuns(TEXTRUNSINFO* run_info,
|
||||
int start_index, int length, LOGFONT* logfont);
|
||||
|
||||
/**
|
||||
* Set color of part characters.
|
||||
*/
|
||||
MG_EXPORT BOOL GUIAPI SetPartColorInGlyphRuns(GLYPHRUNINFO* run_info,
|
||||
MG_EXPORT BOOL GUIAPI SetPartColorInTextRuns(TEXTRUNSINFO* run_info,
|
||||
int start_index, int length, RGBCOLOR color);
|
||||
|
||||
/**
|
||||
* Reset the font of glyph runs for the next rendering under a
|
||||
* new LOGFONT.
|
||||
*/
|
||||
MG_EXPORT BOOL GUIAPI ResetFontInGlyphRuns(GLYPHRUNINFO* run_info,
|
||||
MG_EXPORT BOOL GUIAPI ResetFontInTextRuns(TEXTRUNSINFO* run_info,
|
||||
LOGFONT* logfont);
|
||||
|
||||
/**
|
||||
* Reset the color of glyph runs.
|
||||
*/
|
||||
MG_EXPORT BOOL GUIAPI ResetColorInGlyphRuns(GLYPHRUNINFO* run_info,
|
||||
MG_EXPORT BOOL GUIAPI ResetColorInTextRuns(TEXTRUNSINFO* run_info,
|
||||
RGBCOLOR color);
|
||||
|
||||
/**
|
||||
* Reset the breaking opportunities of glyph runs.
|
||||
*/
|
||||
MG_EXPORT BOOL GUIAPI ResetBreaksInGlyphRuns(GLYPHRUNINFO* run_info,
|
||||
MG_EXPORT BOOL GUIAPI ResetBreaksInTextRuns(TEXTRUNSINFO* run_info,
|
||||
Uint8 ctr, Uint8 wbr, Uint8 lbp);
|
||||
|
||||
/**
|
||||
* Reset the direction and orientation of glyph runs.
|
||||
*/
|
||||
MG_EXPORT BOOL GUIAPI ResetDirectionInGlyphRuns(GLYPHRUNINFO* run_info,
|
||||
MG_EXPORT BOOL GUIAPI ResetDirectionInTextRuns(TEXTRUNSINFO* run_info,
|
||||
GlyphRunDir run_dir, GlyphOrient glyph_orient,
|
||||
GlyphOrientPolicy orient_policy);
|
||||
|
||||
@@ -12537,10 +12532,10 @@ MG_EXPORT BOOL GUIAPI ResetDirectionInGlyphRuns(GLYPHRUNINFO* run_info,
|
||||
* Destroy the glyph run info object. It also frees all data allocated
|
||||
* for shapping and layouting the glyphs.
|
||||
*/
|
||||
MG_EXPORT BOOL GUIAPI DestroyGlyphRunInfo(GLYPHRUNINFO* run_info);
|
||||
MG_EXPORT BOOL GUIAPI DestroyTextRunsInfo(TEXTRUNSINFO* run_info);
|
||||
|
||||
/**
|
||||
* \fn BOOL GUIAPI ShapeGlyphRunsBaisc()
|
||||
* \fn BOOL GUIAPI ShapeTextRunsBaisc()
|
||||
* \brief Analyse and generate a shaped glyph string of a Unicode string
|
||||
* under specific language and writing system.
|
||||
*
|
||||
@@ -12586,13 +12581,13 @@ MG_EXPORT BOOL GUIAPI DestroyGlyphRunInfo(GLYPHRUNINFO* run_info);
|
||||
* \sa GetUCharsUntilParagraphBoundary, GetShapedGlyphsComplex,
|
||||
* GetGlyphsExtentInfo, GetGlyphsPositionInfo, DrawShapedGlyphString
|
||||
*/
|
||||
MG_EXPORT BOOL GUIAPI ShapeGlyphRunsBaisc(GLYPHRUNINFO* run_info,
|
||||
MG_EXPORT BOOL GUIAPI ShapeTextRunsBaisc(TEXTRUNSINFO* run_info,
|
||||
Uint32 render_flags);
|
||||
|
||||
#ifdef _MGCOMPLEX_SCRIPTS
|
||||
|
||||
/**
|
||||
* \fn int GUIAPI ShapeGlyphRunsComplex()
|
||||
* \fn int GUIAPI ShapeTextRunsComplex()
|
||||
* \brief Analyse and generate a shaped glyph string of a Unicode string
|
||||
* under specific language and writing system. This is the complex
|
||||
* implementation based on HarfBuzz, which is LGPL'd shaping engine.
|
||||
@@ -12657,7 +12652,7 @@ MG_EXPORT BOOL GUIAPI ShapeGlyphRunsBaisc(GLYPHRUNINFO* run_info,
|
||||
* \sa GetUCharsUntilParagraphBoundary, GetShapedGlyphsBasic,
|
||||
* GetGlyphsExtentInfo, GetGlyphsPositionInfo, DrawShapedGlyphString
|
||||
*/
|
||||
MG_EXPORT BOOL GUIAPI ShapeGlyphRunsComplex(GLYPHRUNINFO* run_info,
|
||||
MG_EXPORT BOOL GUIAPI ShapeTextRunsComplex(TEXTRUNSINFO* run_info,
|
||||
Uint32 render_flags);
|
||||
|
||||
#endif /* _MGCOMPLEX_SCRIPTS */
|
||||
@@ -12699,7 +12694,7 @@ MG_EXPORT BOOL GUIAPI ShapeGlyphRunsComplex(GLYPHRUNINFO* run_info,
|
||||
* GetGlyphsPositionInfo, DrawShapedGlyphString, GLYPHEXTINFO, glyph_render_flags
|
||||
*
|
||||
MG_EXPORT GLYPHEXTINFO* GUIAPI GetShapedGlyphsExtentInfo(
|
||||
GLYPHRUNINFO* run_info, int run_idx);
|
||||
TEXTRUNSINFO* run_info, int run_idx);
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -12762,7 +12757,7 @@ MG_EXPORT GLYPHEXTINFO* GUIAPI GetShapedGlyphsExtentInfo(
|
||||
* \sa UStrGetBreaks, GetShapedGlyphsBasic, GetShapedGlyphsComplex,
|
||||
* GetGlyphsExtentInfo, DrawShapedGlyphString, GLYPHEXTINFO, glyph_render_flags
|
||||
*/
|
||||
MG_EXPORT int GUIAPI GetShapedGlyphsFittingLine(const GLYPHRUNINFO* run_info,
|
||||
MG_EXPORT int GUIAPI GetShapedGlyphsFittingLine(const TEXTRUNSINFO* run_info,
|
||||
const BreakOppo* break_oppos,
|
||||
int uc_start_index, int x, int y, Uint32 render_flags,
|
||||
int letter_spacing, int word_spacing, int tab_size, int max_extent,
|
||||
@@ -12794,7 +12789,7 @@ MG_EXPORT int GUIAPI GetShapedGlyphsFittingLine(const GLYPHRUNINFO* run_info,
|
||||
*
|
||||
* \sa GetGlyphsExtentFromUChars
|
||||
*/
|
||||
MG_EXPORT int GUIAPI DrawShapedGlyphs(const GLYPHRUNINFO* run_info,
|
||||
MG_EXPORT int GUIAPI DrawShapedGlyphs(const TEXTRUNSINFO* run_info,
|
||||
int uc_start_index, const GLYPHPOS* glyph_pos, int nr_glyphs);
|
||||
|
||||
#endif /* _MGCHARSET_UNICODE */
|
||||
|
||||
@@ -635,11 +635,11 @@ GlyphOrient ScriptGetGlyphOrientation (ScriptType script,
|
||||
if (base_orient == GLYPH_ORIENT_AUTO)
|
||||
base_orient = props.preferred_orient;
|
||||
|
||||
return ScriptGetWideGlyphOrientation (script, props.wide,
|
||||
return GetWideGlyphOrientationForScript (script, props.wide,
|
||||
base_orient, hint);
|
||||
}
|
||||
|
||||
GlyphOrient ScriptGetWideGlyphOrientation (ScriptType script,
|
||||
GlyphOrient GetWideGlyphOrientationForScript (ScriptType script,
|
||||
BOOL wide, GlyphOrient base_orient, GlyphOrientPolicy hint)
|
||||
{
|
||||
ScriptTypeProperties props = get_script_properties (script);
|
||||
|
||||
@@ -17,14 +17,14 @@ SRC_FILES = gdi.c attr.c clip.c map.c coor.c rect.c \
|
||||
text.c achar-uchar.c glyph.c legacy-bidi.c \
|
||||
textout.c tabbedtextout.c drawtext.c \
|
||||
glyph-unicode.c \
|
||||
glyphruninfo.c \
|
||||
textrunsinfo.c \
|
||||
shape-glyphs-basic.c shape-glyphs-complex.c \
|
||||
layout-shaped-glyphs.c
|
||||
endif
|
||||
|
||||
HDR_FILES = drawtext.h mi.h midc.h mistruct.h miwideline.h \
|
||||
pixel_ops.h mifillarc.h mispans.h polygon.h mifpoly.h \
|
||||
glyphruninfo.h
|
||||
textrunsinfo.h
|
||||
|
||||
libnewgdi_la_SOURCES = $(SRC_FILES) $(HDR_FILES)
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
#include "window.h"
|
||||
#include "devfont.h"
|
||||
#include "unicode-ops.h"
|
||||
#include "glyphruninfo.h"
|
||||
#include "textrunsinfo.h"
|
||||
|
||||
#if 0
|
||||
static void bidi_reverse_shaped_glyphs (void* context, int len, int pos)
|
||||
@@ -79,7 +79,7 @@ static void bidi_reverse_shaped_glyphs (void* context, int len, int pos)
|
||||
# define LOCAL_ARRAY_SIZE 128
|
||||
#endif
|
||||
|
||||
BOOL GUIAPI ShapeGlyphRunsBasic(GLYPHRUNINFO* run_info, Uint32 rf)
|
||||
BOOL GUIAPI ShapeTextRunsBasic(TEXTRUNSINFO* run_info, Uint32 rf)
|
||||
{
|
||||
#if 0
|
||||
int ret_value = 0;
|
||||
|
||||
@@ -55,9 +55,9 @@
|
||||
#include "window.h"
|
||||
#include "devfont.h"
|
||||
#include "unicode-ops.h"
|
||||
#include "glyphruninfo.h"
|
||||
#include "textrunsinfo.h"
|
||||
|
||||
BOOL GUIAPI ShapeGlyphRunsComplex(GLYPHRUNINFO* run_info, Uint32 rf)
|
||||
BOOL GUIAPI ShapeTextRunsComplex(TEXTRUNSINFO* run_info, Uint32 rf)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
** glyphruninfo.c: The implementation of APIs related GLYPHRUNINFO
|
||||
** glyphruninfo.c: The implementation of APIs related TEXTRUNSINFO
|
||||
**
|
||||
** Create by WEI Yongming at 2019/03/15
|
||||
*/
|
||||
@@ -51,7 +51,7 @@
|
||||
#include "window.h"
|
||||
#include "devfont.h"
|
||||
#include "unicode-ops.h"
|
||||
#include "glyphruninfo.h"
|
||||
#include "textrunsinfo.h"
|
||||
|
||||
/* Local array size, used for stack-based local arrays */
|
||||
#if SIZEOF_PTR == 8
|
||||
@@ -70,8 +70,8 @@ enum {
|
||||
EMOJI_CHANGED = 1 << 6,
|
||||
};
|
||||
|
||||
typedef struct _GLYPHRUNSTATE {
|
||||
GLYPHRUNINFO* runinfo;
|
||||
typedef struct _TEXTRUNSTATE {
|
||||
TEXTRUNSINFO* runinfo;
|
||||
const Uchar32* text;
|
||||
const Uchar32* end;
|
||||
|
||||
@@ -83,11 +83,6 @@ typedef struct _GLYPHRUNSTATE {
|
||||
int emb_end_offset;
|
||||
BidiLevel emb_level;
|
||||
|
||||
LanguageCode lang;
|
||||
ScriptType script;
|
||||
|
||||
GlyphOrient orient;
|
||||
GlyphOrientPolicy orient_policy;
|
||||
GlyphOrient ort_rsv;
|
||||
BOOL centered_baseline;
|
||||
|
||||
@@ -98,9 +93,9 @@ typedef struct _GLYPHRUNSTATE {
|
||||
EmojiIterator emoji_iter;
|
||||
|
||||
LanguageCode derived_lang;
|
||||
} GLYPHRUNSTATE;
|
||||
} TEXTRUNSTATE;
|
||||
|
||||
static void update_embedding_end(GLYPHRUNSTATE *state)
|
||||
static void update_embedding_end(TEXTRUNSTATE *state)
|
||||
{
|
||||
state->emb_level = state->els[state->emb_end_offset];
|
||||
while (state->emb_end < state->end &&
|
||||
@@ -113,7 +108,7 @@ static void update_embedding_end(GLYPHRUNSTATE *state)
|
||||
state->changed |= EMBEDDING_CHANGED;
|
||||
}
|
||||
|
||||
static void update_end (GLYPHRUNSTATE *state)
|
||||
static void update_end (TEXTRUNSTATE *state)
|
||||
{
|
||||
state->run_end = state->emb_end;
|
||||
if (state->script_iter.end < state->run_end)
|
||||
@@ -143,25 +138,24 @@ static LanguageCode compute_derived_language (LanguageCode lang,
|
||||
return derived_lang;
|
||||
}
|
||||
|
||||
static void state_update_for_new_run (GLYPHRUNSTATE *state)
|
||||
static void state_update_for_new_run (TEXTRUNSTATE *state)
|
||||
{
|
||||
if (state->changed & (SCRIPT_CHANGED | WIDTH_CHANGED)) {
|
||||
GlyphOrient orient = state->orient;
|
||||
GlyphOrient orient = state->runinfo->ort_base;
|
||||
GlyphOrientPolicy orient_policy = state->runinfo->ort_plc;
|
||||
|
||||
if (orient == GLYPH_ORIENT_AUTO)
|
||||
orient = state->runinfo->ort_rsv;
|
||||
|
||||
state->ort_rsv = ScriptGetWideGlyphOrientation(
|
||||
state->ort_rsv = GetWideGlyphOrientationForScript(
|
||||
state->script_iter.script, state->width_iter.upright,
|
||||
orient, orient_policy);
|
||||
}
|
||||
|
||||
if (state->changed & (SCRIPT_CHANGED | LANG_CHANGED))
|
||||
{
|
||||
if (state->changed & (SCRIPT_CHANGED | LANG_CHANGED)) {
|
||||
LanguageCode old_derived_lang = state->derived_lang;
|
||||
state->derived_lang = compute_derived_language (state->lang,
|
||||
state->script);
|
||||
state->derived_lang = compute_derived_language (state->runinfo->lc,
|
||||
state->script_iter.script);
|
||||
if (old_derived_lang != state->derived_lang)
|
||||
state->changed |= DERIVED_LANG_CHANGED;
|
||||
}
|
||||
@@ -173,17 +167,49 @@ static void state_update_for_new_run (GLYPHRUNSTATE *state)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void state_process_run (GLYPHRUNSTATE *state)
|
||||
/* we need a logfont cache */
|
||||
static LOGFONT* create_logfont_for_run(const TEXTRUNSINFO* runinfo,
|
||||
const TEXTRUN* run)
|
||||
{
|
||||
return runinfo->lf;
|
||||
}
|
||||
|
||||
static BOOL state_process_run (TEXTRUNSTATE *state)
|
||||
{
|
||||
TEXTRUN* run;
|
||||
|
||||
state_update_for_new_run (state);
|
||||
|
||||
run = malloc(sizeof(TEXTRUN));
|
||||
if (run == NULL) {
|
||||
_ERR_PRINTF("%s: failed to allocate space for new glyph runs\n",
|
||||
__FUNCTION__);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
run->lc = state->derived_lang;
|
||||
run->st = state->script_iter.script;
|
||||
run->el = state->emb_level;
|
||||
run->dir = state->runinfo->run_dir;
|
||||
run->ort = state->ort_rsv;
|
||||
run->lf = create_logfont_for_run(state->runinfo, run);
|
||||
run->gs = NULL;
|
||||
run->ngs = 0;
|
||||
run->idx = state->run_end - state->text;
|
||||
run->len = state->run_end - state->run_start;
|
||||
list_add(&run->list, &state->runinfo->run_head);
|
||||
|
||||
state->runinfo->nr_runs++;
|
||||
|
||||
return TRUE;
|
||||
|
||||
#if 0
|
||||
const Uchar32 *p;
|
||||
BOOL last_was_forced_break = FALSE;
|
||||
|
||||
/* Only one character has the category LINE_SEPARATOR in Unicode 12.0;
|
||||
* update this if that changes. */
|
||||
#define LINE_SEPARATOR 0x2028
|
||||
|
||||
state_update_for_new_run (state);
|
||||
|
||||
for (p = state->run_start; p < state->run_end; p++) {
|
||||
Uchar32 wc = *p;
|
||||
BOOL is_forced_break = (wc == '\t' || wc == LINE_SEPARATOR);
|
||||
@@ -207,46 +233,12 @@ static void state_process_run (GLYPHRUNSTATE *state)
|
||||
else {
|
||||
}
|
||||
|
||||
is_forced_break = last_was_forced_break; // supress warning
|
||||
last_was_forced_break = is_forced_break;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Finish the final item from the current segment */
|
||||
state->item->length = (p - state->text) - state->item->offset;
|
||||
if (!state->item->analysis.shape_engine) {
|
||||
PangoEngineShape *shape_engine;
|
||||
PangoFont *font;
|
||||
|
||||
if ((!get_shaper_and_font (state, ' ', &shape_engine, &font))) {
|
||||
/* If no shaper was found, warn only once per fontmap/script pair */
|
||||
PangoFontMap *fontmap = state->context->font_map;
|
||||
const char *script_name = string_from_script (get_script (state));
|
||||
|
||||
if (!g_object_get_data (G_OBJECT (fontmap), script_name))
|
||||
{
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
g_warning ("failed to choose a font, expect ugly output. engine-type='%s', script='%s'",
|
||||
pango_font_map_get_shape_engine_type (fontmap),
|
||||
script_name);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
||||
g_object_set_data_full (G_OBJECT (fontmap), script_name,
|
||||
GINT_TO_POINTER (1), NULL);
|
||||
}
|
||||
|
||||
shape_engine = _pango_get_fallback_shaper ();
|
||||
font = NULL;
|
||||
}
|
||||
|
||||
itemize_state_fill_shaper (state, shape_engine, font);
|
||||
}
|
||||
|
||||
state->item = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
static BOOL state_next (GLYPHRUNSTATE *state)
|
||||
static BOOL state_next (TEXTRUNSTATE *state)
|
||||
{
|
||||
if (state->run_end == state->end)
|
||||
return FALSE;
|
||||
@@ -278,23 +270,10 @@ static BOOL state_next (GLYPHRUNSTATE *state)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static inline Uint8 get_glyph_orient_from_logfont (LOGFONT* lf)
|
||||
{
|
||||
return GLYPH_ORIENT_SOUTH;
|
||||
}
|
||||
|
||||
static void update_resolved_orientation (GLYPHRUNINFO *runinfo)
|
||||
{
|
||||
if (runinfo->ort_base == GLYPH_ORIENT_AUTO)
|
||||
runinfo->ort_rsv = get_glyph_orient_from_logfont (runinfo->lf);
|
||||
else
|
||||
runinfo->ort_rsv = runinfo->ort_base;
|
||||
}
|
||||
|
||||
static BOOL create_glyph_runs(GLYPHRUNINFO* runinfo, BidiLevel* els)
|
||||
static BOOL create_glyph_runs(TEXTRUNSINFO* runinfo, BidiLevel* els)
|
||||
{
|
||||
BOOL ok = FALSE;
|
||||
GLYPHRUNSTATE state;
|
||||
TEXTRUNSTATE state;
|
||||
Uint8 local_types_buff[LOCAL_ARRAY_SIZE];
|
||||
Uint8* types_buff = NULL;
|
||||
|
||||
@@ -327,9 +306,14 @@ static BOOL create_glyph_runs(GLYPHRUNINFO* runinfo, BidiLevel* els)
|
||||
update_end (&state);
|
||||
|
||||
do {
|
||||
state_process_run (&state);
|
||||
|
||||
if (!state_process_run (&state))
|
||||
goto out;
|
||||
|
||||
} while (state_next (&state));
|
||||
|
||||
ok = TRUE;
|
||||
|
||||
out:
|
||||
if (types_buff && types_buff != local_types_buff)
|
||||
free (types_buff);
|
||||
@@ -337,19 +321,33 @@ out:
|
||||
return ok;
|
||||
}
|
||||
|
||||
GLYPHRUNINFO* GUIAPI CreateGlyphRunInfo(Uchar32* ucs, int nr_ucs,
|
||||
LanguageCode lang_code, ScriptType script_type,
|
||||
ParagraphDir base_dir, GlyphRunDir run_dir,
|
||||
static inline Uint8 get_glyph_orient_from_logfont (LOGFONT* lf)
|
||||
{
|
||||
switch (lf->rotation) {
|
||||
case -900:
|
||||
return GLYPH_ORIENT_EAST;
|
||||
case 900:
|
||||
return GLYPH_ORIENT_WEST;
|
||||
case 1800:
|
||||
return GLYPH_ORIENT_NORTH;
|
||||
case 0:
|
||||
default:
|
||||
return GLYPH_ORIENT_SOUTH;
|
||||
}
|
||||
}
|
||||
|
||||
TEXTRUNSINFO* GUIAPI CreateTextRunsInfo(Uchar32* ucs, int nr_ucs,
|
||||
LanguageCode lang_code, ParagraphDir base_dir, GlyphRunDir run_dir,
|
||||
GlyphOrient glyph_orient, GlyphOrientPolicy orient_policy,
|
||||
LOGFONT* logfont, RGBCOLOR color)
|
||||
{
|
||||
BOOL ok = FALSE;
|
||||
|
||||
GLYPHRUNINFO* runinfo;
|
||||
TEXTRUNSINFO* runinfo;
|
||||
BidiLevel local_els[LOCAL_ARRAY_SIZE];
|
||||
BidiLevel* els = NULL;
|
||||
|
||||
runinfo = (GLYPHRUNINFO*)calloc(1, sizeof(GLYPHRUNINFO));
|
||||
runinfo = (TEXTRUNSINFO*)calloc(1, sizeof(TEXTRUNSINFO));
|
||||
if (ucs == NULL || nr_ucs <= 0 || runinfo == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -380,7 +378,6 @@ GLYPHRUNINFO* GUIAPI CreateGlyphRunInfo(Uchar32* ucs, int nr_ucs,
|
||||
runinfo->lf = logfont;
|
||||
runinfo->nr_ucs = nr_ucs;
|
||||
runinfo->lc = lang_code;
|
||||
runinfo->st = script_type;
|
||||
runinfo->base_dir = (base_dir == BIDI_PGDIR_LTR) ? 0 : 1;
|
||||
runinfo->run_dir = run_dir;
|
||||
runinfo->ort_base = glyph_orient;
|
||||
@@ -392,8 +389,12 @@ GLYPHRUNINFO* GUIAPI CreateGlyphRunInfo(Uchar32* ucs, int nr_ucs,
|
||||
runinfo->cm_head.color = color;
|
||||
|
||||
INIT_LIST_HEAD(&runinfo->run_head);
|
||||
runinfo->nr_runs = 0;
|
||||
|
||||
update_resolved_orientation(runinfo);
|
||||
if (runinfo->ort_base == GLYPH_ORIENT_AUTO)
|
||||
runinfo->ort_rsv = get_glyph_orient_from_logfont (runinfo->lf);
|
||||
else
|
||||
runinfo->ort_rsv = runinfo->ort_base;
|
||||
|
||||
#if 0
|
||||
int i, j;
|
||||
@@ -422,7 +423,8 @@ GLYPHRUNINFO* GUIAPI CreateGlyphRunInfo(Uchar32* ucs, int nr_ucs,
|
||||
#endif
|
||||
|
||||
if (!create_glyph_runs(runinfo, els)) {
|
||||
_DBG_PRINTF("%s: failed to call create_glyph_runs.\n");
|
||||
_DBG_PRINTF("%s: failed to call create_glyph_runs.\n",
|
||||
__FUNCTION__);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -440,7 +442,7 @@ out:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BOOL GUIAPI SetPartFontInGlyphRuns(GLYPHRUNINFO* runinfo,
|
||||
BOOL GUIAPI SetPartFontInTextRuns(TEXTRUNSINFO* runinfo,
|
||||
int start_index, int length, LOGFONT* logfont)
|
||||
{
|
||||
if (runinfo == NULL)
|
||||
@@ -457,7 +459,7 @@ BOOL GUIAPI SetPartFontInGlyphRuns(GLYPHRUNINFO* runinfo,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
RGBCOLOR __mg_glyphruns_get_color(const GLYPHRUNINFO* runinfo, int index)
|
||||
RGBCOLOR __mg_glyphruns_get_color(const TEXTRUNSINFO* runinfo, int index)
|
||||
{
|
||||
struct list_head *i;
|
||||
|
||||
@@ -473,7 +475,7 @@ RGBCOLOR __mg_glyphruns_get_color(const GLYPHRUNINFO* runinfo, int index)
|
||||
return runinfo->cm_head.color;
|
||||
}
|
||||
|
||||
BOOL GUIAPI SetPartColorInGlyphRuns(GLYPHRUNINFO* runinfo,
|
||||
BOOL GUIAPI SetPartColorInTextRuns(TEXTRUNSINFO* runinfo,
|
||||
int start_index, int length, RGBCOLOR color)
|
||||
{
|
||||
UCHARCOLORMAP* color_entry = NULL;
|
||||
@@ -501,13 +503,13 @@ error:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL GUIAPI ResetFontInGlyphRuns(GLYPHRUNINFO* runinfo, LOGFONT* logfont)
|
||||
BOOL GUIAPI ResetFontInTextRuns(TEXTRUNSINFO* runinfo, LOGFONT* logfont)
|
||||
{
|
||||
if (runinfo == NULL)
|
||||
return FALSE;
|
||||
|
||||
while (!list_empty(&runinfo->run_head)) {
|
||||
GLYPHRUN* run = (GLYPHRUN*)runinfo->run_head.prev;
|
||||
TEXTRUN* run = (TEXTRUN*)runinfo->run_head.prev;
|
||||
list_del(runinfo->run_head.prev);
|
||||
runinfo->se.destroy_glyphs(runinfo->se.engine, run->gs);
|
||||
free(run);
|
||||
@@ -517,27 +519,17 @@ BOOL GUIAPI ResetFontInGlyphRuns(GLYPHRUNINFO* runinfo, LOGFONT* logfont)
|
||||
runinfo->se.destroy_engine(runinfo->se.engine);
|
||||
}
|
||||
|
||||
if (runinfo->l2g) {
|
||||
free(runinfo->l2g);
|
||||
runinfo->l2g = NULL;
|
||||
}
|
||||
|
||||
if (runinfo->ges) {
|
||||
free(runinfo->ges);
|
||||
runinfo->ges = NULL;
|
||||
}
|
||||
|
||||
runinfo->lf = logfont;
|
||||
|
||||
return create_glyph_runs(runinfo, NULL);
|
||||
}
|
||||
|
||||
static void set_run_dir(GLYPHRUNINFO* runinfo, GLYPHRUN* run,
|
||||
static void set_run_dir(TEXTRUNSINFO* runinfo, TEXTRUN* run,
|
||||
GlyphRunDir run_dir, GlyphOrient glyph_orient)
|
||||
{
|
||||
}
|
||||
|
||||
BOOL GUIAPI ResetDirectionInGlyphRuns(GLYPHRUNINFO* runinfo,
|
||||
BOOL GUIAPI ResetDirectionInTextRuns(TEXTRUNSINFO* runinfo,
|
||||
GlyphRunDir run_dir, GlyphOrient glyph_orient,
|
||||
GlyphOrientPolicy orient_policy)
|
||||
{
|
||||
@@ -551,7 +543,7 @@ BOOL GUIAPI ResetDirectionInGlyphRuns(GLYPHRUNINFO* runinfo,
|
||||
runinfo->ort_plc = orient_policy;
|
||||
|
||||
list_for_each(i, &runinfo->run_head) {
|
||||
GLYPHRUN* run = (GLYPHRUN*)i;
|
||||
TEXTRUN* run = (TEXTRUN*)i;
|
||||
if (runinfo->se.engine && run->gs) {
|
||||
runinfo->se.destroy_glyphs(runinfo->se.engine, run->gs);
|
||||
}
|
||||
@@ -559,16 +551,6 @@ BOOL GUIAPI ResetDirectionInGlyphRuns(GLYPHRUNINFO* runinfo,
|
||||
set_run_dir(runinfo, run, run_dir, glyph_orient);
|
||||
}
|
||||
|
||||
if (runinfo->l2g) {
|
||||
free(runinfo->l2g);
|
||||
runinfo->l2g = NULL;
|
||||
}
|
||||
|
||||
if (runinfo->ges) {
|
||||
free(runinfo->ges);
|
||||
runinfo->ges = NULL;
|
||||
}
|
||||
|
||||
if (runinfo->se.engine) {
|
||||
runinfo->se.destroy_engine(runinfo->se.engine);
|
||||
runinfo->se.engine = NULL;
|
||||
@@ -577,7 +559,7 @@ BOOL GUIAPI ResetDirectionInGlyphRuns(GLYPHRUNINFO* runinfo,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL GUIAPI ResetColorInGlyphRuns(GLYPHRUNINFO* runinfo, RGBCOLOR color)
|
||||
BOOL GUIAPI ResetColorInTextRuns(TEXTRUNSINFO* runinfo, RGBCOLOR color)
|
||||
{
|
||||
if (runinfo == NULL)
|
||||
return FALSE;
|
||||
@@ -593,7 +575,7 @@ BOOL GUIAPI ResetColorInGlyphRuns(GLYPHRUNINFO* runinfo, RGBCOLOR color)
|
||||
}
|
||||
|
||||
#if 0
|
||||
BOOL GUIAPI ResetBreaksInGlyphRuns(GLYPHRUNINFO* runinfo,
|
||||
BOOL GUIAPI ResetBreaksInTextRuns(TEXTRUNSINFO* runinfo,
|
||||
Uint8 ctr, Uint8 wbr, Uint8 lbp)
|
||||
{
|
||||
if (runinfo == NULL)
|
||||
@@ -610,7 +592,7 @@ BOOL GUIAPI ResetBreaksInGlyphRuns(GLYPHRUNINFO* runinfo,
|
||||
}
|
||||
#endif
|
||||
|
||||
BOOL GUIAPI DestroyGlyphRunInfo(GLYPHRUNINFO* runinfo)
|
||||
BOOL GUIAPI DestroyTextRunsInfo(TEXTRUNSINFO* runinfo)
|
||||
{
|
||||
if (runinfo == NULL)
|
||||
return FALSE;
|
||||
@@ -622,7 +604,7 @@ BOOL GUIAPI DestroyGlyphRunInfo(GLYPHRUNINFO* runinfo)
|
||||
}
|
||||
|
||||
while (!list_empty(&runinfo->run_head)) {
|
||||
GLYPHRUN* run = (GLYPHRUN*)runinfo->run_head.prev;
|
||||
TEXTRUN* run = (TEXTRUN*)runinfo->run_head.prev;
|
||||
list_del(runinfo->run_head.prev);
|
||||
runinfo->se.destroy_glyphs(runinfo->se.engine, run->gs);
|
||||
free(run);
|
||||
@@ -632,9 +614,6 @@ BOOL GUIAPI DestroyGlyphRunInfo(GLYPHRUNINFO* runinfo)
|
||||
runinfo->se.destroy_engine(runinfo->se.engine);
|
||||
}
|
||||
|
||||
if (runinfo->l2g) free(runinfo->l2g);
|
||||
if (runinfo->ges) free(runinfo->ges);
|
||||
|
||||
free(runinfo);
|
||||
return TRUE;
|
||||
}
|
||||
@@ -33,13 +33,13 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
** glyphruninfo.h: Internal interface related GLYPHRUNINFO.
|
||||
** glyphruninfo.h: Internal interface related TEXTRUNSINFO.
|
||||
**
|
||||
** Create by WEI Yongming at 2019/03/15
|
||||
*/
|
||||
|
||||
#ifndef _MG_NEWGDI_GLYPHRUNINFO_H
|
||||
#define _MG_NEWGDI_GLYPHRUNINFO_H
|
||||
#ifndef _MG_NEWGDI_TEXTRUNSINFO_H
|
||||
#define _MG_NEWGDI_TEXTRUNSINFO_H
|
||||
|
||||
#include "list.h"
|
||||
|
||||
@@ -68,28 +68,54 @@ typedef struct _SHAPPINGENGINE {
|
||||
CB_DESTROY_ENGINE destroy_engine;
|
||||
} SHAPPINGENGINE;
|
||||
|
||||
typedef struct _GLYPHRUN {
|
||||
typedef struct _TEXTRUN {
|
||||
struct list_head list;
|
||||
LOGFONT* lf; // the logfont for this run
|
||||
|
||||
void* gs; // the shaped glyph information
|
||||
|
||||
int nr_gs; // the number of shaped glyphs
|
||||
int si; // start index in the Unicode string
|
||||
int nr_ucs; // the number of Unicode characters
|
||||
int idx; // start index in the Unicode string
|
||||
int len; // the number of Unicode characters
|
||||
|
||||
Uint32 lc:8; // language code
|
||||
Uint32 st:8; // script type
|
||||
Uint32 level:8; // the bidi level
|
||||
Uint32 dir:4; // the run direction
|
||||
Uint32 ort:2; // the glyph orientation
|
||||
} GLYPHRUN;
|
||||
int ngs; // the number of shaped glyphs
|
||||
|
||||
// NOTE: we arrange the fields carefully to avoid wasting space when
|
||||
// we allocate an array of this structure due to the alignment.
|
||||
typedef struct _MAPL2G {
|
||||
GLYPHRUN* glyph_run; // the glyph run this char belongs to.
|
||||
int glyph_index; // the index of the glyph in the run.
|
||||
} MAPL2G;
|
||||
Uint32 lc:8; // language code
|
||||
Uint32 st:8; // script type
|
||||
Uint32 el:8; // the bidi embedding level
|
||||
Uint32 dir:4; // the run direction
|
||||
Uint32 ort:2; // the glyph orientation
|
||||
} TEXTRUN;
|
||||
|
||||
typedef struct _LAYOUTINFO LAYOUTINFO;
|
||||
|
||||
typedef struct _LAYOUTRUN {
|
||||
struct list_head list;
|
||||
TEXTRUN* text_run; // the glyph run
|
||||
int start_idx; // the index in glyph run
|
||||
int nr_glyphs; // the number of glyphs
|
||||
} LAYOUTRUN;
|
||||
|
||||
typedef struct _LAYOUTLINE {
|
||||
LAYOUTINFO* layout_info;
|
||||
|
||||
struct list_head run_head; // the list head for layout runs
|
||||
|
||||
int idx; // the index in uchar string
|
||||
int len; // the length in uchar string
|
||||
|
||||
Uint8 first_line:1; // is first line of the paragraph?
|
||||
Uint8 resolved_dir:3; // resolved direction of the line
|
||||
Uint8 all_even:1; // flag indicating all level is even
|
||||
Uint8 all_odd:1; // flag indicating all level is odd
|
||||
} LAYOUTLINE;
|
||||
|
||||
struct _LAYOUTINFO {
|
||||
const TEXTRUNSINFO* runinfo;
|
||||
|
||||
struct list_head line_head;
|
||||
|
||||
int nr_lines;
|
||||
};
|
||||
|
||||
typedef struct _UCHARCOLORMAP {
|
||||
struct list_head list;
|
||||
@@ -98,44 +124,36 @@ typedef struct _UCHARCOLORMAP {
|
||||
RGBCOLOR color;
|
||||
} UCHARCOLORMAP;
|
||||
|
||||
struct _GLYPHRUNINFO {
|
||||
struct _TEXTRUNSINFO {
|
||||
/* The following fields will be initialized by CreateGlyphRunInfo. */
|
||||
const Uchar32* ucs; // the uchars
|
||||
LOGFONT* lf; // the logfont specified
|
||||
|
||||
UCHARCOLORMAP cm_head;// the head of color map list of the characters
|
||||
// change by calling SetPartColorInGlyphRunInfo
|
||||
struct list_head run_head; // glyph runs
|
||||
// change by SetPartFontInGlyphRunInfo
|
||||
UCHARCOLORMAP cm_head; // the head of color map list of the characters
|
||||
struct list_head run_head;// glyph runs (list)
|
||||
|
||||
int nr_ucs; // number of uchars
|
||||
int nr_runs; // number of runs
|
||||
Uint32 lc:8; // language code specified
|
||||
Uint32 st:8; // script type 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 base_dir:1; // the paragraph direction; 0 for LTR, 1 for RTL
|
||||
Uint32 all_even:1; // flag indicating all level is even
|
||||
Uint32 all_odd:1; // flag indicating all level is odd
|
||||
|
||||
/* The following fields will be initialized by the shapping engine. */
|
||||
SHAPPINGENGINE se; // the shapping engine
|
||||
MAPL2G* l2g; // the logical character to glyph map
|
||||
GLYPHEXTINFO* ges; // the glyph extent information
|
||||
|
||||
Uint32 rf; // the rendering flags
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
RGBCOLOR __mg_glyphruns_get_color(const GLYPHRUNINFO* runinfo, int index);
|
||||
RGBCOLOR __mg_glyphruns_get_color(const TEXTRUNSINFO* runinfo, int index);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif // _MG_NEWGDI_GLYPHRUNINFO_H
|
||||
#endif // _MG_NEWGDI_TEXTRUNSINFO_H
|
||||
|
||||
Reference in New Issue
Block a user