-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved support for multi-line text #123
Comments
I add this data in "forAttributedString": [
{
"content": "Text",
"textStyles": {
"color": "rgb(0, 0, 0)",
"fontSize": 16,
"fontFamily": "Times New Roman",
"fontWeight": 400,
"textDecoration": "none",
"textAlign": "right",
"textTransform": "none"
}
},
{
"content": " Styles",
"textStyles": {
"color": "rgb(255, 0, 0)",
"fontSize": 20,
"fontFamily": "Times New Roman",
"fontWeight": 700,
"textDecoration": "none",
"textAlign": "right",
"textTransform": "none"
}
}
] and, change export function fixTextLayer(layer) {
layer.attributedString = makeEncodedAttributedString(layer.forAttributedString);
delete layer.style;
delete layer.text;
} |
@KimDal-hyeong oh wow, that's super useful! Thank you 🙇♂️ |
It looks like we are using "text" objects with "style" property describing the "text style". However, that style is only a baseline style. "text" objects have "attributedString"s that consist of:
This way one "text" object can describe a string that uses various styles. We should use that instead of creating multiple "text" objects that get hard to arrange. Example (with irrelevant stuff removed): {
"_class": "text",
"style": {
"_class": "style",
"textStyle": {
"_class": "textStyle",
"encodedAttributes": {
"MSAttributedStringFontAttribute": {
"_class": "fontDescriptor",
"attributes": {
"name": "TimesNewRomanPS-BoldMT",
"size": 10
}
},
"MSAttributedStringColorAttribute": {
"_class": "color",
"alpha": 1,
"blue": 0.2862745098039216,
"green": 0.2862745098039216,
"red": 0.2862745098039216
},
},
},
},
"attributedString": {
"_class": "attributedString",
"string": "first second",
"attributes": [
{
"_class": "stringAttribute",
"location": 0,
"length": 6,
"attributes": {
"MSAttributedStringFontAttribute": {
"_class": "fontDescriptor",
"attributes": {
"name": "TimesNewRomanPS-BoldMT",
"size": 10
}
},
"MSAttributedStringColorAttribute": {
"_class": "color",
"alpha": 1,
"blue": 0.2862745098039216,
"green": 0.2862745098039216,
"red": 0.2862745098039216
},
"textStyleVerticalAlignmentKey": 0,
"paragraphStyle": {
"_class": "paragraphStyle",
"alignment": 0,
"lineHeightMultiple": 1
}
}
},
{
"_class": "stringAttribute",
"location": 6,
"length": 6,
"attributes": {
… |
Currently this:
Will render like this:
😵
Broken html (test case for working on this):
The text was updated successfully, but these errors were encountered: