add a new method for DEVFONTOPS: get_feature(). currently used for check whether a devfont contains correct bounding box values for marks

This commit is contained in:
Vincent Wei
2023-08-09 14:08:40 +08:00
parent 5b27cc70fc
commit 0a5ace7f82
16 changed files with 208 additions and 70 deletions
+2
View File
@@ -13003,6 +13003,8 @@ MG_EXPORT int GUIAPI DrawGlyph (HDC hdc, int x, int y, Glyph32 glyph_value,
* \param last_adv The advance on the baseline of the last glyph.
*
* \return The advance on baseline of the vowel.
*
* Since 5.0.13
*/
MG_EXPORT int GUIAPI DrawVowel (HDC hdc, int x, int y, Glyph32 glyph_value,
int last_adv);
+12
View File
@@ -202,6 +202,17 @@ static void destroy (GLYPHTREENODE *root)
/*** device font ops ***/
static DWORD get_feature (LOGFONT* logfont, DEVFONT* devfont,
enum devfont_feature feature)
{
switch (feature) {
case DEVFONT_FEATURE_MARK_BBOX:
return 0;
}
return 0;
}
static DWORD get_glyph_bmptype (LOGFONT* logfont, DEVFONT* devfont)
{
return DEVFONTGLYPHTYPE_PRERDRBMP;
@@ -380,6 +391,7 @@ static int get_glyph_bbox (LOGFONT* logfont, DEVFONT* devfont,
/**************************** Global data ************************************/
FONTOPS __mg_bitmap_font_ops = {
get_feature,
get_glyph_bmptype,
get_ave_width,
get_max_width,
+12
View File
@@ -255,6 +255,17 @@ compute_kernval (TTFINSTANCEINFO* ttf_inst_info)
return kernval;
}
static DWORD get_feature (LOGFONT* logfont, DEVFONT* devfont,
enum devfont_feature feature)
{
switch (feature) {
case DEVFONT_FEATURE_MARK_BBOX:
return 0;
}
return 0;
}
static DWORD get_glyph_bmptype (LOGFONT* logfont, DEVFONT* devfont)
{
if (logfont->style & FS_WEIGHT_BOOK)
@@ -792,6 +803,7 @@ static int is_rotatable (LOGFONT* logfont, DEVFONT* devfont, int rot_desired)
}
/**************************** Global data ************************************/
FONTOPS __mg_ttf_ops = {
get_feature,
get_glyph_bmptype,
get_ave_width,
get_max_width,
+12
View File
@@ -197,6 +197,17 @@ print_bitmap_grey (const BYTE* buffer, int width, int rows, int pitch)
printf("*******************************************\n");
}
static DWORD get_feature (LOGFONT* logfont, DEVFONT* devfont,
enum devfont_feature feature)
{
switch (feature) {
case DEVFONT_FEATURE_MARK_BBOX:
return 1;
}
return 0;
}
static DWORD get_glyph_bmptype (LOGFONT* logfont, DEVFONT* devfont)
{
switch (logfont->style & FS_RENDER_MASK) {
@@ -1265,6 +1276,7 @@ void font_TermFreetypeLibrary (void)
/**************************** Global data ************************************/
FONTOPS __mg_ttf_ops = {
get_feature,
get_glyph_bmptype,
get_ave_width,
get_max_width,
+12
View File
@@ -66,6 +66,17 @@
#define NUF_WIDTH 8
#define NUF_HEIGHT 1
static DWORD get_feature (LOGFONT* logfont, DEVFONT* devfont,
enum devfont_feature feature)
{
switch (feature) {
case DEVFONT_FEATURE_MARK_BBOX:
return 0;
}
return 0;
}
static DWORD get_glyph_bmptype (LOGFONT* logfont, DEVFONT* devfont)
{
return DEVFONTGLYPHTYPE_MONOBMP;
@@ -171,6 +182,7 @@ static void unload_font_data (DEVFONT* devfont, void* data)
}
FONTOPS __mg_null_font_ops = {
get_feature,
get_glyph_bmptype,
get_ave_width,
get_max_width,
+12
View File
@@ -287,6 +287,17 @@ static unsigned char def_smooth_bitmap [] =
static QPF_GLYPH def_glyph = {&def_metrics, def_bitmap};
static QPF_GLYPH def_smooth_glyph = {&def_smooth_metrics, def_smooth_bitmap};
static DWORD get_feature (LOGFONT* logfont, DEVFONT* devfont,
enum devfont_feature feature)
{
switch (feature) {
case DEVFONT_FEATURE_MARK_BBOX:
return 0;
}
return 0;
}
static DWORD get_glyph_bmptype (LOGFONT* logfont, DEVFONT* devfont)
{
if (QPFONT_INFO_P (devfont)->fm->flags & FLAG_MODE_SMOOTH)
@@ -541,6 +552,7 @@ static int is_rotatable (LOGFONT* logfont, DEVFONT* devfont, int rot_desired)
/**************************** Global data ************************************/
FONTOPS __mg_qpf_ops = {
get_feature,
get_glyph_bmptype,
get_ave_width,
get_max_width,
+12
View File
@@ -151,6 +151,17 @@ static void unload_font_data (DEVFONT* devfont, void* data)
/*************** Raw bitmap font operations *********************************/
static DWORD get_feature (LOGFONT* logfont, DEVFONT* devfont,
enum devfont_feature feature)
{
switch (feature) {
case DEVFONT_FEATURE_MARK_BBOX:
return 0;
}
return 0;
}
static DWORD get_glyph_bmptype (LOGFONT* logfont, DEVFONT* devfont)
{
return DEVFONTGLYPHTYPE_MONOBMP;
@@ -280,6 +291,7 @@ static int is_rotatable (LOGFONT* logfont, DEVFONT* devfont, int rot_desired)
/**************************** Global data ************************************/
FONTOPS __mg_rbf_ops = {
get_feature,
get_glyph_bmptype,
get_ave_width,
get_ave_width, // max_width same as ave_width
+12
View File
@@ -377,6 +377,17 @@ static int get_max_width (LOGFONT* logfont, DEVFONT* devfont)
return logfont->size;
}
static DWORD get_feature (LOGFONT* logfont, DEVFONT* devfont,
enum devfont_feature feature)
{
switch (feature) {
case DEVFONT_FEATURE_MARK_BBOX:
return 0;
}
return 0;
}
static DWORD get_glyph_bmptype (LOGFONT* logfont, DEVFONT* devfont)
{
if (logfont->style & FS_WEIGHT_BOOK)
@@ -598,6 +609,7 @@ static int is_rotatable (LOGFONT* logfont, DEVFONT* devfont, int rot_desired)
/**************************** Global data ************************************/
static FONTOPS scripteasy_font_ops = {
get_feature,
get_glyph_bmptype,
get_ave_width,
get_max_width,
+12
View File
@@ -148,6 +148,17 @@ static void unload_font_data (DEVFONT* devfont, void* data)
free (((UPFINFO*) data));
}
static DWORD get_feature (LOGFONT* logfont, DEVFONT* devfont,
enum devfont_feature feature)
{
switch (feature) {
case DEVFONT_FEATURE_MARK_BBOX:
return 0;
}
return 0;
}
static DWORD get_glyph_bmptype (LOGFONT* logfont, DEVFONT* devfont)
{
Uint8* p_upf = (Uint8 *)UPFONT_INFO_P (devfont)->root_dir;
@@ -525,6 +536,7 @@ static int is_rotatable (LOGFONT* logfont, DEVFONT* devfont, int rot_desired)
}
FONTOPS __mg_upf_ops = {
get_feature,
get_glyph_bmptype,
get_ave_width,
get_max_width,
+12
View File
@@ -109,6 +109,17 @@ typedef struct _FONT_PROPT {
int def_glyph;
} FONT_PROPT;
static DWORD get_feature (LOGFONT* logfont, DEVFONT* devfont,
enum devfont_feature feature)
{
switch (feature) {
case DEVFONT_FEATURE_MARK_BBOX:
return 0;
}
return 0;
}
static DWORD get_glyph_bmptype (LOGFONT* logfont, DEVFONT* devfont)
{
return DEVFONTGLYPHTYPE_MONOBMP;
@@ -477,6 +488,7 @@ static void unload_font_data (DEVFONT* devfont, void* data)
}
FONTOPS __mg_vbf_ops = {
get_feature,
get_glyph_bmptype,
get_ave_width,
get_max_width,
+9 -1
View File
@@ -209,7 +209,7 @@ struct _CHARSETOPS
/** Default character. */
Achar32 def_char_value;
/** Whether use legacy BIDI algorithm (Since 5.0.13). */
/** Whether using legacy BIDI algorithm (Since 5.0.13). */
unsigned legacy_bidi:1;
/** The method to get the length of the first character. */
@@ -266,9 +266,17 @@ struct _CHARSETOPS
#define DEVFONTGLYPHTYPE_MASK_BMPTYPE 0x0F
enum devfont_feature {
DEVFONT_FEATURE_MARK_BBOX = 0,
};
/** The font operation structure. */
struct _FONTOPS
{
/** The method to get the feature value of the font (Since 5.0.13). */
DWORD (*get_feature) (LOGFONT* logfont, DEVFONT* devfont,
enum devfont_feature feature);
/** The method to get the glyph bitmap type . */
DWORD (*get_glyph_bmptype) (LOGFONT* logfont, DEVFONT* devfont);
+13 -12
View File
@@ -146,18 +146,19 @@ static BOOL cb_drawtextex2 (void* context, Glyph32 glyph_value,
case ACHAR_BASIC_VOWEL:
if (!ctxt->only_extent) {
#if 0
int bkmode = ctxt->pdc->bkmode;
ctxt->pdc->bkmode = BM_TRANSPARENT;
_gdi_draw_one_glyph (ctxt->pdc, glyph_value,
(ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT,
ctxt->x, ctxt->y, &adv_x, &adv_y);
ctxt->pdc->bkmode = bkmode;
#else
_gdi_draw_one_vowel (ctxt->pdc, glyph_value,
(ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT,
ctxt->last_x, ctxt->last_y, ctxt->last_adv);
#endif
if (_gdi_if_mark_bbox_is_ok(ctxt->pdc, glyph_value)) {
int bkmode = ctxt->pdc->bkmode;
ctxt->pdc->bkmode = ctxt->pdc->bkmode_set;
_gdi_draw_one_glyph (ctxt->pdc, glyph_value,
(ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT,
ctxt->x, ctxt->y, &adv_x, &adv_y);
ctxt->pdc->bkmode = bkmode;
}
else {
_gdi_draw_one_vowel (ctxt->pdc, glyph_value,
(ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT,
ctxt->last_x, ctxt->last_y, ctxt->last_adv);
}
adv_x = adv_y = 0;
}
break;
+2
View File
@@ -82,6 +82,8 @@ static inline int _gdi_get_glyph_advance (PDC pdc, Glyph32 glyph_value,
direction, pdc->cExtra, x, y, adv_x, adv_y, bbox);
}
BOOL _gdi_if_mark_bbox_is_ok(PDC pdc, Glyph32 gv);
int _gdi_draw_one_vowel (PDC pdc, Glyph32 glyph_value, BOOL direction,
int x, int y, int last_adv);
+13
View File
@@ -2806,6 +2806,18 @@ static void draw_glyph_lines (PDC pdc, int x1, int y1, int x2, int y2)
}
}
BOOL _gdi_if_mark_bbox_is_ok(PDC pdc, Glyph32 gv)
{
LOGFONT* logfont;
DEVFONT* devfont;
logfont = pdc->pLogFont;
devfont = SELECT_DEVFONT_BY_GLYPH (logfont, gv);
return devfont->font_ops->get_feature(logfont, devfont,
DEVFONT_FEATURE_MARK_BBOX) != 0;
}
int _gdi_draw_one_glyph (PDC pdc, Glyph32 glyph_value, BOOL direction,
int x, int y, int* adv_x, int* adv_y)
{
@@ -3091,6 +3103,7 @@ int GUIAPI DrawGlyph (HDC hdc, int x, int y, Glyph32 glyph_value,
return advance;
}
/* XXX: an experimental API */
int GUIAPI DrawVowel (HDC hdc, int x, int y, Glyph32 glyph_value,
int last_adv)
{
+26 -24
View File
@@ -161,18 +161,19 @@ static BOOL cb_tabbedtextout (void* context, Glyph32 glyph_value,
case ACHAR_BASIC_VOWEL:
if (!ctxt->only_extent) {
#if 0
int bkmode = ctxt->pdc->bkmode;
ctxt->pdc->bkmode = BM_TRANSPARENT;
_gdi_draw_one_glyph (ctxt->pdc, glyph_value,
(ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT,
ctxt->x, ctxt->y, &adv_x, &adv_y);
ctxt->pdc->bkmode = bkmode;
#else
_gdi_draw_one_vowel (ctxt->pdc, glyph_value,
(ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT,
ctxt->last_x, ctxt->last_y, ctxt->last_adv);
#endif
if (_gdi_if_mark_bbox_is_ok(ctxt->pdc, glyph_value)) {
int bkmode = ctxt->pdc->bkmode;
ctxt->pdc->bkmode = ctxt->pdc->bkmode_set;
_gdi_draw_one_glyph (ctxt->pdc, glyph_value,
(ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT,
ctxt->x, ctxt->y, &adv_x, &adv_y);
ctxt->pdc->bkmode = bkmode;
}
else {
_gdi_draw_one_vowel (ctxt->pdc, glyph_value,
(ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT,
ctxt->last_x, ctxt->last_y, ctxt->last_adv);
}
}
adv_x = adv_y = 0;
break;
@@ -261,18 +262,19 @@ static BOOL cb_tabbedtextoutex (void* context, Glyph32 glyph_value,
break;
case ACHAR_BASIC_VOWEL: {
#if 0
int bkmode = ctxt->pdc->bkmode;
ctxt->pdc->bkmode = BM_TRANSPARENT;
_gdi_draw_one_glyph (ctxt->pdc, glyph_value,
(ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT,
ctxt->x, ctxt->y, &adv_x, &adv_y);
ctxt->pdc->bkmode = bkmode;
#else
_gdi_draw_one_vowel (ctxt->pdc, glyph_value,
(ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT,
ctxt->last_x, ctxt->last_y, ctxt->last_adv);
#endif
if (_gdi_if_mark_bbox_is_ok(ctxt->pdc, glyph_value)) {
int bkmode = ctxt->pdc->bkmode;
ctxt->pdc->bkmode = ctxt->pdc->bkmode_set;
_gdi_draw_one_glyph (ctxt->pdc, glyph_value,
(ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT,
ctxt->x, ctxt->y, &adv_x, &adv_y);
ctxt->pdc->bkmode = bkmode;
}
else {
_gdi_draw_one_vowel (ctxt->pdc, glyph_value,
(ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT,
ctxt->last_x, ctxt->last_y, ctxt->last_adv);
}
adv_x = adv_y = 0;
break;
}
+35 -33
View File
@@ -128,15 +128,15 @@ static BOOL cb_draw_glyph (void* context, Glyph32 glyph_value, unsigned int char
adv_x = adv_y = 0;
}
else if (check_vowel(char_type)) {
int bkmode = GetBkMode (ctxt->hdc);
SetBkMode (ctxt->hdc, BM_TRANSPARENT);
#if 0
DrawGlyph (ctxt->hdc, ctxt->x, ctxt->y, glyph_value, &adv_x, &adv_y);
#else
DrawVowel (ctxt->hdc, ctxt->last_x, ctxt->last_y, glyph_value,
ctxt->last_adv);
#endif
SetBkMode (ctxt->hdc, bkmode);
PDC pdc = dc_HDC2PDC(ctxt->hdc);
if (_gdi_if_mark_bbox_is_ok(pdc, glyph_value)) {
DrawGlyph (ctxt->hdc, ctxt->x, ctxt->y, glyph_value,
&adv_x, &adv_y);
}
else {
DrawVowel (ctxt->hdc, ctxt->last_x, ctxt->last_y,
glyph_value, ctxt->last_adv);
}
adv_x = 0;
adv_y = 0;
}
@@ -175,18 +175,19 @@ static BOOL cb_textout (void* context, Glyph32 glyph_value,
}
else if (check_vowel(char_type)) {
if (!ctxt->only_extent) {
#if 0
int bkmode = ctxt->pdc->bkmode;
ctxt->pdc->bkmode = BM_TRANSPARENT;
_gdi_draw_one_glyph (ctxt->pdc, glyph_value,
(ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT,
ctxt->x, ctxt->y, &adv_x, &adv_y);
ctxt->pdc->bkmode = bkmode;
#else
_gdi_draw_one_vowel (ctxt->pdc, glyph_value,
(ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT,
ctxt->last_x, ctxt->last_y, ctxt->last_adv);
#endif
if (_gdi_if_mark_bbox_is_ok(ctxt->pdc, glyph_value)) {
int bkmode = ctxt->pdc->bkmode;
ctxt->pdc->bkmode = ctxt->pdc->bkmode_set;
_gdi_draw_one_glyph (ctxt->pdc, glyph_value,
(ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT,
ctxt->x, ctxt->y, &adv_x, &adv_y);
ctxt->pdc->bkmode = bkmode;
}
else {
_gdi_draw_one_vowel (ctxt->pdc, glyph_value,
(ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT,
ctxt->last_x, ctxt->last_y, ctxt->last_adv);
}
}
adv_x = adv_y = 0;
}
@@ -356,18 +357,19 @@ cb_textout_omitted (void* context, Glyph32 glyph_value, unsigned int char_type)
adv_x = adv_y = 0;
}
else if (check_vowel(char_type)) {
#if 0
int bkmode = ctxt->pdc->bkmode;
ctxt->pdc->bkmode = BM_TRANSPARENT;
_gdi_draw_one_glyph (ctxt->pdc, glyph_value,
(ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT,
ctxt->x, ctxt->y, &adv_x, &adv_y);
ctxt->pdc->bkmode = bkmode;
#else
_gdi_draw_one_vowel (ctxt->pdc, glyph_value,
(ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT,
ctxt->last_x, ctxt->last_y, ctxt->last_adv);
#endif
if (_gdi_if_mark_bbox_is_ok(ctxt->pdc, glyph_value)) {
int bkmode = ctxt->pdc->bkmode;
ctxt->pdc->bkmode = ctxt->pdc->bkmode_set;
_gdi_draw_one_glyph (ctxt->pdc, glyph_value,
(ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT,
ctxt->x, ctxt->y, &adv_x, &adv_y);
ctxt->pdc->bkmode = bkmode;
}
else {
_gdi_draw_one_vowel (ctxt->pdc, glyph_value,
(ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT,
ctxt->last_x, ctxt->last_y, ctxt->last_adv);
}
adv_x = adv_y = 0;
}
else {