add size_request in LOGFONT for original requested size

This commit is contained in:
Vincent Wei
2019-02-22 17:46:13 +08:00
parent c6c486f306
commit 97babaa4e2
3 changed files with 213 additions and 146 deletions
+8 -3
View File
@@ -5727,7 +5727,10 @@ MG_EXPORT int GUIAPI SubtractRect (RECT* rc, const RECT* psrc1, const RECT* psrc
struct _DEVFONT;
typedef struct _DEVFONT DEVFONT;
/** The logical font structure. */
/**
* The logical font structure.
* \note All fields are read-only.
*/
typedef struct _LOGFONT {
/** The type of the logical font. */
char type [LEN_LOGFONT_NAME_FIELD + 1];
@@ -5736,7 +5739,7 @@ typedef struct _LOGFONT {
/** The charset of the logical font. */
char charset [LEN_LOGFONT_NAME_FIELD + 1];
/** The styles of the logical font. */
DWORD style;
DWORD32 style;
/** The size of the logical font. */
int size;
/** The rotation angle of the logical font. */
@@ -5745,6 +5748,8 @@ typedef struct _LOGFONT {
int ascent;
/** The descent of the logical font. */
int descent;
/** The size requested */
int size_request;
/** The scale factor of sbc device font. */
unsigned short sbc_scale;
/** The scale factor of mbc device font. */
@@ -10566,7 +10571,7 @@ MG_EXPORT int GUIAPI GetGlyphsByRules(LOGFONT* logfont,
* Left-to-right direction.
* Both the writing mode and the typographic mode are vertical.
*/
#define GRF_WRITING_MODE_VERTICAL_LR 0x20008000
#define GRF_WRITING_MODE_VERTICAL_LR 0x20000000
#define GRF_TEXT_ORIENTATION_MASK 0x0F000000
/**
+70 -11
View File
@@ -112,6 +112,7 @@ static PLOGFONT gdiCreateLogFont (const char* type, const char* family,
strncpy (log_font->charset, charset, LEN_LOGFONT_NAME_FIELD);
log_font->charset [LEN_LOGFONT_NAME_FIELD] = '\0';
log_font->size_request = size;
if (size > FONT_MAX_SIZE)
log_font->size = FONT_MAX_SIZE;
else if (size < FONT_MIN_SIZE)
@@ -255,42 +256,73 @@ static PLOGFONT gdiCreateLogFont (const char* type, const char* family,
PLOGFONT GUIAPI CreateLogFontIndirect (LOGFONT *logfont)
{
PLOGFONT font;
PLOGFONT newfont;
DEVFONT* sbc_devfont, *mbc_devfont;
int sbc_value, mbc_value = 0;
if (!logfont) return NULL;
// VincentWei: make sure the logfont has the key for resource manager.
//if ((font = malloc (sizeof (LOGFONT))) == NULL)
if ((font = (PLOGFONT)malloc (sizeof (FONT_RES))) == NULL)
//if ((newfont = malloc (sizeof (LOGFONT))) == NULL)
if ((newfont = (PLOGFONT)malloc (sizeof (FONT_RES))) == NULL)
return INV_LOGFONT;
// VincentWei: make sure the logfont has an invalid key for resource manager.
memcpy (font, logfont, sizeof(LOGFONT));
((FONT_RES *)font)->key = -1;
memcpy (newfont, logfont, sizeof(LOGFONT));
((FONT_RES *)newfont)->key = -1;
// reset request size of newfont to logfont->size_request
newfont->size = logfont->size_request;
sbc_devfont = logfont->sbc_devfont;
if (sbc_devfont->font_ops->new_instance)
sbc_devfont = (*sbc_devfont->font_ops->new_instance) (logfont, sbc_devfont, TRUE);
sbc_devfont = (*sbc_devfont->font_ops->new_instance) (newfont, sbc_devfont, TRUE);
if (sbc_devfont == NULL) {
free (font);
free (newfont);
return INV_LOGFONT;
}
mbc_devfont = logfont->mbc_devfont;
if (mbc_devfont && mbc_devfont->font_ops->new_instance)
mbc_devfont = (*mbc_devfont->font_ops->new_instance) (logfont, mbc_devfont, FALSE);
mbc_devfont = (*mbc_devfont->font_ops->new_instance) (newfont, mbc_devfont, FALSE);
font->sbc_devfont = sbc_devfont;
font->mbc_devfont = mbc_devfont;
newfont->sbc_devfont = sbc_devfont;
newfont->mbc_devfont = mbc_devfont;
return font;
/*reset ascent of logfont*/
sbc_value = newfont->sbc_devfont->font_ops->get_font_ascent (newfont,
newfont->sbc_devfont);
if (newfont->mbc_devfont) {
mbc_value = newfont->mbc_devfont->font_ops->get_font_ascent (newfont,
newfont->mbc_devfont);
newfont->ascent = MAX (sbc_value, mbc_value);
}
else {
newfont->ascent = sbc_value;
}
/*reset descent of logfont*/
sbc_value = newfont->sbc_devfont->font_ops->get_font_descent (newfont,
newfont->sbc_devfont);
if (newfont->mbc_devfont) {
mbc_value = newfont->mbc_devfont->font_ops->get_font_descent (newfont,
newfont->mbc_devfont);
newfont->descent = MAX (sbc_value, mbc_value);
}
else {
newfont->descent = sbc_value;
}
/*reset size of logfont*/
newfont->size = newfont->ascent + newfont->descent;
return newfont;
}
PLOGFONT GUIAPI CreateLogFontIndirectEx (LOGFONT *logfont, int rotation)
{
PLOGFONT newfont;
DEVFONT* sbc_devfont, *mbc_devfont;
int sbc_value, mbc_value = 0;
if (!logfont) return NULL;
@@ -305,6 +337,7 @@ PLOGFONT GUIAPI CreateLogFontIndirectEx (LOGFONT *logfont, int rotation)
sbc_devfont = logfont->sbc_devfont;
mbc_devfont = logfont->mbc_devfont;
newfont->size = logfont->size_request;
newfont->rotation = rotation;
if (logfont->rotation == 0 && rotation != 0) {
/* check if sbc_devfont and mbc_devfont support rotation */
@@ -328,6 +361,32 @@ PLOGFONT GUIAPI CreateLogFontIndirectEx (LOGFONT *logfont, int rotation)
newfont->sbc_devfont = sbc_devfont;
newfont->mbc_devfont = mbc_devfont;
/*reset ascent of logfont*/
sbc_value = newfont->sbc_devfont->font_ops->get_font_ascent (newfont,
newfont->sbc_devfont);
if (newfont->mbc_devfont) {
mbc_value = newfont->mbc_devfont->font_ops->get_font_ascent (newfont,
newfont->mbc_devfont);
newfont->ascent = MAX (sbc_value, mbc_value);
}
else {
newfont->ascent = sbc_value;
}
/*reset descent of logfont*/
sbc_value = newfont->sbc_devfont->font_ops->get_font_descent (newfont,
newfont->sbc_devfont);
if (newfont->mbc_devfont) {
mbc_value = newfont->mbc_devfont->font_ops->get_font_descent (newfont,
newfont->mbc_devfont);
newfont->descent = MAX (sbc_value, mbc_value);
}
else {
newfont->descent = sbc_value;
}
/*reset size of logfont*/
newfont->size = newfont->ascent + newfont->descent;
return newfont;
}
+135 -132
View File
File diff suppressed because it is too large Load Diff