mirror of
https://github.com/storytold/figcraft.git
synced 2026-12-03 15:31:21 -05:00
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:
@@ -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"}}},
|
||||
|
||||
@@ -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
Reference in New Issue
Block a user