DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2525
Version: 1.3-current


The attached program shows a large discrepancy between the results of the
width of a string using fl_width() vs. fl_text_extents().

When run on OSX, output is:
----
With Helvetica size 12..
fl_width("X") says width is 7
fl_width('X') says width is 3
fl_text_extents() says width is 7
----

When run on linux, output is:
----
With Helvetica size 12..
fl_width("X") says width is 8
fl_width('X') says width is 8
fl_text_extents() says width is 8
----


Link: http://www.fltk.org/str.php?L2525
Version: 1.3-current
#include <stdio.h>
#include <FL/Fl.H>
#include <FL/fl_draw.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Double_Window.H>
void Button_CB(Fl_Widget*w, void*v) {
    fl_font(FL_HELVETICA, 12);
    // Use fl_width(char*)
    fprintf(stderr, "With Helvetica size 12..\n");
    fprintf(stderr, "fl_width(\"X\") says width is %d\n", (int)fl_width("X"));
    fprintf(stderr, "fl_width(\'X\') says width is %d\n", (int)fl_width('X'));
    int DX,DY,W,H; fl_text_extents("X",DX,DY,W,H);
    fprintf(stderr, "fl_text_extents() says width is %d\n", W);
}
int main() {
    Fl_Double_Window win(200,200);
    Fl_Button but(10,10,100,25,"Show Widths");
    but.callback(Button_CB);
    win.resizable(win);
    win.show();
    Button_CB(0,0);
    return(Fl::run());
}

_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs

Reply via email to