M6: REST import reads opentypeFlags as the API writes it

Figma's REST API names a text's feature toggles style.opentypeFlags; the
importer looked for openTypeFlags, so features in real files (SF Pro's
SS16 large symbols on an iOS kit's back chevron) were dropped. The old
spelling is still read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012eBDgsvRwsSRpWeWrzabVY
This commit is contained in:
Jindřich Šaršon
2026-11-20 23:30:02 +01:00
parent 69d146243e
commit bb2ecfb170
3 changed files with 5 additions and 3 deletions
+1 -1
View File
@@ -326,7 +326,7 @@ fn text_styles_and_runs() {
"style": {"fontFamily": "Inter", "fontPostScriptName": "Inter-Regular", "fontStyle": "Regular", "fontWeight": 400, "fontSize": 24,
"lineHeightPx": 29, "lineHeightUnit": "INTRINSIC_%", "letterSpacing": 0, "textAlignHorizontal": "CENTER",
"textAlignVertical": "CENTER", "textAutoResize": "HEIGHT", "textCase": "UPPER", "textDecoration": "UNDERLINE",
"paragraphSpacing": 8, "paragraphIndent": 4, "leadingTrim": "CAP_HEIGHT", "openTypeFlags": {"LIGA": 0, "ss01": 1}},
"paragraphSpacing": 8, "paragraphIndent": 4, "leadingTrim": "CAP_HEIGHT", "opentypeFlags": {"LIGA": 0, "ss01": 1}},
// UTF-16 code units: the emoji takes two.
"characterStyleOverrides": [0, 1, 1, 2],
"styleOverrideTable": {"1": {"fontWeight": 700}, "2": {"fills": [solid(1.0, 0.0, 0.0)], "hyperlink": {"type": "URL", "url": "https://example.com"}}},
+2 -1
View File
@@ -95,7 +95,8 @@ fn paragraph(s: &Value, td: &mut TextData) {
if text(s, "leadingTrim") == Some("CAP_HEIGHT") {
td.leading_trim = figcraft_doc::LeadingTrim::CapHeight;
}
if let Some(flags) = s.get("openTypeFlags").and_then(Value::as_object) {
// `opentypeFlags` as the reference tool's API writes it; `openTypeFlags` as earlier files had it.
if let Some(flags) = s.get("opentypeFlags").or_else(|| s.get("openTypeFlags")).and_then(Value::as_object) {
for (tag, on) in flags.iter().take(64) {
if figcraft_doc::valid_feature_tag(&tag.to_ascii_lowercase()) {
td.features.insert(tag.to_ascii_lowercase(), on.as_f64().is_some_and(|x| x != 0.0) || on.as_bool() == Some(true));
File diff suppressed because one or more lines are too long