forked from old/legacy-imlib2
add api call to get text string advances........
SVN revision: 3447
This commit is contained in:
parent
b4491f3c7c
commit
2d96eee956
|
@ -264,6 +264,9 @@ extern "C"
|
|||
int *vertical_advance_return);
|
||||
void imlib_get_text_size(const char *text, int *width_return,
|
||||
int *height_return);
|
||||
void imlib_get_text_advance(const char *text,
|
||||
int *horizontal_advance_return,
|
||||
int *vertical_advance_return);
|
||||
void imlib_add_path_to_font_path(const char *path);
|
||||
void imlib_remove_path_from_font_path(const char *path);
|
||||
char **imlib_list_font_path(int *number_return);
|
||||
|
|
17
src/api.c
17
src/api.c
|
@ -1697,6 +1697,23 @@ imlib_get_text_size(const char *text, int *width_return, int *height_return)
|
|||
}
|
||||
}
|
||||
|
||||
void imlib_get_text_advance(const char *text,
|
||||
int *horizontal_advance_return,
|
||||
int *vertical_advance_return)
|
||||
{
|
||||
ImlibFont *fn;
|
||||
int w, h;
|
||||
|
||||
CHECK_PARAM_POINTER("imlib_get_text_advance", "font", ctxt_font);
|
||||
CHECK_PARAM_POINTER("imlib_get_text_advance", "text", text);
|
||||
fn = (ImlibFont *) ctxt_font;
|
||||
__imlib_calc_advance(fn, &w, &h, text);
|
||||
if (horizontal_advance_return)
|
||||
*horizontal_advance_return = w;
|
||||
if (vertical_advance_return)
|
||||
*vertical_advance_return = h;
|
||||
}
|
||||
|
||||
void
|
||||
imlib_add_path_to_font_path(const char *path)
|
||||
{
|
||||
|
|
27
src/font.c
27
src/font.c
|
@ -381,6 +381,33 @@ __imlib_calc_size(ImlibFont *f, int *width, int *height, const char *text)
|
|||
*height = ph;
|
||||
}
|
||||
|
||||
void
|
||||
__imlib_calc_advance(ImlibFont *f, int *adv_w, int *adv_h, const char *text)
|
||||
{
|
||||
int i, ascent, descent, pw, ph;
|
||||
TT_Glyph_Metrics gmetrics;
|
||||
|
||||
ascent = f->ascent;
|
||||
descent = f->descent;
|
||||
pw = 0;
|
||||
ph = ascent + descent;
|
||||
|
||||
for (i = 0; text[i]; i++)
|
||||
{
|
||||
unsigned char j;
|
||||
|
||||
j = text[i];
|
||||
if (!TT_VALID(f->glyphs[j]))
|
||||
continue;
|
||||
TT_Get_Glyph_Metrics(f->glyphs[j], &gmetrics);
|
||||
if (i == 0)
|
||||
pw += ((-gmetrics.bearingX) / 64);
|
||||
pw += gmetrics.advance / 64;
|
||||
}
|
||||
*adv_w = pw;
|
||||
*adv_h = ph;
|
||||
}
|
||||
|
||||
void
|
||||
__imlib_render_str(ImlibImage *im, ImlibFont *fn, int drx, int dry, const char *text,
|
||||
DATA8 r, DATA8 g, DATA8 b, DATA8 a,
|
||||
|
|
|
@ -33,6 +33,8 @@ ImlibFont *__imlib_load_font(const char *fontname);
|
|||
void __imlib_free_font(ImlibFont *font);
|
||||
void __imlib_calc_size(ImlibFont *f, int *width, int *height,
|
||||
const char *text);
|
||||
void __imlib_calc_advance(ImlibFont *f, int *adv_w, int *adv_h,
|
||||
const char *text);
|
||||
void __imlib_render_str(ImlibImage *im, ImlibFont *fn, int drx,
|
||||
int dry, const char *text,
|
||||
DATA8 r, DATA8 g, DATA8 b, DATA8 a,
|
||||
|
|
Loading…
Reference in New Issue