bugGNUstep - Bugs: bug #21696, [NSText sizeToFit] resizes only to...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #21696: [NSText sizeToFit] resizes only to include the first character

Submitted by:  Christopher Wojno <wojno>
Submitted on:  Sun 02 Dec 2007 03:08:09 AM UTC  
 
Category: Gui/AppKitSeverity: 3 - Normal
Item Group: BugStatus: Fixed
Privacy: PublicAssigned to: Fred Kiefer <FredKiefer>
Open/Closed: Closed

Fri 04 Jan 2008 09:04:10 PM UTC, comment #2:

I added some code to SVN that should fix this problem. Please test it an report back.

Fred Kiefer <FredKiefer>
Project MemberIn charge of this item.
Thu 27 Dec 2007 04:30:45 PM UTC, comment #1:

I spend some time tracking down this problem and as far as I can tell it is caused by GSHorizontalTypesetter. There in the method layoutLineNewParagraph: we get a rectangle for the next set of glyphs and this is already limited by the text container size. In our case the text container has a size of (1, 15) and we and up with an almost empty rectangle to layout into.
What happens is that the first character already overlaps and it tries to break the line. As this fails the rest of the characters as set to invisible and a wrong rectangle gets computed.

I don't have a glue how to solve this. One way would be to already report the text container size differently, when it is resizesable. Or use this information in some other way here. But the whole code looks rather fragile and I dare not touch it.

Fred Kiefer <FredKiefer>
Project MemberIn charge of this item.
Sun 02 Dec 2007 03:08:09 AM UTC, original submission:

Similar to bug #21695, however, while I claimed Horizontal worked, it changed the size only such that the first character in the string sent to the NSText by setString is sized. The remainder of the string is clipped.

NSText *text;
text = [[NSText alloc] initWithFrame:NSMakeRect(0,0,1,15)];
[text setHorizontallyResizable:YES];
[text setVerticallyResizable:NO]; // fails with this YES or NO
[text setFont:[NSFont fontWithName:@"Helvetica" size:10]];
[text setString: @"Menu"];
[text sizeToFit];
NSRect bad = [text frame];

Result:
12 = bad.size.width

One may think that a work-around would be to manually set the frame after multiplying it. This is not the case: Twelve pixes is APPROXIMATELY 1/4th the size as the string is 4 characters. But that is only an estimation and exact only with Monospaced fonts. Additionally, attempts to set the width AFTER a sizeToFit call have not effect.

Summary:

  • Resized incorrectly (wrong width)
  • Cannot manually set width later (by design?)
Christopher Wojno <wojno>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by FredKiefer (Posted a comment)
  • -unavailable- added by wojno (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 29 Nov 2008 02:05:37 PM UTCFredKieferStatusReady For Test=>Fixed
      Open/ClosedIn Test=>Closed
    Fri 04 Jan 2008 09:04:10 PM UTCFredKieferStatusNone=>Ready For Test
      Assigned toNone=>FredKiefer
      Open/ClosedOpen=>In Test

    Back to the top


    Powered by Savane 3.1-cleanup1