Skip to content

Commit

Permalink
If we don't find the optimum reference layer, then use the default la…
Browse files Browse the repository at this point in the history
…yer, and not the last we happened to look at
  • Loading branch information
justvanrossum committed Sep 18, 2023
1 parent ed429c7 commit 739e68a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/fontra/client/core/glyph-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,17 @@ export class VariableGlyphController {
].slice(0, Math.ceil(layerNames.length / 2));

const errors = {};
let referenceLayerName;
for (referenceLayerName of layerNames) {
errors[referenceLayerName] = checkInterpolationCompatibility(
referenceLayerName,
let referenceLayerName = defaultSourceLayerName;
for (const layerName of layerNames) {
errors[layerName] = checkInterpolationCompatibility(
layerName,
layerGlyphs,
errors
);
if (Object.keys(errors[referenceLayerName]).length <= this.sources.length / 2) {
// good enough
if (Object.keys(errors[layerName]).length <= this.sources.length / 2) {
// The number of incompatible sources is half of all sources or less:
// we've found the optimal reference layer.
referenceLayerName = layerName;
break;
}
}
Expand Down

0 comments on commit 739e68a

Please sign in to comment.