diff --git a/README.md b/README.md index 598f6bb5a..facc35e40 100644 --- a/README.md +++ b/README.md @@ -313,12 +313,13 @@ Configuration of build plans are organized under `[buildPlans.]` sect * `family`: String, defines the family name of your custom variant. * `spacing`: Optional, String, denotes the spacing of the custom variant. Valid values include: - `term`: Make the symbols' width suitable for terminal emulators. Arrows and geometric symbols ill become narrower. - - `fontconfig-mono`: Apply `term` spacing changes and further: + - `fontconfig-mono`: Apply `term` spacing changes and further apply changes to be compatible with FontConfig's Mono spacing, which recognizes a font as monospace if and only if its every non-combining characters having the same width. The changes include: - Completely remove wide glyphs. All non-combining glyphs will be exactly the same width. + - As a consequence, the following characters will be **removed**: + - `U+27F5` LONG LEFTWARDS ARROW + - `U+27F6` LONG RIGHTWARDS ARROW - Remove `NWID` and `WWID` OpenType feature. - - This spacing is recommended for Linux users who customize for their terminal fonts: certain applications, including FontConfig, recognizes a font as monospace if and only if its every non-combining glyphs having the same width. - - `fixed`: Apply `fontconfig-mono` changes and remove ligations. + - `fixed`: Apply `fontconfig-mono` changes and further remove ligations. * `serifs`: Optional, String, configures style of serifs. - When set to `slab`, the font will be converted into slab-serif. - Otherwise the font will be sans-serif. diff --git a/font-src/gen/finalize/index.js b/font-src/gen/finalize/index.js index ee98b1f20..64eec0971 100644 --- a/font-src/gen/finalize/index.js +++ b/font-src/gen/finalize/index.js @@ -4,19 +4,19 @@ const finalizeGlyphs = require("./glyphs"); const gcFont = require("./gc"); module.exports = function finalizeFont(para, glyphStore, excludedCodePoints, restFont) { - glyphStore = forceMonospaceIfNeeded(para, glyphStore); glyphStore = gcFont(glyphStore, excludedCodePoints, restFont, {}); glyphStore = finalizeGlyphs(para, glyphStore); + validateMonospace(para, glyphStore); return glyphStore; }; -function forceMonospaceIfNeeded(para, glyphStore) { - const unitWidth = Math.round(para.width); - if (!para.forceMonospace || para.spacing > 0) return glyphStore; - return glyphStore.filterByGlyph({ - has: g => { - const gw = Math.round(g.advanceWidth || 0); - return gw === 0 || gw === unitWidth; - } - }); +function validateMonospace(para, glyphStore) { + if (!para.forceMonospace) return; + let awSet = new Set(); + for (const g of glyphStore.glyphs()) { + awSet.add(Math.round(g.advanceWidth || 0)); + } + if (awSet.size > 2) { + throw new Error("Unreachable! Fixed variant has wide characters"); + } } diff --git a/font-src/glyphs/symbol/arrow.ptl b/font-src/glyphs/symbol/arrow.ptl index 9f135a241..50ef46ecd 100644 --- a/font-src/glyphs/symbol/arrow.ptl +++ b/font-src/glyphs/symbol/arrow.ptl @@ -597,6 +597,7 @@ glyph-block Symbol-Arrow : for-width-kinds WideWidth1 if (MosaicWidthScalar == 1) : begin glyph-block-export ArrowShape - if (MosaicNameSuffix === '.WWID') : begin + + if (!para.forceMonospace && MosaicNameSuffix === '.WWID') : begin alias 'longArrowLeft' 0x27F5 'arrowleft.WWID' alias 'longArrowRight' 0x27F6 'arrowright.WWID'