[TIMOB-15856] iOS: Titanium.UI.iOS.AttributedString clipping problems when used with ATTRIBUTE_BASELINE_OFFSET
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Not Our Bug |
Resolution Date | 2013-12-03T00:24:41.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | n/a |
Labels | ATTRIBUTE_BASELINE_OFFSET, AttributedString, look1 |
Reporter | Malcolm Hollingsworth |
Assignee | Pedro Enrique |
Created | 2013-11-29T16:42:51.000+0000 |
Updated | 2018-08-06T17:52:09.000+0000 |
Description
When using the new AttributedString on a label with the attribute of ATTRIBUTE_BASELINE_OFFSET the text within the label is clipped. This appears in differently depending on choice of font (default or custom) the value set for the offset.
* When you use the default typeface then the top line of the text is clipped off.
var text = 'We\'re pleased to announce the beta version of 3.2.0, a major update to our 3.1.0 version of the Titanium SDK and Titanium Studio.\n\nVersion 3.2.0 brings numerous fixes and improvements across both products, as well as preliminary support for iOS 7.1 and Android 4.4. Today, we\'re asking you to help test out the release and provide feedback before it becomes generally available in mid-December.';
var attr = Ti.UI.iOS.createAttributedString({
text: text,
attributes: [
{
type: Ti.UI.iOS.ATTRIBUTE_BASELINE_OFFSET,
value: 12,
range: [0, text.length]
}
]
});
var label = Ti.UI.createLabel({
attributedString: attr,
backgroundColor: '#fff',
borderColor: '#666',
borderWidth: 1,
color: '#000',
font: {
//fontFamily: 'TitilliumText22L-Light',
fontSize: 24
},
height: Ti.UI.SIZE,
//height: 400,
//verticalAlign: Ti.UI.TEXT_VERTICAL_ALIGNMENT_TOP,
width: 500
});
Values for *verticalAlign* and *height* do not affect the problem.
* Custom fonts make the problem much worse - whilst this may be the fault of the font, the fact that this occurs on the default font must mean it is the clipping routine at fault.
* If you use the documented sample code and add only the ATTRIBUTE_BASELINE_OFFSET attribute this also affects the display of the string by truncated the display with ellipsis.
var text = 'Bacon ipsum dolor Appcelerator Titanium rocks! sit amet fatback leberkas salami sausage tongue strip steak.';
var attr = Titanium.UI.iOS.createAttributedString({
text: text,
attributes: [
// Underlines text
{
type: Titanium.UI.iOS.ATTRIBUTE_UNDERLINES_STYLE,
value: Titanium.UI.iOS.ATTRIBUTE_UNDERLINE_STYLE_SINGLE,
range: [0, text.length]
},
// Sets a background color
{
type: Titanium.UI.iOS.ATTRIBUTE_BACKGROUND_COLOR,
value: "red",
range: [text.indexOf('Appcelerator'), ('Appcelerator').length]
},
{
type: Titanium.UI.iOS.ATTRIBUTE_BACKGROUND_COLOR,
value: "blue",
range: [text.indexOf('Titanium'), ('Titanium').length]
},
{
type: Titanium.UI.iOS.ATTRIBUTE_BACKGROUND_COLOR,
value: "yellow",
range: [text.indexOf('rocks!'), ('rocks!').length]
},
// Sets a foreground color
{
type: Titanium.UI.iOS.ATTRIBUTE_FOREGROUND_COLOR,
value: "orange",
range: [0, text.length]
},
{
type: Titanium.UI.iOS.ATTRIBUTE_FOREGROUND_COLOR,
value: "black",
range: [text.indexOf('rocks!'), ('rocks!').length]
},
{
type: Ti.UI.iOS.ATTRIBUTE_BASELINE_OFFSET,
value: 24,
range: [0, text.length]
}
]
});
var label = Titanium.UI.createLabel({
left: 20,
right: 20,
height: Titanium.UI.SIZE,
attributedString: attr
});
Attachments
File | Date | Size |
---|---|---|
default.jpg | 2013-11-29T16:42:51.000+0000 | 79190 |
mixed.jpg | 2013-11-29T17:48:46.000+0000 | 23814 |
TitilliumText22L-Light.jpg | 2013-11-29T16:42:51.000+0000 | 68337 |
Example when used with the sample code from the documentation adding only base_offset
Tested with native Objective-C app and also fails. Looks like an iOS 7 bug. Tested on iPad and iPhone iOS 7 - Fails iOS 6 - Works as expected
@Pedro thanks for the ObjectiveC checks. Given there is now an obvious issue;
Will the Titanium documentation be updated to show this failure?
Do you inform Apple of the problem?
Do you know if the problem persists in iOS7.1?
Tested again, issue persists in iOS 7.1 Again, it works well in iOS 6.1 but fails in 7.0 and above.
Thanks for the revisit. Were the tests performed with the ObjectiveC code above? Just wanting to confirm again that the issue is with Apple and not with Titanium. Cheers.
Yes, I tested with the Objective-C code on the iPad and iPhone simulator. Both with iOS 6.1 and 7.1
Can we find/file a relate bug with Apple?
Closing as "not our bug". If you disagree, please reopen.