Add support for text-variable-anchor-offset property (#2921)

Co-authored-by: Yingfang Wang <junew@microsoft.com>
Co-authored-by: Alexey Kon <48697757+random3940@users.noreply.github.com>
This commit is contained in:
wangyingfang
2024-10-28 19:15:54 +08:00
committed by GitHub
parent 90a798bfee
commit 1a63194078
192 changed files with 5931 additions and 107 deletions

View File

@@ -134,6 +134,8 @@ template std::optional<PropertyExpression<Color>> convertFunctionToExpression<Co
template std::optional<PropertyExpression<Padding>> convertFunctionToExpression<Padding>(const Convertible&,
Error&,
bool);
template std::optional<PropertyExpression<VariableAnchorOffsetCollection>>
convertFunctionToExpression<VariableAnchorOffsetCollection>(const Convertible&, Error&, bool);
template std::optional<PropertyExpression<Position>> convertFunctionToExpression<Position>(const Convertible&,
Error&,
bool);
@@ -213,6 +215,7 @@ bool interpolatable(type::Type type) noexcept {
return type.match([&](const type::NumberType&) { return true; },
[&](const type::ColorType&) { return true; },
[&](const type::PaddingType&) { return true; },
[&](const type::VariableAnchorOffsetCollectionType&) { return true; },
[&](const type::Array& array) { return array.N && array.itemType == type::Number; },
[&](const auto&) { return false; });
}
@@ -257,6 +260,13 @@ std::optional<std::unique_ptr<Expression>> convertLiteral(type::Type type,
}
return literal(*result);
},
[&](const type::VariableAnchorOffsetCollectionType&) -> std::optional<std::unique_ptr<Expression>> {
auto result = convert<VariableAnchorOffsetCollection>(value, error);
if (!result) {
return std::nullopt;
}
return literal(*result);
},
[&](const type::Array& array) -> std::optional<std::unique_ptr<Expression>> {
if (!isArray(value)) {
error.message = "value must be an array";
@@ -793,6 +803,9 @@ std::optional<std::unique_ptr<Expression>> convertFunctionToExpression(type::Typ
[&](const type::PaddingType&) -> std::optional<std::unique_ptr<Expression>> {
return toPadding(get(literal(*property)), defaultExpr());
},
[&](const type::VariableAnchorOffsetCollectionType&) -> std::optional<std::unique_ptr<Expression>> {
return toVariableAnchorOffset(get(literal(*property)), defaultExpr());
},
[&](const type::Array& array) -> std::optional<std::unique_ptr<Expression>> {
return assertion(array, get(literal(*property)), defaultExpr());
},