9 #define ALPHAS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" \
10 "1234567890`-=\\!@#$%^&*()~_+|[]{};':\",./<>?"
13 struct RrFont *RrFontOpen(struct RrInstance *inst, const char *fontstring)
18 font = malloc(sizeof(struct RrFont));
20 font->font = GlftFontOpen(RrDisplay(inst), RrScreen(inst), fontstring);
22 GlftMeasureString(font->font, ELIPSES, strlen(ELIPSES), &w, &h);
24 GlftMeasureString(font->font, ALPHAS, strlen(ALPHAS), &w, &h);
30 void RrFontClose(struct RrFont *font)
33 GlftFontClose(font->font);
38 int RrFontMeasureString(struct RrFont *font, const char *string)
41 GlftMeasureString(font->font, string, strlen(string), &w, &h);
45 int RrFontHeight(struct RrFont *font)
50 int RrFontMaxCharWidth(struct RrFont *font)
52 return GlftFontMaxCharWidth(font->font);
55 void RrFontRenderString(struct RrSurface *sur, struct RrFont *font,
56 struct RrColor *color, enum RrLayout layout,
57 const char *string, int x, int y, int w, int h)
60 int fh = RrFontHeight(font);
82 text = g_string_new(string);
83 l = g_utf8_strlen(text->str, -1);
84 m = RrFontMeasureString(font, text->str);
85 if (font->elipses > w)
86 l = 0; /* nothing fits.. */
90 /* remove a character from the middle */
91 text = g_string_erase(text, l-- / 2, 1);
92 /* if the elipses are too large, don't show them at all */
93 m = RrFontMeasureString(font, text->str) + font->elipses;
96 text = g_string_insert(text, (l + 1) / 2, ELIPSES);
114 case RR_BOTTOM_RIGHT:
123 GlftRenderString(font->font, text->str, strlen(text->str), &col, x, y);