Cleanup LOGFONT styles

This commit is contained in:
Vincent Wei
2019-01-12 13:55:51 +08:00
parent 0d2352884a
commit 05cf370155
10 changed files with 1043 additions and 633 deletions
+68 -1
View File
@@ -1,12 +1,79 @@
# Release Notes
## Version 3.4.0
The MiniGUI development team announces the availability of MiniGUI 3.4.0.
All users of MiniGUI are recommended strongly to use this version.
Please report any bugs and incompatibilities in
https://github.com/VincentWei/minigui
### What's new in this version
#### Redesigned the style of logical fonts
The styles of LOGFONT changed.
* Add new rendering style:
1. `FS_RENDER_ANY`: Not specified
1. `FS_RENDER_MONO`:
1. `FS_RENDER_OUTLINE`:
1. `FS_RENDER_GREY`:
1. `FS_RENDER_SUBPIXEL`:
* Remove some bad style definitions:
1. `FS_WEIGHT_BOOK`, use `FS_RENDER_GREY` instead.
1. `FS_WEIGHT_LIGHT`, use `FS_RENDER_OUTLINE` instead.
* Introduced the new weight styles:
1. `FONT_WEIGHT_ANY`: Not specified
1. `FONT_WEIGHT_THIN`:
1. `FONT_WEIGHT_EXTRA_LIGHT`:
1. `FONT_WEIGHT_LIGHT`:
1. `FONT_WEIGHT_REGULAR`:
1. `FONT_WEIGHT_MEDIUM`:
1. `FONT_WEIGHT_DEMIBOLD`:
1. `FONT_WEIGHT_BOLD`:
1. `FONT_WEIGHT_EXTRA_BOLD`:
1. `FONT_WEIGHT_BLACK`:
* Introduce the new decoration styles:
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`.
For new app, you should use the new function `CreateLogFontEx` to
create a LOGFONT.
You can still use `CreateLogFontByName` to create a new LOGFONT.
But the style string in the font name changed from
<weight><slant><flipping><other><underline><struckout>
to
<weight><slant><flipping><other><decoration><rendering>
Obviously, `<underline>` and `<struckout>` are merged to `<decoration>`
in order to keep the styel string is still 6-character long.
Now, if you want to use the rendering style SUPIXEL for a TTF font,
please define the font name in the following way:
ttf-Courier-rrncns-*-16-UTF-8
## Version 3.2.1
The MiniGUI development team announces the availability of MiniGUI 3.2.1.
All users of MiniGUI are recommended strongly to use this version.
Please report any bugs and incompatibilities in
https://github.com/VincentWei/minigui.
https://github.com/VincentWei/minigui
### What's new in this version
+4 -4
View File
@@ -1,6 +1,6 @@
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.60)
AC_INIT(libminigui, 3.2.0)
AC_INIT(libminigui, 3.4.0)
AC_CONFIG_SRCDIR(src/main/main.c)
dnl Set various version strings - taken gratefully from the SDL sources
@@ -15,10 +15,10 @@ dnl Set various version strings - taken gratefully from the SDL sources
# set MINIGUI_BINARY_AGE and MINIGUI_INTERFACE_AGE to 0.
#
MINIGUI_MAJOR_VERSION=3
MINIGUI_MINOR_VERSION=2
MINIGUI_MICRO_VERSION=1
MINIGUI_MINOR_VERSION=4
MINIGUI_MICRO_VERSION=0
MINIGUI_INTERFACE_AGE=0
MINIGUI_BINARY_AGE=1
MINIGUI_BINARY_AGE=0
MINIGUI_VERSION=$MINIGUI_MAJOR_VERSION.$MINIGUI_MINOR_VERSION.$MINIGUI_MICRO_VERSION
AC_SUBST(MINIGUI_MAJOR_VERSION)
+162 -22
View File
@@ -5459,6 +5459,7 @@ MG_EXPORT int GUIAPI SubtractRect (RECT* rc, const RECT* psrc1, const RECT* psrc
#define FONT_WEIGHT_NIL '\0'
#define FONT_WEIGHT_ALL '*'
#define FONT_WEIGHT_ANY '*'
#define FONT_WEIGHT_THIN 't'
#define FONT_WEIGHT_EXTRA_LIGHT 'e'
#define FONT_WEIGHT_LIGHT 'l'
@@ -5530,29 +5531,22 @@ MG_EXPORT int GUIAPI SubtractRect (RECT* rc, const RECT* psrc1, const RECT* psrc
#define FS_DECORATE_BOTH 0x03000000
#define FONT_RENDER_NIL '\0'
#define FONT_RENDER_ANY '*'
#define FONT_RENDER_MONO 'n'
#define FONT_RENDER_OUTLINE 'o'
#define FONT_RENDER_GREY 'g'
#define FONT_RENDER_SUBPIXEL 's'
#define FS_RENDER_MASK 0xF0000000
#define FS_RENDER_MONO 0x00000000
#define FS_RENDER_GREY 0x10000000
#define FS_RENDER_SUBPIXEL 0x20000000
#define FS_RENDER_OUTLINE 0x10000000
#define FS_RENDER_GREY 0x20000000
#define FS_RENDER_SUBPIXEL 0x30000000
/* deprecated since v3.2.1, use FS_RENDER_XXX/FONT_RENDER_XXX instead */
#define FONT_WEIGHT_SUBPIXEL 's'
#define FONT_WEIGHT_BOOK 'k'
/* deprecated since v3.2.1, use FS_DECORATE_XXX/FONT_DECORATE_XXX instead */
#define FONT_UNDERLINE_NIL '\0'
#define FONT_UNDERLINE_ALL '*'
#define FONT_UNDERLINE_LINE 'u'
#define FONT_UNDERLINE_NONE 'n'
#define FONT_STRUCKOUT_NIL '\0'
#define FONT_STRUCKOUT_ALL '*'
#define FONT_STRUCKOUT_LINE 's'
#define FONT_STRUCKOUT_NONE 'n'
/*
#define FS_WEIGHT_SUBPIXEL 0x00000000
#define FS_WEIGHT_BOOK 0x00000000
@@ -5566,7 +5560,7 @@ MG_EXPORT int GUIAPI SubtractRect (RECT* rc, const RECT* psrc1, const RECT* psrc
#define FS_STRUCKOUT_NONE 0x00000000
*/
/*
/*
* Backward compatiblilty definitions.
* All FONT_SETWIDTH_* and FONT_SPACING_* types will
* be treated as FONT_FLIP_NIL and FONT_OTHER_NIL respectively.
@@ -5601,6 +5595,16 @@ MG_EXPORT int GUIAPI SubtractRect (RECT* rc, const RECT* psrc1, const RECT* psrc
#define FS_SPACING_CHARCELL 0x00000000
*/
#define FONT_UNDERLINE_NIL '\0'
#define FONT_UNDERLINE_ALL '*'
#define FONT_UNDERLINE_LINE 'u'
#define FONT_UNDERLINE_NONE 'n'
#define FONT_STRUCKOUT_NIL '\0'
#define FONT_STRUCKOUT_ALL '*'
#define FONT_STRUCKOUT_LINE 's'
#define FONT_STRUCKOUT_NONE 'n'
#define FONT_TYPE_NAME_LEN 3
#define FONT_TYPE_NAME_BITMAP_RAW "rbf"
#define FONT_TYPE_NAME_BITMAP_VAR "vbf"
@@ -6074,14 +6078,24 @@ MG_EXPORT void GUIAPI TermVectorialFonts (void);
* \param weight The weight of the logical font, can be one of the values:
* - FONT_WEIGHT_ALL\n
* Any one.
* - FONT_WEIGHT_REGULAR\n
* Regular font.
* - FONT_WEIGHT_BOLD\n
* Bold font.
* - FONT_WEIGHT_BOOK\n
* Anti-aliase font.
* - FONT_WEIGHT_THIN\n
* Thin.
* - FONT_WEIGHT_EXTRA_LIGHT\n
* Extra light (Ultra light).
* - FONT_WEIGHT_LIGHT\n
* Draw the glyph border with the background color.
* Light.
* - FONT_WEIGHT_REGULAR\n
* Regular (normal).
* - FONT_WEIGHT_MEDIUM\n
* Medium.
* - FONT_WEIGHT_DEMIBOLD\n
* Semi Bold (Demi Bold).
* - FONT_WEIGHT_BOLD\n
* Bold.
* - FONT_WEIGHT_EXTRA_BOLD\n
* Extra bold (Ultra Bold).
* - FONT_WEIGHT_BLACK\n
* Black (Heavy).
* \param slant The slant of the logical font, can be one of the values:
* - FONT_SLANT_ALL\n
* Any one.
@@ -6111,10 +6125,10 @@ MG_EXPORT void GUIAPI TermVectorialFonts (void);
* When using TrueType font, kern the glyph and do not use cache.
* - FONT_OTHER_LCDPORTRAIT\n
* When using TrueType font and sub-pixels smoothing strategy,
* set lcd portrait and do not use kern the glyph.
* set LCD portrait and do not kern the glyph.
* - FONT_OTHER_LCDPORTRAITKERN\n
* When using TrueType font and sub-pixels smoothing strategy,
* set lcd portrait and use kern the glyph.
* set LCD portrait and kern the glyph.
* \param underline The underline of the logical font, can be one of the values:
* - FONT_UNDERLINE_ALL\n
* Any one.
@@ -6150,6 +6164,132 @@ MG_EXPORT PLOGFONT GUIAPI CreateLogFont (const char* type, const char* family,
char other, char underline, char struckout,
int size, int rotation);
/**
* \fn PLOGFONT GUIAPI CreateLogFontEx (const char* type, \
const char* family, const char* charset, char weight, \
char slant, char flip, char other, char decoration, \
char rendering, int size, int rotation)
* \brief Creates a logical font.
*
* This function creates a logical font.
*
* \param type The type of the logical font, can be one of the values:
* - FONT_TYPE_NAME_BITMAP_RAW\n
* Creates a logical font by using raw bitmap device font, i.e.
* mono-space bitmap font.
* - FONT_TYPE_NAME_BITMAP_VAR\n
* Creates a logical font by using var-width bitmap device font.
* - FONT_TYPE_NAME_BITMAP_QPF\n
* Creates a logical font by using qpf device font.
* - FONT_TYPE_NAME_BITMAP_BMP\n
* Creates a logical font by using bitmap font.
* - FONT_TYPE_NAME_SCALE_TTF\n
* Creates a logical font by using scalable TrueType device font.
* - FONT_TYPE_NAME_SCALE_T1F\n
* Creates a logical font by using scalable Adobe Type1 device font.
* - FONT_TYPE_NAME_ALL\n
* Creates a logical font by using any type device font.
* \param family The family of the logical font, such as "Courier",
* "Helvetica", and so on.
* \param charset The charset of the logical font. You can specify a
* sigle-byte charset like "ISO8859-1", or a multi-byte charset
* like "GB2312-0".
* \param weight The weight of the logical font, can be one of the values:
* - FONT_WEIGHT_ANY\n
* Any one.
* - FONT_WEIGHT_THIN\n
* Thin.
* - FONT_WEIGHT_EXTRA_LIGHT\n
* Extra light (Ultra light).
* - FONT_WEIGHT_LIGHT\n
* Light.
* - FONT_WEIGHT_REGULAR\n
* Regular (normal).
* - FONT_WEIGHT_MEDIUM\n
* Medium.
* - FONT_WEIGHT_DEMIBOLD\n
* Semi Bold (Demi Bold).
* - FONT_WEIGHT_BOLD\n
* Bold.
* - FONT_WEIGHT_EXTRA_BOLD\n
* Extra bold (Ultra Bold).
* - FONT_WEIGHT_BLACK\n
* Black (Heavy).
* \param slant The slant of the logical font, can be one of the values:
* - FONT_SLANT_ALL\n
* Any one.
* - FONT_SLANT_ROMAN\n
* Regular font.
* - FONT_SLANT_ITALIC\n
* Italic font.
* \param flip Does flip the glyph of the font, can be one of the following values:
* - FONT_FLIP_NIL\n
* Do not flip the glyph.
* - FONT_FLIP_HORZ\n
* Flip the glyph horizontally .
* - FONT_FLIP_VERT\n
* Flip the glyph vertically.
* - FONT_FLIP_HORZVERT\n
* Flip the glyph horizontally and vertically.
* \param other Other rendering features, can be one of the following values:
* - FONT_OTHER_NIL\n
* Not specified.
* - FONT_OTHER_AUTOSCALE\n
* Auto scale the bitmap glyph to match the desired font size.
* - FONT_OTHER_TTFNOCACHE\n
* Do not use cache when using TrueType font.
* - FONT_OTHER_TTFKERN\n
* Kern the glyph when using TrueType font.
* - FONT_OTHER_TTFNOCACHEKERN\n
* When using TrueType font, kern the glyph and do not use cache.
* - FONT_OTHER_LCDPORTRAIT\n
* When using TrueType font and sub-pixels smoothing strategy,
* set lcd portrait and do not use kern the glyph.
* - FONT_OTHER_LCDPORTRAITKERN\n
* When using TrueType font and sub-pixels smoothing strategy,
* set lcd portrait and use kern the glyph.
* \param decoration The decoration (underline and/or struckout line)
of the logical font, can be one of the values:
* - FONT_DECORATE_NONE\n
* Without underline and struckout line.
* - FONT_DECORATE_UNDERLINE\n
* With underline.
* - FONT_DECORATE_STRUCKOUT\n
* With struckout line.
* - FONT_DECORATE_BOTH\n
* With both underline and struckout line.
* \param rendering The rendering type of the logical font, can be one of
* the values:
* - FONT_RENDER_ANY\n
* Any one (not specified).
* - FONT_RENDER_MONO\n
* Use a monochromatic bitmap.
* - FONT_RENDER_OUTLINE\n
* Render the glyph with an outline.
* - FONT_RENDER_GREY\n
* Render the glyph by using a gray bitmap.
* - FONT_RENDER_SUBPIXEL\n
* Use subpixel rendering method (TrueType only).
* \param size The size, i.e. the height, of the logical font. Note that
* the size of the created logical font may be different from the
* size expected.
* \param rotation The rotation of the logical font, it is in units of
* tenth degrees. Note that you can specify rotation only for
* TrueType and Adobe Type1 fonts.
* \return The pointer to the logical font created, NULL on error.
*
* \sa CreateLogFontIndirect, CreateLogFontByName, SelectFont
*
* Example:
*
* \include createlogfontex.c
*
*/
MG_EXPORT PLOGFONT GUIAPI CreateLogFontEx (const char* type, const char* family,
const char* charset, char weight, char slant, char flip,
char other, char decoration, char rendering,
int size, int rotation);
/**
* \fn PLOGFONT GUIAPI CreateLogFontByName (const char* font_name)
* \brief Creates a logical font by a font name.
+13 -7
View File
@@ -1458,7 +1458,6 @@ static LRESULT TreeViewCtrlProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM
rctop = rc.top;
if (mouseX <= right && mouseX >= left && (p != pData->pItemSelected) ) {
PLOGFONT logfont;
c = getCountFromItem (pData, pData->pItemSelected);
c = c - pData->nItemTop - 1;
if (c < 0)
@@ -1471,12 +1470,15 @@ static LRESULT TreeViewCtrlProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM
rc.top += TV_BORDER;
rc.bottom = rc.top + pData->nItemHeight;
/*bugfix: 4864, zhaochengzhang*/
/* VincentWei: do not depend on logfont style
PLOGFONT logfont;
//bugfix: 4864, zhaochengzhang
logfont = GetWindowFont(hwnd);
if (logfont->style & (FS_WEIGHT_BOOK | FS_WEIGHT_LIGHT)) {
rc.left--; rc.top--;
rc.right++; rc.bottom++;
}
*/
InvalidateRect (hwnd, &rc, TRUE);
rc.top = rctop + (count - pData->nItemTop - 1) * pData->nItemHeight;
@@ -1484,17 +1486,18 @@ static LRESULT TreeViewCtrlProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM
rc.top += TV_BORDER;
rc.bottom = rc.top + pData->nItemHeight;
/*bugfix: 4864 zhaochengzhang*/
/* VincentWei: do not depend on logfont style
//bugfix: 4864 zhaochengzhang
if (logfont->style & (FS_WEIGHT_BOOK | FS_WEIGHT_LIGHT)) {
rc.left--; rc.top--;
rc.right++; rc.bottom++;
}
}
*/
InvalidateRect (hwnd, &rc, TRUE);
NotifyParent (hwnd, pData->id, TVN_CLICKED);
}
if (mouseX <= left + h && mouseX >= left) {
PLOGFONT logfont;
if (p->child == NULL)
break;
@@ -1518,13 +1521,16 @@ static LRESULT TreeViewCtrlProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM
tvSetVScrollInfo (hwnd, pData, TRUE);
tvSetHScrollInfo (hwnd, pData, TRUE);
rc.bottom = rcClient.bottom;
/*bugfix: 4864 zhaochengzhang*/
/* VincentWei: do not depend on the logfont style
PLOGFONT logfont;
//bugfix: 4864 zhaochengzhang
logfont = GetWindowFont(hwnd);
if (logfont->style & (FS_WEIGHT_BOOK | FS_WEIGHT_LIGHT)) {
rc.left--; rc.top--;
rc.right++; rc.bottom++;
}
*/
InvalidateRect (hwnd, &rc, TRUE);
NotifyParent (hwnd, pData->id, TVN_CLICKED);
}
+138 -126
View File
File diff suppressed because it is too large Load Diff
+4
View File
@@ -256,6 +256,9 @@ DWORD fontConvertStyle (const char* style_part)
case FONT_RENDER_MONO:
style |= FS_RENDER_MONO;
break;
case FONT_RENDER_OUTLINE:
style |= FS_RENDER_OUTLINE;
break;
case FONT_RENDER_GREY:
style |= FS_RENDER_GREY;
break;
@@ -263,6 +266,7 @@ DWORD fontConvertStyle (const char* style_part)
style |= FS_RENDER_SUBPIXEL;
break;
default:
style |= FS_RENDER_MONO;
break;
}
+138 -112
View File
File diff suppressed because it is too large Load Diff
+70 -38
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/>.
*/
@@ -67,7 +67,7 @@ static inline int get_rotation (LOGFONT* logfont,
}
/************************** Exported functions ******************************/
static PLOGFONT gdiCreateLogFont (const char* type, const char* family,
static PLOGFONT gdiCreateLogFont (const char* type, const char* family,
const char* charset, DWORD style, int size, int rotation)
{
PLOGFONT log_font;
@@ -158,7 +158,7 @@ static PLOGFONT gdiCreateLogFont (const char* type, const char* family,
log_font->sbc_devfont = sbc_devfont;
log_font->mbc_devfont = mbc_devfont;
/*
/*
* Adjust the logical font information
*/
@@ -188,18 +188,18 @@ static PLOGFONT gdiCreateLogFont (const char* type, const char* family,
/*reset charset name of logfont*/
if (log_font->mbc_devfont) {
strncpy (log_font->charset,
strncpy (log_font->charset,
log_font->mbc_devfont->charset_ops->name, LEN_FONT_NAME);
log_font->charset [LEN_FONT_NAME] = '\0';
}
else {
strncpy (log_font->charset,
strncpy (log_font->charset,
log_font->sbc_devfont->charset_ops->name, LEN_FONT_NAME);
log_font->charset [LEN_FONT_NAME] = '\0';
}
/*reset ascent of logfont*/
sbc_value = log_font->sbc_devfont->font_ops->get_font_ascent (log_font,
sbc_value = log_font->sbc_devfont->font_ops->get_font_ascent (log_font,
log_font->sbc_devfont);
if (log_font->mbc_devfont) {
mbc_value = log_font->mbc_devfont->font_ops->get_font_ascent (log_font,
@@ -211,7 +211,7 @@ static PLOGFONT gdiCreateLogFont (const char* type, const char* family,
}
/*reset descent of logfont*/
sbc_value = log_font->sbc_devfont->font_ops->get_font_descent (log_font,
sbc_value = log_font->sbc_devfont->font_ops->get_font_descent (log_font,
log_font->sbc_devfont);
if (log_font->mbc_devfont) {
mbc_value = log_font->mbc_devfont->font_ops->get_font_descent (log_font,
@@ -233,13 +233,13 @@ static PLOGFONT gdiCreateLogFont (const char* type, const char* family,
}
/* remove HORZVERT style if the glyph bmptype is subpixel */
glyph_bmptype = log_font->sbc_devfont->font_ops->get_glyph_type
glyph_bmptype = log_font->sbc_devfont->font_ops->get_glyph_type
(log_font, log_font->sbc_devfont) & DEVFONTGLYPHTYPE_MASK_BMPTYPE;
if (glyph_bmptype == GLYPHBMP_TYPE_SUBPIXEL) {
log_font->style &= ~FS_FLIP_HORZVERT;
}
else if (log_font->mbc_devfont) {
glyph_bmptype = log_font->mbc_devfont->font_ops->get_glyph_type
glyph_bmptype = log_font->mbc_devfont->font_ops->get_glyph_type
(log_font, log_font->mbc_devfont) & DEVFONTGLYPHTYPE_MASK_BMPTYPE;
if (glyph_bmptype == GLYPHBMP_TYPE_SUBPIXEL)
log_font->style &= ~FS_FLIP_HORZVERT;
@@ -261,7 +261,7 @@ PLOGFONT GUIAPI CreateLogFontIndirect (LOGFONT *logfont)
if ((font = malloc (sizeof (LOGFONT))) == NULL)
return INV_LOGFONT;
memcpy (font, logfont, sizeof(LOGFONT));
sbc_devfont = logfont->sbc_devfont;
@@ -282,8 +282,8 @@ PLOGFONT GUIAPI CreateLogFontIndirect (LOGFONT *logfont)
return font;
}
PLOGFONT GUIAPI CreateLogFont (const char* type, const char* family,
const char* charset, char weight, char slant, char flip,
PLOGFONT GUIAPI CreateLogFont (const char* type, const char* family,
const char* charset, char weight, char slant, char flip,
char other, char underline, char struckout, int size, int rotation)
{
char style_name [7];
@@ -291,10 +291,42 @@ PLOGFONT GUIAPI CreateLogFont (const char* type, const char* family,
style_name[1] = slant;
style_name[2] = flip;
style_name[3] = other;
style_name[4] = underline;
style_name[5] = struckout;
if (underline == FONT_UNDERLINE_LINE) {
if (struckout == FONT_STRUCKOUT_LINE) {
style_name[4] = FONT_DECORATE_BOTH;
}
else {
style_name[4] = FONT_DECORATE_UNDERLINE;
}
}
else {
if (struckout == FONT_STRUCKOUT_LINE) {
style_name[4] = FONT_DECORATE_STRUCKOUT;
}
else {
style_name[4] = FONT_DECORATE_NONE;
}
}
style_name[5] = FONT_RENDER_ANY;
style_name[6] = 0;
return gdiCreateLogFont (type, family, charset, fontConvertStyle (style_name), size, rotation);
}
PLOGFONT GUIAPI CreateLogFontEx (const char* type, const char* family,
const char* charset, char weight, char slant, char flip,
char other, char decoration, char rendering,
int size, int rotation)
{
char style_name [7];
style_name[0] = weight;
style_name[1] = slant;
style_name[2] = flip;
style_name[3] = other;
style_name[4] = decoration;
style_name[5] = rendering;
style_name[6] = 0;
return gdiCreateLogFont (type, family, charset, fontConvertStyle (style_name), size, rotation);
}
@@ -339,13 +371,13 @@ void GUIAPI GetLogFontInfo (HDC hdc, LOGFONT* log_font)
void GUIAPI GetFontMetrics (LOGFONT* log_font, FONTMETRICS* font_metrics)
{
int sbc_value, mbc_value;
if (!log_font) return;
if (!font_metrics) return;
font_metrics->font_height = log_font->size;
sbc_value = log_font->sbc_devfont->font_ops->get_font_ascent (log_font,
sbc_value = log_font->sbc_devfont->font_ops->get_font_ascent (log_font,
log_font->sbc_devfont);
if (log_font->mbc_devfont) {
mbc_value = log_font->mbc_devfont->font_ops->get_font_ascent (log_font,
@@ -358,10 +390,10 @@ void GUIAPI GetFontMetrics (LOGFONT* log_font, FONTMETRICS* font_metrics)
font_metrics->descent = font_metrics->font_height - font_metrics->ascent;
sbc_value = log_font->sbc_devfont->font_ops->get_max_width (log_font,
sbc_value = log_font->sbc_devfont->font_ops->get_max_width (log_font,
log_font->sbc_devfont);
if (log_font->mbc_devfont) {
mbc_value = log_font->mbc_devfont->font_ops->get_max_width (log_font,
mbc_value = log_font->mbc_devfont->font_ops->get_max_width (log_font,
log_font->mbc_devfont);
font_metrics->max_width = MAX (sbc_value, mbc_value);
}
@@ -369,10 +401,10 @@ void GUIAPI GetFontMetrics (LOGFONT* log_font, FONTMETRICS* font_metrics)
font_metrics->max_width = sbc_value;
}
sbc_value = log_font->sbc_devfont->font_ops->get_ave_width (log_font,
sbc_value = log_font->sbc_devfont->font_ops->get_ave_width (log_font,
log_font->sbc_devfont);
if (log_font->mbc_devfont) {
mbc_value = log_font->mbc_devfont->font_ops->get_ave_width (log_font,
mbc_value = log_font->mbc_devfont->font_ops->get_ave_width (log_font,
log_font->mbc_devfont);
font_metrics->ave_width = mbc_value;
}
@@ -382,8 +414,8 @@ void GUIAPI GetFontMetrics (LOGFONT* log_font, FONTMETRICS* font_metrics)
}
#if 0
void GUIAPI GetGlyphBitmap (LOGFONT* log_font,
const unsigned char* mchar, int mchar_len,
void GUIAPI GetGlyphBitmap (LOGFONT* log_font,
const unsigned char* mchar, int mchar_len,
GLYPHBITMAP* glyph_bitmap)
{
DEVFONT* sbc_devfont;
@@ -412,7 +444,7 @@ void GUIAPI GetGlyphBitmap (LOGFONT* log_font,
else {
devfont = sbc_devfont;
}
glyph_value = devfont->charset_ops->char_glyph_value(NULL, 0, mchar, mchar_len);
glyph_value = devfont->charset_ops->char_glyph_value(NULL, 0, mchar, mchar_len);
if (devfont->font_ops->get_glyph_bbox) {
glyph_bitmap->bbox_x = 0;
@@ -427,11 +459,11 @@ void GUIAPI GetGlyphBitmap (LOGFONT* log_font,
glyph_bitmap->bbox_x = 0;
glyph_bitmap->bbox_w = 0;
glyph_bitmap->bbox_y = devfont->font_ops->get_font_descent (log_font,
glyph_bitmap->bbox_y = devfont->font_ops->get_font_descent (log_font,
devfont);
devfont->font_ops->get_glyph_advance (log_font,
devfont->font_ops->get_glyph_advance (log_font,
devfont, glyph_value, &glyph_bitmap->bbox_w, 0);
glyph_bitmap->bbox_h = devfont->font_ops->get_font_height (log_font,
glyph_bitmap->bbox_h = devfont->font_ops->get_font_height (log_font,
devfont);
}
@@ -440,8 +472,8 @@ void GUIAPI GetGlyphBitmap (LOGFONT* log_font,
glyph_bitmap->advance_y = 0;
if (devfont->font_ops->start_str_output)
devfont->font_ops->start_str_output (log_font, devfont);
devfont->font_ops->get_glyph_advance (log_font, devfont,
glyph_value,
devfont->font_ops->get_glyph_advance (log_font, devfont,
glyph_value,
&glyph_bitmap->advance_x, &glyph_bitmap->advance_y);
}
else {
@@ -465,7 +497,7 @@ void GUIAPI GetGlyphBitmap (LOGFONT* log_font,
glyph_bitmap->bmp_size = glyph_bitmap->bmp_pitch * glyph_bitmap->bbox_h;
glyph_bitmap->bits = devfont->font_ops->get_glyph_monobitmap (log_font,
glyph_bitmap->bits = devfont->font_ops->get_glyph_monobitmap (log_font,
devfont, glyph_value, NULL);
}
+56 -17
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/>.
*/
@@ -117,12 +117,12 @@ static void make_gray_pixels (PDC pdc)
a = 0;
for (i = 0; i < 16; i++) {
pdc->gray_pixels [i] = GAL_MapRGBA (pdc->alpha_pixel_format,
pdc->gray_pixels [i] = GAL_MapRGBA (pdc->alpha_pixel_format,
r, g, b, a);
a += 16;
}
pdc->gray_pixels [16] = GAL_MapRGBA (pdc->alpha_pixel_format,
pdc->gray_pixels [16] = GAL_MapRGBA (pdc->alpha_pixel_format,
r, g, b, 255);
}
else {
@@ -132,9 +132,9 @@ static void make_gray_pixels (PDC pdc)
int delta_r, delta_g, delta_b;
RGB pal [17];
GAL_GetRGB (pdc->bkcolor, pdc->surface->format,
GAL_GetRGB (pdc->bkcolor, pdc->surface->format,
&pal->r, &pal->g, &pal->b);
GAL_GetRGB (pdc->textcolor, pdc->surface->format,
GAL_GetRGB (pdc->textcolor, pdc->surface->format,
&pal[16].r, &pal[16].g, &pal[16].b);
delta_r = ((int)pal[16].r - (int)pal[0].r) / 16;
@@ -145,7 +145,7 @@ static void make_gray_pixels (PDC pdc)
pal[i].r = pal[i - 1].r + delta_r;
pal[i].g = pal[i - 1].g + delta_g;
pal[i].b = pal[i - 1].b + delta_b;
pdc->gray_pixels [i] = GAL_MapRGB (pdc->surface->format,
pdc->gray_pixels [i] = GAL_MapRGB (pdc->surface->format,
pal[i].r, pal[i].g, pal[i].b);
}
pdc->gray_pixels [0] = pdc->bkcolor;
@@ -162,6 +162,7 @@ static void make_gray_pixels (PDC pdc)
static void make_filter_pixels (PDC pdc)
{
#if 0 // VincentWei: use FS_RENDER_MASK instead (3.4.0)
if (pdc->pLogFont->style & FS_WEIGHT_BOOK) {
int i;
Uint8 r, g, b, a;
@@ -173,12 +174,12 @@ static void make_filter_pixels (PDC pdc)
a = 0;
for (i = 0; i < 16; i++) {
pdc->filter_pixels [i] = GAL_MapRGBA (pdc->alpha_pixel_format,
pdc->filter_pixels [i] = GAL_MapRGBA (pdc->alpha_pixel_format,
r, g, b, a);
a += 16;
}
pdc->filter_pixels [16] = GAL_MapRGBA (pdc->alpha_pixel_format,
pdc->filter_pixels [16] = GAL_MapRGBA (pdc->alpha_pixel_format,
r, g, b, 255);
}
@@ -191,6 +192,44 @@ static void make_filter_pixels (PDC pdc)
pdc->filter_pixels [1] = pdc->bkcolor;
pdc->filter_pixels [2] = pdc->textcolor;
}
#else
switch (pdc->pLogFont->style & FS_RENDER_MASK) {
case FS_RENDER_GREY: {
int i;
Uint8 r, g, b, a;
if (make_alpha_pixel_format (pdc))
return;
GAL_GetRGB (pdc->textcolor, pdc->surface->format, &r, &g, &b);
a = 0;
for (i = 0; i < 16; i++) {
pdc->filter_pixels [i] = GAL_MapRGBA (pdc->alpha_pixel_format,
r, g, b, a);
a += 16;
}
pdc->filter_pixels [16] = GAL_MapRGBA (pdc->alpha_pixel_format,
r, g, b, 255);
break;
}
case FS_RENDER_OUTLINE: {
gal_pixel trans = pdc->bkcolor ^ 1;
if (trans == pdc->textcolor)
trans = pdc->bkcolor ^ 3;
pdc->filter_pixels [0] = trans;
pdc->filter_pixels [1] = pdc->bkcolor;
pdc->filter_pixels [2] = pdc->textcolor;
break;
}
default:
break;
}
#endif
}
Uint32 GUIAPI SetDCAttr (HDC hdc, int attr, Uint32 value)
@@ -244,7 +283,7 @@ PLOGFONT GUIAPI SelectFont (HDC hdc, PLOGFONT log_font)
pdc->pLogFont = g_SysLogFont [1] ? g_SysLogFont [1] : g_SysLogFont [0];
else
pdc->pLogFont = log_font;
make_gray_pixels (pdc);
make_filter_pixels (pdc);
return old;
+390 -306
View File
File diff suppressed because it is too large Load Diff