add CreateLogFontIndirectEx function

This commit is contained in:
Vincent Wei
2019-01-19 14:21:46 +08:00
parent bbf2376f7a
commit 6663c98787
2 changed files with 68 additions and 1 deletions
+23
View File
@@ -6793,6 +6793,29 @@ MG_EXPORT PLOGFONT GUIAPI CreateLogFontByName (const char* font_name);
*/
MG_EXPORT PLOGFONT GUIAPI CreateLogFontIndirect (LOGFONT* logfont);
/**
* \fn PLOGFONT GUIAPI CreateLogFontIndirectEx (LOGFONT* logfont, int rotation)
* \brief Creates a new logical font indirectly from a LOGFONT structure with
* a rotation degrees.
*
* This function creates a new logical font from information in the LOGFONT object
* \a logfont and the new rotation value \a rotation.
*
* Since 3.4.0.
*
* \param logfont The pointer to the reference logical font structure.
* \param rotation The rotation of the logical font, it is in units of
* tenth degrees. Note that you can specify rotation only for
* vector fonts (use FreeType2 font engine).
*
* \return The pointer to the logical font created, NULL on error.
* If \a rotation is not zero and the devfonts of the \a logfont
* does not support rotation, it returns NULL.
*
* \sa CreateLogFont, CreateLogFontIndirect, SelectFont
*/
MG_EXPORT PLOGFONT GUIAPI CreateLogFontIndirectEx (LOGFONT* logfont, int rotation);
/**
* \fn void GUIAPI DestroyLogFont (PLOGFONT log_font)
* \brief Destroys a logical font.
+45 -1
View File
@@ -136,7 +136,7 @@ static PLOGFONT gdiCreateLogFont (const char* type, const char* family,
return INV_LOGFONT;
}
/*check if sbc_devfont and mbc_devfont support rotation*/
/* check if sbc_devfont and mbc_devfont support rotation */
if (get_rotation(log_font, sbc_devfont, rotation) == rotation
&& (!mbc_devfont || get_rotation(log_font, mbc_devfont, rotation) == rotation))
log_font->rotation = rotation;
@@ -287,6 +287,50 @@ PLOGFONT GUIAPI CreateLogFontIndirect (LOGFONT *logfont)
return font;
}
PLOGFONT GUIAPI CreateLogFontIndirectEx (LOGFONT *logfont, int rotation)
{
PLOGFONT newfont;
DEVFONT* sbc_devfont, *mbc_devfont;
if (!logfont) return NULL;
// VincentWei: make sure the logfont has the key for resource manager.
if ((newfont = (PLOGFONT)malloc (sizeof (FONT_RES))) == NULL)
return INV_LOGFONT;
// VincentWei: make sure the logfont has an invalid key for resource manager.
memcpy (newfont, logfont, sizeof(LOGFONT));
((FONT_RES *)newfont)->key = -1;
sbc_devfont = logfont->sbc_devfont;
mbc_devfont = logfont->mbc_devfont;
newfont->rotation = rotation;
if (logfont->rotation == 0 && rotation != 0) {
/* check if sbc_devfont and mbc_devfont support rotation */
if (get_rotation(newfont, sbc_devfont, rotation) == rotation
&& (!mbc_devfont || get_rotation(newfont, mbc_devfont, rotation) == rotation))
newfont->rotation = rotation;
else
newfont->rotation = 0;
}
if (sbc_devfont->font_ops->new_instance)
sbc_devfont = (*sbc_devfont->font_ops->new_instance) (newfont, sbc_devfont, TRUE);
if (sbc_devfont == NULL) {
free (newfont);
return INV_LOGFONT;
}
if (mbc_devfont && mbc_devfont->font_ops->new_instance)
mbc_devfont = (*mbc_devfont->font_ops->new_instance) (newfont, mbc_devfont, FALSE);
newfont->sbc_devfont = sbc_devfont;
newfont->mbc_devfont = mbc_devfont;
return newfont;
}
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)