Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/figma-code-font-family-ctr-resolution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@adobe/spectrum-design-data": patch
---

Resolve the remaining code-font `figma_only` entries in `figma diff` (closes #11k.10.12).

- **sdk/core/src/graph.rs**: added `font-family.json` to `INLINE_CTR_COMPARABLE_SCHEMAS`
so the inline `code-font-family` CTR resolves, letting `Code/Font family`,
`platformScale/code-cjk-font-family`, and `platformScale/code-font-family` match
against their Figma STRING values instead of showing as `figma_only`.
37 changes: 37 additions & 0 deletions sdk/core/src/figma/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2209,6 +2209,43 @@ mod tests {
assert_eq!(report.counts.value_mismatch, 1);
}

#[test]
fn font_family_verbatim_value_agrees() {
let meta = mock_meta(vec![mock_variable(
"platformScale/code-font-family",
"STRING",
vec![("m-desktop", json!("Source Code Pro"))],
)]);
let graph = mock_graph_with_schema(
"code-font-family",
"u-code-font-family",
json!("Source Code Pro"),
"https://example.com/font-family.json",
);
let report = diff_values(&meta, &graph, &[], None).unwrap();
assert_eq!(report.counts.matched, 1);
assert_eq!(report.counts.value_mismatch, 0);
}

/// Unlike font-weight/style, family names compare verbatim — no casing or
/// punctuation normalization, so a genuinely different family mismatches.
#[test]
fn font_family_genuine_difference_mismatches() {
let meta = mock_meta(vec![mock_variable(
"platformScale/code-font-family",
"STRING",
vec![("m-desktop", json!("Fira Code"))],
)]);
let graph = mock_graph_with_schema(
"code-font-family",
"u-code-font-family",
json!("Source Code Pro"),
"https://example.com/font-family.json",
);
let report = diff_values(&meta, &graph, &[], None).unwrap();
assert_eq!(report.counts.value_mismatch, 1);
}

#[test]
fn dp_unit_agrees_with_bare_figma_number() {
let meta = mock_meta(vec![mock_variable(
Expand Down
24 changes: 15 additions & 9 deletions sdk/core/src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1462,21 +1462,23 @@ impl TokenGraph {
}

/// Schemas whose inline CTR `value` is a plain literal directly comparable
/// to a Figma value — unlike `font-family.json`, whose inline CTR value is
/// a bare family-name string with no schema-driven comparison rule, so it
/// deliberately stays unresolved here (see `resolve_relationship_ref`).
/// to a Figma value. `font-family.json`'s inline value is a bare
/// family-name string, compared verbatim against a Figma `STRING`
/// variable by `diff_against_source`'s `"STRING"` branch — same rule as
/// any other literal here, no font-specific normalization.
///
/// Not derived from `figma::import::diff_against_source`'s Figma-side
/// `resolved_type` match (`COLOR`/`FLOAT`/`STRING`) — that classifies by
/// Figma variable type, this by design-data `$schema`, and there's no
/// shared enum between them. Adding a schema here that isn't actually
/// FLOAT/STRING-comparable on the Figma side needs a matching look at
/// `diff_against_source`.
const INLINE_CTR_COMPARABLE_SCHEMAS: [&'static str; 4] = [
const INLINE_CTR_COMPARABLE_SCHEMAS: [&'static str; 5] = [
"dimension.json",
"multiplier.json",
"gradient-stop.json",
"opacity.json",
"font-family.json",
];

/// Rebuild `relationship_tokens` from `self.relationships`: for every CTR
Expand Down Expand Up @@ -3032,18 +3034,19 @@ mod tests {
}

#[test]
fn resolve_relationship_ref_stays_unresolved_through_font_family_chain() {
fn resolve_relationship_ref_resolves_through_font_family_chain() {
// code-cjk-font-family's real shape: its $ref targets
// code-font-family, an inline font-family CTR deliberately excluded
// from INLINE_CTR_COMPARABLE_SCHEMAS. The chain must stay unresolved
// rather than surfacing that inline value.
// code-font-family, an inline font-family CTR in
// INLINE_CTR_COMPARABLE_SCHEMAS. The chain must resolve to the
// inline value, same as dimension/multiplier/opacity CTR chains.
let g = TokenGraph::default().with_relationships(vec![
RelationshipRecord {
file: PathBuf::from("relationships/code.json"),
index: 0,
uuid: Some("22222222-0000-0000-0000-000000000001".to_string()),
raw: json!({
"legacyKey": "code-font-family",
"$schema": "https://opensource.adobe.com/spectrum-design-data/schemas/token-types/font-family.json",
"value": "Source Code Pro",
"uuid": "22222222-0000-0000-0000-000000000001"
}),
Expand All @@ -3060,7 +3063,10 @@ mod tests {
},
]);

assert!(g.resolve_relationship_ref("code-cjk-font-family").is_none());
let rec = g
.resolve_relationship_ref("code-cjk-font-family")
.expect("font-family CTR chain must resolve");
assert_eq!(rec.raw["value"], "Source Code Pro");
}

#[test]
Expand Down
Loading