- // Here we are traversing the current colormap to find
- // the color closest to the one we want.
- Visual * vi = DefaultVisual(display, DefaultScreen(display));
-
- XColor * cmap = new XColor[vi->map_entries];
-
- for(int i = 0; i < vi->map_entries; ++i) {
- cmap[i].pixel = i;
- }
- XQueryColors(display, colormap, cmap, vi->map_entries);
-
- // Walk through the cmap and look for close colors.
- int closest_pixel = 0;
- double closest_distance = 1e20; // we want to minimize this
- double distance = 0;
- for(int t = 0; t < vi->map_entries; ++t) {
- // The Euclidean distance between two points in
- // a three-dimensional space, the RGB color-cube,
- // is used as the distance measurement between two
- // colors.
-
- // Since square-root is monotonous, we don't have to
- // take the square-root to find the minimum, and thus
- // we use the squared distance instead to be faster.
-
- // If we want to get fancy, we could convert the RGB
- // coordinates to a different color-cube, maybe HSV,
- // but the RGB cube seems to work great. (Asger)
- distance = pow(cmap[t].red - xcol.red, 2.0) +
- pow(cmap[t].green - xcol.green, 2.0) +
- pow(cmap[t].blue - xcol.blue, 2.0);
- if (distance < closest_distance) {
- closest_distance = distance;
- closest_pixel = t;
+ LyXFont smallfont(f);
+ smallfont.decSize().decSize().setShape(LyXFont::UP_SHAPE);
+ char c;
+ int tmpx = x;
+ for (size_t i = 0; i < ls; ++i) {
+ c = s[i];
+ if (islower(static_cast<unsigned char>(c))) {
+ c = toupper(c);
+ lyxfont::XSetFont(display, gc, smallfont);
+ XDrawString(display, owner.getPixmap(),
+ gc, tmpx, y, &c, 1);
+ tmpx += lyxfont::XTextWidth(smallfont, &c, 1);
+ } else {
+ lyxfont::XSetFont(display, gc, f);
+ XDrawString(display, owner.getPixmap(),
+ gc, tmpx, y, &c, 1);
+ tmpx += lyxfont::XTextWidth(f, &c, 1);