mirror of
https://github.com/VincentWei/MiniGUI.git
synced 2026-09-24 00:54:18 +08:00
add SIZE* sz for get_glyph_monobmp and get_glyph_graybmp
This commit is contained in:
+13
-6
@@ -278,6 +278,10 @@ PLOGFONT GUIAPI CreateLogFontIndirect (LOGFONT *reflf)
|
||||
|
||||
// reset request size of newlf to reflf->size_request
|
||||
newlf->size = reflf->size_request;
|
||||
if (newlf->size > FONT_MAX_SIZE)
|
||||
newlf->size = FONT_MAX_SIZE;
|
||||
else if (newlf->size < FONT_MIN_SIZE)
|
||||
newlf->size = FONT_MIN_SIZE;
|
||||
|
||||
// create new devfont instance if need
|
||||
for (i = 0; i < MAXNR_DEVFONTS; i++) {
|
||||
@@ -333,9 +337,12 @@ PLOGFONT GUIAPI CreateLogFontIndirectEx (LOGFONT *reflf, int rotation)
|
||||
newlf->charset == NULL)
|
||||
goto error;
|
||||
|
||||
|
||||
// reset request size of newlf to reflf->size_request
|
||||
newlf->size = reflf->size_request;
|
||||
if (newlf->size > FONT_MAX_SIZE)
|
||||
newlf->size = FONT_MAX_SIZE;
|
||||
else if (newlf->size < FONT_MIN_SIZE)
|
||||
newlf->size = FONT_MIN_SIZE;
|
||||
newlf->rotation = rotation;
|
||||
|
||||
// check if all devfonts support rotation
|
||||
@@ -352,11 +359,11 @@ PLOGFONT GUIAPI CreateLogFontIndirectEx (LOGFONT *reflf, int rotation)
|
||||
// create new devfont instance if need
|
||||
for (i = 0; i < MAXNR_DEVFONTS; i++) {
|
||||
DEVFONT* df = reflf->devfonts[i];
|
||||
if (df->font_ops->new_instance)
|
||||
newlf->devfonts[i] = df->font_ops->new_instance(newlf,
|
||||
df, i == 0);
|
||||
if (df == NULL) {
|
||||
goto error;
|
||||
if (df && df->font_ops->new_instance) {
|
||||
newlf->devfonts[i] = df->font_ops->new_instance(newlf, df, i == 0);
|
||||
if (newlf->devfonts[i] == NULL) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -329,7 +329,7 @@ static int get_font_descent (LOGFONT* logfont, DEVFONT* devfont)
|
||||
}
|
||||
|
||||
static const void* get_glyph_monobitmap (LOGFONT* logfont, DEVFONT* devfont,
|
||||
Glyph32 glyph_value, int* pitch, unsigned short* scale)
|
||||
Glyph32 glyph_value, SIZE* sz, int* pitch, unsigned short* scale)
|
||||
{
|
||||
unsigned int uc16;
|
||||
QPF_GLYPH* glyph;
|
||||
@@ -339,14 +339,14 @@ static const void* get_glyph_monobitmap (LOGFONT* logfont, DEVFONT* devfont,
|
||||
uc16 = (*devfont->charset_ops->conv_to_uc32) (glyph_value);
|
||||
else
|
||||
uc16 = glyph_value;
|
||||
|
||||
|
||||
glyph = get_glyph (QPFONT_INFO_P (devfont)->tree, uc16);
|
||||
|
||||
if (glyph == NULL) {
|
||||
if (uc16 < 0x80 && logfont->devfonts[0] != devfont) { /* ASCII */
|
||||
unsigned char ascii_ch = uc16;
|
||||
return logfont->devfonts[0]->font_ops->get_glyph_monobitmap (logfont,
|
||||
logfont->devfonts[0], ascii_ch, pitch, scale);
|
||||
logfont->devfonts[0], ascii_ch, sz, pitch, scale);
|
||||
}
|
||||
else
|
||||
glyph = &def_glyph;
|
||||
@@ -366,7 +366,7 @@ static const void* get_glyph_monobitmap (LOGFONT* logfont, DEVFONT* devfont,
|
||||
}
|
||||
|
||||
static const void* get_glyph_greybitmap (LOGFONT* logfont, DEVFONT* devfont,
|
||||
Glyph32 glyph_value, int* pitch, unsigned short* scale)
|
||||
Glyph32 glyph_value, SIZE* sz, int* pitch, unsigned short* scale)
|
||||
{
|
||||
unsigned int uc16;
|
||||
QPF_GLYPH* glyph;
|
||||
|
||||
@@ -204,7 +204,7 @@ static int get_font_descent (LOGFONT* logfont, DEVFONT* devfont)
|
||||
}
|
||||
|
||||
static const void* get_glyph_monobitmap (LOGFONT* logfont, DEVFONT* devfont,
|
||||
Glyph32 glyph_value, int* pitch, unsigned short* scale)
|
||||
Glyph32 glyph_value, SIZE* sz, int* pitch, unsigned short* scale)
|
||||
{
|
||||
int bitmap_size;
|
||||
|
||||
|
||||
+3
-3
@@ -268,7 +268,7 @@ print_bitmap(char* bits, int width, int height, int pitch)
|
||||
#endif
|
||||
|
||||
static const void* get_glyph_monobitmap (LOGFONT* logfont, DEVFONT* devfont,
|
||||
Glyph32 glyph_value, int* pitch, unsigned short* scale)
|
||||
Glyph32 glyph_value, SIZE* sz, int* pitch, unsigned short* scale)
|
||||
{
|
||||
unsigned int uc16;
|
||||
UPFGLYPH* glyph;
|
||||
@@ -290,7 +290,7 @@ static const void* get_glyph_monobitmap (LOGFONT* logfont, DEVFONT* devfont,
|
||||
if (uc16 < 0x80 && logfont->devfonts[0] != devfont) { /* ASCII */
|
||||
unsigned char ascii_ch = uc16;
|
||||
return logfont->devfonts[0]->font_ops->get_glyph_monobitmap (logfont,
|
||||
logfont->devfonts[0], ascii_ch, pitch, scale);
|
||||
logfont->devfonts[0], ascii_ch, sz, pitch, scale);
|
||||
}
|
||||
else
|
||||
glyph = &def_glyph;
|
||||
@@ -316,7 +316,7 @@ static const void* get_glyph_monobitmap (LOGFONT* logfont, DEVFONT* devfont,
|
||||
}
|
||||
|
||||
static const void* get_glyph_greybitmap (LOGFONT* logfont, DEVFONT* devfont,
|
||||
Glyph32 glyph_value, int* pitch, unsigned short* scale)
|
||||
Glyph32 glyph_value, SIZE* sz, int* pitch, unsigned short* scale)
|
||||
{
|
||||
unsigned int uc16;
|
||||
UPFGLYPH* glyph;
|
||||
|
||||
@@ -239,7 +239,7 @@ static int get_glyph_advance (LOGFONT* logfont, DEVFONT* devfont,
|
||||
}
|
||||
|
||||
static const void* get_glyph_monobitmap (LOGFONT* logfont, DEVFONT* devfont,
|
||||
Glyph32 glyph_value, int* pitch, unsigned short* scale)
|
||||
Glyph32 glyph_value, SIZE* sz, int* pitch, unsigned short* scale)
|
||||
{
|
||||
int offset;
|
||||
Glyph32 eff_value;
|
||||
|
||||
@@ -254,11 +254,11 @@ struct _FONTOPS
|
||||
|
||||
/** The method to get mono-bitmap function. */
|
||||
const void* (*get_glyph_monobitmap) (LOGFONT* logfont, DEVFONT* devfont,
|
||||
Glyph32 glyph_value, int* pitch, unsigned short* scale);
|
||||
Glyph32 glyph_value, SIZE* sz, int* pitch, unsigned short* scale);
|
||||
|
||||
/** The method to get grey bitmap, pitch and scale function */
|
||||
const void* (*get_glyph_greybitmap) (LOGFONT* logfont, DEVFONT* devfont,
|
||||
Glyph32 galph_value, int* pitch, unsigned short* scale);
|
||||
Glyph32 galph_value, SIZE* sz, int* pitch, unsigned short* scale);
|
||||
|
||||
/** The method to get the pre-rendered bitmap of one glyph. */
|
||||
int (*get_glyph_prbitmap) (LOGFONT* logfont, DEVFONT* devfont,
|
||||
|
||||
+18
-8
@@ -230,6 +230,7 @@ int GUIAPI GetGlyphInfo (LOGFONT* logfont, Glyph32 glyph_value,
|
||||
/* get the relative device font */
|
||||
DEVFONT* devfont = SELECT_DEVFONT(logfont, glyph_value);
|
||||
glyph_value = REAL_GLYPH (glyph_value);
|
||||
SIZE sz;
|
||||
|
||||
/* get glyph type */
|
||||
if (glyph_info->mask & GLYPH_INFO_TYPE)
|
||||
@@ -247,7 +248,8 @@ int GUIAPI GetGlyphInfo (LOGFONT* logfont, Glyph32 glyph_value,
|
||||
}
|
||||
|
||||
/* get metrics of the glyph */
|
||||
if (glyph_info->mask & GLYPH_INFO_METRICS) {
|
||||
if ((glyph_info->mask & GLYPH_INFO_METRICS) ||
|
||||
(glyph_info->mask & GLYPH_INFO_BMP)) {
|
||||
glyph_info->advance_x = 0;
|
||||
glyph_info->advance_y = 0;
|
||||
glyph_info->bbox_x = 0;
|
||||
@@ -256,6 +258,9 @@ int GUIAPI GetGlyphInfo (LOGFONT* logfont, Glyph32 glyph_value,
|
||||
_font_get_glyph_advance (logfont, devfont, glyph_value, TRUE,
|
||||
0, 0, 0, &glyph_info->advance_x, &glyph_info->advance_x,
|
||||
(BBOX*)(&glyph_info->bbox_x));
|
||||
|
||||
sz.cx = glyph_info->bbox_w;
|
||||
sz.cy = glyph_info->bbox_h;
|
||||
}
|
||||
|
||||
/* get glyph bitmap info */
|
||||
@@ -266,14 +271,18 @@ int GUIAPI GetGlyphInfo (LOGFONT* logfont, Glyph32 glyph_value,
|
||||
switch (glyph_info->bmp_type) {
|
||||
case GLYPHBMP_TYPE_MONO:
|
||||
glyph_info->bits = devfont->font_ops->get_glyph_monobitmap (
|
||||
logfont, devfont, glyph_value, &glyph_info->bmp_pitch, NULL);
|
||||
logfont, devfont, glyph_value, &sz, &glyph_info->bmp_pitch, NULL);
|
||||
glyph_info->bbox_w = sz.cx;
|
||||
glyph_info->bbox_h = sz.cy;
|
||||
glyph_info->bmp_size = glyph_info->bmp_pitch * glyph_info->bbox_h;
|
||||
break;
|
||||
|
||||
case GLYPHBMP_TYPE_GREY:
|
||||
glyph_info->bits = devfont->font_ops->get_glyph_greybitmap (
|
||||
logfont, devfont, glyph_value,
|
||||
&glyph_info->bmp_pitch, NULL);
|
||||
&sz, &glyph_info->bmp_pitch, NULL);
|
||||
glyph_info->bbox_w = sz.cx;
|
||||
glyph_info->bbox_h = sz.cy;
|
||||
glyph_info->bmp_size =
|
||||
glyph_info->bmp_pitch * glyph_info->bbox_h;
|
||||
break;
|
||||
@@ -281,7 +290,9 @@ int GUIAPI GetGlyphInfo (LOGFONT* logfont, Glyph32 glyph_value,
|
||||
case GLYPHBMP_TYPE_SUBPIXEL:
|
||||
glyph_info->bits = devfont->font_ops->get_glyph_greybitmap (
|
||||
logfont, devfont, glyph_value,
|
||||
&glyph_info->bmp_pitch, NULL);
|
||||
&sz, &glyph_info->bmp_pitch, NULL);
|
||||
glyph_info->bbox_w = sz.cx;
|
||||
glyph_info->bbox_h = sz.cy;
|
||||
glyph_info->bmp_size =
|
||||
glyph_info->bmp_pitch * glyph_info->bbox_h;
|
||||
break;
|
||||
@@ -2017,7 +2028,7 @@ static BOOL _gdi_get_glyph_data (PDC pdc, Glyph32 glyph_value,
|
||||
}
|
||||
|
||||
data = (BYTE*)(*devfont->font_ops->get_glyph_monobitmap) (logfont,
|
||||
devfont, glyph_value, &pitch, &scale);
|
||||
devfont, glyph_value, bbox, &pitch, &scale);
|
||||
|
||||
if (data == NULL)
|
||||
break;
|
||||
@@ -2051,7 +2062,7 @@ static BOOL _gdi_get_glyph_data (PDC pdc, Glyph32 glyph_value,
|
||||
/* get preybitmap */
|
||||
if (devfont->font_ops->get_glyph_greybitmap) {
|
||||
data = (BYTE*)(*devfont->font_ops->get_glyph_greybitmap) (logfont,
|
||||
devfont, glyph_value, &pitch, &scale);
|
||||
devfont, glyph_value, bbox, &pitch, &scale);
|
||||
ctxt->cb = _dc_bookgrey_scan_line;
|
||||
if (data && scale > 1) {
|
||||
bbox->cx = bbox->cx / scale;
|
||||
@@ -2073,7 +2084,7 @@ static BOOL _gdi_get_glyph_data (PDC pdc, Glyph32 glyph_value,
|
||||
*devfont->font_ops->get_glyph_greybitmap) {
|
||||
/* the returned bits will be the subpixled pixmap */
|
||||
data = (BYTE*)(*devfont->font_ops->get_glyph_greybitmap) (logfont,
|
||||
devfont, glyph_value, &pitch, &scale);
|
||||
devfont, glyph_value, bbox, &pitch, &scale);
|
||||
ctxt->cb = _dc_ft2subpixel_scan_line;
|
||||
|
||||
/* flip the subpixeled pixmap */
|
||||
@@ -2936,7 +2947,6 @@ Glyph32 _gdi_set_glyph_dfi(LOGFONT* lf, Glyph32 gv)
|
||||
}
|
||||
}
|
||||
|
||||
// return the first devfont as the default
|
||||
return SET_GLYPH_DFI(gv, dfi);
|
||||
}
|
||||
|
||||
|
||||
@@ -572,8 +572,22 @@ int GUIAPI GetTabbedTextExtentPoint (HDC hdc, const char* text,
|
||||
(NULL, 0, (const unsigned char*)text, len_cur_char);
|
||||
glyph_type = devfont->charset_ops->glyph_type (glyph_value);
|
||||
|
||||
if(devfont == mbc_devfont)
|
||||
glyph_value |= 0x80000000;
|
||||
if (devfont == mbc_devfont) {
|
||||
int i, dfi;
|
||||
DEVFONT* df;
|
||||
|
||||
dfi = 1;
|
||||
for (i = 1; i < MAXNR_DEVFONTS; i++) {
|
||||
if ((df = log_font->devfonts[i])) {
|
||||
if (df->font_ops->is_glyph_existed(log_font, df,
|
||||
glyph_value)) {
|
||||
dfi = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
glyph_value = SET_GLYPH_DFI(glyph_value, dfi);
|
||||
}
|
||||
|
||||
switch (glyph_type & GLYPHTYPE_MCHAR_MASK) {
|
||||
case MCHAR_TYPE_ZEROWIDTH:
|
||||
|
||||
+15
-1
@@ -479,11 +479,25 @@ int GUIAPI GetTextExtentPoint (HDC hdc, const char* text, int len,
|
||||
if (mbc_devfont &&
|
||||
(len_cur_char = mbc_devfont->charset_ops->len_first_char
|
||||
((const unsigned char*)text, left_bytes)) > 0) {
|
||||
int i, dfi;
|
||||
DEVFONT* df;
|
||||
|
||||
glyph_value = (*mbc_devfont->charset_ops->char_glyph_value)(NULL,
|
||||
0, (const unsigned char*)text, 0);
|
||||
|
||||
advance_cur_char = _gdi_get_glyph_advance (pdc, glyph_value | 0x80000000,
|
||||
dfi = 1;
|
||||
for (i = 1; i < MAXNR_DEVFONTS; i++) {
|
||||
if ((df = log_font->devfonts[i])) {
|
||||
if (df->font_ops->is_glyph_existed(log_font, df,
|
||||
glyph_value)) {
|
||||
dfi = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
glyph_value = SET_GLYPH_DFI(glyph_value, dfi);
|
||||
|
||||
advance_cur_char = _gdi_get_glyph_advance (pdc, glyph_value,
|
||||
(pdc->ta_flags & TA_X_MASK) == TA_LEFT,
|
||||
0, 0, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user