mirror of
https://github.com/VincentWei/MiniGUI.git
synced 2026-02-07 19:37:00 +08:00
cleanup and add _WRN_PRINTF for warning
This commit is contained in:
@@ -2055,6 +2055,13 @@ int init_minigui_printf (int (*output_char) (int ch),
|
||||
#define TCS_CLRLINE(fp)
|
||||
#endif
|
||||
|
||||
#define _WRN_PRINTF(fmt, ...) \
|
||||
do { \
|
||||
TCS_PURPLE (stderr); \
|
||||
fprintf (stderr, fmt, ##__VA_ARGS__); \
|
||||
TCS_NONE (stderr); \
|
||||
} while (0)
|
||||
|
||||
#define _ERR_PRINTF(fmt, ...) \
|
||||
do { \
|
||||
TCS_RED (stderr); \
|
||||
|
||||
@@ -12516,7 +12516,7 @@ MG_EXPORT TEXTRUNSINFO* GUIAPI CreateTextRunsInfo(Uchar32* ucs, int nr_ucs,
|
||||
|
||||
/**
|
||||
* Set font of part characters. Please call this function before
|
||||
* calling ShapeTextRunsBaisc or ShapeTextRunsComplex.
|
||||
* calling InitBasicShapingEngine or InitComplexShapingEngine.
|
||||
*/
|
||||
MG_EXPORT BOOL GUIAPI SetPartFontInTextRuns(TEXTRUNSINFO* run_info,
|
||||
int start_index, int length, const char* logfont_name);
|
||||
@@ -12554,7 +12554,7 @@ MG_EXPORT BOOL GUIAPI ResetDirectionInTextRuns(TEXTRUNSINFO* run_info,
|
||||
MG_EXPORT BOOL GUIAPI DestroyTextRunsInfo(TEXTRUNSINFO* run_info);
|
||||
|
||||
/**
|
||||
* \fn BOOL GUIAPI ShapeTextRunsBaisc()
|
||||
* \fn BOOL GUIAPI InitBasicShapingEngine()
|
||||
* \brief Analyse and generate a shaped glyph string of a Unicode string
|
||||
* under specific language and writing system.
|
||||
*
|
||||
@@ -12605,7 +12605,7 @@ MG_EXPORT BOOL GUIAPI InitBasicShapingEngine(TEXTRUNSINFO* run_info);
|
||||
#ifdef _MGCOMPLEX_SCRIPTS
|
||||
|
||||
/**
|
||||
* \fn int GUIAPI ShapeTextRunsComplex()
|
||||
* \fn int GUIAPI InitComplexShapingEngine()
|
||||
* \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.
|
||||
@@ -12677,25 +12677,30 @@ MG_EXPORT BOOL GUIAPI InitComplexShapingEngine(TEXTRUNSINFO* run_info);
|
||||
typedef struct _LAYOUTINFO LAYOUTINFO;
|
||||
typedef struct _LAYOUTLINE LAYOUTLINE;
|
||||
|
||||
/**
|
||||
* Create layout information structure for laying out a paragraph.
|
||||
*/
|
||||
MG_EXPORT LAYOUTINFO* GUIAPI CreateLayoutInfo(
|
||||
const TEXTRUNSINFO* run_info, Uint32 render_flags,
|
||||
const BreakOppo* break_oppos, BOOL persist_lines,
|
||||
int letter_spacing, int word_spacing, int tab_size);
|
||||
|
||||
/**
|
||||
* Destroy the specified layout information structure.
|
||||
*/
|
||||
MG_EXPORT BOOL GUIAPI DestroyLayoutInfo(LAYOUTINFO* layout_info);
|
||||
|
||||
typedef void (*CB_GLYPH_LAID_OUT) (GHANDLE ctxt,
|
||||
LOGFONT* lf, RGBCOLOR color, Glyph32 gv, const GLYPHPOS* pos);
|
||||
|
||||
MG_EXPORT int GUIAPI LayoutNextLine(LAYOUTINFO* layout_info,
|
||||
/**
|
||||
* Layout the next line of a paragraph according to the layout information.
|
||||
*/
|
||||
MG_EXPORT LAYOUTLINE* GUIAPI LayoutNextLine(LAYOUTINFO* layout_info,
|
||||
LAYOUTLINE* prev_Line,
|
||||
int* x, int* y, int max_extent, SIZE* line_size,
|
||||
CB_GLYPH_LAID_OUT cb_laid_out, GHANDLE ctxt);
|
||||
|
||||
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,
|
||||
SIZE* line_size, GLYPHPOS** glyph_pos, int* nr_glyphs);
|
||||
/**
|
||||
* \fn int GUIAPI GetGlyphsExtentInfo()
|
||||
*
|
||||
|
||||
@@ -19,7 +19,7 @@ SRC_FILES = gdi.c attr.c clip.c map.c coor.c rect.c \
|
||||
glyph-unicode.c \
|
||||
textrunsinfo.c \
|
||||
shape-glyphs-basic.c shape-glyphs-complex.c \
|
||||
layout-shaped-glyphs.c
|
||||
layoutinfo.c
|
||||
endif
|
||||
|
||||
HDR_FILES = drawtext.h mi.h midc.h mistruct.h miwideline.h \
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
** layout-shaped-glyphs.c: The implementation of APIs related shaped-glyphs
|
||||
** layoutinfo.c: The implementation of APIs related LAYOUTINFO
|
||||
**
|
||||
** Create by WEI Yongming at 2019/03/14
|
||||
*/
|
||||
@@ -51,6 +51,7 @@
|
||||
#include "window.h"
|
||||
#include "devfont.h"
|
||||
#include "unicode-ops.h"
|
||||
#include "layoutinfo.h"
|
||||
|
||||
#if 0
|
||||
int GUIAPI DrawShapedGlyphString(HDC hdc,
|
||||
@@ -42,12 +42,12 @@
|
||||
#define _MG_NEWGDI_LAYOUTINFO_H
|
||||
|
||||
#include "list.h"
|
||||
#include "textruninfo.h"
|
||||
#include "textrunsinfo.h"
|
||||
|
||||
typedef struct _GLYPHRUN GLYPHRUN;
|
||||
typedef struct _GLYPHINFO GLYPHINFO;
|
||||
typedef struct _SHAPEDGLYPH SHAPEDGLYPH;
|
||||
|
||||
struct _GLYPHINFO {
|
||||
struct _SHAPEDGLYPH {
|
||||
Glyph32 gv;
|
||||
int x_off;
|
||||
int y_off;
|
||||
@@ -57,12 +57,12 @@ struct _GLYPHINFO {
|
||||
};
|
||||
|
||||
struct _GLYPHSTRING {
|
||||
GLYPHINFO* glyphs;
|
||||
SHAPEDGLYPH* glyphs;
|
||||
int* log_clusters;
|
||||
|
||||
int nr_glyphs;
|
||||
int reserved;
|
||||
} GLYPHSTRING;
|
||||
};
|
||||
|
||||
struct _GLYPHRUN {
|
||||
struct list_head list;
|
||||
@@ -72,7 +72,7 @@ struct _GLYPHRUN {
|
||||
|
||||
struct _LAYOUTLINE {
|
||||
struct list_head list;
|
||||
GLYPHLAYOUTINFO* layout_info;
|
||||
LAYOUTINFO* layout_info;
|
||||
int* log_widths; // the widths of the logical chars
|
||||
|
||||
struct list_head run_head; // the list head for glyph runs
|
||||
@@ -98,7 +98,7 @@ struct _GLYPHLAYOUTINFO {
|
||||
struct list_head line_head; // the list head of lines
|
||||
|
||||
LAYOUTLINE *curr_line; // current line
|
||||
int idx_next_char;
|
||||
int left_ucs; // the number of chars not laied out.
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
** shaped-glyph.c: The implementation of APIs related shaped-glyphs
|
||||
** shaped-glyph-basic.c: The implementation of basic shaping engine.
|
||||
**
|
||||
** Reference:
|
||||
**
|
||||
@@ -79,7 +79,7 @@ static void bidi_reverse_shaped_glyphs (void* context, int len, int pos)
|
||||
# define LOCAL_ARRAY_SIZE 128
|
||||
#endif
|
||||
|
||||
BOOL GUIAPI ShapeTextRunsBasic(TEXTRUNSINFO* run_info, Uint32 rf)
|
||||
BOOL GUIAPI InitBasicShapingEngine(TEXTRUNSINFO* run_info)
|
||||
{
|
||||
#if 0
|
||||
int ret_value = 0;
|
||||
|
||||
@@ -57,10 +57,10 @@
|
||||
#include "unicode-ops.h"
|
||||
#include "textrunsinfo.h"
|
||||
|
||||
BOOL GUIAPI ShapeTextRunsComplex(TEXTRUNSINFO* run_info, Uint32 rf)
|
||||
BOOL GUIAPI InitComplexShapingEngine(TEXTRUNSINFO* run_info)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#endif /* _MGCHARSET_UNICODE */
|
||||
#endif /* defined(_MGCHARSET_UNICODE) && defined(_MGCOMPLEX_SCRIPTS) */
|
||||
|
||||
|
||||
@@ -195,7 +195,7 @@ static LOGFONT* create_logfont_for_run(const TEXTRUNSINFO* runinfo,
|
||||
fontname[orient_pos] = FONT_ORIENT_SIDEWAYS_LEFT;
|
||||
break;
|
||||
default:
|
||||
_DBG_PRINTF("%s: bad orientation param: %d\n",
|
||||
_WRN_PRINTF("%s: bad orientation param: %d\n",
|
||||
__FUNCTION__, run->ort);
|
||||
return NULL;
|
||||
}
|
||||
@@ -236,7 +236,7 @@ static void release_logfont_for_run(const TEXTRUNSINFO* runinfo,
|
||||
fontname[orient_pos] = FONT_ORIENT_SIDEWAYS_LEFT;
|
||||
break;
|
||||
default:
|
||||
_DBG_PRINTF("%s: bad orientation param: %d\n",
|
||||
_WRN_PRINTF("%s: bad orientation param: %d\n",
|
||||
__FUNCTION__, run->ort);
|
||||
return;
|
||||
}
|
||||
@@ -467,7 +467,8 @@ TEXTRUNSINFO* GUIAPI CreateTextRunsInfo(Uchar32* ucs, int nr_ucs,
|
||||
els = (BidiLevel*)malloc (nr_ucs * sizeof(BidiLevel));
|
||||
|
||||
if (!els) {
|
||||
_DBG_PRINTF("%s: failed to allocate space for embedding levels.\n");
|
||||
_ERR_PRINTF("%s: failed to allocate space for embedding levels.\n",
|
||||
__FUNCTION__);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -477,7 +478,8 @@ TEXTRUNSINFO* GUIAPI CreateTextRunsInfo(Uchar32* ucs, int nr_ucs,
|
||||
// Calculate the breaking opportunities
|
||||
if (UStrGetBreaks(script_type, ctr, wbr, lbp,
|
||||
ucs, nr_ucs, &bos) == 0) {
|
||||
_DBG_PRINTF("%s: failed to get breaking opportunities.\n");
|
||||
_ERR_PRINTF("%s: failed to get breaking opportunities.\n",
|
||||
__FUNCTION__);
|
||||
goto out;
|
||||
}
|
||||
*/
|
||||
@@ -532,7 +534,7 @@ TEXTRUNSINFO* GUIAPI CreateTextRunsInfo(Uchar32* ucs, int nr_ucs,
|
||||
#endif
|
||||
|
||||
if (!create_glyph_runs(runinfo, els)) {
|
||||
_DBG_PRINTF("%s: failed to call create_glyph_runs.\n",
|
||||
_ERR_PRINTF("%s: failed to call create_glyph_runs.\n",
|
||||
__FUNCTION__);
|
||||
goto out;
|
||||
}
|
||||
@@ -557,10 +559,6 @@ BOOL GUIAPI SetPartFontInTextRuns(TEXTRUNSINFO* runinfo,
|
||||
if (runinfo == NULL)
|
||||
return FALSE;
|
||||
|
||||
// can not change font after shaped the glyphs
|
||||
if (runinfo->sei.inst != NULL)
|
||||
return FALSE;
|
||||
|
||||
// can not change font for empty runs
|
||||
if (list_empty(&runinfo->run_head))
|
||||
return FALSE;
|
||||
@@ -657,11 +655,6 @@ BOOL GUIAPI ResetDirectionInTextRuns(TEXTRUNSINFO* runinfo,
|
||||
set_run_dir(runinfo, run, run_dir, glyph_orient);
|
||||
}
|
||||
|
||||
if (runinfo->sei.inst) {
|
||||
runinfo->sei.free(runinfo->sei.inst);
|
||||
runinfo->sei.inst = NULL;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -690,7 +683,8 @@ BOOL GUIAPI ResetBreaksInTextRuns(TEXTRUNSINFO* runinfo,
|
||||
// Re-calculate the breaking opportunities
|
||||
if (UStrGetBreaks(runinfo->run_head.st, ctr, wbr, lbp,
|
||||
runinfo->ucs, runinfo->run_head.nr_ucs, &runinfo->bos) == 0) {
|
||||
_DBG_PRINTF("%s: failed to get breaking opportunities.\n");
|
||||
_ERR_PRINTF("%s: failed to get breaking opportunities.\n",
|
||||
__FUNCTION__);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user