Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If we don't find the optimum reference layer, then use the default layer #820

Merged
merged 1 commit into from
Sep 18, 2023
Merged
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
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