fix GrTextSizePtr API interface return type consistency
commit 86b5d591d from 20241004 by me, modified return type of
GrTextSize API in the graphics from 'void' to 'int' to convey
and error scenario to indicate when 'r' was not filled in for
the caller, but this is a multi graphics driver API interface
so requires all downstream graphics engines to also support
the return type change.
This API can error and indicates when 'Rect *r' was
successfully updated.
This commit is contained in:
parent
2173d03b14
commit
0b29b1cc12
|
|
@ -160,7 +160,7 @@ void (*GrClosePtr)() = NULL;
|
||||||
void (*GrSetCMapPtr)() = NULL;
|
void (*GrSetCMapPtr)() = NULL;
|
||||||
|
|
||||||
void (*GrSetCursorPtr)() = NULL;
|
void (*GrSetCursorPtr)() = NULL;
|
||||||
void (*GrTextSizePtr)() = NULL;
|
int (*GrTextSizePtr)() = NULL;
|
||||||
void (*GrDrawGlyphPtr)() = NULL;
|
void (*GrDrawGlyphPtr)() = NULL;
|
||||||
void (*GrBitBltPtr)() = NULL;
|
void (*GrBitBltPtr)() = NULL;
|
||||||
int (*GrReadPixelPtr)() = NULL;
|
int (*GrReadPixelPtr)() = NULL;
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@ NullInit()
|
||||||
* Determine the size of a text string.
|
* Determine the size of a text string.
|
||||||
*
|
*
|
||||||
* Results:
|
* Results:
|
||||||
* None.
|
* Returns 0 indicating 'r' has been updated.
|
||||||
*
|
*
|
||||||
* Side effects:
|
* Side effects:
|
||||||
* A rectangle is filled in that is the size of the text in pixels.
|
* A rectangle is filled in that is the size of the text in pixels.
|
||||||
|
|
@ -146,7 +146,7 @@ NullInit()
|
||||||
* ----------------------------------------------------------------------------
|
* ----------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
int
|
||||||
NullTextSize(text, size, r)
|
NullTextSize(text, size, r)
|
||||||
char *text;
|
char *text;
|
||||||
int size;
|
int size;
|
||||||
|
|
@ -157,6 +157,7 @@ NullTextSize(text, size, r)
|
||||||
r->r_xtop = strlen(text);
|
r->r_xtop = strlen(text);
|
||||||
r->r_ybot = 0;
|
r->r_ybot = 0;
|
||||||
r->r_ytop = 1;
|
r->r_ytop = 1;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -257,7 +257,7 @@ groglSetCharSize (size)
|
||||||
* Determine the size of a text string.
|
* Determine the size of a text string.
|
||||||
*
|
*
|
||||||
* Results:
|
* Results:
|
||||||
* 0 on success. -1 on error (no side-effects).
|
* Returns 0 when 'r' updated, otherwise -1 on error (no side-effects).
|
||||||
*
|
*
|
||||||
* Side effects:
|
* Side effects:
|
||||||
* A rectangle is filled in that is the size of the text in pixels.
|
* A rectangle is filled in that is the size of the text in pixels.
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ extern void groglFontText();
|
||||||
extern void groglDefineCursor();
|
extern void groglDefineCursor();
|
||||||
extern void GrOGLSetCursor();
|
extern void GrOGLSetCursor();
|
||||||
extern void GrOGLSetWindow();
|
extern void GrOGLSetWindow();
|
||||||
extern void GrOGLTextSize();
|
extern int GrOGLTextSize();
|
||||||
extern void GrOGLDrawGlyph();
|
extern void GrOGLDrawGlyph();
|
||||||
extern void GrOGLBitBlt();
|
extern void GrOGLBitBlt();
|
||||||
extern void NullBitBlt();
|
extern void NullBitBlt();
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,7 @@ int size; /* Width of characters, in pixels (6 or 8). */
|
||||||
* Determine the size of a text string.
|
* Determine the size of a text string.
|
||||||
*
|
*
|
||||||
* Results:
|
* Results:
|
||||||
* None.
|
* Return 0 when 'r' updated, otherwise -1 on error (no side-effects).
|
||||||
*
|
*
|
||||||
* Side effects:
|
* Side effects:
|
||||||
* A rectangle is filled in that is the size of the text in pixels.
|
* A rectangle is filled in that is the size of the text in pixels.
|
||||||
|
|
@ -182,7 +182,7 @@ int size; /* Width of characters, in pixels (6 or 8). */
|
||||||
* ----------------------------------------------------------------------------
|
* ----------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
int
|
||||||
GrTCairoTextSize(text, size, r)
|
GrTCairoTextSize(text, size, r)
|
||||||
char *text;
|
char *text;
|
||||||
int size;
|
int size;
|
||||||
|
|
@ -195,7 +195,7 @@ Rect *r;
|
||||||
/* Note: size is ignored, as it is passed the current value; */
|
/* Note: size is ignored, as it is passed the current value; */
|
||||||
/* but the font size in cairo has already been set. */
|
/* but the font size in cairo has already been set. */
|
||||||
|
|
||||||
if (tcairoCurrent.mw == 0) return;
|
if (tcairoCurrent.mw == 0) return -1;
|
||||||
|
|
||||||
tcairodata = (TCairoData *)tcairoCurrent.mw->w_grdata2;
|
tcairodata = (TCairoData *)tcairoCurrent.mw->w_grdata2;
|
||||||
cairo_text_extents(tcairodata->context, text, &extents);
|
cairo_text_extents(tcairodata->context, text, &extents);
|
||||||
|
|
@ -204,6 +204,7 @@ Rect *r;
|
||||||
r->r_ybot = -(extents.height + extents.y_bearing);
|
r->r_ybot = -(extents.height + extents.y_bearing);
|
||||||
r->r_xtop = extents.width + extents.x_bearing;
|
r->r_xtop = extents.width + extents.x_bearing;
|
||||||
r->r_xbot = extents.x_bearing;
|
r->r_xbot = extents.x_bearing;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Cairo backing store functions (now removed from the X11-based ones) */
|
/* Cairo backing store functions (now removed from the X11-based ones) */
|
||||||
|
|
@ -598,7 +599,7 @@ LinkedRect *obscure; /* A list of obscuring rectangles */
|
||||||
float tscale;
|
float tscale;
|
||||||
TCairoData *tcairodata = (TCairoData *)tcairoCurrent.mw->w_grdata2;
|
TCairoData *tcairodata = (TCairoData *)tcairoCurrent.mw->w_grdata2;
|
||||||
|
|
||||||
GrTCairoTextSize(text, tcairoCurrent.fontSize, &textrect);
|
if (GrTCairoTextSize(text, tcairoCurrent.fontSize, &textrect) < 0) return;
|
||||||
|
|
||||||
location.r_xbot = pos->p_x + textrect.r_xbot;
|
location.r_xbot = pos->p_x + textrect.r_xbot;
|
||||||
location.r_xtop = pos->p_x + textrect.r_xtop;
|
location.r_xtop = pos->p_x + textrect.r_xtop;
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ extern void grtcairoPutText();
|
||||||
extern void grtcairoFontText();
|
extern void grtcairoFontText();
|
||||||
#endif
|
#endif
|
||||||
extern void GrTCairoSetCursor();
|
extern void GrTCairoSetCursor();
|
||||||
extern void GrTCairoTextSize();
|
extern int GrTCairoTextSize();
|
||||||
extern void GrTCairoDrawGlyph();
|
extern void GrTCairoDrawGlyph();
|
||||||
extern void GrTCairoBitBlt();
|
extern void GrTCairoBitBlt();
|
||||||
extern void NullBitBlt();
|
extern void NullBitBlt();
|
||||||
|
|
|
||||||
|
|
@ -194,7 +194,7 @@ grtoglSetCharSize (size)
|
||||||
* Determine the size of a text string.
|
* Determine the size of a text string.
|
||||||
*
|
*
|
||||||
* Results:
|
* Results:
|
||||||
* None.
|
* Returns 0 when 'r' updated, otherwise -1 on error (no side-effects).
|
||||||
*
|
*
|
||||||
* Side effects:
|
* Side effects:
|
||||||
* A rectangle is filled in that is the size of the text in pixels.
|
* A rectangle is filled in that is the size of the text in pixels.
|
||||||
|
|
@ -203,7 +203,7 @@ grtoglSetCharSize (size)
|
||||||
* ----------------------------------------------------------------------------
|
* ----------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
int
|
||||||
GrTOGLTextSize(text, size, r)
|
GrTOGLTextSize(text, size, r)
|
||||||
char *text;
|
char *text;
|
||||||
int size;
|
int size;
|
||||||
|
|
@ -233,7 +233,7 @@ GrTOGLTextSize(text, size, r)
|
||||||
size );
|
size );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (font == NULL) return;
|
if (font == NULL) return -1;
|
||||||
Tk_GetFontMetrics(font, &overall);
|
Tk_GetFontMetrics(font, &overall);
|
||||||
width = Tk_TextWidth(font, text, strlen(text));
|
width = Tk_TextWidth(font, text, strlen(text));
|
||||||
/* Hack alert! Tk_TextWidth returns values too small! */
|
/* Hack alert! Tk_TextWidth returns values too small! */
|
||||||
|
|
@ -242,6 +242,7 @@ GrTOGLTextSize(text, size, r)
|
||||||
r->r_ybot = -overall.descent;
|
r->r_ybot = -overall.descent;
|
||||||
r->r_xtop = width;
|
r->r_xtop = width;
|
||||||
r->r_xbot = 0;
|
r->r_xbot = 0;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* OpenGL backing store functions (now removed from the X11-based ones) */
|
/* OpenGL backing store functions (now removed from the X11-based ones) */
|
||||||
|
|
@ -682,7 +683,7 @@ grtoglPutText (text, pos, clip, obscure)
|
||||||
int i;
|
int i;
|
||||||
float tscale;
|
float tscale;
|
||||||
|
|
||||||
GrTOGLTextSize(text, toglCurrent.fontSize, &textrect);
|
if (GrTOGLTextSize(text, toglCurrent.fontSize, &textrect) < 0) return;
|
||||||
|
|
||||||
location.r_xbot = pos->p_x + textrect.r_xbot;
|
location.r_xbot = pos->p_x + textrect.r_xbot;
|
||||||
location.r_xtop = pos->p_x + textrect.r_xtop;
|
location.r_xtop = pos->p_x + textrect.r_xtop;
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ extern void grtoglPutText();
|
||||||
extern void grtoglFontText();
|
extern void grtoglFontText();
|
||||||
#endif
|
#endif
|
||||||
extern void GrTOGLSetCursor();
|
extern void GrTOGLSetCursor();
|
||||||
extern void GrTOGLTextSize();
|
extern int GrTOGLTextSize();
|
||||||
extern void GrTOGLDrawGlyph();
|
extern void GrTOGLDrawGlyph();
|
||||||
extern void GrTOGLBitBlt();
|
extern void GrTOGLBitBlt();
|
||||||
extern void NullBitBlt();
|
extern void NullBitBlt();
|
||||||
|
|
|
||||||
|
|
@ -167,7 +167,7 @@ grtkSetCharSize (size)
|
||||||
* Determine the size of a text string.
|
* Determine the size of a text string.
|
||||||
*
|
*
|
||||||
* Results:
|
* Results:
|
||||||
* None.
|
* Returns 0 when 'r' updated, otherwise -1 on error (no side-effects).
|
||||||
*
|
*
|
||||||
* Side effects:
|
* Side effects:
|
||||||
* A rectangle is filled in that is the size of the text in pixels.
|
* A rectangle is filled in that is the size of the text in pixels.
|
||||||
|
|
@ -176,7 +176,7 @@ grtkSetCharSize (size)
|
||||||
* ----------------------------------------------------------------------------
|
* ----------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
int
|
||||||
GrTkTextSize(text, size, r)
|
GrTkTextSize(text, size, r)
|
||||||
char *text;
|
char *text;
|
||||||
int size;
|
int size;
|
||||||
|
|
@ -206,13 +206,14 @@ GrTkTextSize(text, size, r)
|
||||||
size );
|
size );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (font == NULL) return;
|
if (font == NULL) return -1;
|
||||||
Tk_GetFontMetrics(font, &overall);
|
Tk_GetFontMetrics(font, &overall);
|
||||||
width = Tk_TextWidth(font, text, strlen(text));
|
width = Tk_TextWidth(font, text, strlen(text));
|
||||||
r->r_ytop = overall.ascent;
|
r->r_ytop = overall.ascent;
|
||||||
r->r_ybot = -overall.descent;
|
r->r_ybot = -overall.descent;
|
||||||
r->r_xtop = width;
|
r->r_xtop = width;
|
||||||
r->r_xbot = 0;
|
r->r_xbot = 0;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -493,7 +494,7 @@ grtkPutText (text, pos, clip, obscure)
|
||||||
|
|
||||||
if (grCurrent.font == NULL) return;
|
if (grCurrent.font == NULL) return;
|
||||||
|
|
||||||
GrTkTextSize(text, grCurrent.fontSize, &textrect);
|
if (GrTkTextSize(text, grCurrent.fontSize, &textrect) < 0) return;
|
||||||
|
|
||||||
location.r_xbot = pos->p_x + textrect.r_xbot;
|
location.r_xbot = pos->p_x + textrect.r_xbot;
|
||||||
location.r_xtop = pos->p_x + textrect.r_xtop;
|
location.r_xtop = pos->p_x + textrect.r_xtop;
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ extern void GrTkSetCMap();
|
||||||
extern void grtkPutText();
|
extern void grtkPutText();
|
||||||
extern void grtkFontText();
|
extern void grtkFontText();
|
||||||
extern void GrTkSetCursor();
|
extern void GrTkSetCursor();
|
||||||
extern void GrTkTextSize();
|
extern int GrTkTextSize();
|
||||||
extern void GrTkDrawGlyph();
|
extern void GrTkDrawGlyph();
|
||||||
extern void GrTkBitBlt();
|
extern void GrTkBitBlt();
|
||||||
extern void NullBitBlt();
|
extern void NullBitBlt();
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ extern void grx11PutText();
|
||||||
extern void grx11FontText();
|
extern void grx11FontText();
|
||||||
extern void grx11DefineCursor();
|
extern void grx11DefineCursor();
|
||||||
extern void GrX11SetCursor();
|
extern void GrX11SetCursor();
|
||||||
extern void GrX11TextSize();
|
extern int GrX11TextSize();
|
||||||
extern void GrX11DrawGlyph();
|
extern void GrX11DrawGlyph();
|
||||||
extern void GrX11BitBlt();
|
extern void GrX11BitBlt();
|
||||||
extern void NullBitBlt();
|
extern void NullBitBlt();
|
||||||
|
|
|
||||||
|
|
@ -228,7 +228,7 @@ grx11SetCharSize (size)
|
||||||
* Determine the size of a text string.
|
* Determine the size of a text string.
|
||||||
*
|
*
|
||||||
* Results:
|
* Results:
|
||||||
* None.
|
* Returns 0 when 'r' updated, otherwise -1 on error (no side-effects).
|
||||||
*
|
*
|
||||||
* Side effects:
|
* Side effects:
|
||||||
* A rectangle is filled in that is the size of the text in pixels.
|
* A rectangle is filled in that is the size of the text in pixels.
|
||||||
|
|
@ -237,7 +237,7 @@ grx11SetCharSize (size)
|
||||||
* ----------------------------------------------------------------------------
|
* ----------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
int
|
||||||
GrX11TextSize(text, size, r)
|
GrX11TextSize(text, size, r)
|
||||||
char *text;
|
char *text;
|
||||||
int size;
|
int size;
|
||||||
|
|
@ -266,12 +266,13 @@ GrX11TextSize(text, size, r)
|
||||||
size );
|
size );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (font == NULL) return;
|
if (font == NULL) return -1;
|
||||||
XTextExtents(font, text, strlen(text), &dir, &fa, &fd, &overall);
|
XTextExtents(font, text, strlen(text), &dir, &fa, &fd, &overall);
|
||||||
r->r_ytop = overall.ascent;
|
r->r_ytop = overall.ascent;
|
||||||
r->r_ybot = -overall.descent;
|
r->r_ybot = -overall.descent;
|
||||||
r->r_xtop = overall.width - overall.lbearing;
|
r->r_xtop = overall.width - overall.lbearing;
|
||||||
r->r_xbot = -overall.lbearing - 1;
|
r->r_xbot = -overall.lbearing - 1;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -790,7 +791,7 @@ grx11PutText (text, pos, clip, obscure)
|
||||||
|
|
||||||
if (grCurrent.font == NULL) return;
|
if (grCurrent.font == NULL) return;
|
||||||
|
|
||||||
GrX11TextSize(text, grCurrent.fontSize, &textrect);
|
if (GrX11TextSize(text, grCurrent.fontSize, &textrect) < 0) return;
|
||||||
|
|
||||||
location.r_xbot = pos->p_x + textrect.r_xbot;
|
location.r_xbot = pos->p_x + textrect.r_xbot;
|
||||||
location.r_xtop = pos->p_x + textrect.r_xtop;
|
location.r_xtop = pos->p_x + textrect.r_xtop;
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ typedef struct { /* Colormap table entry */
|
||||||
/* Housekeeping and initialization routines */
|
/* Housekeeping and initialization routines */
|
||||||
extern bool (*GrInitPtr)();
|
extern bool (*GrInitPtr)();
|
||||||
extern void (*GrClosePtr)();
|
extern void (*GrClosePtr)();
|
||||||
extern void (*GrTextSizePtr)();
|
extern int (*GrTextSizePtr)();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Display painting and text routines
|
* Display painting and text routines
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue