mirror of
https://github.com/VincentWei/MiniGUI.git
synced 2026-09-26 12:27:58 +08:00
API description related to LAYOUTINFO
This commit is contained in:
+38
-4
@@ -12201,6 +12201,12 @@ MG_EXPORT int GUIAPI UChars2AChars(LOGFONT* logfont, const Uchar32* ucs,
|
||||
*/
|
||||
#define GRF_OVERFLOW_WRAP_ANYWHERE 0x00200000
|
||||
|
||||
#define GRF_OVERFLOW_ELLIPSIZE_MASK 0x000F0000
|
||||
#define GRF_OVERFLOW_ELLIPSIZE_NONE 0x00000000
|
||||
#define GRF_OVERFLOW_ELLIPSIZE_START 0x00010000
|
||||
#define GRF_OVERFLOW_ELLIPSIZE_MIDDLE 0x00020000
|
||||
#define GRF_OVERFLOW_ELLIPSIZE_END 0x00030000
|
||||
|
||||
#define GRF_ALIGN_MASK 0x0000F000
|
||||
/**
|
||||
* Text content is aligned to the start edge of the line box.
|
||||
@@ -12372,6 +12378,14 @@ typedef struct _GLYPHPOS {
|
||||
* The y coordinate of the glyph position.
|
||||
*/
|
||||
int y;
|
||||
/**
|
||||
* The x offset of the glyph position.
|
||||
*/
|
||||
int x_off;
|
||||
/**
|
||||
* The y offset of the glyph position.
|
||||
*/
|
||||
int y_off;
|
||||
/**
|
||||
* Whether suppress the glyph.
|
||||
*/
|
||||
@@ -12586,8 +12600,7 @@ MG_EXPORT BOOL GUIAPI DestroyTextRunsInfo(TEXTRUNSINFO* run_info);
|
||||
* \sa GetUCharsUntilParagraphBoundary, GetShapedGlyphsComplex,
|
||||
* GetGlyphsExtentInfo, GetGlyphsPositionInfo, DrawShapedGlyphString
|
||||
*/
|
||||
MG_EXPORT BOOL GUIAPI ShapeTextRunsBaisc(TEXTRUNSINFO* run_info,
|
||||
Uint32 render_flags);
|
||||
MG_EXPORT BOOL GUIAPI InitBasicShapingEngine(TEXTRUNSINFO* run_info);
|
||||
|
||||
#ifdef _MGCOMPLEX_SCRIPTS
|
||||
|
||||
@@ -12657,11 +12670,32 @@ MG_EXPORT BOOL GUIAPI ShapeTextRunsBaisc(TEXTRUNSINFO* run_info,
|
||||
* \sa GetUCharsUntilParagraphBoundary, GetShapedGlyphsBasic,
|
||||
* GetGlyphsExtentInfo, GetGlyphsPositionInfo, DrawShapedGlyphString
|
||||
*/
|
||||
MG_EXPORT BOOL GUIAPI ShapeTextRunsComplex(TEXTRUNSINFO* run_info,
|
||||
Uint32 render_flags);
|
||||
MG_EXPORT BOOL GUIAPI InitComplexShapingEngine(TEXTRUNSINFO* run_info);
|
||||
|
||||
#endif /* _MGCOMPLEX_SCRIPTS */
|
||||
|
||||
typedef struct _LAYOUTINFO LAYOUTINFO;
|
||||
typedef struct _LAYOUTLINE LAYOUTLINE;
|
||||
|
||||
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);
|
||||
|
||||
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,
|
||||
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()
|
||||
*
|
||||
|
||||
@@ -24,7 +24,7 @@ endif
|
||||
|
||||
HDR_FILES = drawtext.h mi.h midc.h mistruct.h miwideline.h \
|
||||
pixel_ops.h mifillarc.h mispans.h polygon.h mifpoly.h \
|
||||
textrunsinfo.h
|
||||
textrunsinfo.h layoutinfo.h
|
||||
|
||||
libnewgdi_la_SOURCES = $(SRC_FILES) $(HDR_FILES)
|
||||
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
** layoutinfo.h: Internal interface related to LAYOUTINFO.
|
||||
**
|
||||
** Create by WEI Yongming at 2019/03/20
|
||||
*/
|
||||
|
||||
#ifndef _MG_NEWGDI_LAYOUTINFO_H
|
||||
#define _MG_NEWGDI_LAYOUTINFO_H
|
||||
|
||||
#include "list.h"
|
||||
#include "textruninfo.h"
|
||||
|
||||
typedef struct _GLYPHRUN GLYPHRUN;
|
||||
typedef struct _GLYPHINFO GLYPHINFO;
|
||||
|
||||
struct _GLYPHINFO {
|
||||
Glyph32 gv;
|
||||
int x_off;
|
||||
int y_off;
|
||||
int width;
|
||||
|
||||
Uint32 is_cluster_start:1;
|
||||
};
|
||||
|
||||
struct _GLYPHSTRING {
|
||||
GLYPHINFO* glyphs;
|
||||
int* log_clusters;
|
||||
|
||||
int nr_glyphs;
|
||||
int reserved;
|
||||
} GLYPHSTRING;
|
||||
|
||||
struct _GLYPHRUN {
|
||||
struct list_head list;
|
||||
TEXTRUN* text_run; // the text run to which this glyph run belongs
|
||||
GLYPHSTRING* glyphstr; // the glyph string
|
||||
};
|
||||
|
||||
struct _LAYOUTLINE {
|
||||
struct list_head list;
|
||||
GLYPHLAYOUTINFO* layout_info;
|
||||
int* log_widths; // the widths of the logical chars
|
||||
|
||||
struct list_head run_head; // the list head for glyph 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
|
||||
};
|
||||
|
||||
struct _GLYPHLAYOUTINFO {
|
||||
const TEXTRUNSINFO* runinfo;
|
||||
const BreakOppo* break_oppos;
|
||||
|
||||
Uint32 render_flags;
|
||||
int letter_spacing;
|
||||
int word_spacing;
|
||||
int tab_size;
|
||||
|
||||
struct list_head line_head; // the list head of lines
|
||||
|
||||
LAYOUTLINE *curr_line; // current line
|
||||
int idx_next_char;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif // _MG_NEWGDI_LAYOUTINFO_H
|
||||
|
||||
@@ -263,8 +263,6 @@ static BOOL state_process_run (TEXTRUNSTATE *state)
|
||||
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_start - state->text;
|
||||
run->len = state->run_end - state->run_start;
|
||||
list_add_tail(&run->list, &state->runinfo->run_head);
|
||||
@@ -560,7 +558,7 @@ BOOL GUIAPI SetPartFontInTextRuns(TEXTRUNSINFO* runinfo,
|
||||
return FALSE;
|
||||
|
||||
// can not change font after shaped the glyphs
|
||||
if (runinfo->se.engine != NULL)
|
||||
if (runinfo->sei.inst != NULL)
|
||||
return FALSE;
|
||||
|
||||
// can not change font for empty runs
|
||||
@@ -624,13 +622,11 @@ BOOL GUIAPI ResetFontInTextRuns(TEXTRUNSINFO* runinfo, const char* logfont_name)
|
||||
list_del(runinfo->run_head.prev);
|
||||
if (run->lf)
|
||||
release_logfont_for_run(runinfo, run);
|
||||
if (runinfo->se.engine)
|
||||
runinfo->se.destroy_glyphs(runinfo->se.engine, run->gs);
|
||||
free(run);
|
||||
}
|
||||
|
||||
if (runinfo->se.engine) {
|
||||
runinfo->se.destroy_engine(runinfo->se.engine);
|
||||
if (runinfo->sei.inst) {
|
||||
runinfo->sei.free(runinfo->sei.inst);
|
||||
}
|
||||
|
||||
free(runinfo->fontname);
|
||||
@@ -658,16 +654,12 @@ BOOL GUIAPI ResetDirectionInTextRuns(TEXTRUNSINFO* runinfo,
|
||||
|
||||
list_for_each(i, &runinfo->run_head) {
|
||||
TEXTRUN* run = (TEXTRUN*)i;
|
||||
if (runinfo->se.engine && run->gs) {
|
||||
runinfo->se.destroy_glyphs(runinfo->se.engine, run->gs);
|
||||
}
|
||||
|
||||
set_run_dir(runinfo, run, run_dir, glyph_orient);
|
||||
}
|
||||
|
||||
if (runinfo->se.engine) {
|
||||
runinfo->se.destroy_engine(runinfo->se.engine);
|
||||
runinfo->se.engine = NULL;
|
||||
if (runinfo->sei.inst) {
|
||||
runinfo->sei.free(runinfo->sei.inst);
|
||||
runinfo->sei.inst = NULL;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -722,13 +714,11 @@ BOOL GUIAPI DestroyTextRunsInfo(TEXTRUNSINFO* runinfo)
|
||||
list_del(runinfo->run_head.prev);
|
||||
if (run->lf)
|
||||
release_logfont_for_run(runinfo, run);
|
||||
if (runinfo->se.engine)
|
||||
runinfo->se.destroy_glyphs(runinfo->se.engine, run->gs);
|
||||
free(run);
|
||||
}
|
||||
|
||||
if (runinfo->se.engine) {
|
||||
runinfo->se.destroy_engine(runinfo->se.engine);
|
||||
if (runinfo->sei.inst) {
|
||||
runinfo->sei.free(runinfo->sei.inst);
|
||||
}
|
||||
|
||||
free(runinfo->fontname);
|
||||
|
||||
+22
-59
@@ -43,55 +43,49 @@
|
||||
|
||||
#include "list.h"
|
||||
|
||||
typedef Glyph32 (*CB_GET_GLYPH_INFO) (void* engine,
|
||||
void* glyph_infos, int index, int* cluster);
|
||||
typedef struct _TEXTRUN TEXTRUN;
|
||||
typedef struct _GLYPHSTRING GLYPHSTRING;
|
||||
typedef struct _SEINSTANCE SEINSTANCE;
|
||||
typedef struct _TEXTCOLORMAP TEXTCOLORMAP;
|
||||
|
||||
typedef BOOL (*CB_DESTROY_GLYPHS) (void* engine, void* glyph_infos);
|
||||
typedef BOOL (*CB_SHAPE_TEXT_RUN)(SEINSTANCE* instance,
|
||||
const TEXTRUN* run, GLYPHSTRING* gs);
|
||||
|
||||
typedef BOOL (*CB_DESTROY_ENGINE) (void* engine);
|
||||
typedef BOOL (*CB_DESTROY_INSTANCE)(SEINSTANCE* instance);
|
||||
|
||||
typedef struct _SHAPPINGENGINE {
|
||||
/* The pointer to the shaping engine */
|
||||
void* engine;
|
||||
typedef struct _SHAPINGENGINEINFO SHAPINGENGINEINFO;
|
||||
|
||||
/* the callback reverse the glyphs */
|
||||
CB_REVERSE_ARRAY reverse_glyphs;
|
||||
struct _SHAPINGENGINEINFO {
|
||||
/* The pointer to the shaping engine instance */
|
||||
SEINSTANCE* inst;
|
||||
|
||||
/* The callback returns the glyph value and cluster
|
||||
from a void glyph information */
|
||||
CB_GET_GLYPH_INFO get_glyph_info;
|
||||
/* callback to shap a text run */
|
||||
CB_SHAPE_TEXT_RUN shape;
|
||||
|
||||
/* the callback destroy the shaped glyph info */
|
||||
CB_DESTROY_GLYPHS destroy_glyphs;
|
||||
/* callback to destroy the shaping engine instance */
|
||||
CB_DESTROY_INSTANCE free;
|
||||
};
|
||||
|
||||
/* the callback destroy the shapping engine instance */
|
||||
CB_DESTROY_ENGINE destroy_engine;
|
||||
} SHAPPINGENGINE;
|
||||
|
||||
typedef struct _TEXTRUN {
|
||||
struct _TEXTRUN {
|
||||
struct list_head list;
|
||||
LOGFONT* lf; // the logfont for this run
|
||||
|
||||
void* gs; // the shaped glyph information
|
||||
|
||||
int idx; // start index in the Unicode string
|
||||
int len; // the number of Unicode characters
|
||||
|
||||
int ngs; // the number of shaped glyphs
|
||||
|
||||
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 _TEXTCOLORMAP {
|
||||
struct _TEXTCOLORMAP {
|
||||
struct list_head list;
|
||||
int si;
|
||||
int len;
|
||||
RGBCOLOR color;
|
||||
} TEXTCOLORMAP;
|
||||
};
|
||||
|
||||
struct _TEXTRUNSINFO {
|
||||
/* The following fields will be initialized by CreateGlyphRunInfo. */
|
||||
@@ -110,39 +104,8 @@ struct _TEXTRUNSINFO {
|
||||
Uint32 run_dir:4; // the run direction specified
|
||||
Uint32 base_level:1; // the paragraph direction; 0 for LTR, 1 for RTL
|
||||
|
||||
/* The following fields will be initialized by the shapping engine. */
|
||||
SHAPPINGENGINE se; // the shapping engine
|
||||
};
|
||||
|
||||
typedef struct _GLYPHLAYOUTINFO GLYPHLAYOUTINFO;
|
||||
|
||||
typedef struct _GLYPHRUN {
|
||||
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
|
||||
} GLYPHRUN;
|
||||
|
||||
typedef struct _GLYPHLINE {
|
||||
GLYPHLAYOUTINFO* layout_info;
|
||||
|
||||
struct list_head run_head; // the list head for glyph 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
|
||||
} GLYPHLINE;
|
||||
|
||||
struct _GLYPHLAYOUTINFO {
|
||||
const TEXTRUNSINFO* runinfo;
|
||||
|
||||
struct list_head line_head;
|
||||
|
||||
int nr_lines;
|
||||
/* The following fields will be initialized by the shaping engine. */
|
||||
SHAPINGENGINEINFO sei; // the shaping engine information
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user