mirror of
https://github.com/VincentWei/MiniGUI.git
synced 2026-09-25 02:33:59 +08:00
new files
This commit is contained in:
+1
-1
@@ -2000,7 +2000,7 @@ if test "x$build_ttf_support" = "xyes"; then
|
||||
if test "x$build_complex_scripts" = "xyes"; then
|
||||
dnl Check for HarfBuzz library
|
||||
AC_CHECK_LIB(harfbuzz, hb_version,
|
||||
DEP_LIBS="$DEP_LIBS -lharfbuzz",
|
||||
DEP_LIBS="$DEP_LIBS -lharfbuzzex",
|
||||
build_complex_scripts="no")
|
||||
fi
|
||||
|
||||
|
||||
+23
-14
@@ -8731,12 +8731,14 @@ MG_EXPORT void GUIAPI UBidiShape(Uint32 shaping_flags,
|
||||
*/
|
||||
#define BOV_LB_NOTALLOWED 0x0003
|
||||
|
||||
typedef Uint16 BreakOppo;
|
||||
|
||||
/** @} end of breaking_opportunities */
|
||||
|
||||
/**
|
||||
* \fn int GUIAPI UStrGetBreaks(ScriptType writing_system,
|
||||
* Uint8 ctr, Uint8 wbr, Uint8 lbp,
|
||||
* Uchar32* ucs, int nr_ucs, Uint16** break_oppos);
|
||||
* Uchar32* ucs, int nr_ucs, BreakOppo** break_oppos);
|
||||
* \brief Calculate the breaking opportunities of a Uchar32 string under
|
||||
* the specified rules and line breaking policy.
|
||||
*
|
||||
@@ -8794,7 +8796,7 @@ MG_EXPORT void GUIAPI UBidiShape(Uint32 shaping_flags,
|
||||
*/
|
||||
MG_EXPORT int GUIAPI UStrGetBreaks(ScriptType writing_system,
|
||||
Uint8 ctr, Uint8 wbr, Uint8 lbp,
|
||||
Uchar32* ucs, int nr_ucs, Uint16** break_oppos);
|
||||
Uchar32* ucs, int nr_ucs, BreakOppo** break_oppos);
|
||||
|
||||
/** The function determines whether a character is alphanumeric. */
|
||||
MG_EXPORT BOOL GUIAPI IsUCharAlnum(Uchar32 uc);
|
||||
@@ -12276,7 +12278,7 @@ typedef struct _GLYPHPOS {
|
||||
|
||||
/**
|
||||
* \fn int GUIAPI GetGlyphsExtentFromUChars(LOGFONT* logfont_upright,
|
||||
* const Uchar32* uchars, int nr_uchars, const Uint16* break_oppos,
|
||||
* const Uchar32* uchars, int nr_uchars, const BreakOppo* break_oppos,
|
||||
* Uint32 render_flags, int x, int y,
|
||||
* int letter_spacing, int word_spacing, int tab_size, int max_extent,
|
||||
* SIZE* line_size, Glyph32* glyphs, GLYPHEXTINFO* glyph_ext_info,
|
||||
@@ -12353,7 +12355,7 @@ typedef struct _GLYPHPOS {
|
||||
* \sa UStrGetBreaks, DrawGlyphStringEx, GLYPHEXTINFO, glyph_render_flags
|
||||
*/
|
||||
MG_EXPORT int GUIAPI GetGlyphsExtentFromUChars(LOGFONT* logfont_upright,
|
||||
const Achar32* uchars, int nr_uchars, const Uint16* break_oppos,
|
||||
const Achar32* uchars, int nr_uchars, const BreakOppo* break_oppos,
|
||||
Uint32 render_flags, int x, int y,
|
||||
int letter_spacing, int word_spacing, int tab_size, int max_extent,
|
||||
SIZE* line_size, Glyph32* glyphs, GLYPHEXTINFO* glyph_ext_info,
|
||||
@@ -12369,18 +12371,23 @@ typedef struct _GLYPHRUNINFO GLYPHRUNINFO;
|
||||
*
|
||||
* This function also calculates the embedding levels and the
|
||||
* breaking opportunities of the string.
|
||||
*
|
||||
* This function is useful for text in mixed scripts.
|
||||
*/
|
||||
MG_EXPORT GLYPHRUNINFO* GUIAPI CreateGlyphRunInfo(LOGFONT* logfont,
|
||||
Uint32 render_flags, const Uchar32* ucs, int nr_ucs,
|
||||
const char* lang_script_tag, ParagraphDir base_dir);
|
||||
MG_EXPORT GLYPHRUNINFO* GUIAPI CreateGlyphRunInfo(
|
||||
const char* lang_tag, const char* script_tag,
|
||||
Uint8 ctr, Uint8 wbr, Uint8 lbp,
|
||||
Uchar32* ucs, int nr_ucs, ParagraphDir base_dir);
|
||||
|
||||
/**
|
||||
* Destroy the text run info object. It also free the embedde levels
|
||||
* and the breaking opportunities.
|
||||
* Reset the glyph run information for the next rendering under a
|
||||
* new LOGFONT and the rendering flags.
|
||||
*/
|
||||
MG_EXPORT int GUIAPI DestroyGlyphRunInfo(GLYPHRUNINFO* run_info);
|
||||
MG_EXPORT BOOL GUIAPI ResetGlyphRunInfo(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);
|
||||
|
||||
/**
|
||||
* \fn BOOL GUIAPI GetShapedGlyphRunsBasic()
|
||||
@@ -12429,7 +12436,8 @@ MG_EXPORT int GUIAPI DestroyGlyphRunInfo(GLYPHRUNINFO* run_info);
|
||||
* \sa GetUCharsUntilParagraphBoundary, GetShapedGlyphsComplex,
|
||||
* GetGlyphsExtentInfo, GetGlyphsPositionInfo, DrawShapedGlyphString
|
||||
*/
|
||||
MG_EXPORT BOOL GUIAPI ShapeGlyphRunsBaisc(GLYPHRUNINFO* run_info);
|
||||
MG_EXPORT BOOL GUIAPI ShapeGlyphRunsBaisc(GLYPHRUNINFO* run_info,
|
||||
LOGFONT* logfont, Uint32 render_flags);
|
||||
|
||||
/**
|
||||
* \fn int GUIAPI GetShapedGlyphsComplex()
|
||||
@@ -12497,7 +12505,8 @@ 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 ShapeGlyphRunsComplex(GLYPHRUNINFO* run_info,
|
||||
LOGFONT* logfont, Uint32 render_flags);
|
||||
|
||||
/**
|
||||
* \fn int GUIAPI GetGlyphsExtentInfo()
|
||||
|
||||
@@ -17,7 +17,7 @@ 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 \
|
||||
shape-glyphs-basic.c shape-glyphs-complex.c \
|
||||
glyphruninfo.c shape-glyphs-basic.c shape-glyphs-complex.c \
|
||||
layout-shaped-glyphs.c
|
||||
endif
|
||||
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* This file is part of MiniGUI, a mature cross-platform windowing
|
||||
* and Graphics User Interface (GUI) support system for embedded systems
|
||||
* and smart IoT devices.
|
||||
*
|
||||
* Copyright (C) 2002~2018, Beijing FMSoft Technologies Co., Ltd.
|
||||
* Copyright (C) 1998~2002, WEI Yongming
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Or,
|
||||
*
|
||||
* As this program is a library, any link to this program must follow
|
||||
* GNU General Public License version 3 (GPLv3). If you cannot accept
|
||||
* GPLv3, you need to be licensed from FMSoft.
|
||||
*
|
||||
* If you have got a commercial license of this program, please use it
|
||||
* under the terms and conditions of the commercial license.
|
||||
*
|
||||
* For more information about the commercial license, please refer to
|
||||
* <http://www.minigui.com/en/about/licensing-policy/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
** glyphruninfo.c: The implementation of APIs related GLYPHRUNINFO
|
||||
**
|
||||
** Create by WEI Yongming at 2019/03/15
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#if defined(_MGCHARSET_UNICODE)
|
||||
|
||||
#include "minigui.h"
|
||||
#include "gdi.h"
|
||||
#include "window.h"
|
||||
#include "devfont.h"
|
||||
#include "unicode-ops.h"
|
||||
#include "glyphruninfo.h"
|
||||
|
||||
/* Local array size, used for stack-based local arrays */
|
||||
|
||||
#if SIZEOF_PTR == 8
|
||||
# define LOCAL_ARRAY_SIZE 256
|
||||
#else
|
||||
# define LOCAL_ARRAY_SIZE 128
|
||||
#endif
|
||||
|
||||
GLYPHRUNINFO* GUIAPI CreateGlyphRunInfo(
|
||||
const char* lang_tag, const char* script_tag,
|
||||
Uint8 ctr, Uint8 wbr, Uint8 lbp,
|
||||
Uchar32* ucs, int nr_ucs, ParagraphDir base_dir)
|
||||
{
|
||||
BOOL ok = FALSE;
|
||||
|
||||
GLYPHRUNINFO* runinfo;
|
||||
BidiLevel* els = NULL;
|
||||
BreakOppo* bos = NULL;
|
||||
|
||||
BidiLevel max_level = 0;
|
||||
|
||||
BidiType local_bidi_ts[LOCAL_ARRAY_SIZE];
|
||||
BidiType *bidi_ts = NULL;
|
||||
|
||||
BidiBracketType local_brk_ts[LOCAL_ARRAY_SIZE];
|
||||
BidiBracketType *brk_ts = NULL;
|
||||
|
||||
ScriptType script_type = SCRIPT_COMMON;
|
||||
|
||||
int i, j;
|
||||
|
||||
runinfo = (GLYPHRUNINFO*)calloc(1, sizeof(GLYPHRUNINFO));
|
||||
if (ucs == NULL || nr_ucs <= 0 || runinfo == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (nr_ucs < LOCAL_ARRAY_SIZE)
|
||||
bidi_ts = local_bidi_ts;
|
||||
else
|
||||
bidi_ts = malloc (nr_ucs * sizeof(BidiType));
|
||||
|
||||
if (!bidi_ts)
|
||||
goto out;
|
||||
|
||||
UStrGetBidiTypes(ucs, nr_ucs, bidi_ts);
|
||||
|
||||
if (nr_ucs < LOCAL_ARRAY_SIZE)
|
||||
brk_ts = local_brk_ts;
|
||||
else
|
||||
brk_ts = (BidiBracketType*)malloc (nr_ucs * sizeof(BidiBracketType));
|
||||
|
||||
if (!brk_ts)
|
||||
goto out;
|
||||
|
||||
UStrGetBracketTypes (ucs, bidi_ts, nr_ucs, brk_ts);
|
||||
|
||||
els = (BidiLevel*)malloc (nr_ucs * sizeof(BidiLevel));
|
||||
if (!els) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
max_level = UBidiGetParagraphEmbeddingLevels(bidi_ts, brk_ts, nr_ucs,
|
||||
&base_dir, els) - 1;
|
||||
if (max_level < 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
// remove the bidi marks from embedding levels and original string.
|
||||
j = 0;
|
||||
for (i = 0; i < nr_ucs; i++) {
|
||||
if (!BIDI_IS_EXPLICIT_OR_BN (bidi_ts[i])) {
|
||||
els[j] = els[i];
|
||||
ucs[j] = ucs[i];
|
||||
j++;
|
||||
}
|
||||
}
|
||||
nr_ucs = j;
|
||||
|
||||
// Calculate the breaking opportunities
|
||||
if (UStrGetBreaks(script_type, ctr, wbr, lbp,
|
||||
ucs, nr_ucs, &bos) == 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
runinfo->ucs = ucs;
|
||||
runinfo->nr_ucs = nr_ucs;
|
||||
runinfo->els = els;
|
||||
runinfo->bos = bos;
|
||||
runinfo->base_dir = base_dir;
|
||||
runinfo->lang_tag = lang_tag;
|
||||
runinfo->script_tag = script_tag;
|
||||
ok = TRUE;
|
||||
|
||||
out:
|
||||
if (bidi_ts && bidi_ts != local_bidi_ts)
|
||||
free (bidi_ts);
|
||||
|
||||
if (brk_ts && brk_ts != local_brk_ts)
|
||||
free (brk_ts);
|
||||
|
||||
if (ok)
|
||||
return runinfo;
|
||||
|
||||
if (runinfo->runs) free(runinfo->runs);
|
||||
if (els) free(els);
|
||||
if (bos) free(bos);
|
||||
free(runinfo);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BOOL GUIAPI ResetGlyphRunInfo(GLYPHRUNINFO* run_info)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL GUIAPI DestroyGlyphRunInfo(GLYPHRUNINFO* run_info)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#endif /* _MGCHARSET_UNICODE */
|
||||
|
||||
+31
-18
@@ -78,31 +78,44 @@ typedef enum {
|
||||
GR_DIRECTION_BTT
|
||||
} GlyphRunDir;
|
||||
|
||||
struct _GLPYHRUNINFO {
|
||||
/* the logfont for upright glyphs */
|
||||
LOGFONT* lfur;
|
||||
/* The logfont for sideways glyphs */
|
||||
LOGFONT* lfsw;
|
||||
typedef struct _MAPL2G {
|
||||
// Glyph index in the run; Less than 0 if it is ignored.
|
||||
Sint32 glyph_index;
|
||||
// the run index; a 16-bit unsigned number is enough.
|
||||
Uint16 run_index;
|
||||
// number of glyphs the uchar maps to.
|
||||
Sint16 nr_glyphs;
|
||||
} MAPL2G;
|
||||
|
||||
typedef struct _GLYPHRUN {
|
||||
LanguageCode lc;
|
||||
ScriptType st;
|
||||
GlyphRunDir dir;
|
||||
int si; // start index
|
||||
int len;
|
||||
} GLYPHRUN;
|
||||
|
||||
struct _GLYPHRUNINFO {
|
||||
/* The following fields will be initialized by CreateGlyphRunInfo. */
|
||||
Uchar32* ucs;
|
||||
SHAPPINGENGINE* se;
|
||||
|
||||
struct _textrun {
|
||||
LanguageCode lc;
|
||||
ScriptType st;
|
||||
GlyphRunDir dir;
|
||||
int si; // start index
|
||||
int len;
|
||||
}* runs;
|
||||
|
||||
BidiLevel* els;
|
||||
Uint16* bos;
|
||||
BreakOppo* bos;
|
||||
GLYPHRUN* runs;
|
||||
|
||||
/* The following fields will be initialized by the Shapping Engine. */
|
||||
LOGFONT* lfur; // The logfont for upright glyphs
|
||||
LOGFONT* lfsw; // The logfont for sideways glyphs
|
||||
SHAPPINGENGINE se;
|
||||
MAPL2G* u2g;
|
||||
SHAPEDGLYPHS** sgs;
|
||||
GLYPHEXTINFO** ges;
|
||||
|
||||
const char* lang_tag;
|
||||
const char* script_tag;
|
||||
Uint32 render_flags;
|
||||
int nr_ucs;
|
||||
int nr_runs;
|
||||
int nr_scripts;
|
||||
Uint32 render_flags;
|
||||
ParagraphDir base_dir;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -79,7 +79,8 @@ static void bidi_reverse_shaped_glyphs (void* context, int len, int pos)
|
||||
# define LOCAL_ARRAY_SIZE 128
|
||||
#endif
|
||||
|
||||
BOOL GUIAPI ShapeGlyphRunsBasic(GLYPHRUNINFO* run_info)
|
||||
BOOL GUIAPI ShapeGlyphRunsBasic(GLYPHRUNINFO* run_info,
|
||||
LOGFONT* lf, Uint32 rf)
|
||||
{
|
||||
#if 0
|
||||
int ret_value = 0;
|
||||
|
||||
@@ -57,7 +57,8 @@
|
||||
#include "unicode-ops.h"
|
||||
#include "glyphruninfo.h"
|
||||
|
||||
BOOL GUIAPI ShapeGlyphRunsComplex(GLYPHRUNINFO* run_info)
|
||||
BOOL GUIAPI ShapeGlyphRunsComplex(GLYPHRUNINFO* run_info,
|
||||
LOGFONT* lf, Uint32 rf)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user