diff --git a/src/font/charset-arabic.c b/src/font/charset-arabic.c index 1e16f4a2..8ed2ea5d 100644 --- a/src/font/charset-arabic.c +++ b/src/font/charset-arabic.c @@ -458,7 +458,7 @@ static unsigned int iso8859_6_glyph_type (Glyph32 glyph_value) { unsigned int ch_type = MCHAR_TYPE_UNKNOWN; - if (is_arabic_glyph_vowel (glyph_value)){ /* is vowel */ + if (is_arabic_glyph_vowel (glyph_value)) { /* is vowel */ ch_type = MCHAR_TYPE_VOWEL; } else{ diff --git a/src/font/charset.c b/src/font/charset.c index 643e4fd3..2512ad65 100644 --- a/src/font/charset.c +++ b/src/font/charset.c @@ -43,6 +43,8 @@ #include #include +#define DEBUG + #include "common.h" #include "minigui.h" #include "gdi.h" diff --git a/src/font/varbitmap.c b/src/font/varbitmap.c index 48bf2354..9449702b 100644 --- a/src/font/varbitmap.c +++ b/src/font/varbitmap.c @@ -1,33 +1,33 @@ /* - * This file is part of MiniGUI, a mature cross-platform windowing + * 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 . - * + * * 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 * . */ @@ -42,8 +42,6 @@ #include #include -#define DEBUG - #include "common.h" #ifdef _MGFONT_VBF @@ -54,7 +52,7 @@ #include "misc.h" #ifdef HAVE_MMAP - #include +#include #endif #include "devfont.h" @@ -62,40 +60,41 @@ #include "charset.h" #include "fontname.h" -#define HEADER_LEN 68 +#define HEADER_LEN 68 +#define LEN_VBF_NAME 79 #define VARFONT_INFO_P(devfont) ((VBFINFO*)(devfont->data)) #define VARFONT_INFO(devfont) ((VBFINFO*)(devfont.data)) typedef struct _FILE_LAYOUT { - Uint32 off_bboxs; - Uint32 len_bboxs; + Uint32 off_bboxs; + Uint32 len_bboxs; - Uint32 off_advxs; - Uint32 len_advxs; + Uint32 off_advxs; + Uint32 len_advxs; - Uint32 off_advys; - Uint32 len_advys; + Uint32 off_advys; + Uint32 len_advys; - Uint32 off_bit_offs; - Uint32 len_bit_offs; + Uint32 off_bit_offs; + Uint32 len_bit_offs; - Uint32 off_bits; - Uint32 len_bits; + Uint32 off_bits; + Uint32 len_bits; - Uint32 font_size; + Uint32 font_size; } FILE_LAYOUT; typedef struct _FONT_PROPT { - char font_name [LEN_DEVFONT_NAME + 1]; - char max_width; - char ave_width; - char height; - char descent; + char font_name [LEN_VBF_NAME + 1]; + char max_width; + char ave_width; + char height; + char descent; - int first_glyph; - int last_glyph; - int def_glyph; + int first_glyph; + int last_glyph; + int def_glyph; } FONT_PROPT; static DWORD get_glyph_bmptype (LOGFONT* logfont, DEVFONT* devfont) @@ -103,7 +102,7 @@ static DWORD get_glyph_bmptype (LOGFONT* logfont, DEVFONT* devfont) return DEVFONTGLYPHTYPE_MONOBMP; } -static int get_ch_width (LOGFONT* logfont, DEVFONT* devfont, +static int get_ch_width (LOGFONT* logfont, DEVFONT* devfont, Glyph32 glyph_value) { VBFINFO* vbf_info = VARFONT_INFO_P (devfont); @@ -149,7 +148,7 @@ static int get_font_size (LOGFONT* logfont, DEVFONT* devfont, int expect) static int get_font_ascent (LOGFONT* logfont, DEVFONT* devfont) { - int ascent = VARFONT_INFO_P (devfont)->height + int ascent = VARFONT_INFO_P (devfont)->height - VARFONT_INFO_P (devfont)->descent; return ascent * GET_DEVFONT_SCALE (logfont, devfont); @@ -157,11 +156,10 @@ static int get_font_ascent (LOGFONT* logfont, DEVFONT* devfont) static int get_font_descent (LOGFONT* logfont, DEVFONT* devfont) { - return VARFONT_INFO_P (devfont)->descent + return VARFONT_INFO_P (devfont)->descent * GET_DEVFONT_SCALE (logfont, devfont); } - static int get_glyph_bbox (LOGFONT* logfont, DEVFONT* devfont, Glyph32 glyph_value, int* px, int* py, int* pwidth, int* pheight) @@ -171,7 +169,8 @@ static int get_glyph_bbox (LOGFONT* logfont, DEVFONT* devfont, unsigned short scale = GET_DEVFONT_SCALE (logfont, devfont); glyph_value = REAL_GLYPH(glyph_value); - if (glyph_value < vbf_info->first_glyph || glyph_value > vbf_info->last_glyph) + if (glyph_value < vbf_info->first_glyph + || glyph_value > vbf_info->last_glyph) glyph_value = vbf_info->def_glyph; /*have bbox*/ @@ -179,9 +178,6 @@ static int get_glyph_bbox (LOGFONT* logfont, DEVFONT* devfont, int offset; offset = glyph_value - vbf_info->first_glyph; - _DBG_PRINTF("%s: GV(%x) OFFSET(%d)\n", - __FUNCTION__, glyph_value, offset); - if (px) { tempint = vbf_info->bbox[offset].x; #if MGUI_BYTEORDER == MGUI_BIG_ENDIAN @@ -260,7 +256,7 @@ static const void* get_glyph_monobitmap (LOGFONT* logfont, DEVFONT* devfont, eff_value = vbf_info->def_glyph; if (vbf_info->bits_offset == NULL) - offset = (((size_t)vbf_info->max_width + 7) >> 3) * vbf_info->height + offset = (((size_t)vbf_info->max_width + 7) >> 3) * vbf_info->height * (eff_value - first_value); else { offset = vbf_info->bits_offset [eff_value - vbf_info->first_glyph]; @@ -269,7 +265,7 @@ static const void* get_glyph_monobitmap (LOGFONT* logfont, DEVFONT* devfont, offset = ArchSwap16 (offset); #endif } - + if(pitch){ int width = 0; if (vbf_info->bbox) { @@ -291,11 +287,11 @@ static const void* get_glyph_monobitmap (LOGFONT* logfont, DEVFONT* devfont, #if 0 { - int bbox_w; + int bbox_w; int bbox_h; get_glyph_bbox (logfont, devfont, glyph_value, NULL, NULL, &bbox_w, &bbox_h); - print_bitmap (vbf_info->all_glyph_bits + offset, + print_bitmap (vbf_info->all_glyph_bits + offset, bbox_w, bbox_h, *pitch); } #endif @@ -339,7 +335,8 @@ static void swap_intdata (Uint32* data, int num) } #endif -static void* load_font_data (DEVFONT* devfont, const char* fontname, const char* filename) +static void* load_font_data (DEVFONT* devfont, const char* fontname, + const char* filename) { FILE* fp = NULL; @@ -359,7 +356,7 @@ static void* load_font_data (DEVFONT* devfont, const char* fontname, const char* if (fread (version, 1, VBF_LEN_VERSION_INFO, fp) < VBF_LEN_VERSION_INFO) goto error; - version [VBF_LEN_VERSION_INFO] = '\0'; + version [VBF_LEN_VERSION_INFO] = '\0'; if (strcmp (version, VBF_VERSION3) != 0) { _ERR_PRINTF ("FONT>VBF: Error on loading vbf: %s, version: %s," @@ -370,19 +367,19 @@ static void* load_font_data (DEVFONT* devfont, const char* fontname, const char* if (fread(vender, 1, VBF_LEN_VENDER_INFO, fp) < VBF_LEN_VENDER_INFO) goto error; - if (fread(&len_header, sizeof(short), 1, fp) < 1) + if (fread(&len_header, sizeof(Uint16), 1, fp) < 1) goto error; - if (fread (&layout, sizeof (FILE_LAYOUT), 1, fp) < 1) + if (fread(&layout, sizeof(Uint32), 11, fp) < 1) goto error; #if MGUI_BYTEORDER == MGUI_BIG_ENDIAN len_header = ArchSwap16 (len_header); - swap_intdata ((Uint32*)&layout, sizeof(layout)/sizeof(int)); + swap_intdata ((Uint32*)&layout, 11); #endif #ifdef HAVE_MMAP - if ((temp = mmap (NULL, layout.font_size, PROT_READ, MAP_SHARED, + if ((temp = mmap (NULL, layout.font_size, PROT_READ, MAP_SHARED, fileno(fp), 0)) == MAP_FAILED) goto error; temp += len_header; @@ -428,15 +425,15 @@ static void* load_font_data (DEVFONT* devfont, const char* fontname, const char* if (layout.len_bits <= 0) goto error; - info->all_glyph_bits = (const unsigned char*)(temp + + info->all_glyph_bits = (const unsigned char*)(temp + layout.off_bits-HEADER_LEN); #if 0 if (real_fontname) { - strncpy (real_fontname, info->name, LEN_DEVFONT_NAME); - real_fontname [LEN_DEVFONT_NAME] = '\0'; + strncpy (real_fontname, info->name, LEN_VBF_NAME); + real_fontname [LEN_VBF_NAME] = '\0'; } #endif - + return info; error: diff --git a/src/font/varbitmap.h b/src/font/varbitmap.h index fe02dd04..b3483b8a 100644 --- a/src/font/varbitmap.h +++ b/src/font/varbitmap.h @@ -1,39 +1,39 @@ /* - * This file is part of MiniGUI, a mature cross-platform windowing + * 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 . - * + * * 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 * . */ /* ** varbitmap.h: the head file of raw bitmap font operation set. -** +** */ #ifndef GUI_FONT_VARBITMAP_H @@ -43,43 +43,55 @@ extern "C" { #endif /* __cplusplus */ - -typedef struct _VBF_BBOX -{ +typedef struct _VBF_BBOX { char x, y, w, h; } VBF_BBOX; -typedef struct -{ - char ver_info [4]; /* font version*/ - const char* name; /* font name*/ +typedef struct { + /* font version*/ + char ver_info [4]; + /* font name*/ + const char* name; - char max_width; /* The max width in pixels. */ - char ave_width; /* The average width in pixels. */ - char height; /* The height in pixels. */ - char descent; /* The pixels below the base line. */ + /* The max width in pixels. */ + char max_width; + /* The average width in pixels. */ + char ave_width; + /* The height in pixels. */ + char height; + /* The pixels below the base line. */ + char descent; - int first_glyph; /* The glyph number of the first character in this font.*/ - int last_glyph; /* The glyph number of the last character in this font.*/ - int def_glyph; /* The glyph number of the default character in this font.*/ + /* The glyph number of the first character in this font.*/ + int first_glyph; + /* The glyph number of the last character in this font.*/ + int last_glyph; + /* The glyph number of the default character in this font.*/ + int def_glyph; - unsigned int font_size; /* used by mmap. It should be zero for in-core vbfs. */ + /* used by mmap. It should be zero for in-core vbfs. */ + unsigned int font_size; - const VBF_BBOX* bbox; /* The pointer to the glyph bounding box array or NULL. */ + /* The pointer to the glyph bounding box array or NULL. */ + const VBF_BBOX* bbox; - const char* advance_x; /* The pointer to the glyph advance x array. - If bbox is NULL, the array contains the width of each glyph. - If advance_x is NULL, the glyph has the universal width, - that's max_width. */ - const char* advance_y; /* The pointer to the glyph advance y array. - If bbox is NULL, advance_y should be NULL. - If bbox is not NULL and advance_y is NULL, - all glyph has the universal advance_y, that is, zero. */ + /* The pointer to the glyph advance x array. + If bbox is NULL, the array contains the width of each glyph. + If advance_x is NULL, the glyph has the universal width, + that's max_width. */ + const char* advance_x; + /* The pointer to the glyph advance y array. + If bbox is NULL, advance_y should be NULL. + If bbox is not NULL and advance_y is NULL, + all glyph has the universal advance_y, that is, zero. */ + const char* advance_y; - const unsigned int* bits_offset; /* The pointer to the glyph bitmap offset array - whose number will be used to fetch glyph bitmap - from bits array or NULL. */ - const unsigned char* all_glyph_bits; /* The 8-bit right-padded bitmap data for all glyphs. */ + /* The pointer to the glyph bitmap offset array + whose number will be used to fetch glyph bitmap + from bits array or NULL. */ + const unsigned int* bits_offset; + /* The 8-bit right-padded bitmap data for all glyphs. */ + const unsigned char* all_glyph_bits; } VBFINFO; #define VBF_LEN_VERSION_INFO 10 diff --git a/src/include/devfont.h b/src/include/devfont.h index 4479e341..cdf05b9f 100644 --- a/src/include/devfont.h +++ b/src/include/devfont.h @@ -171,7 +171,7 @@ struct _CHARSETOPS */ int (*pos_first_char) (const unsigned char* mstr, int mstrlen); - /** The method to get the type of one glyph. */ + /** The method to get the BIDI type of one glyph. */ unsigned int (*bidi_glyph_type) (Glyph32 glyph_value); /** Get mirrored glyph diff --git a/src/newgdi/bidi.c b/src/newgdi/bidi.c index e7401d47..5087085a 100644 --- a/src/newgdi/bidi.c +++ b/src/newgdi/bidi.c @@ -32,7 +32,7 @@ * . */ /* -** textout.c: Hight level textout drawing. +** bidi.c ** ** Current maintainer: houhuihua. ** @@ -63,7 +63,7 @@ static Glyph32* _gdi_get_glyphs_string(PDC pdc, const unsigned char* text, int i = 0; int len_cur_char; int left_bytes = text_len; - int glyph_type; + unsigned int glyph_type; Glyph32 glyph_value; DEVFONT* sbc_devfont = pdc->pLogFont->sbc_devfont; DEVFONT* mbc_devfont = pdc->pLogFont->mbc_devfont; @@ -114,7 +114,7 @@ static Glyph32* _gdi_get_glyphs_string(PDC pdc, const unsigned char* text, return logical_glyphs; } -static int inline get_glyph_type (LOGFONT* logfont, Glyph32 glyph_value) +static unsigned int inline get_glyph_type(LOGFONT* logfont, Glyph32 glyph_value) { if (IS_MBC_GLYPH (glyph_value)) return logfont->mbc_devfont->charset_ops->glyph_type(glyph_value); @@ -152,7 +152,7 @@ static int output_visual_glyphs_ltr (PDC pdc, Glyph32* visual_glyphs, { int i = 0; int j = 0; - int glyph_type; + unsigned int glyph_type; Glyph32 glyph_value; Glyph32 biggest_vowel = 0; @@ -229,7 +229,7 @@ static int output_vowels_rtl (PDC pdc, Glyph32* end_glyph, int left_num, { int i = 0; Glyph32 glyph_value; - int glyph_type; + unsigned int glyph_type; int old_text_align = pdc->ta_flags; int old_bkmode = pdc->bkmode; @@ -259,7 +259,7 @@ static int output_unowned_vowels_rtl (PDC pdc, Glyph32* end_glyph, int left_num, int i = 0; Glyph32 glyph_value = INV_GLYPH_VALUE; Glyph32 biggest_vowel = INV_GLYPH_VALUE; - int glyph_type; + unsigned int glyph_type; int cur_advance = 0; int max_advance = 0; int bkmode = pdc->bkmode; @@ -318,7 +318,7 @@ static int output_visual_glyphs_rtl (PDC pdc, Glyph32* visual_glyphs, int nr_glyphs, CB_ONE_GLYPH cb_one_glyph, void* context) { int cur = nr_glyphs - 1; - int glyph_type; + unsigned int glyph_type; Glyph32 glyph_value; int vowel_num; int outed_vowel_num; @@ -376,7 +376,7 @@ static int _gdi_output_glyphs_direct(PDC pdc, const unsigned char* text, int text_len, CB_ONE_GLYPH cb_one_glyph, void* context, BOOL if_break, BOOL if_draw) { - int glyph_type; + unsigned int glyph_type; Glyph32 glyph_value; DEVFONT* sbc_devfont = pdc->pLogFont->sbc_devfont; DEVFONT* mbc_devfont = pdc->pLogFont->mbc_devfont; @@ -478,7 +478,7 @@ int _gdi_reorder_text (PDC pdc, const unsigned char* text, int text_len, BOOL direction, CB_ONE_GLYPH cb_one_glyph, void* context) { int i = 0; - int glyph_type; + unsigned int glyph_type; Glyph32 glyph_value; DEVFONT* sbc_devfont = pdc->pLogFont->sbc_devfont; DEVFONT* mbc_devfont = pdc->pLogFont->mbc_devfont; @@ -554,7 +554,7 @@ _gdi_get_glyphs_string_charbreak(PDC pdc, const unsigned char* text, int i = 0; int len_cur_char; int left_bytes = text_len; - int glyph_type; + unsigned int glyph_type; Glyph32 glyph_value; DEVFONT* sbc_devfont = pdc->pLogFont->sbc_devfont; DEVFONT* mbc_devfont = pdc->pLogFont->mbc_devfont; @@ -821,7 +821,8 @@ _gdi_output_glyphs_direct_sbc_rtol_break(PDC pdc, const unsigned char* text, DRAWTEXTEX2_CTXT* ctxt = (DRAWTEXTEX2_CTXT*)context; int nr_glyphs = 0; int i = 0; - int glyph_type, glyph_value; + unsigned int glyph_type; + Glyph32 glyph_value; DEVFONT* sbc_devfont = pdc->pLogFont->sbc_devfont; if(ctxt->nFormat & DT_WORDBREAK){ @@ -1004,7 +1005,7 @@ int GUIAPI GetGlyphsExtentPoint( PDC pdc = dc_HDC2PDC(hdc); PLOGFONT log_font = pdc->pLogFont; DEVFONT* devfont = NULL; - int glyph_type = 0; + unsigned int glyph_type = 0; size->cx = 0; size->cy = 0; @@ -1053,7 +1054,7 @@ int GUIAPI GetGlyphsExtent( int i = 0; int advance = 0; int adv_x, adv_y; - int glyph_type; + unsigned int glyph_type; Glyph32 glyph_value = INV_GLYPH_VALUE; PDC pdc = dc_HDC2PDC(hdc); PLOGFONT log_font = pdc->pLogFont; diff --git a/src/newgdi/glyph.c b/src/newgdi/glyph.c index f40601b5..c202b602 100644 --- a/src/newgdi/glyph.c +++ b/src/newgdi/glyph.c @@ -2322,7 +2322,7 @@ int _font_get_glyph_advance (LOGFONT* logfont, DEVFONT* devfont, bbox_x = x; bbox_y = y; - /* in freetype get_glyph_bbox loads glyph, so we must get_glyph_bbox + /* in freetype get_glyph_bbox loads glyph, so we must call get_glyph_bbox * before get_glyph_advance, get_glyph_monobitmap.... */ devfont->font_ops->get_glyph_bbox (logfont, devfont, diff --git a/src/newgdi/textout.c b/src/newgdi/textout.c index e5ddaf8b..5da8af74 100644 --- a/src/newgdi/textout.c +++ b/src/newgdi/textout.c @@ -162,7 +162,8 @@ typedef struct _TEXTOUT_CTXT BOOL only_extent; } TEXTOUT_CTXT; -static BOOL cb_textout (void* context, Glyph32 glyph_value, unsigned int glyph_type) +static BOOL cb_textout (void* context, Glyph32 glyph_value, + unsigned int glyph_type) { TEXTOUT_CTXT* ctxt = (TEXTOUT_CTXT*)context; int adv_x, adv_y; @@ -172,8 +173,7 @@ static BOOL cb_textout (void* context, Glyph32 glyph_value, unsigned int glyph_t adv_x = adv_y = 0; } else if (check_vowel(glyph_type)) { - if (!ctxt->only_extent) - { + if (!ctxt->only_extent) { bkmode = ctxt->pdc->bkmode; //ctxt->pdc->bkmode = BM_TRANSPARENT; _gdi_draw_one_glyph (ctxt->pdc, glyph_value, @@ -182,8 +182,8 @@ static BOOL cb_textout (void* context, Glyph32 glyph_value, unsigned int glyph_t ctxt->pdc->bkmode = bkmode; } - //adv_x = adv_y = 0; - adv_x = 0; + //adv_x = adv_y = 0; + adv_x = 0; } else { if (ctxt->only_extent)