Open kross50 opened 6 years ago
(FIX) CLTextTool: Color: border width slider: causes text clipping at max setting:
The following is the fix for you to implement in 2 places:
(void)sizeToFitWithMaxWidth:(CGFloat)width lineHeight:(CGFloat)lineHeight { self.transform = CGAffineTransformIdentity; _label.transform = CGAffineTransformIdentity;
CGSize size = [_label sizeThatFits:CGSizeMake(width / (15/MAX_FONT_SIZE), FLT_MAX)]; size = CGSizeMake(size.width + 35., size.height + 35.); // ##### FIX added additional width and height to prevents clipping from increasing border width _label.frame = CGRectMake(16, 16, size.width, size.height);
CGFloat viewW = (_label.width + 32); CGFloat viewH = _label.font.lineHeight;
CGFloat ratio = MIN(width / viewW, lineHeight / viewH); [self setScale:ratio]; }
...
(id)initWithTool:(CLTextTool*)tool { self = [super initWithFrame:CGRectMake(0, 0, 132, 132)]; if(self){ _label = [[CLTextLabel alloc] init]; [_label setTextColor:[CLImageEditorTheme toolbarTextColor]]; _label.numberOfLines = 0; _label.backgroundColor = [UIColor clearColor]; _label.layer.borderColor = [[UIColor blackColor] CGColor]; _label.layer.cornerRadius = 3; _label.font = [UIFont systemFontOfSize:MAX_FONT_SIZE]; _label.minimumScaleFactor = 1/MAX_FONT_SIZE; _label.adjustsFontSizeToFitWidth = YES; _label.textAlignment = NSTextAlignmentCenter; self.text = @""; [self addSubview:_label];
CGSize size = [_label sizeThatFits:CGSizeMake(FLT_MAX, FLT_MAX)]; size = CGSizeMake(size.width + 35., size.height + 35.); // ##### FIX added additional width and height to prevents clipping from increasing border width _label.frame = CGRectMake(16, 16, size.width, size.height); self.frame = CGRectMake(0, 0, size.width + 32, size.height + 32); _deleteButton = [UIButton buttonWithType:UIButtonTypeCustom]; [_deleteButton setImage:[tool imageForKey:kCLTextToolDeleteIconName defaultImageName:@"btn_delete.png"] forState:UIControlStateNormal]; _deleteButton.frame = CGRectMake(0, 0, 32, 32); _deleteButton.center = _label.frame.origin; [_deleteButton addTarget:self action:@selector(pushedDeleteBtn:) forControlEvents:UIControlEventTouchUpInside]; [self addSubview:_deleteButton]; _circleView = [[CLCircleView alloc] initWithFrame:CGRectMake(0, 0, 32, 32)]; _circleView.center = CGPointMake(_label.width + _label.left, _label.height + _label.top); _circleView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin; _circleView.radius = 0.7; _circleView.color = [UIColor whiteColor]; _circleView.borderColor = [UIColor blackColor]; _circleView.borderWidth = 5; [self addSubview:_circleView]; _arg = 0; [self setScale:1]; [self initGestures];
} return self; }
I couldn't reproduce this issue. Are there any factors that depend on the environment?
(FIX) CLTextTool: Color: border width slider: causes text clipping at max setting:
The following is the fix for you to implement in 2 places:
(void)sizeToFitWithMaxWidth:(CGFloat)width lineHeight:(CGFloat)lineHeight { self.transform = CGAffineTransformIdentity; _label.transform = CGAffineTransformIdentity;
CGSize size = [_label sizeThatFits:CGSizeMake(width / (15/MAX_FONT_SIZE), FLT_MAX)]; size = CGSizeMake(size.width + 35., size.height + 35.); // ##### FIX added additional width and height to prevents clipping from increasing border width _label.frame = CGRectMake(16, 16, size.width, size.height);
CGFloat viewW = (_label.width + 32); CGFloat viewH = _label.font.lineHeight;
CGFloat ratio = MIN(width / viewW, lineHeight / viewH); [self setScale:ratio]; }
...
(id)initWithTool:(CLTextTool*)tool { self = [super initWithFrame:CGRectMake(0, 0, 132, 132)]; if(self){ _label = [[CLTextLabel alloc] init]; [_label setTextColor:[CLImageEditorTheme toolbarTextColor]]; _label.numberOfLines = 0; _label.backgroundColor = [UIColor clearColor]; _label.layer.borderColor = [[UIColor blackColor] CGColor]; _label.layer.cornerRadius = 3; _label.font = [UIFont systemFontOfSize:MAX_FONT_SIZE]; _label.minimumScaleFactor = 1/MAX_FONT_SIZE; _label.adjustsFontSizeToFitWidth = YES; _label.textAlignment = NSTextAlignmentCenter; self.text = @""; [self addSubview:_label];
} return self; }