FLTK logo

Re: [fltk.general] bug in fl_measure?

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: bug in fl_measure? magik Apr 26, 2006  
 
here is code, it is strange, if text is text without spaces it returns good
w value, but if there are spaces "sadfsdfasdf adsfasdf" it gives w some
about "sadfsdfasdf" but not all... h value is alvays good...

code:

void GedDrawings::DrawText(int x, int y, const char *text, int
font)                /* Text. */
{
  int w, h;
  uchar r, g, b;
  int text_size = mainWin->toolbar->get_font_size_int();
  fl_font(font,text_size);
  fl_measure(text, w, h);
  cout << w << ":" << h << "\n";
  uchar *buff = new uchar[w * h * 3];
  Fl::get_color(color_, r, g, b);
  Fl_Color tmp_color = fl_rgb_color(r, g, b);  //docasna barva popredi
  Fl_Color back_color_ = (tmp_color == fl_rgb_color(255,255,255)) ?
fl_rgb_color(0,0,0) : fl_rgb_color(255,255,255);
  GEDMyText MyText(w, h, text, tmp_color, back_color_);
  MyText.SetFont(text_size, font);
  MyText.GetBuffer(buff);
  for (int y1 = 0; y1 < h; y1++)
  {
    for (int x1 = 0; x1 < w; x1++)
    {
      int index2 = (x1 + y1 * w) * 3;
      r = buff[index2];
      g = buff[index2+1];
      b = buff[index2+2];
      color_ = fl_rgb_color(r, g, b);
      if (color_ != back_color_)
      {
        PutPixel(x+x1, y+y1);
      }
    }
  }
  color_ = tmp_color;  //nastav barvu zpet...
//   Fl::redraw();
  delete [] buff;
}


matthiasm wrote:

> 
> Did you set a font first? Did you use the fl_measure for labels and
> give the box a zero size?
> 
> Please post some sample code so we can see what you are trying to do.
> 
> On Apr 26, 2006, at 10:38 AM, magik wrote:
> 
>> try get values for text with spaces:-) In my case, it gets bad
>> values: fltk
>> v 1.1.7
> 
> Matthias
> 
> ----
> http://robowerk.com/


Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.