aboutsummaryrefslogtreecommitdiff
path: root/dw/fltkplatform.cc
diff options
context:
space:
mode:
Diffstat (limited to 'dw/fltkplatform.cc')
-rw-r--r--dw/fltkplatform.cc48
1 files changed, 42 insertions, 6 deletions
diff --git a/dw/fltkplatform.cc b/dw/fltkplatform.cc
index 68819c91..099c449c 100644
--- a/dw/fltkplatform.cc
+++ b/dw/fltkplatform.cc
@@ -141,7 +141,7 @@ FltkFont::~FltkFont ()
static void strstrip(char *big, const char *little)
{
if (strlen(big) >= strlen(little) &&
- strcasecmp(big + strlen(big) - strlen(little), little) == 0)
+ misc::AsciiStrcasecmp(big + strlen(big) - strlen(little), little) == 0)
*(big + strlen(big) - strlen(little)) = '\0';
}
@@ -525,14 +525,18 @@ int FltkPlatform::textWidth (core::style::Font *font, const char *text,
if ((cu = fl_toupper(c)) == c) {
/* already uppercase, just draw the character */
fl_font(ff->font, ff->size);
- width += font->letterSpacing;
- width += (int)fl_width(text + curr, next - curr);
+ if (fl_nonspacing(cu) == 0) {
+ width += font->letterSpacing;
+ width += (int)fl_width(text + curr, next - curr);
+ }
} else {
/* make utf8 string for converted char */
nb = fl_utf8encode(cu, chbuf);
fl_font(ff->font, sc_fontsize);
- width += font->letterSpacing;
- width += (int)fl_width(chbuf, nb);
+ if (fl_nonspacing(cu) == 0) {
+ width += font->letterSpacing;
+ width += (int)fl_width(chbuf, nb);
+ }
}
}
} else {
@@ -544,7 +548,9 @@ int FltkPlatform::textWidth (core::style::Font *font, const char *text,
while (next < len) {
next = nextGlyph(text, curr);
- width += font->letterSpacing;
+ c = fl_utf8decode(text + curr, text + next, &nb);
+ if (fl_nonspacing(c) == 0)
+ width += font->letterSpacing;
curr = next;
}
}
@@ -553,6 +559,36 @@ int FltkPlatform::textWidth (core::style::Font *font, const char *text,
return width;
}
+char *FltkPlatform::textToUpper (const char *text, int len)
+{
+ char *newstr = NULL;
+
+ if (len > 0) {
+ int newlen;
+
+ newstr = (char*) malloc(3 * len + 1);
+ newlen = fl_utf_toupper((const unsigned char*)text, len, newstr);
+ assert(newlen <= 3 * len);
+ newstr[newlen] = '\0';
+ }
+ return newstr;
+}
+
+char *FltkPlatform::textToLower (const char *text, int len)
+{
+ char *newstr = NULL;
+
+ if (len > 0) {
+ int newlen;
+
+ newstr = (char*) malloc(3 * len + 1);
+ newlen = fl_utf_tolower((const unsigned char*)text, len, newstr);
+ assert(newlen <= 3 * len);
+ newstr[newlen] = '\0';
+ }
+ return newstr;
+}
+
int FltkPlatform::nextGlyph (const char *text, int idx)
{
return fl_utf8fwd (&text[idx + 1], text, &text[strlen (text)]) - text;