Compare commits

..
7 Commits
19 changed files with 954 additions and 1511 deletions
+8 -76
View File
@@ -1,85 +1,12 @@
# Release Notes
## Version 3.4.0
## Version 3.2.2
The MiniGUI development team announces the availability of MiniGUI 3.4.0.
The MiniGUI development team announces the availability of MiniGUI 3.2.2.
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
#### Tunning the logical font APIs
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 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`:
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 style 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
#### 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.
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
@@ -116,6 +43,11 @@ Please report any bugs and incompatibilities in
* BUGFIXING:
1. handle `PNG_COLOR_TYPE_GRAY_ALPHA` color type of PNG files.
1. Fix a bug to free a null pointer (ReleaseDC).
1. No need to make the pitch of FT2 monobitmap is single-byte aligned.
This bug may generate dirty dots for monobitmap glyph from TTF.
1. Skip null pixels for SUBPIXEL glyphs. This bug will always show background
pixels of one SUBPIXEL glyph.
1. Fix the bug of wrong bounding box handling for SUBPIXEL rendering of glyph.
* TUNNING:
1. Tune GLYPHINFO structure and GetGlyphInfo to return BIDI glyph type.
+10 -13
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.4.0)
AC_INIT(libminigui, 3.2.2)
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=4
MINIGUI_MICRO_VERSION=0
MINIGUI_MINOR_VERSION=2
MINIGUI_MICRO_VERSION=2
MINIGUI_INTERFACE_AGE=0
MINIGUI_BINARY_AGE=0
MINIGUI_BINARY_AGE=1
MINIGUI_VERSION=$MINIGUI_MAJOR_VERSION.$MINIGUI_MINOR_VERSION.$MINIGUI_MICRO_VERSION
AC_SUBST(MINIGUI_MAJOR_VERSION)
@@ -537,7 +537,7 @@ AC_ARG_ENABLE(sefsupport,
build_sef_support=$enableval)
AC_ARG_WITH(ttfsupport,
[ --with-ttfsupport=ft2/none How to support TrueType font (FreeType 2 or None) <default=ft2>],
[ --with-ttfsupport=ft1/ft2/none How to support TrueType font (FreeType 1/FreeType 2/None) <default=none>],
use_ttf_lib=$withval)
AC_ARG_ENABLE(ttfcache,
@@ -1978,20 +1978,17 @@ 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")
;;
*)
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")
;;
esac
+12 -12
View File
@@ -1,14 +1,14 @@
static LOGFONT *logfont, *logfontgb12, *logfontbig24;
logfont = CreateLogFont (NULL, "SansSerif", "ISO8859-1",
FONT_WEIGHT_REGULAR, FONT_SLANT_ITALIC, FONT_FLIP_NONE,
FONT_OTHER_NIL, FONT_UNDERLINE_NONE, FONT_STRUCKOUT_LINE,
16, 0);
logfontgb12 = CreateLogFont (NULL, "song", "GB2312",
FONT_WEIGHT_REGULAR, FONT_SLANT_ROMAN, FONT_FLIP_NONE,
FONT_OTHER_NIL, FONT_UNDERLINE_LINE, FONT_STRUCKOUT_LINE,
12, 0);
logfontbig24 = CreateLogFont (NULL, "ming", "BIG5",
FONT_WEIGHT_REGULAR, FONT_SLANT_ROMAN, FONT_FLIP_NONE,
FONT_OTHER_NIL, FONT_UNDERLINE_LINE, FONT_STRUCKOUT_NONE,
24, 0);
logfont = CreateLogFont (NULL, "SansSerif", "ISO8859-1",
FONT_WEIGHT_REGULAR, FONT_SLANT_ITALIC, FONT_SETWIDTH_NORMAL,
FONT_SPACING_CHARCELL, FONT_UNDERLINE_NONE, FONT_STRUCKOUT_LINE,
16, 0);
logfontgb12 = CreateLogFont (NULL, "song", "GB2312",
FONT_WEIGHT_REGULAR, FONT_SLANT_ROMAN, FONT_SETWIDTH_NORMAL,
FONT_SPACING_CHARCELL, FONT_UNDERLINE_LINE, FONT_STRUCKOUT_LINE,
12, 0);
logfontbig24 = CreateLogFont (NULL, "ming", "BIG5",
FONT_WEIGHT_REGULAR, FONT_SLANT_ROMAN, FONT_SETWIDTH_NORMAL,
FONT_SPACING_CHARCELL, FONT_UNDERLINE_LINE, FONT_STRUCKOUT_NONE,
24, 0);
-14
View File
@@ -1,14 +0,0 @@
static LOGFONT *logfont, *logfontgb12, *logfontttf;
logfont = CreateLogFontEx (NULL, "SansSerif", "ISO8859-1",
FONT_WEIGHT_REGULAR, FONT_SLANT_ITALIC, FONT_FLIP_NONE,
FONT_OTHER_NIL, FONT_DECORATE_NONE, FONT_RENDER_MONO,
16, 0);
logfontgb12 = CreateLogFontEx (NULL, "song", "GB2312",
FONT_WEIGHT_REGULAR, FONT_SLANT_ROMAN, FONT_FLIP_NONE,
FONT_OTHER_NIL, FONT_DECORATE_NONE, FONT_RENDER_MONO,
12, 0);
logfontttf = CreateLogFontEx ("ttf", "Courier", "UTF-8",
FONT_WEIGHT_BLACK, FONT_SLANT_ROMAN, FONT_FLIP_NONE,
FS_OTHER_LCDPORTRAIT, FONT_DECORATE_NONE, FONT_RENDER_SUBPIXEL,
24, 0);
+67 -242
View File
@@ -5459,28 +5459,24 @@ 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'
#define FONT_WEIGHT_REGULAR 'r'
#define FONT_WEIGHT_MEDIUM 'm'
#define FONT_WEIGHT_DEMIBOLD 'd'
#define FONT_WEIGHT_BOLD 'b'
#define FONT_WEIGHT_EXTRA_BOLD 'x'
#define FONT_WEIGHT_BLACK 'c'
#define FONT_WEIGHT_BOLD 'b'
#define FONT_WEIGHT_BOOK 'k'
#define FONT_WEIGHT_DEMIBOLD 'd'
#define FONT_WEIGHT_LIGHT 'l'
#define FONT_WEIGHT_MEDIUM 'm'
#define FONT_WEIGHT_REGULAR 'r'
#define FONT_WEIGHT_SUBPIXEL 's'
#define FS_WEIGHT_MASK 0x000000FF
#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 FS_WEIGHT_BLACK 0x00000001
#define FS_WEIGHT_BOLD 0x00000002
#define FS_WEIGHT_BOOK 0x00000004
#define FS_WEIGHT_DEMIBOLD 0x00000006 /* BOOK | BOLD */
#define FS_WEIGHT_LIGHT 0x00000010
#define FS_WEIGHT_MEDIUM 0x00000020
#define FS_WEIGHT_SUBPIXEL 0x00000040
#define FS_WEIGHT_REGULAR 0x00000000
#define FONT_SLANT_NIL '\0'
#define FONT_SLANT_ALL '*'
@@ -5494,10 +5490,9 @@ MG_EXPORT int GUIAPI SubtractRect (RECT* rc, const RECT* psrc1, const RECT* psrc
#define FS_SLANT_ROMAN 0x00000000
#define FONT_FLIP_NIL '\0'
#define FONT_FLIP_HORZ 'h'
#define FONT_FLIP_VERT 'v'
#define FONT_FLIP_HORZVERT 't'
#define FONT_FLIP_NONE 'n'
#define FONT_FLIP_HORZ 'H'
#define FONT_FLIP_VERT 'V'
#define FONT_FLIP_HORZVERT 'T'
#define FS_FLIP_MASK 0x0000F000
#define FS_FLIP_HORZ 0x00001000
@@ -5505,64 +5500,22 @@ MG_EXPORT int GUIAPI SubtractRect (RECT* rc, const RECT* psrc1, const RECT* psrc
#define FS_FLIP_HORZVERT 0x00003000 /* HORZ | VERT */
#define FONT_OTHER_NIL '\0'
#define FONT_OTHER_NONE 'n'
#define FONT_OTHER_AUTOSCALE 's'
#define FONT_OTHER_TTFNOCACHE 'c'
#define FONT_OTHER_TTFKERN 'k'
#define FONT_OTHER_TTFNOCACHEKERN 'r'
#define FONT_OTHER_LCDPORTRAIT 'p'
#define FONT_OTHER_LCDPORTRAITKERN 'q'
#define FONT_OTHER_AUTOSCALE 'S'
#define FONT_OTHER_TTFNOCACHE 'N'
#define FONT_OTHER_TTFKERN 'K'
#define FONT_OTHER_TTFNOCACHEKERN 'R'
#define FONT_OTHER_LCDPORTRAIT 'P'
#define FONT_OTHER_LCDPORTRAITKERN 'Q'
#define FS_OTHER_MASK 0x00FF0000
#define FS_OTHER_AUTOSCALE 0x00010000
#define FS_OTHER_TTFNOCACHE 0x00020000
#define FS_OTHER_TTFKERN 0x00040000
#define FS_OTHER_LCDPORTRAIT 0x00100000
#define FS_OTHER_TTFNOCACHEKERN 0x00060000 /* KERN | NOCACHE */
#define FS_OTHER_LCDPORTRAITKERN 0x00140000 /* KERN | PORTRAIT */
#define FS_OTHER_LCDPORTRAIT 0x00100000
#define FS_OTHER_LCDPORTRAITKERN 0x00140000
#define FONT_DECORATE_NIL '\0'
#define FONT_DECORATE_NONE 'n'
#define FONT_DECORATE_UNDERLINE 'u'
#define FONT_DECORATE_STRUCKOUT 's'
#define FONT_DECORATE_BOTH 'b'
#define FS_DECORATE_MASK 0x0F000000
#define FS_DECORATE_UNDERLINE 0x01000000
#define FS_DECORATE_STRUCKOUT 0x02000000
#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_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'
/*
#define FS_WEIGHT_SUBPIXEL 0x00000000
#define FS_WEIGHT_BOOK 0x00000000
#define FS_UNDERLINE_MASK 0x00000000
#define FS_UNDERLINE_LINE 0x00000000
#define FS_UNDERLINE_NONE 0x00000000
#define FS_STRUCKOUT_MASK 0x00000000
#define FS_STRUCKOUT_LINE 0x00000000
#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.
@@ -5602,11 +5555,19 @@ MG_EXPORT int GUIAPI SubtractRect (RECT* rc, const RECT* psrc1, const RECT* psrc
#define FONT_UNDERLINE_LINE 'u'
#define FONT_UNDERLINE_NONE 'n'
#define FS_UNDERLINE_MASK 0x00F00000
#define FS_UNDERLINE_LINE 0x00100000
#define FS_UNDERLINE_NONE 0x00000000
#define FONT_STRUCKOUT_NIL '\0'
#define FONT_STRUCKOUT_ALL '*'
#define FONT_STRUCKOUT_LINE 's'
#define FONT_STRUCKOUT_NONE 'n'
#define FS_STRUCKOUT_MASK 0x0F000000
#define FS_STRUCKOUT_LINE 0x01000000
#define FS_STRUCKOUT_NONE 0x00000000
#define FONT_TYPE_NAME_LEN 3
#define FONT_TYPE_NAME_BITMAP_RAW "rbf"
#define FONT_TYPE_NAME_BITMAP_VAR "vbf"
@@ -5657,72 +5618,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
@@ -6080,143 +6041,14 @@ 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_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 kern the glyph.
* - FONT_OTHER_LCDPORTRAITKERN\n
* When using TrueType font and sub-pixels smoothing strategy,
* 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.
* - FONT_UNDERLINE_LINE\n
* With underline.
* - FONT_UNDERLINE_NONE\n
* Without underline.
* \param struckout The struckout line of the logical font, can be one of
* the values:
* - FONT_STRUCKOUT_ALL\n
* Any one.
* - FONT_STRUCKOUT_LINE\n
* With struckout line.
* - FONT_STRUCKOUT_NONE\n
* Without struckout line.
* \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 createlogfont.c
*
*/
MG_EXPORT 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);
/**
* \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).
* Bold font.
* - FONT_WEIGHT_BOOK\n
* Anti-aliase font.
* - FONT_WEIGHT_LIGHT\n
* Draw the glyph border with the background color.
* \param slant The slant of the logical font, can be one of the values:
* - FONT_SLANT_ALL\n
* Any one.
@@ -6250,28 +6082,21 @@ MG_EXPORT PLOGFONT GUIAPI CreateLogFont (const char* type, const char* family,
* - 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
* \param underline The underline of the logical font, can be one of the values:
* - FONT_UNDERLINE_ALL\n
* Any one.
* - FONT_UNDERLINE_LINE\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
* - FONT_UNDERLINE_NONE\n
* Without underline.
* \param struckout The struckout line 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).
* - FONT_STRUCKOUT_ALL\n
* Any one.
* - FONT_STRUCKOUT_LINE\n
* With struckout line.
* - FONT_STRUCKOUT_NONE\n
* Without struckout line.
* \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.
@@ -6284,12 +6109,12 @@ MG_EXPORT PLOGFONT GUIAPI CreateLogFont (const char* type, const char* family,
*
* Example:
*
* \include createlogfontex.c
* \include createlogfont.c
*
*/
MG_EXPORT PLOGFONT GUIAPI CreateLogFontEx (const char* type, const char* family,
MG_EXPORT PLOGFONT GUIAPI CreateLogFont (const char* type, const char* family,
const char* charset, char weight, char slant, char flip,
char other, char decoration, char rendering,
char other, char underline, char struckout,
int size, int rotation);
/**
+7 -13
View File
@@ -1458,6 +1458,7 @@ 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)
@@ -1470,15 +1471,12 @@ static LRESULT TreeViewCtrlProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM
rc.top += TV_BORDER;
rc.bottom = rc.top + pData->nItemHeight;
/* VincentWei: do not depend on logfont style
PLOGFONT logfont;
//bugfix: 4864, zhaochengzhang
/*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;
@@ -1486,18 +1484,17 @@ static LRESULT TreeViewCtrlProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM
rc.top += TV_BORDER;
rc.bottom = rc.top + pData->nItemHeight;
/* VincentWei: do not depend on logfont style
//bugfix: 4864 zhaochengzhang
/*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;
@@ -1521,16 +1518,13 @@ static LRESULT TreeViewCtrlProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM
tvSetVScrollInfo (hwnd, pData, TRUE);
tvSetHScrollInfo (hwnd, pData, TRUE);
rc.bottom = rcClient.bottom;
/* VincentWei: do not depend on the logfont style
PLOGFONT logfont;
//bugfix: 4864 zhaochengzhang
/*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);
}
+5 -6
View File
@@ -4,21 +4,20 @@ 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 freetype2.c font-engines.c\
rawbitmap.c varbitmap.c qpf.c upf.c \
fontcache.c freetype1.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 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 freetype1.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 = $(FT2_INC_DIR)
AM_CPPFLAGS = $(FT1_INC_DIR) $(FT2_INC_DIR)
AM_CPPFLAGS += -I$(abs_top_srcdir)/src/include -I$(abs_top_srcdir)/include
libfont_la_SOURCES = $(SRC_FILES) $(HDR_FILES)
+83 -85
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,32 +485,30 @@ 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
*/
strncpy (bitmapfont_dev_font->name, bmpfont_name, LEN_UNIDEVFONT_NAME);
/*
* Set device name and add BOLD & ITALIC style
*/
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;
#endif
return NULL;
bitmapfont_dev_font->name [LEN_UNIDEVFONT_NAME] = '\0';
bitmapfont_dev_font->style = fontConvertStyle (bitmapfont_dev_font->name);
@@ -519,22 +517,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;
@@ -542,7 +540,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;
@@ -553,7 +551,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);
@@ -564,8 +562,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;
}
@@ -579,7 +577,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);
@@ -587,13 +585,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;
}
@@ -604,19 +602,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;
@@ -631,7 +629,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");
}
@@ -644,7 +642,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");
@@ -653,19 +651,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");
}
}
+59 -77
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,10 +102,8 @@ 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;
@@ -125,8 +123,6 @@ 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;
@@ -149,20 +145,8 @@ 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;
}
/* The glyph renderer can do auto slant, so ignore slant style */
//match_bits [i] |= MATCHED_SLANT;
/* FIXME: ignore style */
dev_font = dev_font->next;
i ++;
@@ -175,11 +159,9 @@ 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)
&& (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,
&& (match_bits [i] & MATCHED_CHARSET)) {
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 */
@@ -196,7 +178,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;
@@ -207,7 +189,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 */
@@ -236,12 +218,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);
}
@@ -258,7 +240,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);
}
@@ -283,7 +265,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);
@@ -340,10 +322,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)
{
@@ -352,27 +334,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)
{
@@ -387,13 +369,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;
}
@@ -404,14 +386,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;
@@ -424,7 +406,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;
}
@@ -439,7 +421,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;
@@ -580,7 +562,7 @@ static UPFINFO* incore_upfonts [] = {
&__mgif_upf_times_12x10,
&__mgif_upf_times_17x14,
#endif
NULL
NULL
};
#define NR_UPFONTS (sizeof (incore_upfonts) / sizeof (UPFINFO*))
@@ -667,7 +649,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) {
@@ -692,8 +674,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;
@@ -709,11 +691,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;
@@ -723,20 +705,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;
@@ -756,7 +738,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);
@@ -781,13 +763,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 ) {
@@ -800,14 +782,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;
}
@@ -826,7 +808,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)
+145 -162
View File
File diff suppressed because it is too large Load Diff
+8 -64
View File
@@ -131,54 +131,38 @@ DWORD fontConvertStyle (const char* style_part)
{
DWORD style = 0;
style &= ~FS_WEIGHT_MASK;
switch (style_part [0]) {
case FONT_WEIGHT_BLACK:
style |= FS_WEIGHT_BLACK;
break;
case FONT_WEIGHT_EXTRA_BOLD:
style |= FS_WEIGHT_EXTRA_BOLD;
break;
case FONT_WEIGHT_BOLD:
style |= FS_WEIGHT_BOLD;
break;
/* deprecated since v3.2.1
case FONT_WEIGHT_BOOK:
style |= FS_WEIGHT_BOOK;
break;
*/
case FONT_WEIGHT_DEMIBOLD:
style |= FS_WEIGHT_DEMIBOLD;
break;
case FONT_WEIGHT_LIGHT:
style |= FS_WEIGHT_LIGHT;
break;
case FONT_WEIGHT_MEDIUM:
style |= FS_WEIGHT_MEDIUM;
break;
case FONT_WEIGHT_REGULAR:
style |= FS_WEIGHT_REGULAR;
break;
case FONT_WEIGHT_LIGHT:
style |= FS_WEIGHT_LIGHT;
break;
case FONT_WEIGHT_EXTRA_LIGHT:
style |= FS_WEIGHT_EXTRA_LIGHT;
break;
case FONT_WEIGHT_THIN:
style |= FS_WEIGHT_THIN;
break;
/* deprecated since v3.2.1
case FONT_WEIGHT_SUBPIXEL:
style |= FS_WEIGHT_SUBPIXEL;
break;
case FONT_WEIGHT_SUBPIXEL:
style |= FS_WEIGHT_SUBPIXEL;
break;
case FONT_WEIGHT_ALL:
style |= FS_WEIGHT_MASK;
break;
*/
break;
default:
style |= FS_WEIGHT_ANY;
break;
return 0xFFFFFFFF;
}
style &= ~FS_SLANT_MASK;
switch (style_part [1]) {
case FONT_SLANT_ITALIC:
style |= FS_SLANT_ITALIC;
@@ -196,7 +180,6 @@ DWORD fontConvertStyle (const char* style_part)
return 0xFFFFFFFF;
}
style &= ~FS_FLIP_MASK;
switch (style_part [2]) {
case FONT_FLIP_HORZ:
style |= FS_FLIP_HORZ;
@@ -211,7 +194,6 @@ DWORD fontConvertStyle (const char* style_part)
break;
}
style &= ~FS_OTHER_MASK;
switch (style_part [3]) {
case FONT_OTHER_AUTOSCALE:
style |= FS_OTHER_AUTOSCALE;
@@ -235,43 +217,6 @@ DWORD fontConvertStyle (const char* style_part)
break;
}
style &= ~FS_DECORATE_MASK;
switch (style_part [4]) {
case FONT_DECORATE_NONE:
break;
case FONT_DECORATE_UNDERLINE:
style |= FS_DECORATE_UNDERLINE;
break;
case FONT_DECORATE_STRUCKOUT:
style |= FS_DECORATE_STRUCKOUT;
break;
case FONT_DECORATE_BOTH:
style |= FS_DECORATE_BOTH;
break;
default:
break;
}
style &= ~FS_RENDER_MASK;
switch (style_part [5]) {
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;
case FONT_RENDER_SUBPIXEL:
style |= FS_RENDER_SUBPIXEL;
break;
default:
style |= FS_RENDER_MONO;
break;
}
/* deprecated since v3.2.1
switch (style_part [4]) {
case FONT_UNDERLINE_LINE:
style |= FS_UNDERLINE_LINE;
@@ -299,7 +244,6 @@ DWORD fontConvertStyle (const char* style_part)
default:
return 0xFFFFFFFF;
}
*/
return style;
}
+121 -171
View File
File diff suppressed because it is too large Load Diff
+6 -8
View File
@@ -54,7 +54,6 @@ 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
@@ -125,20 +124,19 @@ typedef struct tagTTFCACHEINFO {
void *bitmap;
} TTFCACHEINFO, *PTTFCACHEINFO;
extern HCACHE __mg_ttc_create(char *family, char *charset,
DWORD style, int size, int rotation,
int nblk, int blksize, int ndir, MakeHashKeyFunc makeHashKey);
extern HCACHE __mg_ttc_create(char *family, char *charset, DWORD style, int size,
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, int rotation);
extern HCACHE __mg_ttc_is_exist(char *family, char *charset,
DWORD style, int size);
extern void __mg_ttc_refer(HCACHE hCache);
#endif
#endif
#undef TTF_DBG
+39 -71
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,
@@ -227,19 +227,19 @@ static PLOGFONT gdiCreateLogFont (const char* type, const char* family,
/* reset style of logfont */
/* remove HORZVERT style if weight is subpixel */
if ((log_font->style & FS_RENDER_MASK) == FS_RENDER_SUBPIXEL) {
if (log_font->style & FS_WEIGHT_SUBPIXEL) {
log_font->style &= ~FS_FLIP_HORZVERT;
log_font->style &= ~FS_SLANT_ITALIC;
}
/* 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,42 +291,10 @@ PLOGFONT GUIAPI CreateLogFont (const char* type, const char* family,
style_name[1] = slant;
style_name[2] = flip;
style_name[3] = other;
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[4] = underline;
style_name[5] = struckout;
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);
}
@@ -371,13 +339,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,
@@ -390,10 +358,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);
}
@@ -401,10 +369,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;
}
@@ -414,8 +382,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;
@@ -444,7 +412,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;
@@ -459,11 +427,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);
}
@@ -472,8 +440,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 {
@@ -497,7 +465,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);
}
+3 -6
View File
@@ -482,12 +482,9 @@ static DEVFONT* new_instance (LOGFONT* logfont, DEVFONT* devfont,
BOOL need_sbc_font)
{
if (QPFONT_INFO_P (devfont)->fm->flags & FLAG_MODE_SMOOTH) {
logfont->style &= ~FS_RENDER_MASK;
logfont->style |= FS_RENDER_GREY;
}
else {
logfont->style &= ~FS_RENDER_MASK;
logfont->style |= FS_RENDER_MONO;
logfont->style &= ~FS_WEIGHT_SUBPIXEL;
logfont->style |= FS_WEIGHT_BOOK;
logfont->style &= ~FS_WEIGHT_LIGHT;
}
return devfont;
+3 -6
View File
@@ -471,12 +471,9 @@ static DEVFONT* new_instance (LOGFONT* logfont, DEVFONT* devfont,
*set logfont to weight book;
**/
if (!((UPFV1_FILE_HEADER*)p_upf)->mono_bitmap) {
logfont->style &= ~FS_RENDER_MASK;
logfont->style |= FS_RENDER_GREY;
}
else {
logfont->style &= ~FS_RENDER_MASK;
logfont->style |= FS_RENDER_MONO;
logfont->style &= ~FS_WEIGHT_SUBPIXEL;
logfont->style |= FS_WEIGHT_BOOK;
logfont->style &= ~FS_WEIGHT_LIGHT;
}
return devfont;
+17 -56
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,7 +162,6 @@ 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;
@@ -174,12 +173,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);
}
@@ -192,44 +191,6 @@ 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)
@@ -283,7 +244,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;
+2 -14
View File
@@ -61,20 +61,8 @@ typedef struct _BBOX
int w, h;
} 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_get_glyph_advance (PDC pdc, Glyph32 glyph_value,
BOOL direction, int x, int y, int* adv_x, int* adv_y, BBOX* bbox);
int _gdi_draw_one_glyph (PDC pdc, Glyph32 glyph_value, BOOL direction,
int x, int y, int* adv_x, int* adv_y);
+359 -415
View File
File diff suppressed because it is too large Load Diff