mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
lottie: fix text stroke's 'of' property
The text stroke's 'of' property determines whether the stroke appears above (true) or below (false) the fill. Previously, it was incorrectly used to decide whether the stroke would render. @Issue: https://github.com/thorvg/thorvg/issues/3126
This commit is contained in:
parent
c460591b39
commit
12b9c5fc53
3 changed files with 7 additions and 5 deletions
|
@ -1090,10 +1090,11 @@ void LottieBuilder::updateText(LottieLayer* layer, float frameNo)
|
||||||
shape->translate(cursor.x - textGroupMatrix.e13, cursor.y - textGroupMatrix.e23);
|
shape->translate(cursor.x - textGroupMatrix.e13, cursor.y - textGroupMatrix.e23);
|
||||||
shape->opacity(255);
|
shape->opacity(255);
|
||||||
|
|
||||||
if (doc.stroke.render) {
|
if (doc.stroke.width > 0.0f) {
|
||||||
shape->stroke(StrokeJoin::Round);
|
shape->stroke(StrokeJoin::Round);
|
||||||
shape->stroke(doc.stroke.width / scale);
|
shape->stroke(doc.stroke.width / scale);
|
||||||
shape->stroke(doc.stroke.color.rgb[0], doc.stroke.color.rgb[1], doc.stroke.color.rgb[2]);
|
shape->stroke(doc.stroke.color.rgb[0], doc.stroke.color.rgb[1], doc.stroke.color.rgb[2]);
|
||||||
|
shape->order(doc.stroke.below);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto needGroup = false;
|
auto needGroup = false;
|
||||||
|
@ -1145,8 +1146,8 @@ void LottieBuilder::updateText(LottieLayer* layer, float frameNo)
|
||||||
fillOpacity = (uint8_t)(fillOpacity - f * (fillOpacity - (*s)->style.fillOpacity(frameNo)));
|
fillOpacity = (uint8_t)(fillOpacity - f * (fillOpacity - (*s)->style.fillOpacity(frameNo)));
|
||||||
shape->fill(color.rgb[0], color.rgb[1], color.rgb[2], fillOpacity);
|
shape->fill(color.rgb[0], color.rgb[1], color.rgb[2], fillOpacity);
|
||||||
|
|
||||||
if (doc.stroke.render) {
|
shape->stroke(f * (*s)->style.strokeWidth(frameNo) / scale);
|
||||||
shape->stroke(f * (*s)->style.strokeWidth(frameNo) / scale);
|
if (shape->strokeWidth() > 0.0f) {
|
||||||
auto rangeColor = (*s)->style.strokeColor(frameNo); //TODO: use flag to check whether it was really set
|
auto rangeColor = (*s)->style.strokeColor(frameNo); //TODO: use flag to check whether it was really set
|
||||||
if (tvg::equal(f, 1.0f)) strokeColor = rangeColor;
|
if (tvg::equal(f, 1.0f)) strokeColor = rangeColor;
|
||||||
else {
|
else {
|
||||||
|
@ -1156,6 +1157,7 @@ void LottieBuilder::updateText(LottieLayer* layer, float frameNo)
|
||||||
}
|
}
|
||||||
strokeOpacity = (uint8_t)(strokeOpacity - f * (strokeOpacity - (*s)->style.strokeOpacity(frameNo)));
|
strokeOpacity = (uint8_t)(strokeOpacity - f * (strokeOpacity - (*s)->style.strokeOpacity(frameNo)));
|
||||||
shape->stroke(strokeColor.rgb[0], strokeColor.rgb[1], strokeColor.rgb[2], strokeOpacity);
|
shape->stroke(strokeColor.rgb[0], strokeColor.rgb[1], strokeColor.rgb[2], strokeOpacity);
|
||||||
|
shape->order(doc.stroke.below);
|
||||||
}
|
}
|
||||||
|
|
||||||
cursor.x += f * (*s)->style.letterSpacing(frameNo);
|
cursor.x += f * (*s)->style.letterSpacing(frameNo);
|
||||||
|
|
|
@ -62,7 +62,7 @@ struct TextDocument
|
||||||
struct {
|
struct {
|
||||||
RGB24 color;
|
RGB24 color;
|
||||||
float width;
|
float width;
|
||||||
bool render = false;
|
bool below = false;
|
||||||
} stroke;
|
} stroke;
|
||||||
char* name = nullptr;
|
char* name = nullptr;
|
||||||
float size;
|
float size;
|
||||||
|
|
|
@ -177,7 +177,7 @@ bool LottieParser::getValue(TextDocument& doc)
|
||||||
else if (KEY_AS("sz")) getValue(doc.bbox.size);
|
else if (KEY_AS("sz")) getValue(doc.bbox.size);
|
||||||
else if (KEY_AS("sc")) getValue(doc.stroke.color);
|
else if (KEY_AS("sc")) getValue(doc.stroke.color);
|
||||||
else if (KEY_AS("sw")) doc.stroke.width = getFloat();
|
else if (KEY_AS("sw")) doc.stroke.width = getFloat();
|
||||||
else if (KEY_AS("of")) doc.stroke.render = getBool();
|
else if (KEY_AS("of")) doc.stroke.below = !getBool();
|
||||||
else skip(key);
|
else skip(key);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue