diff --git a/doc/index.html b/doc/index.html index 86fffcd..18137ad 100644 --- a/doc/index.html +++ b/doc/index.html @@ -1507,6 +1507,13 @@ font. The advances are not adjusted for rotation so you will have to translate the advances (which are calculated as if the text was drawn horizontally from left to right) depending on the text orientation. +
+int imlib_get_text_inset(const char *text);
+ +
This function returns the inset of the first character of the +text string passed in using the current font and returns that value in pixels. +
+
void imlib_add_path_to_font_path(const char *path);
This function adds the directory path to the end of the current diff --git a/src/Imlib2.h b/src/Imlib2.h index 2234948..75832ac 100644 --- a/src/Imlib2.h +++ b/src/Imlib2.h @@ -267,6 +267,7 @@ extern "C" void imlib_get_text_advance(const char *text, int *horizontal_advance_return, int *vertical_advance_return); + int imlib_get_text_inset(const char *text); 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); diff --git a/src/api.c b/src/api.c index 3d9de19..6fda303 100644 --- a/src/api.c +++ b/src/api.c @@ -1714,6 +1714,17 @@ void imlib_get_text_advance(const char *text, *vertical_advance_return = h; } +int imlib_get_text_inset(const char *text) +{ + ImlibFont *fn; + int w, h; + + CHECK_PARAM_POINTER_RETURN("imlib_get_text_advance", "font", ctxt_font, 0); + CHECK_PARAM_POINTER_RETURN("imlib_get_text_advance", "text", text, 0); + fn = (ImlibFont *) ctxt_font; + return __imlib_calc_inset(fn, text); +} + void imlib_add_path_to_font_path(const char *path) { diff --git a/src/colormod.c b/src/colormod.c index d88ba64..d98ed80 100644 --- a/src/colormod.c +++ b/src/colormod.c @@ -77,7 +77,7 @@ __imlib_CmodReset(ImlibColorModifier *cm) void __imlib_DataCmodApply(DATA32 *data, int w, int h, int jump, - int *fl, ImlibColorModifier *cm) + ImlibImageFlags *fl, ImlibColorModifier *cm) { int x, y; DATA32 *p; diff --git a/src/colormod.h b/src/colormod.h index c8fc0be..3845fe3 100644 --- a/src/colormod.h +++ b/src/colormod.h @@ -1,6 +1,17 @@ #ifndef __COLORMOD #define __COLORMOD 1 +#include "common.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include "image.h" + typedef struct _imlib_color_modifier ImlibColorModifier; struct _imlib_color_modifier @@ -48,7 +59,7 @@ void __imlib_CmodSetTables(ImlibColorModifier *cm, DATA8 *r, DATA8 *g, DATA8 *b, DATA8 *a); void __imlib_CmodReset(ImlibColorModifier *cm); void __imlib_DataCmodApply(DATA32 *data, int w, int h, - int jump, int *fl, + int jump, ImlibImageFlags *fl, ImlibColorModifier *cm); void __imlib_CmodGetTables(ImlibColorModifier *cm, DATA8 *r, diff --git a/src/font.c b/src/font.c index f45ccde..2cce756 100644 --- a/src/font.c +++ b/src/font.c @@ -408,6 +408,25 @@ __imlib_calc_advance(ImlibFont *f, int *adv_w, int *adv_h, const char *text) *adv_h = ph; } +int +__imlib_calc_inset(ImlibFont *f, const char *text) +{ + int i; + TT_Glyph_Metrics gmetrics; + + 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); + return ((-gmetrics.bearingX) / 64); + } + return 0; +} + void __imlib_render_str(ImlibImage *im, ImlibFont *fn, int drx, int dry, const char *text, DATA8 r, DATA8 g, DATA8 b, DATA8 a, diff --git a/src/font.h b/src/font.h index 4df738a..ff9709c 100644 --- a/src/font.h +++ b/src/font.h @@ -35,6 +35,7 @@ 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); +int __imlib_calc_inset(ImlibFont *f, 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, diff --git a/src/rend.c b/src/rend.c index 65a3fc8..685ada7 100644 --- a/src/rend.c +++ b/src/rend.c @@ -1,4 +1,5 @@ #include +#include #include #include "common.h" #include "colormod.h" @@ -11,6 +12,7 @@ #include "grab.h" #include "blend.h" #include "rend.h" +#include "rotate.h" /* size of the lines per segment we scale / render at a time */ #define LINESIZE 16 @@ -354,11 +356,7 @@ __imlib_RenderImageSkewed(Display *d, ImlibImage *im, Drawable w, Drawable m, char dither_mask, ImlibColorModifier *cmod, ImlibOp op) { - XImage *xim = NULL, *mxim = NULL; Context *ct; - static GC gc = 0; - static GC gcm = 0; - XGCValues gcv; int dx1, dy1, dx2, dy2, dw, dh, tsx, tsy; ImlibImage *back;