add font ascent/descent checking

SVN revision: 3442
This commit is contained in:
Carsten Haitzler 2000-09-13 15:08:05 +00:00
parent 71d101387e
commit d660812fe8
8 changed files with 91 additions and 4 deletions

View File

@ -12,6 +12,7 @@ if test X"$enable_shared" = Xyes; then
DLLDFLAGS=-export-dynamic
AC_SUBST(DLLDFLAGS)
fi
AM_WITH_DMALLOC
AC_PROG_INSTALL
AC_PROG_MAKE_SET

View File

@ -328,6 +328,7 @@ char *evas_get_text_font(Evas e, Evas_Object o);
int evas_get_text_size(Evas e, Evas_Object o);
int evas_text_at_position(Evas e, Evas_Object o, double x, double y, int *char_x, int *char_y, int *char_w, int *char_h);
void evas_text_at(Evas e, Evas_Object o, int index, int *char_x, int *char_y, int *char_w, int *char_h);
void evas_text_get_ascent_descent(Evas e, Evas_Object o, double *ascent, double *descent);
/* object query ops */
void evas_get_color(Evas e, Evas_Object o, int *r, int *g, int *b, int *a);

View File

@ -1424,6 +1424,18 @@ __evas_gl_text_font_free(Evas_GL_Font *fn)
__evas_gl_text_cache_flush();
}
int
__evas_gl_text_font_get_ascent(Evas_GL_Font *fn)
{
return fn->ascent;
}
int
__evas_gl_text_font_get_descent(Evas_GL_Font *fn)
{
return fn->descent;
}
void
__evas_gl_text_font_add_path(char *path)
{

View File

@ -158,6 +158,8 @@ void __evas_gl_image_draw(Evas_GL_Image *im, Display *disp, Window w,
/********/
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);
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);

View File

@ -186,6 +186,20 @@ __evas_imlib_text_font_free(Evas_Imlib_Font *fn)
imlib_free_font();
}
int
__evas_imlib_text_font_get_ascent(Evas_Imlib_Font *fn)
{
imlib_context_set_font((Imlib_Font)fn);
return imlib_get_font_ascent();
}
int
__evas_imlib_text_font_get_descent(Evas_Imlib_Font *fn)
{
imlib_context_set_font((Imlib_Font)fn);
return imlib_get_font_descent();
}
void
__evas_imlib_text_font_add_path(char *path)
{

View File

@ -60,6 +60,8 @@ void __evas_imlib_image_draw(Evas_Imlib_Image *im, Display *disp, W
/********/
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);
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);

View File

@ -249,6 +249,53 @@ evas_text_at(Evas e, Evas_Object o, int index,
}
}
void
evas_text_get_ascent_descent(Evas e, Evas_Object o,
double *ascent, double *descent)
{
int a, d;
Evas_Object_Text oo;
oo = o;
a = 0; d = 0;
switch (e->current.render_method)
{
case RENDER_METHOD_ALPHA_SOFTWARE:
{
Evas_Imlib_Font *fn;
fn = __evas_imlib_text_font_new(e->current.display, oo->current.font, oo->current.size);
if (fn)
{
a = __evas_imlib_text_font_get_ascent(fn);
d = __evas_imlib_text_font_get_descent(fn);
__evas_imlib_text_font_free(fn);
}
}
break;
case RENDER_METHOD_BASIC_HARDWARE:
break;
case RENDER_METHOD_3D_HARDWARE:
{
Evas_GL_Font *fn;
fn = __evas_gl_text_font_new(e->current.display, oo->current.font, oo->current.size);
if (fn)
{
a = __evas_gl_text_font_get_ascent(fn);
d = __evas_gl_text_font_get_descent(fn);
__evas_gl_text_font_free(fn);
}
}
break;
case RENDER_METHOD_ALPHA_HARDWARE:
break;
default:
break;
}
if (ascent) *ascent = a;
if (descent) *descent = d;
}
void
evas_set_text(Evas e, Evas_Object o, char *text)

View File

@ -73,7 +73,7 @@ main(int argc, char **argv)
Colormap cmap;
Window win;
int win_w, win_h;
int i, a, w, h;
int i, a, w, h, m;
Evas e;
Evas_Object o[128], o_rect, o_line, o_grad, o_fps, o_text;
Evas_Gradient grad;
@ -149,7 +149,7 @@ main(int argc, char **argv)
h /= 2;
evas_show(e, o[1]);
for (i = 2 ; i < 120; i++)
for (i = 2 ; i < 10; i++)
{
o[i] = evas_add_image_from_file(e, "img/mush.png");
evas_show(e, o[i]);
@ -160,6 +160,7 @@ main(int argc, char **argv)
evas_callback_add(e, o[i], CALLBACK_MOUSE_IN, mouse_in, NULL);
evas_callback_add(e, o[i], CALLBACK_MOUSE_OUT, mouse_out, NULL);
}
/*
for (i = 120; i < 128; i++)
{
o[i] = evas_add_text(e, "notepad", 16, imgs[i & 0x7]);
@ -222,7 +223,7 @@ main(int argc, char **argv)
evas_callback_add(e, o_text, CALLBACK_MOUSE_MOVE, mouse_move, NULL);
evas_callback_add(e, o_text, CALLBACK_MOUSE_IN, mouse_in, NULL);
evas_callback_add(e, o_text, CALLBACK_MOUSE_OUT, mouse_out, NULL);
*/
o_fps = evas_add_text(e, "morpheus", 16, "FPS...");
evas_set_color(e, o_fps, 255, 255, 255, 120);
evas_move(e, o_fps, win_w, win_h);
@ -236,6 +237,7 @@ main(int argc, char **argv)
a = 0;
down = 0;
t1 = get_time();
m = 0;
for (;;)
{
double x, y;
@ -288,9 +290,10 @@ main(int argc, char **argv)
}
}
/* while (XPending(d));*/
for (i = 2; i < 128; i++)
for (i = 2; i < 10; i++)
{
int j, k;
double ww, hh;
if (!evas_get_data(e, o[i], "clicked"))
{
@ -301,11 +304,16 @@ main(int argc, char **argv)
if (i < 100)
evas_set_image_file(e, o[i], imgs[(i) & 0x7]);
evas_move(e, o[i], x, y);
ww = ((1.2 + cos((double)(a + j + m) * 2 * 3.141592654 / 1000)) * 48);
hh = ww;
evas_resize(e, o[i], ww, hh);
evas_set_image_fill(e, o[i], 0, 0, ww, hh);
}
}
evas_set_angle(e, o_grad, (double)a * 360 / 1000);
evas_render(e);
a++;
m++;
if ((a % 25) == 0)
{
char buf[64];