From ee5a1f86a784a18ed5665e8a2012165f68aac3ed Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Mon, 29 Apr 2019 17:34:45 +0800 Subject: [PATCH] fixbug of FT2 subpixel glyph rendering --- RELEASE-NOTES.md | 2 +- include/minigui.h | 95 +++++++++++++++++++++----------------------- src/font/freetype2.c | 6 +-- src/newgdi/glyph.c | 2 + 4 files changed, 52 insertions(+), 53 deletions(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 89b1f177..2569a5c8 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -18,7 +18,7 @@ Please report any bugs and incompatibilities in * macro: `_MGUSE_SYNC_UPDATE` 1. New API `UpdateInvalidClient`. You can use this function to update the invalid client region of a window instantly. - 1. New API `LoadDevFontFromFile`. You can use this function to load + 1. New API `LoadDevFontFromIncoreData`. You can use this function to load a device font from incore data. 1. Use different colors for the output of `_DBG_PRINTF` and `_ERR_PRINTF`. 1. Add `__mg_save_jpg` function for storing MYBITMAP as JPEG file (10km). diff --git a/include/minigui.h b/include/minigui.h index 95641665..58766bc8 100644 --- a/include/minigui.h +++ b/include/minigui.h @@ -2726,6 +2726,7 @@ MG_EXPORT HCURSOR GUIAPI GetSystemCursor (int csrid); * \return Handle to the current system cursor, zero means no current cursor. */ MG_EXPORT HCURSOR GUIAPI GetCurrentCursor (void); + #else static inline HCURSOR LoadCursorFromFile(const char* filename) { @@ -2860,6 +2861,7 @@ MG_EXPORT void GUIAPI GetCursorPos (POINT* ppt); MG_EXPORT void GUIAPI SetCursorPos (int x, int y); #ifdef _MGHAVE_CURSOR + /** * \fn HCURSOR GUIAPI SetCursorEx (HCURSOR hcsr, BOOL set_def) * \brief Changes the current cursor. @@ -2878,7 +2880,7 @@ MG_EXPORT void GUIAPI SetCursorPos (int x, int y); * * \sa SetCursor, SetDefaultCursor, GetDefaultCursor */ - MG_EXPORT HCURSOR GUIAPI SetCursorEx (HCURSOR hcsr, BOOL set_def); +MG_EXPORT HCURSOR GUIAPI SetCursorEx (HCURSOR hcsr, BOOL set_def); /** * \fn HCURSOR GUIAPI GetDefaultCursor (void) @@ -2892,52 +2894,6 @@ MG_EXPORT void GUIAPI SetCursorPos (int x, int y); */ MG_EXPORT HCURSOR GUIAPI GetDefaultCursor (void); -#else -static inline HCURSOR SetCursorEx(HCURSOR hcsr, BOOL set_def) { - return (HCURSOR)0; -} - -static inline HCURSOR GetDefaultCursor(void) { - return (HCURSOR)0; -} - -#endif /* _MGHAVE_CURSOR */ - -/** - * \def SetCursor(hcsr) - * \brief Changes the current cursor. - * - * This function changes the current cursor to be \a hcsr. - * - * \param hcsr The expected cursor handle. - * \return The old cursor handle. - * - * \note This function defined as a macro calling \a SetCursorEx with - * passing \a set_def as FALSE. - * - * \sa SetCursorEx, SetDefaultCursor - */ - #define SetCursor(hcsr) SetCursorEx (hcsr, FALSE) - -/** - * \def SetDefaultCursor(hcsr) - * \brief Changes the current cursor, and set it as the default cursor. - * - * This function changes the current cursor to be \a hcsr, and set it as - * the default cursor. - * - * \param hcsr The expected cursor handle. - * \return The old cursor handle. - * - * \note This function defined as a macro calling \a SetCursorEx with - * passing \a set_def as TRUE. - * - * \sa SetCursorEx, SetCursor - */ - #define SetDefaultCursor(hcsr) SetCursorEx (hcsr, TRUE) - -#ifdef _MGHAVE_CURSOR - /** * \fn int GUIAPI ShowCursor (BOOL fShow) * \brief Shows or hides cursor. @@ -2954,13 +2910,54 @@ static inline HCURSOR GetDefaultCursor(void) { */ MG_EXPORT int GUIAPI ShowCursor (BOOL fShow); -#else +#else /* _MGHAVE_CURSOR */ + +static inline HCURSOR SetCursorEx(HCURSOR hcsr, BOOL set_def) { + return (HCURSOR)0; +} + +static inline HCURSOR GetDefaultCursor(void) { + return (HCURSOR)0; +} static inline int GUIAPI ShowCursor (BOOL fShow) { return 0; } -#endif /* _MGHAVE_CURSOR */ +#endif /* !_MGHAVE_CURSOR */ + +/** + * \def SetCursor(hcsr) + * \brief Changes the current cursor. + * + * This function changes the current cursor to be \a hcsr. + * + * \param hcsr The expected cursor handle. + * \return The old cursor handle. + * + * \note This function defined as a macro calling \a SetCursorEx with + * passing \a set_def as FALSE. + * + * \sa SetCursorEx, SetDefaultCursor + */ +#define SetCursor(hcsr) SetCursorEx (hcsr, FALSE) + +/** + * \def SetDefaultCursor(hcsr) + * \brief Changes the current cursor, and set it as the default cursor. + * + * This function changes the current cursor to be \a hcsr, and set it as + * the default cursor. + * + * \param hcsr The expected cursor handle. + * \return The old cursor handle. + * + * \note This function defined as a macro calling \a SetCursorEx with + * passing \a set_def as TRUE. + * + * \sa SetCursorEx, SetCursor + */ +#define SetDefaultCursor(hcsr) SetCursorEx (hcsr, TRUE) /** @} end of cursor_fns */ diff --git a/src/font/freetype2.c b/src/font/freetype2.c index 11f4cc38..e35ad162 100644 --- a/src/font/freetype2.c +++ b/src/font/freetype2.c @@ -511,7 +511,7 @@ char_bitmap_pixmap (LOGFONT* logfont, DEVFONT* devfont, if (pitch) *pitch = cacheinfo->pitch; - if (!is_grey && sz) { + if (sz) { sz->cx = cacheinfo->width; sz->cy = cacheinfo->height; } @@ -592,7 +592,7 @@ char_bitmap_pixmap (LOGFONT* logfont, DEVFONT* devfont, pcache->flag = TRUE; } - if (!is_grey && sz) { + if (sz) { sz->cx = pcache->width; sz->cy = pcache->height; } @@ -604,7 +604,7 @@ char_bitmap_pixmap (LOGFONT* logfont, DEVFONT* devfont, buffer = get_raster_bitmap_buffer (source->rows * source->pitch); memcpy(buffer, source->buffer, source->rows * source->pitch); - if (!is_grey && sz) { + if (sz) { sz->cx = source->width; sz->cy = source->rows; } diff --git a/src/newgdi/glyph.c b/src/newgdi/glyph.c index 91da77cf..2ccee5c7 100644 --- a/src/newgdi/glyph.c +++ b/src/newgdi/glyph.c @@ -3786,6 +3786,8 @@ static BOOL _gdi_get_glyph_data (PDC pdc, Glyph32 glyph_value, /* the returned bits will be the subpixled pixmap */ data = (BYTE*)(*devfont->font_ops->get_glyph_greybitmap) (logfont, devfont, REAL_GLYPH(glyph_value), bbox, &pitch, &scale); + // the width of SUBPIXEL bitmap is 3x real width of bbox + bbox->cx /= 3; ctxt->cb = _dc_ft2subpixel_scan_line; } #endif