void Fl_Device::rtl_draw(const char *str, int n, float x, float y) { // USE BUFFER HERE ALSO SetTextColor(fl_gc, fl_colorref); SelectObject(fl_gc, current_font); int i = 0; int lx = 0; const WCHAR *skod; resize_buffer(n); int wn = fl_utf2unicode((const unsigned char *)str, n, wstr); while (i < wn) { lx = int(fl_width(wstr[i])); x -= lx; skod = (const WCHAR*)wstr + i; #ifndef _WIN32_WCE TextOutW(fl_gc, int(floor(x+.5f)), int(floor(y+.5f)), skod, 1); #else RECT rect = {int(floor(x+.5f)),int(floor(y+.5f)), 0,0}; DrawText(fl_gc, skod, 1, &rect, DT_SINGLELINE | DT_TOP | DT_LEFT | DT_NOCLIP); #endif if (fl_nonspacing(wstr[i])) { x += lx; } i++; } }
float Fl_Device::width(unsigned int c) const { #if HAVE_XUTF8 unsigned int ucs; unsigned int ulen = fl_fast_utf2ucs((unsigned char*)&c, 1, &ucs); if (ulen < 1) ulen = 1; unsigned int no_spc = fl_nonspacing(ucs); if(no_spc) ucs = no_spc; char glyph[2]; if(fl_ucs2fontmap(glyph, ucs, fl_fontsize->encoding_num) < 0) { // the char is not valid in this encoding fl_ucs2fontmap(glyph, '?', fl_fontsize->encoding_num); } XChar2b char2[2]; char2[0].byte1 = glyph[1]; char2[0].byte2 = glyph[0]; char2[1].byte1 = char2[1].byte2 = 0; return XTextWidth16(current_font, char2, 1); #else char ch=char(c); return width(&ch,1); #endif }
void Fl_Device::transformed_draw(const char *str, int n, float x, float y) { if (font_gc != fl_gc) { font_gc = fl_gc; XSetFont(fl_display, fl_gc, current_font->fid); } int X = int(floor(x+.5f)); int Y = int(floor(y+.5f)); #if HAVE_XUTF8 char glyph[2]; // byte1 and byte2 value of the UTF-8 char XChar2b buf[128]; // drawing buffer int pos = 0; // position in buffer int ulen; // byte length of the UTF-8 char unsigned int ucs; // Unicode value of the UTF-8 char unsigned int no_spc; // Spacing char equivalent of a non-spacing char while(n > 0) { if(pos>120) { XDrawString16(fl_display, fl_window, fl_gc, X, Y, buf, pos); X += XTextWidth16(current_font, buf, pos); pos = 0; } ulen = fl_fast_utf2ucs((unsigned char*)str, n, &ucs); if (ulen < 1) ulen = 1; no_spc = fl_nonspacing(ucs); if(no_spc) ucs = no_spc; if(fl_ucs2fontmap(glyph, ucs, fl_fontsize->encoding_num) < 0) { // the char is not valid in this encoding fl_ucs2fontmap(glyph, '?', fl_fontsize->encoding_num); } if(no_spc) { XDrawString16(fl_display, fl_window, fl_gc, X, Y, buf, pos); X += XTextWidth16(current_font, buf, pos); pos = 0; (*buf).byte1 = glyph[1]; (*buf).byte2 = glyph[0]; X -= XTextWidth16(current_font, buf, 1); } else { (*(buf + pos)).byte1 = glyph[1]; (*(buf + pos)).byte2 = glyph[0]; } pos++; str += ulen; n-=ulen; } if(pos>0) XDrawString16(fl_display, fl_window, fl_gc, X, Y, buf, pos); #else XDrawString(fl_display, fl_window, fl_gc, X, Y, str, n); #endif }
float Fl_Device::width(const char *str, int n) const { #if HAVE_XUTF8 char glyph[2]; // byte1 and byte2 value of the UTF-8 char XChar2b buf[128]; // measure buffer int pos = 0; // position in buffer int ulen; // byte length of the UTF-8 char unsigned int ucs; // Unicode value of the UTF-8 char unsigned int no_spc; // Spacing char equivalent of a non-spacing char float W=0; while(n > 0) { if(pos>120) { W += XTextWidth16(current_font, buf, pos); pos = 0; } ulen = fl_fast_utf2ucs((unsigned char*)str, n, &ucs); if (ulen < 1) ulen = 1; no_spc = fl_nonspacing(ucs); if(no_spc) ucs = no_spc; if(fl_ucs2fontmap(glyph, ucs, fl_fontsize->encoding_num) < 0) { // the char is not valid in this encoding fl_ucs2fontmap(glyph, '?', fl_fontsize->encoding_num); } if(no_spc) { W += XTextWidth16(current_font, buf, pos); pos = 0; (*buf).byte1 = glyph[1]; (*buf).byte2 = glyph[0]; W -= XTextWidth16(current_font, buf, 1); } else { (*(buf + pos)).byte1 = glyph[1]; (*(buf + pos)).byte2 = glyph[0]; } pos++; str += ulen; n-=ulen; } if(pos>0) W += XTextWidth16(current_font, buf, pos); return W; #else return XTextWidth(current_font, str, n); #endif }
float Fl_Device::width(const char* c, int n) const { int i = 0; float w = 0; unsigned int ucs; while (i < n) { int l = fl_fast_utf2ucs((const unsigned char*)c + i, n - i, &ucs); if (l < 1) l = 1; i += l; if (!fl_nonspacing(ucs)) { w += fl_width(ucs); } } return w; }
void Fl_Device::transformed_draw(const char *str, int n, float x, float y) { SetTextColor(fl_gc, fl_colorref); SelectObject(fl_gc, current_font); #ifdef _WIN32_WCE RECT rect = { int(floor(x+.5f)), int(floor(y+.5f)), 0, 0 }; #else int X = int(floor(x+.5f)); int Y = int(floor(y+.5f)); #endif unsigned ucs; unsigned no_spc; WCHAR buf[128]; // drawing buffer int pos = 0; // position in buffer while(n > 0) { if(pos>120) { #ifdef _WIN32_WCE DrawText(fl_gc, buf, pos, &rect, DT_SINGLELINE | DT_TOP | DT_LEFT | DT_NOCLIP); rect.left += wchar_width(buf, pos); #else TextOutW(fl_gc, X, Y, buf, pos); X += wchar_width(buf, pos); #endif pos = 0; } int ulen = fl_fast_utf2ucs((unsigned char*)str, n, &ucs); if (ulen < 1) ulen = 1; no_spc = fl_nonspacing(ucs); if(no_spc) ucs = no_spc; buf[pos] = ucs; if(no_spc) { #ifdef _WIN32_WCE DrawText(fl_gc, buf, pos, &rect, DT_SINGLELINE | DT_TOP | DT_LEFT | DT_NOCLIP); rect.left += wchar_width(buf, pos); rect.left -= fl_width(buf[pos]); #else TextOutW(fl_gc, X, Y, buf, pos); X += wchar_width(buf, pos); X -= fl_width(buf[pos]); #endif buf[0] = ucs; pos = 0; } pos++; str += ulen; n-=ulen; } if(pos>0) #ifdef _WIN32_WCE DrawText(fl_gc, buf, pos, &rect, DT_SINGLELINE | DT_TOP | DT_LEFT | DT_NOCLIP); #else TextOutW(fl_gc, X, Y, buf, pos); #endif }