( snapshot: GitSnapshot, path: string, )
| 112 | }; |
| 113 | |
| 114 | const readIcons = ( |
| 115 | snapshot: GitSnapshot, |
| 116 | path: string, |
| 117 | ): { manifest: FamilyIcons; modified: string } => { |
| 118 | const categoryCatalog = readIconCategories(snapshot); |
| 119 | const contents = snapshot.read(path); |
| 120 | const icons = contents |
| 121 | .toString('utf8') |
| 122 | .trim() |
| 123 | .split(/\r?\n/) |
| 124 | .map((line, index) => { |
| 125 | const match = line.match(/^(\S+)\s+([0-9a-fA-F]+)$/); |
| 126 | if (!match?.[1] || !match[2]) { |
| 127 | throw new Error(`${path}:${index + 1} is not a codepoint mapping`); |
| 128 | } |
| 129 | return { |
| 130 | name: match[1], |
| 131 | codepoint: Number.parseInt(match[2], 16), |
| 132 | categories: categoryCatalog.categories.get(match[1]), |
| 133 | }; |
| 134 | }) |
| 135 | .toSorted( |
| 136 | (left, right) => |
| 137 | compareStrings(left.name, right.name) || |
| 138 | left.codepoint - right.codepoint, |
| 139 | ); |
| 140 | const changed = snapshot.lastChanged(path); |
| 141 | return { |
| 142 | manifest: familyIconsSchema.parse({ |
| 143 | inputModes: ['codepoint', 'name-ligature'], |
| 144 | icons, |
| 145 | categoriesSource: categoryCatalog.source, |
| 146 | source: { |
| 147 | revision: changed.revision, |
| 148 | path, |
| 149 | sha256: sha256(contents), |
| 150 | }, |
| 151 | }), |
| 152 | modified: changed.date, |
| 153 | }; |
| 154 | }; |
| 155 | |
| 156 | const supportsCodepoint = ( |
| 157 | ranges: Awaited<ReturnType<typeof inspectFont>>['unicodeRanges'], |
no test coverage detected