Make the WWS.inherits consistent with variants inheritance configuration (#2251)
* Make the WWS.inherits consistent with variants inheritance configuration * doc refine
This commit is contained in:
parent
a7b4790cd5
commit
96456df68a
3 changed files with 55 additions and 26 deletions
|
@ -100,22 +100,6 @@ Subsection `ligations` is used to customize the ligation set assigned to `calt`
|
|||
|
||||
* `inherits`: Optional, String, defines the inherited ligation set. When absent, the ligation set will not inherit any other sets. Valid values are:
|
||||
|
||||
- `--default-center-ops--`: Default ligation set would be assigned to undefined.
|
||||
- `--c-center-ops--`: Default ligation set would be assigned to undefined.
|
||||
- `--default-equality-inequality--`: Default ligation set would be assigned to undefined.
|
||||
- `--c-equality-inequality--`: Default ligation set would be assigned to undefined.
|
||||
- `--raku-equality-inequality--`: Default ligation set would be assigned to undefined.
|
||||
- `--ml-equality-inequality--`: Default ligation set would be assigned to undefined.
|
||||
- `--fstar-equality-inequality--`: Default ligation set would be assigned to undefined.
|
||||
- `--haskell-equality-inequality--`: Default ligation set would be assigned to undefined.
|
||||
- `--matlab-equality-inequality--`: Default ligation set would be assigned to undefined.
|
||||
- `--verilog-equality-inequality--`: Default ligation set would be assigned to undefined.
|
||||
- `--wolfram-equality-inequality--`: Default ligation set would be assigned to undefined.
|
||||
- `--erlang-equality-inequality--`: Default ligation set would be assigned to undefined.
|
||||
- `--default-kern--`: Default ligation set would be assigned to undefined.
|
||||
- `--default-chaining--`: Default ligation set would be assigned to undefined.
|
||||
- `--fast-chaining--`: Default ligation set would be assigned to undefined.
|
||||
- `--c-like-chaining--`: Default ligation set would be assigned to undefined.
|
||||
- `default-calt`: Inherit default ligation set.
|
||||
- `dlig`: Default ligation set would be assigned to Discretionary ligatures.
|
||||
- `clike`: Default ligation set would be assigned to C-Like.
|
||||
|
@ -3213,6 +3197,17 @@ Subsection `slopes` is used to change the slope angles and grades that the custo
|
|||
* `menu`: String from `upright`, `italic` or `oblique`. Configures the slope grade used when naming fonts.
|
||||
* `css`: String from `normal`, `italic` or `oblique`. Configures the [CSS font-style](https://developer.mozilla.org/zh-CN/docs/Web/CSS/font-style) value.
|
||||
|
||||
In addition to list all the weights/widths/slopes directly, the user could also configure the weights/widths/slopes list using “inherits” to inherit the list from another build plan:
|
||||
|
||||
```toml
|
||||
[buildPlans.IosevkaCustom2]
|
||||
family = "Iosevka Custom 2"
|
||||
|
||||
weights.inherits = "buildPlans.IosevkaCustom1" # Inherit weights list from "IosevkaCustom1"
|
||||
widths.inherits = "buildPlans.IosevkaCustom1" # Inherit widths list from "IosevkaCustom1"
|
||||
slopes.inherits = "default" # Inherit slopes list from default
|
||||
```
|
||||
|
||||
#### Compatibility Ligatures
|
||||
|
||||
Certain software, notably Emacs, relies on pre-encoded ligatures instead of OpenType to provide ligations. Iosevka could be configured with additional subsection `compatibilityLigatures`, being an array of records with following fields:
|
||||
|
|
|
@ -11,6 +11,7 @@ export default async function processLigSetPreDef(argv, dirs) {
|
|||
const headerPath = path.resolve(dirs.fragments, "description-predefined-ligation-sets.md");
|
||||
md.log(await fs.promises.readFile(headerPath, "utf-8"));
|
||||
for (const gr in ligData.rawSets) {
|
||||
if (!ligData.rawSets[gr].desc) continue;
|
||||
const readmeDesc =
|
||||
ligData.rawSets[gr].readmeDesc ||
|
||||
`Default ligation set would be assigned to ${ligData.rawSets[gr].desc}`;
|
||||
|
|
|
@ -1272,22 +1272,48 @@ function resolveWws(bpName, buildPlans, defaultConfig) {
|
|||
function resolveWwsAspect(aspectName, bpName, buildPlans, defaultConfig, deps) {
|
||||
const bp = buildPlans[bpName];
|
||||
if (!bp) fail(`Build plan ${bpName} not found.`);
|
||||
if (deps.includes(bp)) {
|
||||
fail(`Circular dependency detected when resolving ${aspectName} of ${bp.family}.`);
|
||||
}
|
||||
const updatedDeps = [...deps, bpName];
|
||||
|
||||
if (bp[aspectName]) {
|
||||
return shimBpAspect(aspectName, bp[aspectName], defaultConfig[aspectName]);
|
||||
const aspect = bp[aspectName];
|
||||
if (typeof aspect.inherits == "string") {
|
||||
if (aspect.inherits === "default") {
|
||||
return defaultConfig[aspectName];
|
||||
} else {
|
||||
// Make sure it start with `buildPlans.`
|
||||
if (!aspect.inherits.startsWith("buildPlans.")) {
|
||||
fail(
|
||||
`Invalid \`inherits\`2 value for ${aspectName} in ${bpName}. ` +
|
||||
`It must be \`default\` or start with \`buildPlans.\`.`,
|
||||
);
|
||||
}
|
||||
const inheritedPlanName = aspect.inherits.slice("buildPlans.".length);
|
||||
return resolveWwsAspect(
|
||||
aspectName,
|
||||
inheritedPlanName,
|
||||
buildPlans,
|
||||
defaultConfig,
|
||||
updatedDeps,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return shimBpAspect(aspectName, bp[aspectName], defaultConfig[aspectName]);
|
||||
}
|
||||
} else if (bp[`${aspectName}-inherits`]) {
|
||||
echo.warn(
|
||||
`The ${aspectName}-inherits syntax is deprecated. ` +
|
||||
`Use the new syntax \`${aspectName}.inherits = "buildPlans.<plan name>\` instead.`,
|
||||
);
|
||||
const inheritedPlanName = bp[`${aspectName}-inherits`];
|
||||
const inheritedPlan = buildPlans[inheritedPlanName];
|
||||
if (deps.includes(inheritedPlan))
|
||||
fail(`Circular dependency detected when resolving ${aspectName} of ${bp.family}.`);
|
||||
|
||||
const updatedDes = [...deps, bpName];
|
||||
return resolveWwsAspect(
|
||||
aspectName,
|
||||
inheritedPlanName,
|
||||
buildPlans,
|
||||
defaultConfig,
|
||||
updatedDes,
|
||||
updatedDeps,
|
||||
);
|
||||
} else {
|
||||
return defaultConfig[aspectName];
|
||||
|
@ -1304,11 +1330,18 @@ function shimBpAspect(aspectName, aspect, defaultAspect) {
|
|||
}
|
||||
function shimBpAspectKey(aspectName, sink, k, v, defaultAspect) {
|
||||
if (typeof v === "string") {
|
||||
if (!/^default\./.test(v))
|
||||
throw new Error(`Invalid configuration '${v}' for ${aspectName}.${k}'`);
|
||||
if (!v.startsWith("default."))
|
||||
throw new Error(
|
||||
`Invalid configuration '${v}' for ${aspectName}.${k}'. ` +
|
||||
`It must start with 'default.'`,
|
||||
);
|
||||
const remappingKey = v.slice("default.".length);
|
||||
if (!defaultAspect[remappingKey])
|
||||
throw new Error(`Invalid configuration '${v}' for ${aspectName}.${k}'`);
|
||||
throw new Error(
|
||||
`Invalid configuration '${v}' for ${aspectName}.${k}'. ` +
|
||||
`The default aspect doesn't have a key '${remappingKey}'.`,
|
||||
);
|
||||
|
||||
sink[k] = defaultAspect[remappingKey];
|
||||
} else {
|
||||
sink[k] = v;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue