mirror of
https://github.com/VincentWei/MiniGUI.git
synced 2026-09-25 11:07:54 +08:00
cleanup BIDI APIs
This commit is contained in:
+86
-29
@@ -9577,8 +9577,11 @@ typedef Uint32 Glyph32;
|
||||
* \brief Data type of struct _GLYPHMAPINFO.
|
||||
*/
|
||||
typedef struct _GLYPHMAPINFO {
|
||||
/** The index of the character in the text string. */
|
||||
int byte_index;
|
||||
/** The length of the character in bytes. */
|
||||
int char_len;
|
||||
/** The direction of the glyph; TRUE for RTL, FALSE for LTR. */
|
||||
BOOL is_rtol;
|
||||
} GLYPHMAPINFO;
|
||||
|
||||
@@ -10451,7 +10454,6 @@ MG_EXPORT int GUIAPI GetGlyphsByRules(LOGFONT* logfont,
|
||||
* - The direction of the glyphs;
|
||||
* - The writing mode (horizontal or vertical) and text orientation;
|
||||
* - The hyphenation handling method;
|
||||
* - The BIDI method;
|
||||
* - The hanging punctation method;
|
||||
* - Whether and how to adjust the glyph position for alignment of justify.
|
||||
* @{
|
||||
@@ -10499,14 +10501,6 @@ MG_EXPORT int GUIAPI GetGlyphsByRules(LOGFONT* logfont,
|
||||
#define GRF_TEXT_COMBINE_UPRIGHT_NONE 0x00000000
|
||||
#define GRF_TEXT_COMBINE_UPRIGHT_ALL 0x00040000
|
||||
|
||||
#define GRF_BIDI_MASK 0x00F00000
|
||||
#define GRF_BIDI_NORMAL 0x00000000
|
||||
#define GRF_BIDI_EMBED 0x00100000
|
||||
#define GRF_BIDI_ISOLATE 0x00200000
|
||||
#define GRF_BIDI_BIDI_OVERRIDE 0x00300000
|
||||
#define GRF_BIDI_ISOLATE_OVERRIDE 0x00400000
|
||||
#define GRF_BIDI_PLAINTEXT 0x00500000
|
||||
|
||||
#define GRF_ALIGN_MASK 0x0F000000
|
||||
#define GRF_ALIGN_LEFT 0x00000000
|
||||
#define GRF_ALIGN_RIGHT 0x01000000
|
||||
@@ -10582,7 +10576,8 @@ typedef struct _GLYPHPOSORT {
|
||||
* \param logfont The logfont used to parse the glyph string.
|
||||
* \param x The x-position of first glyph.
|
||||
* \param y The y-position of first glyph.
|
||||
* \param glyphs The pointer to the glyph string.
|
||||
* \param glyphs The pointer to the glyph string. The glyphs should be reordered
|
||||
* to be visual ones by calling BIDI functions.
|
||||
* \param break_opps The pointer to the break opportunities array of the glpyhs.
|
||||
* It should be returned by \a GetGlyphsByRules.
|
||||
* \param nr_glyphs The number of the glyphs.
|
||||
@@ -10999,28 +10994,68 @@ MG_EXPORT int GUIAPI BIDIGetTextVisualGlyphs (LOGFONT* log_font,
|
||||
const char* text, int text_len, Glyph32** glyphs,
|
||||
GLYPHMAPINFO** glyphs_map);
|
||||
|
||||
/** \fn Glyph32* GUIAPI BIDILogGlyphs2VisGlyphs (LOGFONT* log_font,
|
||||
* Glyph32* glyphs, int nr_glyphs, GLYPHMAPINFO* glyphs_map)
|
||||
* \brief Reorder the logical glyphs string to visual glyphs string.
|
||||
/** \fn BOOL GUIAPI BIDILogGlyphs2VisGlyphsEx (LOGFONT* log_font,
|
||||
* Glyph32* glyphs, int nr_glyphs, GLYPHMAPINFO* glyph_map, int pel)
|
||||
* \brief Reorder the specified logical glyph string to the visual glyph string.
|
||||
*
|
||||
* This function reorders the logical glyphs string to visual
|
||||
* glyphs string. If \a glyphs_map is not NULL, also returns the visual
|
||||
* glyphs map info.
|
||||
* This function reorders the logical glyph string in place to a visual
|
||||
* glyphs string. If \a index_map is not NULL, it also returns
|
||||
* the index of logical glyphs.
|
||||
*
|
||||
* \param log_font The logical font.
|
||||
* \param glyphs The pointer to the glyph string.
|
||||
* \param nr_glyphs The length of the glyph string.
|
||||
* \param glyphs_map The position map from the logical glyph string to
|
||||
* the visual glyph string.
|
||||
* \param glyphs_map The position map returned by \a BIDIGetTextLogicalGlyphs;
|
||||
* can be NULL.
|
||||
* \param pel The paragraph embedding level, can be one of the following values:
|
||||
* - 0: Level 0 (left to right)
|
||||
* - 1: Level 1 (right to left)
|
||||
* - others: Determine according to the heuristic given in
|
||||
* steps P2 and P3 of the Unicode bidirectional algorithm.
|
||||
*
|
||||
* \return The pointer to the visual glyph string.
|
||||
* \return TRUE on success, otherwise FALSE.
|
||||
*/
|
||||
MG_EXPORT Glyph32* GUIAPI BIDILogGlyphs2VisGlyphs (LOGFONT* log_font,
|
||||
Glyph32* glyphs, int nr_glyphs, GLYPHMAPINFO* glyphs_map);
|
||||
MG_EXPORT BOOL GUIAPI BIDILogGlyphs2VisGlyphsEx (LOGFONT* log_font,
|
||||
Glyph32* glyphs, int nr_glyphs, GLYPHMAPINFO* glyph_map, int pel);
|
||||
|
||||
/** obsolete; use BIDILogGlyphs2VisGlyphsEx instead */
|
||||
static inline Glyph32* BIDILogGlyphs2VisGlyphs (LOGFONT* log_font,
|
||||
Glyph32* glyphs, int nr_glyphs, GLYPHMAPINFO* glyph_map)
|
||||
{
|
||||
if (BIDILogGlyphs2VisGlyphsEx (log_font, glyphs, nr_glyphs, glyph_map, -1))
|
||||
return glyphs;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/** \fn BOOL GUIAPI BIDIGetVisualGlyphIndexMap (LOGFONT* log_font,
|
||||
* Glyph32* glyphs, int nr_glyphs, int** index_map, int pel)
|
||||
* \brief Reorder the specified logical glyph string to the visual glyph string.
|
||||
*
|
||||
* This function reorders the logical glyph string in place to a visual
|
||||
* glyphs string. If \a index_map is not NULL, it also returns
|
||||
* the index of logical glyphs.
|
||||
*
|
||||
* \param log_font The logical font.
|
||||
* \param glyphs The pointer to the glyph string.
|
||||
* \param nr_glyphs The length of the glyph string.
|
||||
* \param index_map The pointer to the position map from the logical glyph string to
|
||||
* the visual glyph string. If *index_map is NULL, the function will
|
||||
* try to allocate a new one. The caller should free it when it is not useful.
|
||||
* \param pel The paragraph embedding level, can be one of the following values:
|
||||
* - 0: Level 0 (left to right)
|
||||
* - 1: Level 1 (right to left)
|
||||
* - others: Determine according to the heuristic given in
|
||||
* steps P2 and P3 of the Unicode bidirectional algorithm.
|
||||
*
|
||||
* \return TRUE on success, otherwise FALSE.
|
||||
*/
|
||||
MG_EXPORT BOOL GUIAPI BIDIGetVisualGlyphIndexMap (LOGFONT* log_font,
|
||||
Glyph32* glyphs, int nr_glyphs, int** index_map, int pel);
|
||||
|
||||
/**
|
||||
* \fn void GUIAPI BIDIGetLogicalEmbedLevels (LOGFONT* log_font, \
|
||||
Glyph32* glyphs, int nr_glyphs, Uint8** embed_levels)
|
||||
* \fn void GUIAPI BIDIGetLogicalEmbedLevelsEx (LOGFONT* log_font, \
|
||||
const Glyph32* glyphs, int nr_glyphs, int pel, Uint8** embed_levels)
|
||||
* \brief Get the logical embedding levels for the logical glyph string
|
||||
* and generate runs by embedding levels, the for reorder to get
|
||||
* visual glyph string.
|
||||
@@ -11028,28 +11063,50 @@ MG_EXPORT Glyph32* GUIAPI BIDILogGlyphs2VisGlyphs (LOGFONT* log_font,
|
||||
* \param log_font The logical font.
|
||||
* \param glyphs The pointer to the logical glyph string.
|
||||
* \param nr_glyphs The length of the glyph string.
|
||||
* \param pel The paragraph embedding level, can be one of the following values:
|
||||
* - 0: Level 0 (left to right)
|
||||
* - 1: Level 1 (right to left)
|
||||
* - others: Determine according to the heuristic given in
|
||||
* steps P2 and P3 of the Unicode bidirectional algorithm.
|
||||
* \param embed_levels The logical embedding level.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
MG_EXPORT void GUIAPI BIDIGetLogicalEmbedLevels (LOGFONT* log_font,
|
||||
Glyph32* glyphs, int nr_glyphs, Uint8** embed_levels);
|
||||
MG_EXPORT void GUIAPI BIDIGetLogicalEmbedLevelsEx (LOGFONT* log_font,
|
||||
Glyph32* glyphs, int nr_glyphs, int pel, Uint8** embed_levels);
|
||||
|
||||
static inline void BIDIGetLogicalEmbeddLevels (LOGFONT* log_font,
|
||||
Glyph32* glyphs, int nr_glyphs, Uint8** embed_levels)
|
||||
{
|
||||
BIDIGetLogicalEmbedLevelsEx (log_font, glyphs, nr_glyphs, -1, embed_levels);
|
||||
}
|
||||
|
||||
/**
|
||||
* \fn void GUIAPI BIDIGetVisualEmbedLevels (LOGFONT* log_font,
|
||||
Glyph32* glyphs, int nr_glyphs, Uint8** embed_levels)
|
||||
* \fn void GUIAPI BIDIGetVisualEmbedLevelsEx (LOGFONT* log_font,
|
||||
const Glyph32* glyphs, int nr_glyphs, int pel, Uint8** embed_levels)
|
||||
* \brief Get the visual embedding levels for the given logical glyph
|
||||
* string, then you can get the edge for visual glyphs.
|
||||
*
|
||||
* \param log_font The logical font.
|
||||
* \param glyphs The pointer to the logical glyph string.
|
||||
* \param nr_glyphs The length of the glyph string.
|
||||
* \param pel The paragraph embedding level, can be one of the following values:
|
||||
* - 0: Level 0 (left to right)
|
||||
* - 1: Level 1 (right to left)
|
||||
* - others: Determine according to the heuristic given in
|
||||
* steps P2 and P3 of the Unicode bidirectional algorithm.
|
||||
* \param embed_levels The embedding level logical to visual.
|
||||
*
|
||||
* \return void.
|
||||
*/
|
||||
MG_EXPORT void GUIAPI BIDIGetVisualEmbedLevels (LOGFONT* log_font,
|
||||
Glyph32* glyphs, int nr_glyphs, Uint8** embed_levels);
|
||||
MG_EXPORT void GUIAPI BIDIGetVisualEmbedLevelsEx (LOGFONT* log_font,
|
||||
Glyph32* glyphs, int nr_glyphs, int pel, Uint8** embed_levels);
|
||||
|
||||
static inline void BIDIGetVisualEmbeddLevels (LOGFONT* log_font,
|
||||
Glyph32* glyphs, int nr_glyphs, Uint8** embed_levels)
|
||||
{
|
||||
BIDIGetVisualEmbedLevelsEx (log_font, glyphs, nr_glyphs, -1, embed_levels);
|
||||
}
|
||||
|
||||
/** @} end of glyph */
|
||||
/*
|
||||
|
||||
+24
-18
@@ -532,7 +532,8 @@ static void bidi_string_reverse (void* context, int len, int pos)
|
||||
}
|
||||
}
|
||||
|
||||
static void bidi_resolve_string (const CHARSETOPS* charset_ops, Glyph32* glyphs, int len,
|
||||
static void bidi_resolve_string (const CHARSETOPS* charset_ops,
|
||||
Glyph32* glyphs, int len, int pel,
|
||||
TYPERUN **ptype_rl_list, BYTE *pmax_level)
|
||||
{
|
||||
BYTE base_level = 0;
|
||||
@@ -543,7 +544,13 @@ static void bidi_resolve_string (const CHARSETOPS* charset_ops, Glyph32* glyphs,
|
||||
type_rl_list = get_runtype_link (charset_ops, glyphs, len);
|
||||
|
||||
/* 1.Find base level */
|
||||
bidi_resolveParagraphs(&type_rl_list, &base_dir, &base_level);
|
||||
if (pel != 0 && pel != 1) {
|
||||
bidi_resolveParagraphs(&type_rl_list, &base_dir, &base_level);
|
||||
}
|
||||
else {
|
||||
base_level = pel;
|
||||
base_dir = BIDI_LEVEL_TO_DIR (base_level);
|
||||
}
|
||||
|
||||
/* 2.Resolving Explicit levels.*/
|
||||
bidi_resolveExplicit(&type_rl_list, base_dir);
|
||||
@@ -590,8 +597,8 @@ static void bidi_reorder_cb (void* context, int len,
|
||||
DBGLOG("\nReordering, Done\n");
|
||||
}
|
||||
|
||||
void __mg_charset_bidi_get_embeddlevels (const CHARSETOPS* charset_ops, Glyph32* glyphs, int len,
|
||||
Uint8* embedding_level_list, Uint8 type)
|
||||
void __mg_charset_bidi_get_embeddlevels (const CHARSETOPS* charset_ops,
|
||||
Glyph32* glyphs, int len, int pel, Uint8* embedding_levels, Uint8 type)
|
||||
{
|
||||
int i = 0;
|
||||
BYTE max_level = 1;
|
||||
@@ -600,16 +607,16 @@ void __mg_charset_bidi_get_embeddlevels (const CHARSETOPS* charset_ops, Glyph32*
|
||||
print_hexstr(glyphs, len, FALSE);
|
||||
|
||||
/* W1~W7, N1~N2, I1~I2, Get the Embedding Level. */
|
||||
bidi_resolve_string (charset_ops, glyphs, len, &type_rl_list, &max_level);
|
||||
bidi_resolve_string (charset_ops, glyphs, len, pel, &type_rl_list, &max_level);
|
||||
|
||||
/* type = 0, get the logical embedding level; else visual level.*/
|
||||
for (pp = type_rl_list->next; pp->next; pp = pp->next){
|
||||
int pos = POS (pp), len = LEN (pp);
|
||||
for(i = 0; i < len; i++)
|
||||
embedding_level_list[pos + i] = LEVEL(pp);
|
||||
embedding_levels[pos + i] = LEVEL(pp);
|
||||
}
|
||||
if (type) {
|
||||
bidi_reorder_cb(embedding_level_list, len, &type_rl_list, max_level,
|
||||
bidi_reorder_cb(embedding_levels, len, &type_rl_list, max_level,
|
||||
bidi_index_reverse);
|
||||
}
|
||||
|
||||
@@ -619,8 +626,8 @@ void __mg_charset_bidi_get_embeddlevels (const CHARSETOPS* charset_ops, Glyph32*
|
||||
print_hexstr(glyphs, len, TRUE);
|
||||
}
|
||||
|
||||
Glyph32* __mg_charset_bidi_map_reorder (const CHARSETOPS* charset_ops, Glyph32* glyphs,
|
||||
int len, GLYPHMAPINFO* map)
|
||||
Glyph32* __mg_charset_bidi_map_reorder (const CHARSETOPS* charset_ops,
|
||||
Glyph32* glyphs, int len, GLYPHMAPINFO* map, int pel)
|
||||
{
|
||||
BYTE max_level = 1;
|
||||
TYPERUN *type_rl_list = NULL;
|
||||
@@ -632,11 +639,9 @@ Glyph32* __mg_charset_bidi_map_reorder (const CHARSETOPS* charset_ops, Glyph32*
|
||||
print_hexstr(glyphs, len, FALSE);
|
||||
|
||||
/* W1~W7, N1~N2, I1~I2, Get the Embedding Level. */
|
||||
bidi_resolve_string (charset_ops, glyphs, len, &type_rl_list, &max_level);
|
||||
bidi_resolve_string (charset_ops, glyphs, len, pel, &type_rl_list, &max_level);
|
||||
|
||||
for (node_p=type_rl_list->next; node_p->next;
|
||||
node_p=node_p->next)
|
||||
{
|
||||
for (node_p=type_rl_list->next; node_p->next; node_p=node_p->next) {
|
||||
run_pos = node_p->pos;
|
||||
run_len = node_p->len;
|
||||
|
||||
@@ -657,8 +662,8 @@ Glyph32* __mg_charset_bidi_map_reorder (const CHARSETOPS* charset_ops, Glyph32*
|
||||
return glyphs;
|
||||
}
|
||||
|
||||
Glyph32* __mg_charset_bidi_index_reorder (const CHARSETOPS* charset_ops, Glyph32* glyphs,
|
||||
int len, int* index_map)
|
||||
Glyph32* __mg_charset_bidi_index_reorder (const CHARSETOPS* charset_ops,
|
||||
Glyph32* glyphs, int len, int* index_map, int pel)
|
||||
{
|
||||
BYTE max_level = 1;
|
||||
TYPERUN *type_rl_list = NULL;
|
||||
@@ -666,7 +671,7 @@ Glyph32* __mg_charset_bidi_index_reorder (const CHARSETOPS* charset_ops, Glyph32
|
||||
print_hexstr(glyphs, len, FALSE);
|
||||
|
||||
/* W1~W7, N1~N2, I1~I2, Get the Embedding Level. */
|
||||
bidi_resolve_string (charset_ops, glyphs, len, &type_rl_list, &max_level);
|
||||
bidi_resolve_string (charset_ops, glyphs, len, pel, &type_rl_list, &max_level);
|
||||
|
||||
bidi_reorder_cb(index_map, len, &type_rl_list, max_level,
|
||||
bidi_string_reverse);
|
||||
@@ -679,7 +684,8 @@ Glyph32* __mg_charset_bidi_index_reorder (const CHARSETOPS* charset_ops, Glyph32
|
||||
return glyphs;
|
||||
}
|
||||
|
||||
Glyph32* __mg_charset_bidi_glyphs_reorder (const CHARSETOPS* charset_ops, Glyph32* glyphs, int len)
|
||||
Glyph32* __mg_charset_bidi_glyphs_reorder (const CHARSETOPS* charset_ops,
|
||||
Glyph32* glyphs, int len, int pel)
|
||||
{
|
||||
BYTE max_level = 1;
|
||||
TYPERUN *type_rl_list = NULL;
|
||||
@@ -687,7 +693,7 @@ Glyph32* __mg_charset_bidi_glyphs_reorder (const CHARSETOPS* charset_ops, Glyph3
|
||||
print_hexstr(glyphs, len, FALSE);
|
||||
|
||||
/* W1~W7, N1~N2, I1~I2, Get the Embedding Level. */
|
||||
bidi_resolve_string (charset_ops, glyphs, len, &type_rl_list, &max_level);
|
||||
bidi_resolve_string (charset_ops, glyphs, len, pel, &type_rl_list, &max_level);
|
||||
|
||||
bidi_reorder_cb (glyphs, len, &type_rl_list, max_level, bidi_string_reverse);
|
||||
|
||||
|
||||
+10
-8
@@ -68,18 +68,20 @@ typedef struct _BIDICHAR_MIRROR_MAP {
|
||||
|
||||
typedef void (*CB_DO_REORDER) (void* context, int len, int pos);
|
||||
|
||||
Glyph32* __mg_charset_bidi_glyphs_reorder (const CHARSETOPS* charset_ops, Glyph32* glyphs, int len);
|
||||
Glyph32* __mg_charset_bidi_glyphs_reorder (const CHARSETOPS* charset_ops,
|
||||
Glyph32* glyphs, int len, int pel);
|
||||
|
||||
Glyph32* __mg_charset_bidi_map_reorder (const CHARSETOPS* charset_ops, Glyph32* glyphs,
|
||||
int len, GLYPHMAPINFO* map);
|
||||
Glyph32* __mg_charset_bidi_map_reorder (const CHARSETOPS* charset_ops,
|
||||
Glyph32* glyphs, int len, GLYPHMAPINFO* map, int pel);
|
||||
|
||||
void __mg_charset_bidi_get_embeddlevels (const CHARSETOPS* charset_ops, Glyph32* glyphs,
|
||||
int len, Uint8* embedding_level_list, Uint8 type);
|
||||
Glyph32* __mg_charset_bidi_index_reorder (const CHARSETOPS* charset_ops,
|
||||
Glyph32* glyphs, int len, int* index_map, int pel);
|
||||
|
||||
Glyph32* __mg_charset_bidi_index_reorder (const CHARSETOPS* charset_ops, Glyph32* glyphs,
|
||||
int len, int* index_map);
|
||||
void __mg_charset_bidi_get_embeddlevels (const CHARSETOPS* charset_ops,
|
||||
Glyph32* glyphs, int len, int pel, Uint8* embedding_levels, Uint8 type);
|
||||
|
||||
Uint32 __mg_charset_bidi_str_base_dir (const CHARSETOPS* charset_ops, Glyph32* glyphs, int len);
|
||||
Uint32 __mg_charset_bidi_str_base_dir (const CHARSETOPS* charset_ops,
|
||||
Glyph32* glyphs, int len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
+99
-130
@@ -467,7 +467,8 @@ Glyph32* _gdi_bidi_reorder (PDC pdc, const unsigned char* text, int text_len,
|
||||
if (mbc_devfont && mbc_devfont->charset_ops->bidi_glyph_type) {
|
||||
logical_glyphs = _gdi_get_glyphs_string (pdc, text, text_len, nr_glyphs);
|
||||
if (*nr_glyphs > 0)
|
||||
__mg_charset_bidi_glyphs_reorder (mbc_devfont->charset_ops, logical_glyphs, *nr_glyphs);
|
||||
__mg_charset_bidi_glyphs_reorder (mbc_devfont->charset_ops,
|
||||
logical_glyphs, *nr_glyphs, -1);
|
||||
}
|
||||
|
||||
return logical_glyphs;
|
||||
@@ -866,7 +867,8 @@ int _gdi_reorder_text_break (PDC pdc, const unsigned char* text,
|
||||
|
||||
logical_glyphs = _gdi_get_glyphs_string_break(pdc, text, text_len,
|
||||
&nr_glyphs, context);
|
||||
__mg_charset_bidi_glyphs_reorder (mbc_devfont->charset_ops, logical_glyphs, nr_glyphs);
|
||||
__mg_charset_bidi_glyphs_reorder (mbc_devfont->charset_ops,
|
||||
logical_glyphs, nr_glyphs, -1);
|
||||
|
||||
if(!logical_glyphs)
|
||||
return 0;
|
||||
@@ -980,76 +982,6 @@ int GUIAPI BIDIGetTextLogicalGlyphs(
|
||||
return i;
|
||||
}
|
||||
|
||||
/* \bref: Get the visual glyph string and the glyphs map table, if
|
||||
* caller not malloc space for glyphs or glyphs_map, it will malloc
|
||||
* space inner.
|
||||
*
|
||||
* \param LOGFONT* log_font: The logical font.
|
||||
* \param unsigned char* text: Input logical string, input.
|
||||
* \param int text_len: Input logical string len, input.
|
||||
* \param Glyph32** glyphs: visual glyph string, input/output.
|
||||
* \param GLYPHMAPINFO* glyph_map: position mapping from Visual glyphs
|
||||
* string to Logical text, output.
|
||||
*
|
||||
* \param return int : return visual glyph string len, output.
|
||||
*/
|
||||
int GUIAPI BIDIGetTextVisualGlyphs(
|
||||
LOGFONT* log_font,
|
||||
const char* text,
|
||||
int text_len,
|
||||
Glyph32** glyphs,
|
||||
GLYPHMAPINFO** glyphs_map)
|
||||
{
|
||||
int nr_glyphs = 0;
|
||||
DEVFONT* mbc_devfont = log_font->mbc_devfont;
|
||||
|
||||
if(glyphs == NULL || glyphs_map == NULL)
|
||||
return nr_glyphs;
|
||||
|
||||
nr_glyphs = BIDIGetTextLogicalGlyphs(log_font, text, text_len,
|
||||
glyphs, glyphs_map);
|
||||
|
||||
if(mbc_devfont && mbc_devfont->charset_ops->bidi_glyph_type){
|
||||
__mg_charset_bidi_map_reorder (mbc_devfont->charset_ops, *glyphs,
|
||||
nr_glyphs, *glyphs_map);
|
||||
|
||||
__mg_charset_bidi_glyphs_reorder (mbc_devfont->charset_ops, *glyphs, nr_glyphs);
|
||||
}
|
||||
return nr_glyphs;
|
||||
}
|
||||
|
||||
/* bref: reorder the logical glyphs string to visual glyphs string.
|
||||
* if glyphs_map not NULL, get the visual glyphs map info.
|
||||
*
|
||||
* \param LOGFONT* log_font: The logical font.
|
||||
* \param Glyph32* glyphs: visual glyph string, Input.
|
||||
* \param int nr_glyphs: glyph string len, Input.
|
||||
* \param GLYPHMAPINFO* glyph_map: position mapping from logical glyphs.
|
||||
* string to Logical text, output.
|
||||
*
|
||||
* \param Glyph32* : return visual glyph string, output.
|
||||
*/
|
||||
Glyph32* GUIAPI BIDILogGlyphs2VisGlyphs(
|
||||
LOGFONT* log_font,
|
||||
Glyph32* glyphs,
|
||||
int nr_glyphs,
|
||||
GLYPHMAPINFO* glyphs_map)
|
||||
{
|
||||
DEVFONT* mbc_devfont = log_font->mbc_devfont;
|
||||
|
||||
if (mbc_devfont && mbc_devfont->charset_ops->bidi_glyph_type) {
|
||||
/* get the visual glyphs map from the logical glyphs map. */
|
||||
if (glyphs_map) {
|
||||
__mg_charset_bidi_map_reorder (mbc_devfont->charset_ops,
|
||||
glyphs, nr_glyphs, glyphs_map);
|
||||
}
|
||||
__mg_charset_bidi_glyphs_reorder (mbc_devfont->charset_ops, glyphs, nr_glyphs);
|
||||
}
|
||||
|
||||
return glyphs;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* \param HDC* hdc: The device context.
|
||||
* \param Glyph32* glyph: Input glyph string, input.
|
||||
@@ -1196,10 +1128,10 @@ static int* generate_ranges(PLOGFONT log_font, Glyph32* log_glyphs,
|
||||
int* p = NULL;
|
||||
int max_ranges = DEF_RANGES * 2;
|
||||
GLYPHMAPINFO* v_map = NULL;
|
||||
Uint8* embedding_level_list = NULL;
|
||||
Uint8* embedding_levels = NULL;
|
||||
|
||||
BIDIGetLogicalEmbedLevels(log_font, log_glyphs,
|
||||
nr_glyphs, &embedding_level_list);
|
||||
BIDIGetLogicalEmbeddLevels(log_font, log_glyphs,
|
||||
nr_glyphs, &embedding_levels);
|
||||
|
||||
/* get all the logical ranges in the same language.
|
||||
* default malloc DEF_RANGES ranges.*/
|
||||
@@ -1209,7 +1141,7 @@ static int* generate_ranges(PLOGFONT log_font, Glyph32* log_glyphs,
|
||||
p[m++] = l_start_index;
|
||||
for(i = l_start_index; i <= l_end_index; i++){
|
||||
if((i+1) <= l_end_index
|
||||
&& embedding_level_list[i] != embedding_level_list[i+1]){
|
||||
&& embedding_levels[i] != embedding_levels[i+1]){
|
||||
if(m > (max_ranges-2)) {
|
||||
max_ranges += DEF_RANGES*2;
|
||||
p = realloc(p, max_ranges * sizeof(int));
|
||||
@@ -1227,8 +1159,7 @@ static int* generate_ranges(PLOGFONT log_font, Glyph32* log_glyphs,
|
||||
}
|
||||
|
||||
v_map = l_map;
|
||||
BIDILogGlyphs2VisGlyphs (log_font, log_glyphs,
|
||||
nr_glyphs, v_map);
|
||||
BIDILogGlyphs2VisGlyphs (log_font, log_glyphs, nr_glyphs, v_map);
|
||||
|
||||
*nr_ranges = m;
|
||||
|
||||
@@ -1242,7 +1173,7 @@ static int* generate_ranges(PLOGFONT log_font, Glyph32* log_glyphs,
|
||||
}
|
||||
}
|
||||
|
||||
free(embedding_level_list);
|
||||
free(embedding_levels);
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -1348,8 +1279,7 @@ void GUIAPI GetTextRangesLog2VisTest(
|
||||
&l_glyphs, &l_map);
|
||||
|
||||
v_map = l_map;
|
||||
BIDILogGlyphs2VisGlyphs (log_font, l_glyphs,
|
||||
nr_glyphs, v_map);
|
||||
BIDILogGlyphs2VisGlyphs (log_font, l_glyphs, nr_glyphs, v_map);
|
||||
|
||||
/* get all the logical ranges in the same language.
|
||||
* default malloc 5 ranges.*/
|
||||
@@ -1495,69 +1425,108 @@ void GUIAPI BIDIGetTextRangesLog2Vis(LOGFONT* log_font,
|
||||
free(l_glyphs);
|
||||
}
|
||||
|
||||
/*
|
||||
* bref: get the logical embedding levels for the logical glyph string
|
||||
* and generate runs by embedding levels, then for reorder to get
|
||||
* visual glyph string.
|
||||
*
|
||||
* \param LOGFONT* log_font: The logical font.
|
||||
* \param Glyph32* glyphs: Input logical glyph string, input.
|
||||
* \param int nr_glyphs: Input logical string len, input.
|
||||
* \param Uint8** embedding_level_list: embedding level Logical, output.
|
||||
*
|
||||
* \param return void.
|
||||
*/
|
||||
void GUIAPI BIDIGetLogicalEmbedLevels(
|
||||
LOGFONT* log_font,
|
||||
Glyph32* glyphs,
|
||||
int nr_glyphs,
|
||||
Uint8** embedding_level_list)
|
||||
int GUIAPI BIDIGetTextVisualGlyphs(LOGFONT* log_font,
|
||||
const char* text, int text_len,
|
||||
Glyph32** glyphs,
|
||||
GLYPHMAPINFO** glyphs_map)
|
||||
{
|
||||
int i = 0;
|
||||
int nr_glyphs = 0;
|
||||
DEVFONT* mbc_devfont = log_font->mbc_devfont;
|
||||
|
||||
if(*embedding_level_list == NULL)
|
||||
*embedding_level_list = malloc(nr_glyphs * sizeof (Uint8));
|
||||
if (glyphs == NULL || glyphs_map == NULL)
|
||||
return nr_glyphs;
|
||||
|
||||
nr_glyphs = BIDIGetTextLogicalGlyphs(log_font, text, text_len,
|
||||
glyphs, glyphs_map);
|
||||
|
||||
if (mbc_devfont && mbc_devfont->charset_ops->bidi_glyph_type){
|
||||
__mg_charset_bidi_map_reorder (mbc_devfont->charset_ops, *glyphs,
|
||||
nr_glyphs, *glyphs_map, -1);
|
||||
__mg_charset_bidi_glyphs_reorder (mbc_devfont->charset_ops,
|
||||
*glyphs, nr_glyphs, -1);
|
||||
}
|
||||
return nr_glyphs;
|
||||
}
|
||||
|
||||
BOOL GUIAPI BIDILogGlyphs2VisGlyphsEx (LOGFONT* log_font,
|
||||
Glyph32* glyphs, int nr_glyphs, GLYPHMAPINFO* glyph_map, int pel)
|
||||
{
|
||||
DEVFONT* mbc_devfont = log_font->mbc_devfont;
|
||||
|
||||
if (nr_glyphs > 0 && mbc_devfont
|
||||
&& mbc_devfont->charset_ops->bidi_glyph_type) {
|
||||
if (glyph_map) {
|
||||
__mg_charset_bidi_map_reorder (mbc_devfont->charset_ops,
|
||||
glyphs, nr_glyphs, glyph_map, pel);
|
||||
}
|
||||
__mg_charset_bidi_glyphs_reorder (mbc_devfont->charset_ops,
|
||||
glyphs, nr_glyphs, pel);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL GUIAPI BIDIGetVisualGlyphIndexMap (LOGFONT* log_font,
|
||||
Glyph32* glyphs, int nr_glyphs, int** index_map, int pel)
|
||||
{
|
||||
DEVFONT* mbc_devfont = log_font->mbc_devfont;
|
||||
|
||||
if (nr_glyphs > 0 && mbc_devfont
|
||||
&& mbc_devfont->charset_ops->bidi_glyph_type) {
|
||||
if (*index_map == NULL)
|
||||
*index_map = malloc (nr_glyphs * sizeof (int));
|
||||
|
||||
if (*index_map) {
|
||||
int i;
|
||||
for (i = 0; i < nr_glyphs; i++) {
|
||||
*index_map[i] = i;
|
||||
}
|
||||
|
||||
__mg_charset_bidi_index_reorder (mbc_devfont->charset_ops,
|
||||
glyphs, nr_glyphs, *index_map, pel);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void GUIAPI BIDIGetLogicalEmbedLevelsEx(LOGFONT* log_font,
|
||||
Glyph32* glyphs, int nr_glyphs, int pel,
|
||||
Uint8** embedding_levels)
|
||||
{
|
||||
DEVFONT* mbc_devfont = log_font->mbc_devfont;
|
||||
|
||||
if (*embedding_levels == NULL)
|
||||
*embedding_levels = malloc(nr_glyphs * sizeof (Uint8));
|
||||
|
||||
if (mbc_devfont && mbc_devfont->charset_ops->bidi_glyph_type) {
|
||||
__mg_charset_bidi_get_embeddlevels (mbc_devfont->charset_ops, glyphs, nr_glyphs,
|
||||
*embedding_level_list, 0);
|
||||
__mg_charset_bidi_get_embeddlevels (mbc_devfont->charset_ops,
|
||||
glyphs, nr_glyphs, pel, *embedding_levels, 0);
|
||||
}
|
||||
else{
|
||||
for(i = 0; i < nr_glyphs; i++){
|
||||
(*embedding_level_list)[i] = i;
|
||||
}
|
||||
else {
|
||||
memset (*embedding_levels, 0, sizeof(Uint8) * nr_glyphs);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* \param LOGFONT* log_font: The logical font.
|
||||
* \param Glyph32* glyphs: Input logical glyph string, input.
|
||||
* \param int nr_glyphs: Input logical string len, input.
|
||||
* \param Uint8 *embedding_level_list: embedding level logical
|
||||
* to visual, output.
|
||||
*
|
||||
* \param return void.
|
||||
*/
|
||||
void GUIAPI BIDIGetVisualEmbedLevels(
|
||||
LOGFONT* log_font,
|
||||
Glyph32* glyphs,
|
||||
int nr_glyphs,
|
||||
Uint8** embedding_level_list)
|
||||
void GUIAPI BIDIGetVisualEmbedLevelsEx(LOGFONT* log_font,
|
||||
Glyph32* glyphs, int nr_glyphs, int pel,
|
||||
Uint8** embedding_levels)
|
||||
{
|
||||
int i = 0;
|
||||
DEVFONT* mbc_devfont = log_font->mbc_devfont;
|
||||
|
||||
if(*embedding_level_list == NULL)
|
||||
*embedding_level_list = malloc(nr_glyphs * sizeof (Uint8));
|
||||
if (*embedding_levels == NULL)
|
||||
*embedding_levels = malloc(nr_glyphs * sizeof (Uint8));
|
||||
|
||||
if (mbc_devfont && mbc_devfont->charset_ops->bidi_glyph_type) {
|
||||
__mg_charset_bidi_get_embeddlevels (mbc_devfont->charset_ops, glyphs, nr_glyphs,
|
||||
*embedding_level_list, 1);
|
||||
__mg_charset_bidi_get_embeddlevels (mbc_devfont->charset_ops,
|
||||
glyphs, nr_glyphs, pel, *embedding_levels, 1);
|
||||
}
|
||||
else{
|
||||
for(i = 0; i < nr_glyphs; i++){
|
||||
(*embedding_level_list)[i] = i;
|
||||
}
|
||||
else {
|
||||
memset (*embedding_levels, 0, sizeof(Uint8) * nr_glyphs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user