Results 1 to 4 of 4

Thread: Bug in 2.1? CL_Font::get_text_size

  1. #1
    Lesser Knight
    Join Date
    Jan 2010
    Posts
    52

    Default Bug in 2.1? CL_Font::get_text_size

    I think the CL_Font::get_text_size is returning the wrong height when you have \n in your string. Not sure if this is fixed in 2.2 or not.

    If my string is "Hello", my height is 37. But if my string is "Hello\nHello" I get a height of 111. Seems like it ought to be around 74.

  2. #2
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Yes, you are right

    (This both exists in both 2.1 and 2.2)

    "CL_Size CL_Font::get_text_size(CL_GraphicContext &gc, const CL_StringRef &text)"

    contains:

    Code:
    int line_spacing = fm.get_height() + fm.get_external_leading();
    CL_Size line_size = get_provider()->get_text_size(gc, lines[i]);
    if ((i+1) != lines.size())	// Do not add the line spacing on the last line
    	line_size.height += line_spacing;
    The line "int line_spacing" is obviously wrong.

    I personally haven't got time to create a patch at the moment.

  3. #3
    Lesser Knight
    Join Date
    Jan 2010
    Posts
    52

    Default

    Should it just be external leading?

  4. #4
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Yeah, I think so.

    Until it's patched, I think that you can simply copy the code in:

    "CL_Size CL_Font::get_text_size(CL_GraphicContext &gc, const CL_StringRef &text)"

    ... and fix it, and use it directly in your application.

    (Because CL_Font contains get_provider() as a public function )

Similar Threads

  1. I need help using CL_Font with a System font on the Mac
    By eoliveri in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 08-07-2007, 01:59 PM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •