split shaped-glyph.c into three files

This commit is contained in:
Vincent Wei
2019-03-14 17:26:14 +08:00
parent f218b7b892
commit 8f841a0bc0
4 changed files with 198 additions and 81 deletions
+3 -1
View File
@@ -16,7 +16,9 @@ SRC_FILES = gdi.c attr.c clip.c map.c coor.c rect.c \
mifillarc.c mifpolycon.c miarc.c rotatebmp.c \
text.c achar-uchar.c glyph.c legacy-bidi.c \
textout.c tabbedtextout.c drawtext.c \
glyph-unicode.c shaped-glyph.c
glyph-unicode.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 \
+127
View File
@@ -0,0 +1,127 @@
/*
* 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/>.
*/
/*
** layout-shaped-glyphs.c: The implementation of APIs related shaped-glyphs
**
** Create by WEI Yongming at 2019/03/14
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "common.h"
#ifdef _MGCHARSET_UNICODE
#include "minigui.h"
#include "gdi.h"
#include "window.h"
#include "devfont.h"
#include "unicode-ops.h"
int GUIAPI GetGlyphsExtentInfo(LOGFONT* logfont,
LanguageCode lang_code, UCharScriptType writing_system,
Uint32 render_flags, const Uchar32* ucs, int nr_ucs,
const BidiLevel embedding_levels, BidiType base_dir,
const SHAPEDGLYPHS* shaped_glyphs,
GLYPHEXTINFO* glyph_ext_info, LOGFONT** logfont_sideways)
{
return 0;
}
int GUIAPI GetGlyphsPositionInfo(
LOGFONT* logfont_upright, LOGFONT* logfont_sideways,
const Uchar32* ucs, int nr_ucs,
const Uint16* break_oppos,
const BidiLevel embedding_levels, BidiType base_dir,
const SHAPEDGLYPHS* shaped_glyphs,
Uint32 render_flags, int x, int y,
int letter_spacing, int word_spacing, int tab_size, int max_extent,
GLYPHEXTINFO* glyph_ext_info, SIZE* line_size, GLYPHPOS* glyph_pos)
{
return 0;
}
int GUIAPI DrawShapedGlyphString(HDC hdc,
LOGFONT* logfont_upright, LOGFONT* logfont_sideways,
const SHAPEDGLYPHS* shaped_glyphs,
const GLYPHPOS* glyph_pos, int nr_glyphs)
{
int i;
int n = 0;
Uint32 old_ta;
PLOGFONT old_lf;
if (shaped_glyphs == NULL || glyph_pos == NULL || nr_glyphs <= 0)
return 0;
old_ta = SetTextAlign(hdc, TA_LEFT | TA_TOP | TA_UPDATECP);
old_lf = GetCurFont(hdc);
for (i = 0; i < nr_glyphs; i++) {
if (glyph_pos[i].suppressed == 0 && glyph_pos[i].whitespace == 0) {
Glyph32 gv = shaped_glyphs->cb_get_glyph_info(
shaped_glyphs->shaping_engine, shaped_glyphs->glyph_infos,
i, NULL);
if (glyph_pos[i].orientation == GLYPH_ORIENTATION_UPRIGHT) {
if (logfont_upright)
SelectFont(hdc, logfont_upright);
else
goto error;
}
else {
if (logfont_sideways)
SelectFont(hdc, logfont_sideways);
else
goto error;
}
DrawGlyph(hdc, glyph_pos[i].x, glyph_pos[i].y, gv,
NULL, NULL);
n++;
}
}
error:
SelectFont(hdc, old_lf);
SetTextAlign(hdc, old_ta);
return n;
}
#endif /* _MGCHARSET_UNICODE */
@@ -263,85 +263,5 @@ out:
return 0;
}
int GUIAPI GetShapedGlyphsComplex(LOGFONT* logfont,
LanguageCode lang_code, UCharScriptType writing_system,
Uint32 render_flags, const Uchar32* ucs, int nr_ucs,
const BidiLevel embedding_levels, BidiType base_dir,
SHAPEDGLYPHS* shaped_glyphs)
{
return 0;
}
int GUIAPI GetGlyphsExtentInfo(LOGFONT* logfont,
LanguageCode lang_code, UCharScriptType writing_system,
Uint32 render_flags, const Uchar32* ucs, int nr_ucs,
const BidiLevel embedding_levels, BidiType base_dir,
const SHAPEDGLYPHS* shaped_glyphs,
GLYPHEXTINFO* glyph_ext_info, LOGFONT** logfont_sideways)
{
return 0;
}
int GUIAPI GetGlyphsPositionInfo(
LOGFONT* logfont_upright, LOGFONT* logfont_sideways,
const Uchar32* ucs, int nr_ucs,
const Uint16* break_oppos,
const BidiLevel embedding_levels, BidiType base_dir,
const SHAPEDGLYPHS* shaped_glyphs,
Uint32 render_flags, int x, int y,
int letter_spacing, int word_spacing, int tab_size, int max_extent,
GLYPHEXTINFO* glyph_ext_info, SIZE* line_size, GLYPHPOS* glyph_pos)
{
return 0;
}
int GUIAPI DrawShapedGlyphString(HDC hdc,
LOGFONT* logfont_upright, LOGFONT* logfont_sideways,
const SHAPEDGLYPHS* shaped_glyphs,
const GLYPHPOS* glyph_pos, int nr_glyphs)
{
int i;
int n = 0;
Uint32 old_ta;
PLOGFONT old_lf;
if (shaped_glyphs == NULL || glyph_pos == NULL || nr_glyphs <= 0)
return 0;
old_ta = SetTextAlign(hdc, TA_LEFT | TA_TOP | TA_UPDATECP);
old_lf = GetCurFont(hdc);
for (i = 0; i < nr_glyphs; i++) {
if (glyph_pos[i].suppressed == 0 && glyph_pos[i].whitespace == 0) {
Glyph32 gv = shaped_glyphs->cb_get_glyph_info(
shaped_glyphs->shaping_engine, shaped_glyphs->glyph_infos,
i, NULL);
if (glyph_pos[i].orientation == GLYPH_ORIENTATION_UPRIGHT) {
if (logfont_upright)
SelectFont(hdc, logfont_upright);
else
goto error;
}
else {
if (logfont_sideways)
SelectFont(hdc, logfont_sideways);
else
goto error;
}
DrawGlyph(hdc, glyph_pos[i].x, glyph_pos[i].y, gv,
NULL, NULL);
n++;
}
}
error:
SelectFont(hdc, old_lf);
SetTextAlign(hdc, old_ta);
return n;
}
#endif /* _MGCHARSET_UNICODE */
+68
View File
@@ -0,0 +1,68 @@
/*
* 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/>.
*/
/*
** shaped-glyph.c: The implementation of APIs related shaped-glyphs
**
** Reference:
**
** https://docs.microsoft.com/en-us/typography/opentype/spec/
**
** Create by WEI Yongming at 2019/03/06
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "common.h"
#include "minigui.h"
#include "gdi.h"
#include "window.h"
#include "devfont.h"
#include "unicode-ops.h"
#ifdef _MGCHARSET_UNICODE
int GUIAPI GetShapedGlyphsComplex(LOGFONT* logfont,
LanguageCode lang_code, UCharScriptType writing_system,
Uint32 render_flags, const Uchar32* ucs, int nr_ucs,
const BidiLevel embedding_levels, BidiType base_dir,
SHAPEDGLYPHS* shaped_glyphs)
{
return 0;
}
#endif /* _MGCHARSET_UNICODE */