Backward compatiblity of CreateLogFont

This commit is contained in:
Vincent Wei
2019-01-14 10:23:37 +08:00
parent 8dc0ee2ade
commit 612c395c06
4 changed files with 48 additions and 62 deletions
+24 -20
View File
@@ -20,20 +20,20 @@ The styles of LOGFONT changed.
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:
* Some bad style definitions are deprecated:
1. `FS_WEIGHT_BOOK`; use `FS_RENDER_GREY` instead.
1. `FS_WEIGHT_SUBPIXEL`; use `FS_RENDER_SUBPIXEL` instead.
* Introduced or redefined the weight styles to follow OpenType specification:
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`:
1. `FONT_WEIGHT_THIN`: Thin.
1. `FONT_WEIGHT_EXTRA_LIGHT`: Extra light (Ultra Light).
1. `FONT_WEIGHT_LIGHT`: Light.
1. `FONT_WEIGHT_REGULAR`: Regular (Normal).
1. `FONT_WEIGHT_MEDIUM`: Medium.
1. `FONT_WEIGHT_DEMIBOLD`: Demi Bold (Semi Bold)
1. `FONT_WEIGHT_BOLD`: Bold.
1. `FONT_WEIGHT_EXTRA_BOLD`: Extra Bold (Ultra Bold).
1. `FONT_WEIGHT_BLACK`: Black (Heavy).
* Introduce the new decoration styles and replace
`FONT_UNDERLINE_LINE` and `FONT_STRUCKOUT_LINE` with them:
1. `FONT_DECORATE_ANY`:
@@ -41,13 +41,17 @@ The styles of LOGFONT changed.
1. `FONT_DECORATE_UNDERLINE`:
1. `FONT_DECORATE_STRUCKOUT`:
1. `FONT_DECORATE_BOTH`:
* The following style are deprecated:
1. `FONT_OTHER_LCDPORTRAIT`
1. `FONT_OTHER_LCDPORTRAITKERN`
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 a new app, you should use the new function `CreateLogFontEx` to
create a LOGFONT, and specify the weight and rendering method of the glyph.
For new app, you should use the new function `CreateLogFontEx` to
create a LOGFONT.
For the back-compatibility, you can still use `CreateLogFont` to create a new
LOGFONT. However, `FS_WEIGHT_BOOK` will be treated `FS_WEIGHT_REGULAR` and
`FS_RENDER_GREY`, while `FS_WEIGHT_SUBPIXEL` will be treated
`FS_WEIGHT_REGULAR` and `FS_RENDER_SUBPIXEL`.
You can still use `CreateLogFontByName` to create a new LOGFONT.
But the style string in the font name changed from
@@ -58,10 +62,10 @@ to
<weight><slant><flipping><other><decoration><rendering>
Obviously, `<underline>` and `<struckout>` are merged to `<decoration>`
Note that `<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,
Consequently, if you want to use the rendering method SUPIXEL for a TTF font,
please define the font name in the following way:
ttf-Courier-rrncns-*-16-UTF-8
+12 -35
View File
@@ -5470,6 +5470,12 @@ MG_EXPORT int GUIAPI SubtractRect (RECT* rc, const RECT* psrc1, const RECT* psrc
#define FONT_WEIGHT_EXTRA_BOLD 'x'
#define FONT_WEIGHT_BLACK 'c'
/* Backward compatiblilty definitions.
* deprecated since v3.4.0, use FS_RENDER_XXX/FONT_RENDER_XXX instead
*/
#define FONT_WEIGHT_SUBPIXEL 's'
#define FONT_WEIGHT_BOOK 'k'
#define FS_WEIGHT_MASK 0x000000FF
#define FS_WEIGHT_ANY 0
#define FS_WEIGHT_THIN 10
@@ -5510,6 +5516,8 @@ MG_EXPORT int GUIAPI SubtractRect (RECT* rc, const RECT* psrc1, const RECT* psrc
#define FONT_OTHER_TTFNOCACHE 'c'
#define FONT_OTHER_TTFKERN 'k'
#define FONT_OTHER_TTFNOCACHEKERN 'r'
/* Backward compatiblilty definitions; deprecated since v3.4.0 */
#define FONT_OTHER_LCDPORTRAIT 'p'
#define FONT_OTHER_LCDPORTRAITKERN 'q'
@@ -5517,9 +5525,7 @@ MG_EXPORT int GUIAPI SubtractRect (RECT* rc, const RECT* psrc1, const RECT* psrc
#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 FONT_DECORATE_NIL '\0'
#define FONT_DECORATE_NONE 'n'
@@ -5545,23 +5551,6 @@ MG_EXPORT int GUIAPI SubtractRect (RECT* rc, const RECT* psrc1, const RECT* psrc
#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
@@ -5575,28 +5564,12 @@ MG_EXPORT int GUIAPI SubtractRect (RECT* rc, const RECT* psrc1, const RECT* psrc
#define FONT_SETWIDTH_NORMAL 'n'
#define FONT_SETWIDTH_TTFNOCACHE 'w'
/*
#define FS_SETWIDTH_MASK 0x0000F000
#define FS_SETWIDTH_BOLD 0x00001000
#define FS_SETWIDTH_CONDENSED 0x00002000
#define FS_SETWIDTH_SEMICONDENSED 0x00004000
#define FS_SETWIDTH_TTFNOCACHE 0x00008000
#define FS_SETWIDTH_NORMAL 0x00000000
*/
#define FONT_SPACING_NIL '\0'
#define FONT_SPACING_ALL '*'
#define FONT_SPACING_MONOSPACING 'm'
#define FONT_SPACING_PROPORTIONAL 'p'
#define FONT_SPACING_CHARCELL 'c'
/*
#define FS_SPACING_MASK 0x000F0000
#define FS_SPACING_MONOSPACING 0x00010000
#define FS_SPACING_PROPORTIONAL 0x00020000
#define FS_SPACING_CHARCELL 0x00000000
*/
#define FONT_UNDERLINE_NIL '\0'
#define FONT_UNDERLINE_ALL '*'
#define FONT_UNDERLINE_LINE 'u'
@@ -6098,6 +6071,10 @@ MG_EXPORT void GUIAPI TermVectorialFonts (void);
* Extra bold (Ultra Bold).
* - FONT_WEIGHT_BLACK\n
* Black (Heavy).
* - FONT_WEIGHT_BOOK\n
* For backforward compatibility only, same as FONT_WEIGHT_REGULAR and FONT_RENDER_GREY.
* - FONT_WEIGHT_SUBPIXEL\n
* For backforward compatibility only, same as FONT_WEIGHT_REGULAR and FONT_RENDER_SUBPIXEL.
* \param slant The slant of the logical font, can be one of the values:
* - FONT_SLANT_ALL\n
* Any one.
-6
View File
@@ -225,12 +225,6 @@ DWORD fontConvertStyle (const char* style_part)
case FONT_OTHER_TTFNOCACHEKERN:
style |= FS_OTHER_TTFNOCACHEKERN;
break;
case FONT_OTHER_LCDPORTRAIT:
style |= FS_OTHER_LCDPORTRAIT;
break;
case FONT_OTHER_LCDPORTRAITKERN:
style |= FS_OTHER_LCDPORTRAITKERN;
break;
default:
break;
}
+12 -1
View File
@@ -293,6 +293,17 @@ PLOGFONT GUIAPI CreateLogFont (const char* type, const char* family,
style_name[1] = slant;
style_name[2] = flip;
style_name[3] = other;
style_name[5] = FONT_RENDER_ANY;
if (weight == FONT_WEIGHT_BOOK) {
style_name[0] = FONT_WEIGHT_REGULAR;
style_name[5] = FONT_RENDER_GREY;
}
else if (weight == FONT_WEIGHT_SUBPIXEL) {
style_name[0] = FONT_WEIGHT_REGULAR;
style_name[5] = FONT_RENDER_SUBPIXEL;
}
if (underline == FONT_UNDERLINE_LINE) {
if (struckout == FONT_STRUCKOUT_LINE) {
style_name[4] = FONT_DECORATE_BOTH;
@@ -309,7 +320,7 @@ PLOGFONT GUIAPI CreateLogFont (const char* type, const char* family,
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);