cleanup font name and glyph renderer

This commit is contained in:
Vincent Wei
2019-01-13 13:10:13 +08:00
parent ea8ab93bad
commit bb187f1ee3
12 changed files with 307 additions and 264 deletions

View File

@@ -10,7 +10,7 @@ Please report any bugs and incompatibilities in
### What's new in this version
#### Redesigned the style of logical fonts
#### Tunning the logical font APIs
The styles of LOGFONT changed.
@@ -34,15 +34,14 @@ The styles of LOGFONT changed.
1. `FONT_WEIGHT_BOLD`:
1. `FONT_WEIGHT_EXTRA_BOLD`:
1. `FONT_WEIGHT_BLACK`:
* Introduce the new decoration styles:
* Introduce the new decoration styles and replace
`FONT_UNDERLINE_LINE` and `FONT_STRUCKOUT_LINE` with them:
1. `FONT_DECORATE_ANY`:
1. `FONT_DECORATE_NONE`:
1. `FONT_DECORATE_UNDERLINE`:
1. `FONT_DECORATE_STRUCKOUT`:
1. `FONT_DECORATE_BOTH`:
* Replace `FONT_UNDERLINE_LINE` and `FONT_STRUCKOUT_LINE` with
For the back-compatibility, you can still use `CreateLogFont` to
create a new LOGFONT. However, the `FS_WEIGHT_BOOK` and `FS_WEIGHT_LIGHT`
will be ignored, and the rendering type will be set as `FS_RENDER_ANY`.
@@ -67,6 +66,13 @@ please define the font name in the following way:
ttf-Courier-rrncns-*-16-UTF-8
#### Changes of font rendering manners
#### Others
* Support for FreeType1 removed.
## Version 3.2.1
The MiniGUI development team announces the availability of MiniGUI 3.2.1.

View File

@@ -537,7 +537,7 @@ AC_ARG_ENABLE(sefsupport,
build_sef_support=$enableval)
AC_ARG_WITH(ttfsupport,
[ --with-ttfsupport=ft1/ft2/none How to support TrueType font (FreeType 1/FreeType 2/None) <default=none>],
[ --with-ttfsupport=ft2/none How to support TrueType font (FreeType 2 or None) <default=ft2>],
use_ttf_lib=$withval)
AC_ARG_ENABLE(ttfcache,
@@ -1978,17 +1978,20 @@ fi
dnl Check FreeType lib
case "$use_ttf_lib" in
ft2)
dnl Check for FreeType2 library
AC_CHECK_LIB(freetype, FT_Library_Version,
DEP_LIBS="$DEP_LIBS -lfreetype",
use_ttf_lib="none")
;;
ft1)
dnl Check for FreeType1 library
AC_CHECK_LIB(ttf, TT_FreeType_Version,
DEP_LIBS="$DEP_LIBS -lttf",
use_ttf_lib="none")
;;
ft2)
dnl Check for FreeType2 library
AC_CHECK_LIB(freetype, FT_Library_Version,
DEP_LIBS="$DEP_LIBS -lfreetype",
use_ttf_lib="none")
*)
use_ttf_lib="none"
;;
esac

View File

@@ -5471,15 +5471,16 @@ MG_EXPORT int GUIAPI SubtractRect (RECT* rc, const RECT* psrc1, const RECT* psrc
#define FONT_WEIGHT_BLACK 'c'
#define FS_WEIGHT_MASK 0x000000FF
#define FS_WEIGHT_THIN 0x00000010
#define FS_WEIGHT_EXTRA_LIGHT 0x00000011
#define FS_WEIGHT_LIGHT 0x00000012
#define FS_WEIGHT_REGULAR 0x00000000
#define FS_WEIGHT_MEDIUM 0x00000020
#define FS_WEIGHT_DEMIBOLD 0x00000021
#define FS_WEIGHT_EXTRA_BOLD 0x00000022
#define FS_WEIGHT_BOLD 0x00000023
#define FS_WEIGHT_BLACK 0x00000024
#define FS_WEIGHT_ANY 0
#define FS_WEIGHT_THIN 10
#define FS_WEIGHT_EXTRA_LIGHT 20
#define FS_WEIGHT_LIGHT 30
#define FS_WEIGHT_REGULAR 40
#define FS_WEIGHT_MEDIUM 50
#define FS_WEIGHT_DEMIBOLD 60
#define FS_WEIGHT_EXTRA_BOLD 70
#define FS_WEIGHT_BOLD 80
#define FS_WEIGHT_BLACK 90
#define FONT_SLANT_NIL '\0'
#define FONT_SLANT_ALL '*'
@@ -5655,72 +5656,72 @@ MG_EXPORT int GUIAPI SubtractRect (RECT* rc, const RECT* psrc1, const RECT* psrc
* \def FONT_CHARSET_GB1988_0
* \brief EUC encoding of GB1988 charset, treat as ISO8859-1.
*/
#define FONT_CHARSET_GB1988_0 "GB1988-0"
#define FONT_CHARSET_GB1988_0 "GB1988-0"
/**
* \def FONT_CHARSET_GB2312_0
* \brief EUC encoding of GB2312 charset.
*/
#define FONT_CHARSET_GB2312_0 "GB2312-0"
#define FONT_CHARSET_GB2312_0 "GB2312-0"
#define FONT_CHARSET_GBK "GBK"
/**
* \def FONT_CHARSET_GB18030_0
* \brief EUC encoding of GB18030 charset.
*/
#define FONT_CHARSET_GB18030_0 "GB18030-0"
#define FONT_CHARSET_GB18030_0 "GB18030-0"
#define FONT_CHARSET_BIG5 "BIG5"
/**
* \def FONT_CHARSET_EUCTW
* \brief EUC encoding of CNS11643 charset, not supported.
*/
#define FONT_CHARSET_EUCTW "EUC-TW"
#define FONT_CHARSET_EUCTW "EUC-TW"
#define FONT_CHARSET_EUCKR "EUC-KR"
/**
* \def FONT_CHARSET_KSC5636_0
* \brief EUC encoding of KSC5636 charset, treat as ISO8859-1.
*/
#define FONT_CHARSET_KSC5636_0 "KSC5636-0"
#define FONT_CHARSET_KSC5636_0 "KSC5636-0"
/**
* \def FONT_CHARSET_KSC5601_0
* \brief EUC encoding of KSC5601 charset.
*/
#define FONT_CHARSET_KSC5601_0 "KSC5601-0"
#define FONT_CHARSET_KSC5601_0 "KSC5601-0"
#define FONT_CHARSET_EUCJP "EUC-JP"
/**
* \def FONT_CHARSET_JISX0201_0
* \brief EUC encoding of JISX0201 charset.
*/
#define FONT_CHARSET_JISX0201_0 "JISX0201-0"
#define FONT_CHARSET_JISX0201_0 "JISX0201-0"
/**
* \def FONT_CHARSET_JISX0208_0
* \brief EUC encoding of JISX0208 charset.
*/
#define FONT_CHARSET_JISX0208_0 "JISX0208-0"
#define FONT_CHARSET_JISX0208_0 "JISX0208-0"
#define FONT_CHARSET_SHIFTJIS "SHIFT-JIS"
/**
* \def FONT_CHARSET_JISX0201_1
* \brief Shift-JIS encoding of JISX0201 charset
*/
#define FONT_CHARSET_JISX0201_1 "JISX0201-1"
#define FONT_CHARSET_JISX0201_1 "JISX0201-1"
/**
* \def FONT_CHARSET_JISX0208_1
* \brief Shift-JIS encoding of JISX0208 charset.
*/
#define FONT_CHARSET_JISX0208_1 "JISX0208-1"
#define FONT_CHARSET_JISX0208_1 "JISX0208-1"
/**
* \def FONT_CHARSET_ISO_10646_1
* \brief UCS-2 encoding of UNICODE.
*/
#define FONT_CHARSET_ISO_10646_1 "ISO-10646-1"
#define FONT_CHARSET_ISO_10646_1 "ISO-10646-1"
/**
* \def FONT_CHARSET_UTF8

View File

@@ -4,20 +4,21 @@ noinst_LTLIBRARIES = libfont.la
SRC_FILES = charset.c charset-arabic.c charset-bidi.c \
sysfont.c logfont.c devfont.c fontname.c \
rawbitmap.c varbitmap.c qpf.c upf.c \
fontcache.c freetype1.c freetype2.c font-engines.c\
rawbitmap.c varbitmap.c qpf.c upf.c \
fontcache.c freetype2.c font-engines.c\
gbunimap.c gbkunimap.c gb18030unimap.c big5unimap.c \
ujisunimap.c sjisunimap.c euckrunimap.c \
textops.c mapunitogb.c mapunitogbk.c mapunitobig5.c mapunitogb18030.c \
bitmapfont.c scripteasy.c
HDR_FILES = charset.h rawbitmap.h varbitmap.h freetype1.h freetype2.h qpf.h \
upf.h bitmapfont.h gunichartables.h se_minigui.h unicode-bidi-tables.h
HDR_FILES = charset.h rawbitmap.h varbitmap.h freetype2.h qpf.h \
upf.h bitmapfont.h gunichartables.h se_minigui.h unicode-bidi-tables.h
EXTRA_DIST = convgbmap.c jisunimap.c $(SRC_FILES) $(HDR_FILES) \
makefile.ng makefile.msvc
AM_CPPFLAGS = $(FT1_INC_DIR) $(FT2_INC_DIR)
# AM_CPPFLAGS = $(FT1_INC_DIR) $(FT2_INC_DIR)
AM_CPPFLAGS = $(FT2_INC_DIR)
AM_CPPFLAGS += -I$(abs_top_srcdir)/src/include -I$(abs_top_srcdir)/include
libfont_la_SOURCES = $(SRC_FILES) $(HDR_FILES)

View File

@@ -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 <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/>.
*/
@@ -71,7 +71,7 @@ static unsigned char def_glyph [] = {0};
/*** tree ops ***/
/*
* rebalance the tree.
* rebalance the tree.
*/
static int rebalance (GLYPHTREENODE **root, int *l, int *m)
{
@@ -79,7 +79,7 @@ static int rebalance (GLYPHTREENODE **root, int *l, int *m)
int ll, lm, ml, mm;
*l = rebalance (&(*root)->left, &ll, &lm);
*m = rebalance (&(*root)->right, &ml, &mm);
if ( (*root)->right ) {
if ( *l + ml + 1 < mm ) {
/* Shift less-ward */
@@ -101,13 +101,13 @@ static int rebalance (GLYPHTREENODE **root, int *l, int *m)
b->right = c;
}
}
return 1 + *l + *m;
}
}
else {
*l = *m = 0;
return 0;
}
}
}
/*
@@ -116,22 +116,22 @@ static int rebalance (GLYPHTREENODE **root, int *l, int *m)
static void insert (GLYPHTREENODE *root, int min, int max,
int glyph_width, BITMAP *bmp)
{
if (max < root->min) {
if (!root->left) {
root->left = (GLYPHTREENODE *) calloc (sizeof (GLYPHTREENODE), 1);
root->left->min = min;
root->left->min = min;
root->left->max = max;
}
insert (root->left, min, max, glyph_width, bmp);
return;
}
else if (min > root->max) {
if (!root->right) {
root->right = (GLYPHTREENODE *) calloc (sizeof (GLYPHTREENODE),
root->right = (GLYPHTREENODE *) calloc (sizeof (GLYPHTREENODE),
1);
root->right->min = min;
root->right->min = min;
root->right->max = max;
}
@@ -142,10 +142,10 @@ static void insert (GLYPHTREENODE *root, int min, int max,
max == root->max &&
root->nr_glyphs == 0) {
root->data = bmp;
root->nr_glyphs = max - min + 1;
root->nr_glyphs = max - min + 1;
root->glyph_width = glyph_width;
}
return;
}
@@ -153,7 +153,7 @@ static void insert (GLYPHTREENODE *root, int min, int max,
static GLYPHTREENODE *look_up (GLYPHTREENODE *root, int offset)
{
GLYPHTREENODE *p;
for (p = root; p; )
{
if (offset < p->min)
@@ -163,7 +163,7 @@ static GLYPHTREENODE *look_up (GLYPHTREENODE *root, int offset)
else /* found */
return p;
}
return NULL;
}
@@ -184,7 +184,7 @@ static void destroy (GLYPHTREENODE *root)
p->left = q->right;
q->right = p;
}
return;
}
@@ -228,12 +228,12 @@ static int get_font_ascent (LOGFONT* logfont, DEVFONT* devfont)
else if (height >= 10)
return height - 1;
return height;
return height;
}
static int get_font_descent (LOGFONT* logfont, DEVFONT* devfont)
{
int height = ((BMPFONTINFO *)devfont->data)->height;
int height = ((BMPFONTINFO *)devfont->data)->height;
if (height >= 40)
return 6;
@@ -244,11 +244,11 @@ static int get_font_descent (LOGFONT* logfont, DEVFONT* devfont)
else if (height >= 10)
return 1;
return 0;
return 0;
}
static int
get_glyph_prbitmap (LOGFONT* logfont, DEVFONT* devfont,
get_glyph_prbitmap (LOGFONT* logfont, DEVFONT* devfont,
Glyph32 glyph_value, BITMAP *bmp)
{
GLYPHTREENODE *node = NULL;
@@ -283,9 +283,9 @@ get_glyph_prbitmap (LOGFONT* logfont, DEVFONT* devfont,
bmp->bmColorKey = node->data->bmColorKey;
bmp->bmWidth = node->glyph_width;
bmp->bmHeight = bmpfont_info->height;
bmp->bmPitch = node->data->bmPitch;
bmp->bmPitch = node->data->bmPitch;
bmp->bmBits = node->data->bmBits;
bmp->bmBits += node->glyph_width * (glyph_value - node->min) *
bmp->bmBits += node->glyph_width * (glyph_value - node->min) *
node->data->bmBytesPerPixel;
if(node->data->bmAlphaMask) {
@@ -307,14 +307,14 @@ static BOOL is_glyph_existed (LOGFONT* logfont, DEVFONT* devfont, Glyph32 glyph_
return FALSE;
node = look_up (root, glyph_value);
if (node == NULL)
if (node == NULL)
return FALSE;
else
return TRUE;
}
static int get_glyph_advance (LOGFONT* logfont, DEVFONT* devfont,
static int get_glyph_advance (LOGFONT* logfont, DEVFONT* devfont,
Glyph32 glyph_value, int* px, int* py)
{
GLYPHTREENODE *node = NULL;
@@ -344,7 +344,7 @@ static int get_glyph_bbox (LOGFONT* logfont, DEVFONT* devfont,
if (py)
*py -= get_font_ascent (logfont, devfont);
node = look_up (root, glyph_value);
if (node == NULL) {
if (pwidth)
@@ -390,8 +390,8 @@ static BMPFONTINFO *
build_bmpfont_info (const char *bmpfont_name, const BITMAP* glyph_bmp,
int offset, int nr_glyphs, int glyph_width)
{
BMPFONTINFO *bmpfont_info = (BMPFONTINFO *)calloc (1,
BMPFONTINFO *bmpfont_info = (BMPFONTINFO *)calloc (1,
sizeof(BMPFONTINFO));
if (!bmpfont_info)
return NULL;
@@ -401,46 +401,46 @@ build_bmpfont_info (const char *bmpfont_name, const BITMAP* glyph_bmp,
bmpfont_info->name [LEN_UNIDEVFONT_NAME] = '\0';
/* set height */
if ((bmpfont_info->height
if ((bmpfont_info->height
= fontGetHeightFromName (bmpfont_name)) == -1) {
_ERR_PRINTF ("FONT>Bitmap: Invalid font name (height): %s.\n",
bmpfont_name);
goto error_load;
}
bmpfont_info->ave_width = glyph_width;
bmpfont_info->max_width = glyph_width;
bmpfont_info->node_cnt = 1;
/* set tree root */
if (!bmpfont_info->tree) {
bmpfont_info->tree = (GLYPHTREENODE *) calloc (1,
bmpfont_info->tree = (GLYPHTREENODE *) calloc (1,
sizeof (GLYPHTREENODE));
if (!bmpfont_info->tree) {
_ERR_PRINTF ("FONT>Bitmap: fail to calloc memory space for root.\n");
goto error_load;
}
}
}
bmpfont_info->tree->min = offset;
bmpfont_info->tree->max = offset + nr_glyphs - 1;
bmpfont_info->tree->nr_glyphs = nr_glyphs;
bmpfont_info->tree->glyph_width = glyph_width;
bmpfont_info->tree->data = (void *)glyph_bmp;
bmpfont_info->tree->data = (void *)glyph_bmp;
return bmpfont_info;
error_load:
_ERR_PRINTF ("FONT>Bitmap: Error in building Bitmap Font Info!\n");
free (bmpfont_info);
bmpfont_info = NULL;
return NULL;
}
#if 0 // VincentWei: bad implementation
static int set_devfont_style (char* name, char style)
{
int i;
@@ -461,7 +461,7 @@ static int set_devfont_style (char* name, char style)
return 1;
}
#endif
/************************/
DEVFONT *CreateBMPDevFont (const char *bmpfont_name, const BITMAP* glyph_bmp,
@@ -474,10 +474,10 @@ DEVFONT *CreateBMPDevFont (const char *bmpfont_name, const BITMAP* glyph_bmp,
int offset;
if (!fontGetCharsetFromName (bmpfont_name, charset)) {
_ERR_PRINTF ("FONT>Bitmap: Invalid font name (charset): %s.\n",
_ERR_PRINTF ("FONT>Bitmap: Invalid font name (charset): %s.\n",
bmpfont_name);
goto error_create;
}
}
if ((charset_ops = GetCharsetOpsEx (charset)) == NULL) {
_ERR_PRINTF ("FONT>Bitmap: Not supported charset: %s.\n", charset);
@@ -485,30 +485,32 @@ DEVFONT *CreateBMPDevFont (const char *bmpfont_name, const BITMAP* glyph_bmp,
}
offset = (charset_ops->char_glyph_value) (NULL, 0,
(const unsigned char*) start_mchar, 0);
(const unsigned char*) start_mchar, 0);
bmpfont_info = build_bmpfont_info (bmpfont_name, glyph_bmp,
offset, nr_glyphs,
glyph_width);
if (bmpfont_info == NULL)
return NULL;
bitmapfont_dev_font = (DEVFONT *)calloc (1, sizeof (DEVFONT));
bitmapfont_dev_font = (DEVFONT *)calloc (1, sizeof (DEVFONT));
if (bitmapfont_dev_font == NULL) {
free(bmpfont_info);
free (bitmapfont_dev_font);
return NULL;
}
/*
* Set device name and add BOLD & ITALIC style
*/
strncpy (bitmapfont_dev_font->name ,bmpfont_name, LEN_UNIDEVFONT_NAME);
/*
* Set device name
*/
strncpy (bitmapfont_dev_font->name, bmpfont_name, LEN_UNIDEVFONT_NAME);
#if 0 // VincentWei: bad implementation
if (!set_devfont_style (bitmapfont_dev_font->name, FONT_WEIGHT_BOLD))
return NULL;
return NULL;
if (!set_devfont_style (bitmapfont_dev_font->name, FONT_SLANT_ITALIC))
return NULL;
return NULL;
#endif
bitmapfont_dev_font->name [LEN_UNIDEVFONT_NAME] = '\0';
bitmapfont_dev_font->style = fontConvertStyle (bitmapfont_dev_font->name);
@@ -517,22 +519,22 @@ DEVFONT *CreateBMPDevFont (const char *bmpfont_name, const BITMAP* glyph_bmp,
bitmapfont_dev_font->data = bmpfont_info;
if (bitmapfont_dev_font->charset_ops->bytes_maxlen_char > 1)
if (bitmapfont_dev_font->charset_ops->bytes_maxlen_char > 1)
font_AddMBDevFont (bitmapfont_dev_font);
else
else
font_AddSBDevFont (bitmapfont_dev_font);
return bitmapfont_dev_font;
error_create:
_ERR_PRINTF ("FONT>Bitmap: Error in creating bitmap font!\n");
_ERR_PRINTF ("FONT>Bitmap: Error in creating bitmap font!\n");
free (bitmapfont_dev_font);
bitmapfont_dev_font = NULL;
return NULL;
return NULL;
}
BOOL AddGlyphsToBMPFont (DEVFONT* dev_font, BITMAP* glyph_bmp,
BOOL AddGlyphsToBMPFont (DEVFONT* dev_font, BITMAP* glyph_bmp,
const char* start_mchar, int nr_glyphs, int glyph_width)
{
int offset;
@@ -540,7 +542,7 @@ BOOL AddGlyphsToBMPFont (DEVFONT* dev_font, BITMAP* glyph_bmp,
int m = 0;
BMPFONTINFO *info = (BMPFONTINFO *)dev_font->data;
GLYPHTREENODE *root = info->tree;
if (!dev_font || !root)
return FALSE;
@@ -551,7 +553,7 @@ BOOL AddGlyphsToBMPFont (DEVFONT* dev_font, BITMAP* glyph_bmp,
if (look_up (root, offset) == NULL) {
insert (root, offset, (offset + nr_glyphs - 1 ),
glyph_width, glyph_bmp);
/* rebalance tree. 'root' can't be carried into rebalance */
rebalance (&(((BMPFONTINFO *)dev_font->data)->tree), &l, &m);
@@ -562,8 +564,8 @@ BOOL AddGlyphsToBMPFont (DEVFONT* dev_font, BITMAP* glyph_bmp,
info->ave_width = (info->ave_width * info->node_cnt + glyph_width)/
(info->node_cnt + 1);
info->node_cnt++;
}
}
return TRUE;
}
@@ -577,7 +579,7 @@ void DestroyBMPFont (DEVFONT* dev_font)
destroy (((BMPFONTINFO *)dev_font->data)->tree);
((BMPFONTINFO *)dev_font->data)->tree = NULL;
}
/* free bitmap font info*/
if (dev_font->data != NULL) {
free(dev_font->data);
@@ -585,13 +587,13 @@ void DestroyBMPFont (DEVFONT* dev_font)
}
/*delete dev_font from device font linked list and free dev_fonts*/
if (dev_font->charset_ops->bytes_maxlen_char > 1)
if (dev_font->charset_ops->bytes_maxlen_char > 1)
font_DelMBDevFont (dev_font);
else
else
font_DelSBDevFont (dev_font);
dev_font = NULL;
return;
}
@@ -602,19 +604,19 @@ static int print_tree_struct ( GLYPHTREENODE *node)
if (node == NULL)
return 0;
_MG_PRINTF ("%d", node->min);
if (node->left != NULL || node->right != NULL)
{
_MG_PRINTF ("(");
print_tree_struct (node->left);
if (node->right != NULL)
{
_MG_PRINTF (",");
print_tree_struct (node->right);
}
_MG_PRINTF (")");
}
return 0;
@@ -629,7 +631,7 @@ static void dump_tree (DEVFONT *dev_font)
_MG_PRINTF ("the tree is empty.\n");
return;
}
print_tree_struct (((BMPFONTINFO *)dev_font->data)->tree);
_MG_PRINTF ("\n");
}
@@ -642,7 +644,7 @@ static int avl_look_up (DEVFONT *dev_font, char *start_mchar, int n)
offset = (*dev_font->charset_ops->char_glyph_value) (NULL, 0,
(const unsigned char*)start_mchar, n);
offset += n;
p = look_up (((BMPFONTINFO *)dev_font->data)->tree, offset);
if (p == NULL) {
_MG_PRINTF ("Find nothing. \n");
@@ -651,19 +653,19 @@ static int avl_look_up (DEVFONT *dev_font, char *start_mchar, int n)
else {
_MG_PRINTF ("Found %s+%d \n", start_mchar, n);
return 1;
}
return 0;
}
static void destroy_avl_tree (DEVFONT *dev_font)
{
if (dev_font && ((BMPFONTINFO *)dev_font->data)->tree != NULL) {
destroy (((BMPFONTINFO *)dev_font->data)->tree);
((BMPFONTINFO *)dev_font->data)->tree = NULL;
_MG_PRINTF ("Succeed to destroy avl tree.\n");
}
}

View File

@@ -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 <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/>.
*/
@@ -102,8 +102,10 @@ void font_ResetDevFont (void)
#define MATCHED_TYPE 0x01
#define MATCHED_FAMILY 0x02
#define MATCHED_CHARSET 0x04
#define MATCHED_WEIGHT 0x08
#define MATCHED_SLANT 0x10
static DEVFONT* get_matched_devfont (LOGFONT* log_font, DEVFONT* list_head,
static DEVFONT* get_matched_devfont (LOGFONT* log_font, DEVFONT* list_head,
int list_len, char* req_charset)
{
int i = 0;
@@ -123,6 +125,8 @@ static DEVFONT* get_matched_devfont (LOGFONT* log_font, DEVFONT* list_head,
while (dev_font) {
int type_req;
char family [LEN_FONT_NAME + 1];
int weight_req = log_font->style & FS_WEIGHT_MASK;
int weight_cur = dev_font->style & FS_WEIGHT_MASK;
/* clear match_bits first. */
match_bits [i] = 0;
@@ -145,8 +149,20 @@ static DEVFONT* get_matched_devfont (LOGFONT* log_font, DEVFONT* list_head,
match_bits [i] |= MATCHED_CHARSET;
}
/* does match the weight requested? */
if (weight_req == FS_WEIGHT_ANY || weight_req == weight_cur) {
match_bits [i] |= MATCHED_WEIGHT;
}
else if (dev_font->font_ops->get_glyph_type(log_font, dev_font)
== DEVFONTGLYPHTYPE_MONOBMP
&& weight_req > FS_WEIGHT_DEMIBOLD
&& weight_cur < FS_WEIGHT_MEDIUM) {
// For mono glyph, the glyph render can do auot-bold
match_bits [i] |= MATCHED_WEIGHT;
}
/* FIXME: ignore style */
/* The glyph renderer can do auto slant, so ignore slant style */
//match_bits [i] |= MATCHED_SLANT;
dev_font = dev_font->next;
i ++;
@@ -159,9 +175,11 @@ static DEVFONT* get_matched_devfont (LOGFONT* log_font, DEVFONT* list_head,
int error;
if ((match_bits [i] & MATCHED_TYPE)
&& (match_bits [i] & MATCHED_FAMILY)
&& (match_bits [i] & MATCHED_CHARSET)) {
error = log_font->size -
(*dev_font->font_ops->get_font_size) (log_font, dev_font,
&& (match_bits [i] & MATCHED_CHARSET)
&& (match_bits [i] & MATCHED_WEIGHT)
/* && (match_bits [i] & MATCHED_SLANT)*/) {
error = log_font->size -
(*dev_font->font_ops->get_font_size) (log_font, dev_font,
log_font->size);
error = ABS (error);
if (min_error >= error) { /* use >=, make the later has a higher priority */
@@ -178,7 +196,7 @@ static DEVFONT* get_matched_devfont (LOGFONT* log_font, DEVFONT* list_head,
FreeFixStr ((char*)match_bits);
#endif
matched_font->font_ops->get_font_size (log_font, matched_font,
matched_font->font_ops->get_font_size (log_font, matched_font,
log_font->size);
return matched_font;
@@ -189,7 +207,7 @@ static DEVFONT* get_matched_devfont (LOGFONT* log_font, DEVFONT* list_head,
for (i = 0; i < list_len; i++) {
int error;
if (match_bits [i] & MATCHED_CHARSET) {
error = log_font->size -
error = log_font->size -
(*dev_font->font_ops->get_font_size) (log_font, dev_font, log_font->size);
error = ABS (error);
if (min_error >= error) { /* use >=, make the later has a higher priority */
@@ -218,12 +236,12 @@ DEVFONT* font_GetMatchedSBDevFont (LOGFONT* log_font)
/*mbc logfont --- sbc devfont*/
char sysfont_charset [LEN_FONT_NAME + 1];
fontGetCharsetFromName (g_SysLogFont[0]->sbc_devfont->name, sysfont_charset);
matched_devfont = get_matched_devfont (log_font, sb_dev_font_head,
matched_devfont = get_matched_devfont (log_font, sb_dev_font_head,
nr_sb_dev_fonts, sysfont_charset);
}
else {
/*sbc logfont --- sbc devfont*/
matched_devfont = get_matched_devfont (log_font, sb_dev_font_head,
matched_devfont = get_matched_devfont (log_font, sb_dev_font_head,
nr_sb_dev_fonts,log_font->charset);
}
@@ -240,7 +258,7 @@ DEVFONT* font_GetMatchedMBDevFont (LOGFONT* log_font)
return NULL;
/*mbc logfont --- mbc devfont*/
else
return get_matched_devfont (log_font, mb_dev_font_head,
return get_matched_devfont (log_font, mb_dev_font_head,
nr_mb_dev_fonts, log_font->charset);
}
@@ -265,7 +283,7 @@ unsigned short font_GetBestScaleFactor (int height, int expect)
{
int error, min_error;
unsigned short scale = 1;
min_error = height - expect;
min_error = ABS (min_error);
@@ -322,10 +340,10 @@ void dbg_dumpDevFonts (void)
/***** Added in MiniGUI V2.2 for bitmap font *****/
/*
/*
* Removes an element from single-byte devfont linked list. If two elements
* contain the same data, only the first is removed. If none of the elements
* contain the data, the single-byte devfont linked list is unchanged
* contain the data, the single-byte devfont linked list is unchanged
*/
void font_DelSBDevFont (DEVFONT* dev_font)
{
@@ -334,27 +352,27 @@ void font_DelSBDevFont (DEVFONT* dev_font)
tmp = sb_dev_font_head;
while (tmp != NULL) {
if (tmp == dev_font) {
if (prev != NULL)
if (prev != NULL)
prev->next = tmp->next;
else
else
sb_dev_font_head = tmp->next;
nr_sb_dev_fonts --;
break;
break;
}
prev = tmp;
tmp = prev->next;
}
return;
}
/*
/*
* Removes an element from multiple-byte devfont linked list. If two elements
* contain the same data, only the first is removed. If none of the elements
* contain the data, the multiple-byte devfont linked list is unchanged
* contain the data, the multiple-byte devfont linked list is unchanged
*/
void font_DelMBDevFont (DEVFONT* dev_font)
{
@@ -369,13 +387,13 @@ void font_DelMBDevFont (DEVFONT* dev_font)
mb_dev_font_head = tmp->next;
nr_mb_dev_fonts --;
break;
break;
}
prev = tmp;
tmp = prev->next;
}
return;
}
@@ -386,14 +404,14 @@ static DEVFONT* make_devfont (const char* font_name, void* data, BOOL is_filenam
DEVFONT* devfont;
CHARSETOPS* charset_ops;
char charset [LEN_FONT_NAME + 1];
/*find the FONTOPS and LOADER*/
while (fontops_info->type) {
if (strncmp (font_name, fontops_info->type, FONT_TYPE_NAME_LEN) == 0)
break;
fontops_info++;
}
if (fontops_info->type == NULL) {
_MG_PRINTF ("FONT>DevFont: invalid font type: %s.\n", font_name);
return NULL;
@@ -406,7 +424,7 @@ static DEVFONT* make_devfont (const char* font_name, void* data, BOOL is_filenam
}
if ((charset_ops = GetCharsetOpsEx (charset)) == NULL) {
_MG_PRINTF ("FONT>DevFont: Invalid charset name %s of font %s.\n",
_MG_PRINTF ("FONT>DevFont: Invalid charset name %s of font %s.\n",
charset, font_name);
return NULL;
}
@@ -421,7 +439,7 @@ static DEVFONT* make_devfont (const char* font_name, void* data, BOOL is_filenam
devfont->data = devfont->font_ops->load_font_data (font_name, data);
if (devfont->data == NULL) {
_MG_PRINTF ("FONT>DevFont: error in loading font %s from %s file.\n",
_MG_PRINTF ("FONT>DevFont: error in loading font %s from %s file.\n",
font_name, (const char*) data);
free (devfont);
return NULL;
@@ -562,7 +580,7 @@ static UPFINFO* incore_upfonts [] = {
&__mgif_upf_times_12x10,
&__mgif_upf_times_17x14,
#endif
NULL
NULL
};
#define NR_UPFONTS (sizeof (incore_upfonts) / sizeof (UPFINFO*))
@@ -649,7 +667,7 @@ static void del_all_devfonts (void)
DEVFONT* cur;
DEVFONT* head;
head = sb_dev_font_head;
head = sb_dev_font_head;
one_list:
cur = head;
while (cur) {
@@ -674,8 +692,8 @@ one_list:
*/
static inline void del_devfont_from_list(const char* font_name, BOOL is_mbc_list)
{
static inline void del_devfont_from_list(const char* font_name, BOOL is_mbc_list)
{
DEVFONT* head;
DEVFONT* cur;
DEVFONT* prev;
@@ -691,11 +709,11 @@ static inline void del_devfont_from_list(const char* font_name, BOOL is_mbc_list
prev = NULL;
}
while (cur) {
if (strcmp (cur->name, font_name) == 0) {
/*unload cur->data*/
if (!cur->relationship && cur->need_unload)
cur->font_ops->unload_font_data (cur->data);
while (cur) {
if (strcmp (cur->name, font_name) == 0) {
/*unload cur->data*/
if (!cur->relationship && cur->need_unload)
cur->font_ops->unload_font_data (cur->data);
if (cur == head) {
cur = cur->next;
@@ -705,20 +723,20 @@ static inline void del_devfont_from_list(const char* font_name, BOOL is_mbc_list
}
else {
prev->next = cur->next;
free (cur);
cur = prev->next;
free (cur);
cur = prev->next;
}
if (is_mbc_list)
nr_mb_dev_fonts--;
else
nr_sb_dev_fonts--;
}
else {
}
else {
prev = cur;
cur = cur->next;
}
}
}
}
if (is_mbc_list)
mb_dev_font_head = head;
@@ -738,7 +756,7 @@ static void font_DelDevFont (const char* font_name)
del_devfont_from_list(font_name, FALSE);
}
DEVFONT* GUIAPI LoadDevFontFromFile
DEVFONT* GUIAPI LoadDevFontFromFile
(const char *devfont_name, const char *file_name)
{
DEVFONT* devfont = make_devfont (devfont_name, (char*)file_name, TRUE);
@@ -763,13 +781,13 @@ static BOOL init_or_term_specifical_fonts (char* etc_section, BOOL is_unload)
char font_name [LEN_UNIDEVFONT_NAME + 1];
char font_file [MAX_PATH+1];
char font_path [MAX_PATH+1];
char *font_file_name = NULL;
MEM_RES* memres = NULL;
char *font_file_name = NULL;
MEM_RES* memres = NULL;
char key[12];
int added_num = 0;
font_file_name = font_file;
font_file_name = font_file;
/*get font number in minigui etc*/
if (GetMgEtcIntValue (etc_section, "font_number", &font_num) < 0 ) {
@@ -782,14 +800,14 @@ static BOOL init_or_term_specifical_fonts (char* etc_section, BOOL is_unload)
for (i=0; i<font_num; i++) {
snprintf (key, sizeof(key)-1, "name%d", i);
if (GetMgEtcValue (etc_section, key, font_name, LEN_UNIDEVFONT_NAME) < 0) {
_MG_PRINTF ("FONT>DevFont: can't get name of key %s in section %s.\n",
_MG_PRINTF ("FONT>DevFont: can't get name of key %s in section %s.\n",
key, etc_section);
continue;
}
snprintf (key, sizeof(key)-1, "fontfile%d", i);
if (GetMgEtcValue (etc_section, key, font_file_name, MAX_PATH) < 0) {
_MG_PRINTF ("FONT>DevFont: can't get font_file of key %s in section %s.\n",
_MG_PRINTF ("FONT>DevFont: can't get font_file of key %s in section %s.\n",
key, etc_section);
continue;
}
@@ -808,7 +826,7 @@ static BOOL init_or_term_specifical_fonts (char* etc_section, BOOL is_unload)
else {
/* [DK] Fix Bug #4801, which introduce a absolute path check error in Windows,
* first to load from sytem res path, else load it directly(relative or absolute path).*/
if ((0 == mg_path_joint(font_path, MAX_PATH + 1, sysres_get_system_res_path(), font_file))
if ((0 == mg_path_joint(font_path, MAX_PATH + 1, sysres_get_system_res_path(), font_file))
&& ((AddDevFont (font_name, font_path, TRUE)) == TRUE))
added_num++;
else if ((AddDevFont (font_name, font_file, TRUE)) == TRUE)

View File

@@ -58,25 +58,22 @@
#include "freetype2.h"
#endif
typedef struct _MemBlk
{
typedef struct _MemBlk {
void *data;
int len;
struct _MemBlk *hashPrev;
struct _MemBlk *hashNext;
struct _MemBlk *lruPrev;
struct _MemBlk *lruNext;
}MemBlk;
} MemBlk;
typedef MemBlk LruQueueDummyHead;
typedef MemBlk HashQueueDummyHead;
/* hash directory array in every cache */
typedef struct _HashDirectory
{
typedef struct _HashDirectory {
HashQueueDummyHead hashHead;
}HashDirectory;
} HashDirectory;
/* The structure is description of Cache
blkSize : the size of each block in cache(in byte)
@@ -88,14 +85,14 @@ typedef struct _HashDirectory
*hashDir : the hash directory pointer
lruQueueDummyHead : head node of lru queue
makeHashKeyFunc : the function which make hash key */
typedef struct cache
{
typedef struct cache {
/* Information about font */
char family[LEN_FONT_NAME + 1];
// VincentWei: no need to check charset for TrueType
//char charset[LEN_FONT_NAME + 1];
DWORD render_style; // render style
int render_style; // render style
int fontsize;
int rotation;
int refers;
int blkSize;
@@ -106,7 +103,7 @@ typedef struct cache
HashDirectory *hashDir;
LruQueueDummyHead lruQueueDummyHead;
MakeHashKeyFunc makeHashKeyFunc;
}cache_t;
} cache_t;
/* Least-Recently-Used-Order
global cache LRU queue */
@@ -127,8 +124,7 @@ typedef struct _CacheQueueNode
cacheSize : each cache's size(in BYTE and
everyone has the same size!)
nCache : how many cache Now!! */
struct _CacheSystem
{
struct _CacheSystem {
CacheQueueNode queueDummyHead;
int maxCache;
@@ -461,12 +457,13 @@ __mg_ttc_write(HCACHE hCache, TTFCACHEINFO *data, int size)
/* create a cache for a font instance.
nblk : how many block in the cache.
blks ize : each block's size
blksize : each block's size
ndir : how many hash entries in the cache
makeHashKey : the function which make the hash key */
HCACHE
__mg_ttc_create(char *family, char *charset, DWORD style, int size,
int nblk, int blksize, int ndir, MakeHashKeyFunc makeHashKey)
__mg_ttc_create(char *family, char *charset,
DWORD style, int size, int rotation,
int nblk, int blksize, int ndir, MakeHashKeyFunc makeHashKey)
{
CacheQueueNode *temp;
if (family == NULL || /* charset == NULL || */makeHashKey == NULL) {
@@ -487,6 +484,7 @@ __mg_ttc_create(char *family, char *charset, DWORD style, int size,
//strncpy(temp->cache.charset, charset, LEN_FONT_NAME);
temp->cache.render_style = (style & FS_RENDER_MASK);
temp->cache.fontsize = size;
temp->cache.rotation = rotation;
temp->cache.blkSize = blksize;
temp->cache.nBlk = nblk;
temp->cache.nDir = ndir;
@@ -577,7 +575,8 @@ __mg_ttc_sys_deinit(void)
HCACHE
__mg_ttc_is_exist(char *family, char *charset, DWORD style, int size)
__mg_ttc_is_exist(char *family, char *charset,
DWORD style, int size, int rotation)
{
CacheQueueNode *p;
@@ -615,6 +614,7 @@ __mg_ttc_is_exist(char *family, char *charset, DWORD style, int size)
&& strncmp(p->cache.charset, charset, LEN_FONT_NAME) == 0
#endif
&& p->cache.fontsize == size
&& p->cache.rotation == rotation
&& (style & FS_RENDER_MASK) == p->cache.render_style) {
return (HCACHE) p;
}

View File

@@ -174,6 +174,7 @@ DWORD fontConvertStyle (const char* style_part)
break;
*/
default:
style |= FS_WEIGHT_ANY;
break;
}

View File

@@ -617,6 +617,7 @@ get_glyph_monobitmap (LOGFONT* logfont, DEVFONT* devfont,
if (scale) *scale = 1;
return char_bitmap_pixmap (logfont, devfont, glyph_value, pitch, FALSE);
}
static const void*
get_glyph_greybitmap (LOGFONT* logfont, DEVFONT* devfont,
const Glyph32 glyph_value, int* pitch,
@@ -736,7 +737,6 @@ new_instance (LOGFONT* logfont, DEVFONT* devfont, BOOL need_sbc_font)
if (FT_New_Size (face, &size))
goto out;
if (FT_Activate_Size (size))
goto out_size;
@@ -788,7 +788,7 @@ new_instance (LOGFONT* logfont, DEVFONT* devfont, BOOL need_sbc_font)
(ft_inst_info->rotation == 0)) {
HCACHE hCache = __mg_ttc_is_exist(logfont->family, logfont->charset,
logfont->style, logfont->size);
logfont->style, logfont->size, logfont->rotation);
DP(("__mg_ttc_is_exist() return %p\n", hCache));
/* No this style's cache */
if (hCache == 0) {
@@ -838,9 +838,11 @@ new_instance (LOGFONT* logfont, DEVFONT* devfont, BOOL need_sbc_font)
"blksize(bitmap) = %d, nblk = %d\n",
rows, col, blksize, blksize-sizeof(TTFCACHEINFO), nblk));
ft_inst_info->cache = __mg_ttc_create(logfont->family, logfont->charset,
logfont->style, logfont->size, nblk , blksize ,
_TTF_HASH_NDIR, make_hash_key);
ft_inst_info->cache = __mg_ttc_create(logfont->family,
logfont->charset, logfont->style, logfont->size,
logfont->rotation, nblk , blksize, _TTF_HASH_NDIR,
make_hash_key);
DP(("__mg_ttc_create() return %p\n", ft_inst_info->cache));
} else {
ft_inst_info->cache = hCache;
@@ -855,12 +857,28 @@ new_instance (LOGFONT* logfont, DEVFONT* devfont, BOOL need_sbc_font)
ft_inst_info->size = size;
#endif
//According to face information, change the style information for logical font.
// According to face information, change the style information for logical font.
if (face->style_flags & FT_STYLE_FLAG_ITALIC)
new_devfont->style |= FS_SLANT_ITALIC;
#if 0 // VincentWei: use TT_OS2 table data here
if (face->style_flags & FT_STYLE_FLAG_BOLD)
new_devfont->style |= FS_WEIGHT_BOLD;
#else
{
TT_OS2* tt_os2 = (TT_OS2*)FT_Get_Sfnt_Table (face, FT_SFNT_OS2);
unsigned int weight_style = FS_WEIGHT_REGULAR;
if (tt_os2->usWeightClass >= 100 && tt_os2->usWeightClass <= 900) {
weight_style = (tt_os2->usWeightClass/100 * 10);
}
else {
_DBG_PRINTF("FreeType2: Unknown tt_os2->usWeightClass: %u\n", tt_os2->usWeightClass);
}
new_devfont->style &= ~FS_WEIGHT_MASK;
new_devfont->style |= weight_style;
}
#endif
return new_devfont;

View File

@@ -54,6 +54,7 @@ extern "C" {
#include FT_CACHE_MANAGER_H
#include FT_TRIGONOMETRY_H
#include FT_IMAGE_H
#include FT_TRUETYPE_TABLES_H
#if 0
#define _MGFONT_TTF_CACHE 1
@@ -124,19 +125,20 @@ typedef struct tagTTFCACHEINFO {
void *bitmap;
} TTFCACHEINFO, *PTTFCACHEINFO;
extern HCACHE __mg_ttc_create(char *family, char *charset, DWORD style, int size,
int nblk, int blksize, int ndir, MakeHashKeyFunc makeHashKey);
extern HCACHE __mg_ttc_create(char *family, char *charset,
DWORD style, int size, int rotation,
int nblk, int blksize, int ndir, MakeHashKeyFunc makeHashKey);
extern int __mg_ttc_write(HCACHE hCache, TTFCACHEINFO *data, int size);
extern void __mg_ttc_release(HCACHE hCache);
extern int __mg_ttc_sys_init(int maxCache, int cacheSize);
extern void __mg_ttc_sys_deinit(void);
extern TTFCACHEINFO *__mg_ttc_search(HCACHE hCache,
extern TTFCACHEINFO *__mg_ttc_search(HCACHE hCache,
unsigned short unicode, int *size);
extern HCACHE __mg_ttc_is_exist(char *family, char *charset,
DWORD style, int size);
extern HCACHE __mg_ttc_is_exist(char *family, char *charset,
DWORD style, int size, int rotation);
extern void __mg_ttc_refer(HCACHE hCache);
#endif
#endif
#undef TTF_DBG

View File

@@ -61,8 +61,20 @@ typedef struct _BBOX
int w, h;
} BBOX;
int _gdi_get_glyph_advance (PDC pdc, Glyph32 glyph_value,
BOOL direction, int x, int y, int* adv_x, int* adv_y, BBOX* bbox);
int _font_get_glyph_advance (LOGFONT* logfont, DEVFONT* devfont,
Glyph32 glyph_value, BOOL direction, int ch_extra,
int x, int y, int* adv_x, int* adv_y, BBOX* bbox);
static inline int _gdi_get_glyph_advance (PDC pdc, Glyph32 glyph_value,
BOOL direction, int x, int y, int* adv_x, int* adv_y, BBOX* bbox)
{
LOGFONT* logfont = pdc->pLogFont;
DEVFONT* devfont = SELECT_DEVFONT(logfont, glyph_value);
glyph_value = REAL_GLYPH (glyph_value);
return _font_get_glyph_advance (logfont, devfont, glyph_value,
direction, pdc->cExtra, x, y, adv_x, adv_y, bbox);
}
int _gdi_draw_one_glyph (PDC pdc, Glyph32 glyph_value, BOOL direction,
int x, int y, int* adv_x, int* adv_y);

View File

@@ -220,31 +220,21 @@ int GUIAPI GetGlyphInfo (LOGFONT* logfont, Glyph32 glyph_value,
}
}
glyph_info->advance_x = 0;
glyph_info->advance_y = 0;
glyph_info->bbox_x = 0;
glyph_info->bbox_y = 0;
devfont->font_ops->get_glyph_bbox (logfont, devfont, glyph_value,
&glyph_info->bbox_x, &glyph_info->bbox_y,
&glyph_info->bbox_w, &glyph_info->bbox_h);
/* get the glyph advance info.*/
advance = devfont->font_ops->get_glyph_advance(logfont, devfont,
glyph_value, &glyph_info->advance_x, &glyph_info->advance_y);
if (logfont->style & FS_WEIGHT_BOLD) {
advance++;
glyph_info->advance_x++;
}
/*get height and descent of devfont*/
if (glyph_info->mask & GLYPH_INFO_METRICS)
{
/* get metrics of the glyph */
if (glyph_info->mask & GLYPH_INFO_METRICS) {
glyph_info->height = devfont->font_ops->get_font_height
(logfont, devfont);
glyph_info->descent = devfont->font_ops->get_font_descent
(logfont, devfont);
glyph_info->advance_x = 0;
glyph_info->advance_y = 0;
glyph_info->bbox_x = 0;
glyph_info->bbox_y = 0;
_font_get_glyph_advance (logfont, devfont, glyph_value, TRUE,
0, 0, 0, &glyph_info->advance_x, &glyph_info->advance_x,
(BBOX*)(&glyph_info->bbox_x));
}
if (glyph_info->mask & GLYPH_INFO_BMP) {
@@ -4058,8 +4048,9 @@ static inline BOOL _gdi_glyph_if_need_lock(DEVFONT* devfont)
}
#endif
int _gdi_get_glyph_advance (PDC pdc, Glyph32 glyph_value,
BOOL direction, int x, int y, int* adv_x, int* adv_y, BBOX* bbox)
int _font_get_glyph_advance (LOGFONT* logfont, DEVFONT* devfont,
Glyph32 glyph_value, BOOL direction, int ch_extra,
int x, int y, int* adv_x, int* adv_y, BBOX* bbox)
{
int bold = 0;
int tmp_x = x;
@@ -4067,8 +4058,6 @@ int _gdi_get_glyph_advance (PDC pdc, Glyph32 glyph_value,
int adv_len;
int bbox_x = 0, bbox_y = 0;
int bbox_w = 0, bbox_h = 0;
LOGFONT* logfont = pdc->pLogFont;
DEVFONT* devfont = SELECT_DEVFONT(logfont, glyph_value);
int advance = 0;
int glyph_bmptype;
@@ -4077,6 +4066,9 @@ int _gdi_get_glyph_advance (PDC pdc, Glyph32 glyph_value,
BOOL lock = _gdi_glyph_if_need_lock(devfont);
#endif
glyph_bmptype = devfont->font_ops->get_glyph_type (logfont, devfont)
& DEVFONTGLYPHTYPE_MASK_BMPTYPE;
bbox_x = x;
bbox_y = y;
@@ -4086,16 +4078,17 @@ int _gdi_get_glyph_advance (PDC pdc, Glyph32 glyph_value,
if (lock) LOCK (&__mg_gdilock);
#endif
/*in freetype get_glyph_bbox loads glyph, so we must get_glyph_bbox
* before get_glyph_advance, get_glyph_monobitmap....*/
/* in freetype get_glyph_bbox loads glyph, so we must get_glyph_bbox
* before get_glyph_advance, get_glyph_monobitmap....
*/
devfont->font_ops->get_glyph_bbox (logfont, devfont,
REAL_GLYPH(glyph_value), &bbox_x, &bbox_y, &bbox_w, &bbox_h);
if (logfont->style & FS_WEIGHT_BOLD
&& !(devfont->style & FS_WEIGHT_BOLD)
&& ((devfont->font_ops->get_glyph_type (logfont, devfont)
& DEVFONTGLYPHTYPE_MASK_BMPTYPE)
== DEVFONTGLYPHTYPE_MONOBMP)) {
// VincentWei: only use auto bold when the weight of devfont does not
// match the weight of logfont.
if ((logfont->style & FS_WEIGHT_MASK) > FS_WEIGHT_MEDIUM
&& (devfont->style & FS_WEIGHT_MASK) < FS_WEIGHT_DEMIBOLD
&& (glyph_bmptype == DEVFONTGLYPHTYPE_MONOBMP)) {
bold = GET_DEVFONT_SCALE (logfont, devfont);
bbox_w += bold;
}
@@ -4114,34 +4107,21 @@ int _gdi_get_glyph_advance (PDC pdc, Glyph32 glyph_value,
if (lock) UNLOCK (&__mg_gdilock);
#endif
if (!direction){
if (bbox) bbox->x -= (bold + pdc->cExtra + adv_len);
if (!direction) {
if (bbox) bbox->x -= (bold + ch_extra + adv_len);
}
if (direction) {
tmp_x += bold + pdc->cExtra;
tmp_x += bold + ch_extra;
if (adv_x) *adv_x = tmp_x - x;
if (adv_y) *adv_y = tmp_y - y;
}
else {
tmp_x -= bold + pdc->cExtra;
tmp_x -= bold + ch_extra;
if (adv_x) *adv_x = x - tmp_x;
if (adv_y) *adv_y = y - tmp_y;
}
glyph_bmptype = devfont->font_ops->get_glyph_type (logfont, devfont)
& DEVFONTGLYPHTYPE_MASK_BMPTYPE;
#if 0 // VincentWei: use FS_RENDER_MASK instead (3.4.0)
#define FS_WEIGHT_BOOK_LIGHT (FS_WEIGHT_BOOK | FS_WEIGHT_LIGHT)
if (glyph_bmptype == DEVFONTGLYPHTYPE_MONOBMP) {
if (logfont->style & FS_WEIGHT_BOOK_LIGHT) {
if (adv_x) *adv_x += 1;
advance += 1;
}
}
#else
if (glyph_bmptype == DEVFONTGLYPHTYPE_MONOBMP) {
switch (logfont->style & FS_RENDER_MASK) {
case FS_RENDER_GREY:
@@ -4151,13 +4131,10 @@ int _gdi_get_glyph_advance (PDC pdc, Glyph32 glyph_value,
break;
}
}
#endif
//return adv_len + bold + pdc->cExtra;
return adv_len + bold + pdc->cExtra + advance;
return adv_len + bold + ch_extra + advance;
}
void _gdi_get_next_point_online (int pre_x, int pre_y, int advance, BOOL direction, PDC pdc, int *next_x, int *next_y)
{
int delta_x, delta_y;
@@ -4249,7 +4226,7 @@ static void make_back_area(PDC pdc, int x0, int y0, int x1, int y1,
int h = pdc->pLogFont->size;
int ascent = pdc->pLogFont->ascent;
if(pdc->pLogFont->rotation)
if (pdc->pLogFont->rotation)
*flag = ROTATE_RECT;
else if (pdc->pLogFont->style & FS_SLANT_ITALIC &&
!(pdc->pLogFont->sbc_devfont->style & FS_SLANT_ITALIC))
@@ -4577,8 +4554,10 @@ int _gdi_draw_one_glyph (PDC pdc, Glyph32 glyph_value, BOOL direction,
glyph_bmptype = devfont->font_ops->get_glyph_type (logfont, devfont)
& DEVFONTGLYPHTYPE_MASK_BMPTYPE;
if ((logfont->style & FS_WEIGHT_BOLD)
&& !(devfont->style & FS_WEIGHT_BOLD)
// VincentWei: only use auto bold when the weight of devfont does not
// match the weight of logfont.
if ((logfont->style & FS_WEIGHT_MASK) > FS_WEIGHT_MEDIUM
&& (devfont->style & FS_WEIGHT_MASK) < FS_WEIGHT_DEMIBOLD
&& (glyph_bmptype == DEVFONTGLYPHTYPE_MONOBMP)) {
bold = GET_DEVFONT_SCALE (logfont, devfont);
}