Text crashes when switching to non-integer font sizes

Create issue
Issue #86 resolved
Thomas Moeller created an issue

Text displayed with SoText2 nodes triggers memory access violations when changing the font size to a non integer value. The attached scene graph reproduces the issue. Moving the point dragger from left to right, which is connected to the font size, will trigger an application crash.

FontBug.jpg

The issue is related to caching of glyphs. Accessing glyphs that are assumed to be in the cache fails because the glyph2d_specmatch() function in the file glyph2d.cpp returns a mismatch of two font specifications that are identical except for the font size fraction. Changing the function to do an integer comparison of the font size fixes the issue.

static SbBool 
glyph2d_specmatch(const cc_font_specification * spec1, 
                  const cc_font_specification * spec2)
{
  assert(spec1);
  assert(spec2);

  if ((!cc_string_compare(&spec1->name, &spec2->name)) &&
      (!cc_string_compare(&spec1->style, &spec2->style)) &&
      (int(spec1->size) == int(spec2->size))) {
    /* No need to compare complexity for 2D fonts */
    return TRUE;
  }
  else return FALSE;
}

Comments (4)

  1. Roy Walmsley

    Thomas

    I tested this with your iv file and verified, both the original bug and that the change fixes it.

    I'll just implement a fix.

    Roy

  2. Log in to comment