From 54af8d51ff8c955b6838d9e2b0bc4c173a3d154a Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Wed, 13 Sep 2000 17:11:53 +0000 Subject: [PATCH] routiens for mroe text info..... SVN revision: 3454 --- legacy/evas/src/evas_gl_routines.c | 60 +++++++++++++++++++++++++++ legacy/evas/src/evas_gl_routines.h | 4 ++ legacy/evas/src/evas_imlib_routines.c | 30 ++++++++++++++ legacy/evas/src/evas_imlib_routines.h | 4 ++ 4 files changed, 98 insertions(+) diff --git a/legacy/evas/src/evas_gl_routines.c b/legacy/evas/src/evas_gl_routines.c index 2ede0d6091..e419b01bfb 100644 --- a/legacy/evas/src/evas_gl_routines.c +++ b/legacy/evas/src/evas_gl_routines.c @@ -1436,6 +1436,66 @@ __evas_gl_text_font_get_descent(Evas_GL_Font *fn) return fn->descent; } +int +__evas_gl_text_font_get_max_ascent(Evas_GL_Font *fn) +{ + return fn->max_ascent / 64; +} + +int +__evas_gl_text_font_get_max_descent(Evas_GL_Font *fn) +{ + return fn->max_descent / 64; +} + +void +__evas_gl_text_font_get_advances(Evas_GL_Font *fn, char *text, + int *advance_horiz, + int *advance_vert) +{ + int i, ascent, descent, pw, ph; + TT_Glyph_Metrics gmetrics; + + ascent = fn->ascent; + descent = fn->descent; + pw = 0; + ph = ascent + descent; + + for (i = 0; text[i]; i++) + { + unsigned char j; + + j = text[i]; + if (!TT_VALID(fn->glyphs[j])) + continue; + TT_Get_Glyph_Metrics(fn->glyphs[j], &gmetrics); + if (i == 0) + pw += ((-gmetrics.bearingX) / 64); + pw += gmetrics.advance / 64; + } + *advance_horiz = pw; + *advance_vert = ph; +} + +int +__evas_gl_text_font_get_first_inset(Evas_GL_Font *fn, char *text) +{ + int i; + TT_Glyph_Metrics gmetrics; + + for (i = 0; text[i]; i++) + { + unsigned char j; + + j = text[i]; + if (!TT_VALID(fn->glyphs[j])) + continue; + TT_Get_Glyph_Metrics(fn->glyphs[j], &gmetrics); + return ((-gmetrics.bearingX) / 64); + } + return 0; +} + void __evas_gl_text_font_add_path(char *path) { diff --git a/legacy/evas/src/evas_gl_routines.h b/legacy/evas/src/evas_gl_routines.h index c9d7e4b003..8b2caa7d5f 100644 --- a/legacy/evas/src/evas_gl_routines.h +++ b/legacy/evas/src/evas_gl_routines.h @@ -160,6 +160,10 @@ Evas_GL_Font *__evas_gl_text_font_new(Display *disp, char *font, int size); void __evas_gl_text_font_free(Evas_GL_Font *fn); int __evas_gl_text_font_get_ascent(Evas_GL_Font *fn); int __evas_gl_text_font_get_descent(Evas_GL_Font *fn); +int __evas_gl_text_font_get_max_ascent(Evas_GL_Font *fn); +int __evas_gl_text_font_get_max_descent(Evas_GL_Font *fn); +void __evas_gl_text_font_get_advances(Evas_GL_Font *fn, char *text, int *advance_horiz, int *advance_vert); +int __evas_gl_text_font_get_first_inset(Evas_GL_Font *fn, char *text); void __evas_gl_text_font_add_path(char *path); void __evas_gl_text_font_del_path(char *path); char **__evas_gl_text_font_list_paths(int *count); diff --git a/legacy/evas/src/evas_imlib_routines.c b/legacy/evas/src/evas_imlib_routines.c index 4b13e52dec..2038cc98f4 100644 --- a/legacy/evas/src/evas_imlib_routines.c +++ b/legacy/evas/src/evas_imlib_routines.c @@ -200,6 +200,36 @@ __evas_imlib_text_font_get_descent(Evas_Imlib_Font *fn) return imlib_get_font_descent(); } +int +__evas_imlib_text_font_get_max_ascent(Evas_Imlib_Font *fn) +{ + imlib_context_set_font((Imlib_Font)fn); + return imlib_get_maximum_font_ascent(); +} + +int +__evas_imlib_text_font_get_max_descent(Evas_Imlib_Font *fn) +{ + imlib_context_set_font((Imlib_Font)fn); + return imlib_get_maximum_font_descent(); +} + +void +__evas_imlib_text_font_get_advances(Evas_Imlib_Font *fn, char *text, + int *advance_horiz, + int *advance_vert) +{ + imlib_context_set_font((Imlib_Font)fn); + imlib_get_text_advance(text, advance_horiz, advance_vert); +} + +int +__evas_imlib_text_font_get_first_inset(Evas_Imlib_Font *fn, char *text) +{ + imlib_context_set_font((Imlib_Font)fn); + return imlib_get_text_inset(text); +} + void __evas_imlib_text_font_add_path(char *path) { diff --git a/legacy/evas/src/evas_imlib_routines.h b/legacy/evas/src/evas_imlib_routines.h index 90f2c68d34..ce8761f399 100644 --- a/legacy/evas/src/evas_imlib_routines.h +++ b/legacy/evas/src/evas_imlib_routines.h @@ -62,6 +62,10 @@ Evas_Imlib_Font *__evas_imlib_text_font_new(Display *disp, char *font, int size void __evas_imlib_text_font_free(Evas_Imlib_Font *fn); int __evas_imlib_text_font_get_ascent(Evas_Imlib_Font *fn); int __evas_imlib_text_font_get_descent(Evas_Imlib_Font *fn); +int __evas_imlib_text_font_get_max_ascent(Evas_Imlib_Font *fn); +int __evas_imlib_text_font_get_max_descent(Evas_Imlib_Font *fn); +void __evas_imlib_text_font_get_advances(Evas_Imlib_Font *fn, char *text, int *advance_horiz, int *advance_vert); +int __evas_imlib_text_font_get_first_inset(Evas_Imlib_Font *fn, char *text); void __evas_imlib_text_font_add_path(char *path); void __evas_imlib_text_font_del_path(char *path); char **__evas_imlib_text_font_list_paths(int *count);