ntk 8.17.0 → 8.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/fontconfig.js +19 -1
  2. package/package.json +1 -1
package/lib/fontconfig.js CHANGED
@@ -226,8 +226,26 @@ export function platformFamilies(family, platform = globalThis.process?.platform
226
226
  return changed ? out.join(',') : family;
227
227
  }
228
228
 
229
+ /**
230
+ * A family name as fontconfig's pattern syntax reads it (FcNameParse): a
231
+ * `-` starts the point size, a `:` the properties, a `,` the next family,
232
+ * and a `\` escapes each of them. Unescaped, the CSS list
233
+ * `tablet-gothic-condensed, "arial narrow", arial` was the family `tablet`
234
+ * and a size fc-match could not read, the families after it were gone, and
235
+ * the face was fontconfig's default for nothing: Verdana, where a browser
236
+ * sets Arial Narrow.
237
+ */
238
+ function fcName(name) {
239
+ return name.replace(/[\\\-:,]/g, '\\$&');
240
+ }
241
+
229
242
  function patternFor({ family, weight, style }) {
230
- let fc = platformFamilies(family || 'sans-serif');
243
+ let fc = String(platformFamilies(family || 'sans-serif'))
244
+ .split(',')
245
+ .map((name) => name.trim().replace(/^["']|["']$/g, ''))
246
+ .filter(Boolean)
247
+ .map(fcName)
248
+ .join(',');
231
249
  const fcWeight = normalizeWeight(weight);
232
250
  if (fcWeight !== undefined) fc += `:weight=${fcWeight}`;
233
251
  if (style && style.includes('italic')) fc += ':slant=italic';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ntk",
3
- "version": "8.17.0",
3
+ "version": "8.17.1",
4
4
  "description": "Desktop UI toolkit for X11 with canvas-like 2d and OpenGL rendering",
5
5
  "author": "Andrey Sidorov <sidorares@yandex.ru>",
6
6
  "license": "MIT",