@skvggor/pharos 1.0.0 → 1.1.0

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.
package/README.md CHANGED
@@ -48,6 +48,7 @@ export function App() {
48
48
  | `fluid` | `boolean` | `false` | Width follows the parent; height keeps the aspect ratio. |
49
49
  | `gapRatio` | `number` | `0.16` | Pixel gap as a fraction of the pixel (fluid mode). |
50
50
  | `letterSpacingRatio` | `number` | `0.5` | Letter gap as a fraction of the pixel (fluid mode). |
51
+ | `registry` | `GlyphRegistry` | global | Isolated glyph registry to render from (see *Isolated registries*). |
51
52
 
52
53
  ## Kerning
53
54
 
@@ -146,6 +147,36 @@ registerGlyph("€", [
146
147
  ]);
147
148
  ```
148
149
 
150
+ ## Isolated registries
151
+
152
+ `registerGlyph` mutates a process-wide glyph table. When that global state is a
153
+ problem — SSR, tests, or two parts of an app that need different glyph sets —
154
+ create an isolated registry and pass it to `PixelText`:
155
+
156
+ ```tsx
157
+ import { createGlyphRegistry, PixelText } from "@skvggor/pharos";
158
+
159
+ const registry = createGlyphRegistry();
160
+ registry.registerGlyph("€", euroSource);
161
+
162
+ <PixelText text="10€" registry={registry} />;
163
+ ```
164
+
165
+ Each registry starts from a copy of the built-in glyphs and keeps its own parse
166
+ cache, so registrations never leak across instances.
167
+
168
+ ## Missing glyphs
169
+
170
+ Unknown characters fall back to a blank space. The spacer is tagged with
171
+ `pharos__space--fallback`, so you can surface gaps in your character set:
172
+
173
+ ```css
174
+ /* highlight missing glyphs while developing */
175
+ .pharos__space--fallback {
176
+ outline: 1px dashed #f00;
177
+ }
178
+ ```
179
+
149
180
  ## Development
150
181
 
151
182
  ```bash
package/dist/pharos.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("react/jsx-runtime");var t={"#":`on`,".":`off`,7:`tl`,9:`tr`,1:`bl`,3:`br`},n={width:12,height:18,accentTop:0,capTop:3,xHeight:6,baseline:13,descenderBottom:17};function r(e){return e!==`off`}function i(e){if(e.length!==n.height)throw Error(`Glyph must have ${n.height} rows, received ${e.length}.`);return e.map((e,r)=>{if(e.length!==n.width)throw Error(`Glyph row ${r} must have ${n.width} columns, received ${e.length}.`);return Array.from(e,(e,n)=>{let i=t[e];if(!i)throw Error(`Unknown glyph marker "${e}" at row ${r}, column ${n}.`);return i})})}function a(){return Array.from({length:n.height},()=>Array.from({length:n.width},()=>`off`))}var o={" ":[`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`],A:[`............`,`............`,`............`,`.....97.....`,`.....##.....`,`....####....`,`....#..#....`,`...##..##...`,`...##..##...`,`..########..`,`..##....##..`,`.##......##.`,`.##......##.`,`####....####`,`............`,`............`,`............`,`............`],E:[`............`,`............`,`............`,`..########..`,`..##........`,`..##........`,`..##........`,`..##........`,`..#######...`,`..##........`,`..##........`,`..##........`,`..##........`,`..########..`,`............`,`............`,`............`,`............`],H:[`............`,`............`,`............`,`.####..####.`,`..##....##..`,`..##....##..`,`..##....##..`,`..##....##..`,`..########..`,`..##....##..`,`..##....##..`,`..##....##..`,`..##....##..`,`.####..####.`,`............`,`............`,`............`,`............`],I:[`............`,`............`,`............`,`...######...`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`...######...`,`............`,`............`,`............`,`............`],L:[`............`,`............`,`............`,`.####.......`,`..##........`,`..##........`,`..##........`,`..##........`,`..##........`,`..##........`,`..##........`,`..##........`,`..##........`,`..########..`,`............`,`............`,`............`,`............`],O:[`............`,`............`,`............`,`...######...`,`.3#......#1.`,`.#........#.`,`##........##`,`##........##`,`##........##`,`##........##`,`##........##`,`.#........#.`,`.9#......#7.`,`...######...`,`............`,`............`,`............`,`............`],T:[`............`,`............`,`............`,`############`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`....####....`,`............`,`............`,`............`,`............`],l:[`............`,`............`,`............`,`....####....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`...######...`,`............`,`............`,`............`,`............`],o:[`............`,`............`,`............`,`............`,`............`,`............`,`....####....`,`...##..##...`,`..##....##..`,`..##....##..`,`..##....##..`,`..##....##..`,`...##..##...`,`....####....`,`............`,`............`,`............`,`............`],p:[`............`,`............`,`............`,`............`,`............`,`............`,`..######....`,`..##..##....`,`..##...##...`,`..##...##...`,`..##...##...`,`..##..##....`,`..######....`,`..##........`,`..##........`,`..##........`,`..##........`,`.####.......`],M:[`............`,`............`,`............`,`.##......##.`,`.###....###.`,`.####..####.`,`.##.####.##.`,`.##.####.##.`,`.##..##..##.`,`.##......##.`,`.##......##.`,`.##......##.`,`.##......##.`,`####....####`,`............`,`............`,`............`,`............`],a:[`............`,`............`,`............`,`............`,`............`,`............`,`...######...`,`..##....##..`,`........##..`,`...#######..`,`..##....##..`,`.##.....##..`,`..##....##..`,`..########..`,`............`,`............`,`............`,`............`],á:[`............`,`.......##...`,`......##....`,`............`,`............`,`............`,`...######...`,`..##....##..`,`........##..`,`...#######..`,`..##....##..`,`.##.....##..`,`..##....##..`,`..########..`,`............`,`............`,`............`,`............`],u:[`............`,`............`,`............`,`............`,`............`,`............`,`.####.####..`,`..##...##...`,`..##...##...`,`..##...##...`,`..##...##...`,`..##...##...`,`..##...##...`,`..#######...`,`............`,`............`,`............`,`............`],n:[`............`,`............`,`............`,`............`,`............`,`............`,`..#####.....`,`..##..##....`,`..##...##...`,`..##...##...`,`..##...##...`,`..##...##...`,`..##...##...`,`.####.####..`,`............`,`............`,`............`,`............`],d:[`............`,`............`,`............`,`.......###..`,`.......###..`,`.......##...`,`...####.##..`,`..##..####..`,`.##....###..`,`.##.....##..`,`.##.....##..`,`.##....###..`,`..##..####..`,`...####.##..`,`............`,`............`,`............`,`............`],r:[`............`,`............`,`............`,`............`,`............`,`............`,`..######....`,`..###..##...`,`..##........`,`..##........`,`..##........`,`..##........`,`..##........`,`.#####......`,`............`,`............`,`............`,`............`],s:[`............`,`............`,`............`,`............`,`............`,`............`,`..#####.....`,`.##...##....`,`.##.........`,`..####......`,`.....###....`,`.......##...`,`.##...##....`,`..#####.....`,`............`,`............`,`............`,`............`],v:[`............`,`............`,`............`,`............`,`............`,`............`,`.##......##.`,`.##......##.`,`..##....##..`,`..##....##..`,`...##..##...`,`...##..##...`,`....####....`,`.....##.....`,`............`,`............`,`............`,`............`],k:[`............`,`............`,`............`,`.##.........`,`.##.........`,`.##.........`,`.##....##...`,`.##...##....`,`.##..##.....`,`.#####......`,`.##.##......`,`.##..##.....`,`.##...##....`,`.##....##...`,`............`,`............`,`............`,`............`],g:[`............`,`............`,`............`,`............`,`............`,`............`,`..######....`,`.##....##...`,`.##....##...`,`.##....##...`,`.##....##...`,`.##....##...`,`..#######...`,`.......##...`,`.......##...`,`.#.....##...`,`.##...##....`,`..#####.....`],0:[`............`,`............`,`............`,`...######...`,`..##....##..`,`.##......##.`,`.##......##.`,`.##......##.`,`.##......##.`,`.##......##.`,`.##......##.`,`.##......##.`,`..##....##..`,`...######...`,`............`,`............`,`............`,`............`],9:[`............`,`............`,`............`,`...#####....`,`..##...##...`,`.##....##...`,`.##....##...`,`..##...##...`,`...######...`,`.......##...`,`.......##...`,`.......##...`,`.......##...`,`.......##...`,`............`,`............`,`............`,`............`],1:[`............`,`............`,`............`,`...####.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`...######...`,`............`,`............`,`............`,`............`],2:[`............`,`............`,`............`,`..######....`,`.##....##...`,`.......##...`,`......##....`,`.....##.....`,`....##......`,`...##.......`,`..##........`,`..##........`,`..##........`,`..########..`,`............`,`............`,`............`,`............`],3:[`............`,`............`,`............`,`..######....`,`.##....##...`,`.......##...`,`.......##...`,`....#####...`,`.......##...`,`.......##...`,`.......##...`,`.......##...`,`.##....##...`,`..######....`,`............`,`............`,`............`,`............`],4:[`............`,`............`,`............`,`.....###....`,`....####....`,`...##.##....`,`..##..##....`,`.##...##....`,`.########...`,`......##....`,`......##....`,`......##....`,`......##....`,`......##....`,`............`,`............`,`............`,`............`],5:[`............`,`............`,`............`,`..#######...`,`..##........`,`..##........`,`..######....`,`.......##...`,`.......##...`,`.......##...`,`.......##...`,`.......##...`,`.##....##...`,`..######....`,`............`,`............`,`............`,`............`],6:[`............`,`............`,`............`,`....####....`,`..###.......`,`.##.........`,`.##.........`,`.######.....`,`.##....##...`,`.##....##...`,`.##....##...`,`.##....##...`,`..##..##....`,`...####.....`,`............`,`............`,`............`,`............`],7:[`............`,`............`,`............`,`..########..`,`.......##...`,`......##....`,`.....##.....`,`.....##.....`,`....##......`,`....##......`,`....##......`,`...##.......`,`...##.......`,`...##.......`,`............`,`............`,`............`,`............`],8:[`............`,`............`,`............`,`..######....`,`.##....##...`,`.##....##...`,`.##....##...`,`..######....`,`.##....##...`,`.##....##...`,`.##....##...`,`.##....##...`,`.##....##...`,`..######....`,`............`,`............`,`............`,`............`],B:[`............`,`............`,`............`,`.#######....`,`.##....##...`,`.##....##...`,`.##...##....`,`.######.....`,`.##...##....`,`.##....##...`,`.##....##...`,`.##....##...`,`.##....##...`,`.#######....`,`............`,`............`,`............`,`............`],C:[`............`,`............`,`............`,`...#####....`,`.##.....##..`,`.##.........`,`##..........`,`##..........`,`##..........`,`##..........`,`.##.........`,`.##.....##..`,`...#####....`,`............`,`............`,`............`,`............`,`............`],D:[`............`,`............`,`............`,`.######.....`,`.##...##....`,`.##....##...`,`.##....##...`,`.##.....##..`,`.##.....##..`,`.##....##...`,`.##....##...`,`.##...##....`,`.######.....`,`............`,`............`,`............`,`............`,`............`],F:[`............`,`............`,`............`,`.########...`,`.##.........`,`.##.........`,`.##.........`,`.######.....`,`.##.........`,`.##.........`,`.##.........`,`.##.........`,`.##.........`,`.##.........`,`............`,`............`,`............`,`............`],G:[`............`,`............`,`............`,`...#####....`,`.##.....##..`,`.##.........`,`##..........`,`##..........`,`##..#####...`,`##......##..`,`##......##..`,`.##....##...`,`...#####....`,`............`,`............`,`............`,`............`,`............`],J:[`............`,`............`,`............`,`....######..`,`.......##...`,`.......##...`,`.......##...`,`.......##...`,`.......##...`,`.......##...`,`.......##...`,`##.....##...`,`.##...##....`,`..#####.....`,`............`,`............`,`............`,`............`],K:[`............`,`............`,`............`,`.##....##...`,`.##...##....`,`.##..##.....`,`.##.##......`,`.####.......`,`.####.......`,`.##.##......`,`.##..##.....`,`.##...##....`,`.##....##...`,`.##.....##..`,`............`,`............`,`............`,`............`],N:[`............`,`............`,`............`,`.##.....##..`,`.###....##..`,`.####...##..`,`.##.##..##..`,`.##..##.##..`,`.##...####..`,`.##....###..`,`.##.....##..`,`.##.....##..`,`.##.....##..`,`.##.....##..`,`............`,`............`,`............`,`............`],P:[`............`,`............`,`............`,`.######.....`,`.##...##....`,`.##....##...`,`.##....##...`,`.##...##....`,`.######.....`,`.##.........`,`.##.........`,`.##.........`,`.##.........`,`.##.........`,`............`,`............`,`............`,`............`],Q:[`............`,`............`,`............`,`...######...`,`.##......##.`,`##........##`,`##........##`,`##........##`,`##........##`,`##........##`,`.##......##.`,`...######...`,`.......###..`,`........###.`,`............`,`............`,`............`,`............`],R:[`............`,`............`,`............`,`.######.....`,`.##...##....`,`.##....##...`,`.##...##....`,`.######.....`,`.##.##......`,`.##..##.....`,`.##...##....`,`.##...##....`,`.##....##...`,`.##....##...`,`............`,`............`,`............`,`............`],S:[`............`,`............`,`............`,`..######....`,`.##....##...`,`.##.........`,`.##.........`,`..#####.....`,`.....###....`,`.......##...`,`.......##...`,`.##....##...`,`.##....##...`,`..######....`,`............`,`............`,`............`,`............`],U:[`............`,`............`,`............`,`.##.....##..`,`.##.....##..`,`.##.....##..`,`.##.....##..`,`.##.....##..`,`.##.....##..`,`.##.....##..`,`.##.....##..`,`.##....##...`,`..##...##...`,`...#####....`,`............`,`............`,`............`,`............`],V:[`............`,`............`,`............`,`##........##`,`.##......##.`,`.##......##.`,`..##....##..`,`..##....##..`,`...##..##...`,`...##..##...`,`....####....`,`....####....`,`.....##.....`,`.....##.....`,`............`,`............`,`............`,`............`],W:[`............`,`............`,`............`,`##........##`,`##........##`,`##........##`,`##........##`,`##...##...##`,`##..####..##`,`##.##..##.##`,`####....####`,`###......###`,`.##......##.`,`.##......##.`,`............`,`............`,`............`,`............`],X:[`............`,`............`,`............`,`##........##`,`.##......##.`,`..##....##..`,`...##..##...`,`....####....`,`.....##.....`,`....####....`,`...##..##...`,`..##....##..`,`.##......##.`,`##........##`,`............`,`............`,`............`,`............`],Y:[`............`,`............`,`............`,`##........##`,`.##......##.`,`..##....##..`,`...##..##...`,`....####....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`...######...`,`............`,`............`,`............`,`............`],Z:[`............`,`............`,`............`,`..########..`,`.......##...`,`......##....`,`.....##.....`,`....##......`,`...##.......`,`..##........`,`..##........`,`..##........`,`..##........`,`..########..`,`............`,`............`,`............`,`............`],b:[`............`,`............`,`............`,`.##.........`,`.##.........`,`.##.........`,`.#####......`,`.##..##.....`,`.##...##....`,`.##...##....`,`.##...##....`,`.##...##....`,`.##..##.....`,`.#####......`,`............`,`............`,`............`,`............`],c:[`............`,`............`,`............`,`............`,`............`,`............`,`...####.....`,`..##..##....`,`.##.........`,`.##.........`,`.##.........`,`.##.........`,`..##..##....`,`...####.....`,`............`,`............`,`............`,`............`],e:[`............`,`............`,`............`,`............`,`............`,`............`,`...####.....`,`..##..##....`,`.##....##...`,`.########...`,`.##.........`,`.##.........`,`..##..##....`,`...####.....`,`............`,`............`,`............`,`............`],f:[`............`,`............`,`............`,`....####....`,`...##..#....`,`...##.......`,`.#######....`,`...##.......`,`...##.......`,`...##.......`,`...##.......`,`...##.......`,`...##.......`,`...##.......`,`............`,`............`,`............`,`............`],h:[`............`,`............`,`............`,`.##.........`,`.##.........`,`.##.........`,`.#####......`,`.##..##.....`,`.##...##....`,`.##...##....`,`.##...##....`,`.##...##....`,`.##...##....`,`.##...##....`,`............`,`............`,`............`,`............`],i:[`............`,`............`,`............`,`............`,`.....##.....`,`............`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`...######...`,`............`,`............`,`............`,`............`],j:[`............`,`............`,`............`,`............`,`.....##.....`,`............`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`##...##.....`,`.##.##......`,`..###.......`],m:[`............`,`............`,`............`,`............`,`............`,`............`,`##########..`,`##..##..##..`,`##..##..##..`,`##..##..##..`,`##..##..##..`,`##..##..##..`,`##..##..##..`,`##..##..##..`,`............`,`............`,`............`,`............`],q:[`............`,`............`,`............`,`............`,`............`,`............`,`..######....`,`.##....##...`,`.##....##...`,`.##....##...`,`.##....##...`,`.##....##...`,`..#######...`,`.......##...`,`.......##...`,`.......##...`,`.......##...`,`.....#####..`],t:[`............`,`............`,`............`,`............`,`...##.......`,`...##.......`,`.######.....`,`...##.......`,`...##.......`,`...##.......`,`...##.......`,`...##.......`,`...##..##...`,`....####....`,`............`,`............`,`............`,`............`],w:[`............`,`............`,`............`,`............`,`............`,`............`,`##........##`,`##........##`,`##...##...##`,`##..####..##`,`##.##..##.##`,`####....####`,`.##......##.`,`.##......##.`,`............`,`............`,`............`,`............`],x:[`............`,`............`,`............`,`............`,`............`,`............`,`.##.....##..`,`..##...##...`,`...##.##....`,`....###.....`,`....###.....`,`...##.##....`,`..##...##...`,`.##.....##..`,`............`,`............`,`............`,`............`],y:[`............`,`............`,`............`,`............`,`............`,`............`,`.##.....##..`,`.##.....##..`,`.##.....##..`,`.##.....##..`,`..##...##...`,`..#######...`,`.......##...`,`.......##...`,`.......##...`,`.......##...`,`##.....##...`,`.######.....`],z:[`............`,`............`,`............`,`............`,`............`,`............`,`..######....`,`.....##.....`,`.....##.....`,`....##......`,`...##.......`,`..##........`,`..##........`,`..######....`,`............`,`............`,`............`,`............`],"?":[`............`,`............`,`............`,`..######....`,`.##....##...`,`.......##...`,`......##....`,`.....##.....`,`.....##.....`,`............`,`.....##.....`,`.....##.....`,`............`,`............`,`............`,`............`,`............`,`............`],":":[`............`,`............`,`............`,`............`,`............`,`............`,`.....##.....`,`.....##.....`,`............`,`............`,`............`,`.....##.....`,`.....##.....`,`............`,`............`,`............`,`............`,`............`],";":[`............`,`............`,`............`,`............`,`............`,`............`,`.....##.....`,`.....##.....`,`............`,`............`,`............`,`.....##.....`,`.....##.....`,`.....##.....`,`....##......`,`............`,`............`,`............`],"-":[`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`..######....`,`..######....`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`],"'":[`............`,`............`,`............`,`.....##.....`,`.....##.....`,`....##......`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`],'"':[`............`,`............`,`............`,`...##.##....`,`...##.##....`,`..##.##.....`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`],"(":[`............`,`............`,`............`,`....##......`,`...##.......`,`..##........`,`..##........`,`..##........`,`..##........`,`..##........`,`..##........`,`..##........`,`...##.......`,`....##......`,`............`,`............`,`............`,`............`],")":[`............`,`............`,`............`,`......##....`,`.......##...`,`........##..`,`........##..`,`........##..`,`........##..`,`........##..`,`........##..`,`........##..`,`.......##...`,`......##....`,`............`,`............`,`............`,`............`],"/":[`............`,`............`,`............`,`........##..`,`.......##...`,`......##....`,`......##....`,`.....##.....`,`.....##.....`,`....##......`,`....##......`,`...##.......`,`...##.......`,`..##........`,`............`,`............`,`............`,`............`],"@":[`............`,`............`,`............`,`..######....`,`.##....##...`,`##......##..`,`##..###.##..`,`##.##.#.##..`,`##.##.#.##..`,`##.##.#.##..`,`##..####.#..`,`##..........`,`.##....##...`,`..######....`,`............`,`............`,`............`,`............`],ç:[`............`,`............`,`............`,`............`,`............`,`............`,`...####.....`,`..##..##....`,`.##.........`,`.##.........`,`.##.........`,`..##..##....`,`...####.....`,`....##......`,`.....##.....`,`...###......`,`............`,`............`],Ç:[`............`,`............`,`............`,`...#####....`,`.##.....##..`,`.##.........`,`##..........`,`##..........`,`##..........`,`.##.........`,`.##.....##..`,`...#####....`,`....##......`,`.....##.....`,`...###......`,`............`,`............`,`............`],",":[`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`...##.......`,`...##.......`,`...##.......`,`..##........`,`............`,`............`],"!":[`............`,`............`,`............`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`............`,`.....##.....`,`.....##.....`,`............`,`............`,`............`,`............`],".":[`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`...##.......`,`...##.......`,`............`,`............`,`............`,`............`]},s={acute:[`.......##...`,`......##....`],grave:[`....##......`,`.....##.....`],circumflex:[`.....##.....`,`....#..#....`],tilde:[`...###.##...`,`..##.###....`],diaeresis:[`....#..#....`,`....#..#....`]};function c(e,t,n){return e.map((e,r)=>r===n?t[0]:r===n+1?t[1]:e)}var l=e=>e.map((e,t)=>t===4?`............`:e),u=(e,t)=>c(o[e],t,3),d=(e,t)=>c(o[e],t,0);Object.assign(o,{á:u(`a`,s.acute),à:u(`a`,s.grave),â:u(`a`,s.circumflex),ã:u(`a`,s.tilde),ä:u(`a`,s.diaeresis),é:u(`e`,s.acute),è:u(`e`,s.grave),ê:u(`e`,s.circumflex),í:c(l(o.i),s.acute,3),î:c(l(o.i),s.circumflex,3),ó:u(`o`,s.acute),ô:u(`o`,s.circumflex),õ:u(`o`,s.tilde),ú:u(`u`,s.acute),ü:u(`u`,s.diaeresis),ñ:u(`n`,s.tilde),Á:d(`A`,s.acute),À:d(`A`,s.grave),Â:d(`A`,s.circumflex),Ã:d(`A`,s.tilde),É:d(`E`,s.acute),Ê:d(`E`,s.circumflex),Í:d(`I`,s.acute),Ó:d(`O`,s.acute),Ô:d(`O`,s.circumflex),Õ:d(`O`,s.tilde),Ú:d(`U`,s.acute)});var f=new Map;function p(e,t){if(e.length!==1)throw Error(`registerGlyph expects a single character, got "${e}".`);i(t),o[e]=t,f.delete(e)}function m(){return Object.keys(o)}function h(e){let t=o[e];if(!t)return;let n=f.get(e);if(n)return n;let r=i(t);return f.set(e,r),r}function g(e){return e in o}function _(e){return Array.from(e,e=>{let t=h(e);return t?{character:e,matrix:t,isFallback:!1}:{character:e,matrix:h(` `)??a(),isFallback:!0}})}function v(e){let t=1/0,n=-1/0;for(let i of e)for(let e=0;e<i.length;e++)r(i[e])&&(e<t&&(t=e),e>n&&(n=e));return n===-1/0?null:{start:t,end:n}}function y(e){return typeof e==`number`?`${e}px`:e}function b(e,t,n){return!!e[t]?.[n]&&e[t][n]!==`off`}function x(e){return e.reduce((e,t)=>e+t.filter(r).length,0)}function S({text:t,pixelSize:i,gap:a,letterSpacing:o,color:s,offColor:c,pixelShape:l=`dot`,smartCorners:u=!1,smoothness:d=.6,proportional:f=!0,spaceWidth:p=4,renderOff:m=!0,fluid:h=!1,gapRatio:g=.16,letterSpacingRatio:S=.5,className:C,style:w,...T}){let E=_(t),D=T[`aria-label`]??t,O=n.width,k=E.map(e=>f?v(e.matrix):{start:0,end:O-1}),A={...w};if(h){let e=0;k.forEach((t,n)=>{if(t===null)e+=p;else{let n=t.end-t.start+1;e+=n+(n-1)*g}n<E.length-1&&(e+=S)}),A[`--ph-units`]=e>0?e:1,A[`--ph-gap-ratio`]=g,A[`--ph-letter-ratio`]=S}else i!==void 0&&(A[`--ph-pixel-size`]=y(i)),a!==void 0&&(A[`--ph-gap`]=y(a)),o!==void 0&&(A[`--ph-letter-spacing`]=y(o));s!==void 0&&(A[`--ph-on-color`]=s),c!==void 0&&(A[`--ph-off-color`]=c);let j=u&&(l===`square`||l===`squircle`),M=`calc(var(--ph-pixel-size) * ${d/2})`,N=[`pharos`,`ph-shape-${l}`,h&&`pharos--fluid`,C].filter(Boolean).join(` `),P=E.reduce((e,t)=>e+x(t.matrix),0),F=0;return(0,e.jsx)(`span`,{...T,role:`img`,"aria-label":D,className:N,style:A,children:E.map((t,i)=>{let a=k[i];if(a===null)return(0,e.jsx)(`span`,{"aria-hidden":`true`,className:`pharos__space`,style:{width:`calc(var(--ph-pixel-size) * ${p})`}},`${t.character}-${i}`);let{start:o,end:s}=a;return(0,e.jsx)(`span`,{"aria-hidden":`true`,className:`pharos__char`,style:{"--ph-cols":s-o+1,"--ph-rows":n.height},children:t.matrix.flatMap((n,i)=>n.slice(o,s+1).map((n,a)=>{let s=o+a,c=r(n);if(!m&&!c)return null;let l=[`pharos__pixel`],u={"--ph-row":i,"--ph-col":s};return m||(u.gridColumn=s-o+1,u.gridRow=i+1),c&&(l.push(`pharos__pixel--on`),u[`--ph-i`]=F++,u[`--ph-n`]=P),n!==`on`&&n!==`off`?l.push(`ph-tri-${n}`):j&&n===`on`&&(u.borderRadius=`${!b(t.matrix,i-1,s)&&!b(t.matrix,i,s-1)?M:`0`} ${!b(t.matrix,i-1,s)&&!b(t.matrix,i,s+1)?M:`0`} ${!b(t.matrix,i+1,s)&&!b(t.matrix,i,s+1)?M:`0`} ${!b(t.matrix,i+1,s)&&!b(t.matrix,i,s-1)?M:`0`}`),(0,e.jsx)(`span`,{className:l.join(` `),style:u},`${i}-${s}`)}))},`${t.character}-${i}`)})})}exports.GLYPHS=o,exports.METRICS=n,exports.PixelText=S,exports.getCharacters=m,exports.getGlyphMatrix=h,exports.glyphBounds=v,exports.hasGlyph=g,exports.isLit=r,exports.registerGlyph=p,exports.renderText=_;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("react/jsx-runtime");function t(e,t,n){let r=e[t]?.[n];return r!==void 0&&r!==`off`}function n(e,n,r,i){return`${!t(e,n-1,r)&&!t(e,n,r-1)?i:`0`} ${!t(e,n-1,r)&&!t(e,n,r+1)?i:`0`} ${!t(e,n+1,r)&&!t(e,n,r+1)?i:`0`} ${!t(e,n+1,r)&&!t(e,n,r-1)?i:`0`}`}function r(e,{spaceWidth:t,gapRatio:n,letterSpacingRatio:r}){let i=0;return e.forEach((a,o)=>{if(a===null)i+=t;else{let e=a.end-a.start+1;i+=e+(e-1)*n}o<e.length-1&&(i+=r)}),i>0?i:1}var i={"#":`on`,".":`off`,7:`tl`,9:`tr`,1:`bl`,3:`br`},a={width:12,height:18,accentTop:0,capTop:3,xHeight:6,baseline:13,descenderBottom:17};function o(e){return e!==`off`}var s=new WeakMap;function c(e){let t=s.get(e);if(t!==void 0)return t;let n=e.reduce((e,t)=>e+t.filter(o).length,0);return s.set(e,n),n}function l(e){if(e.length!==a.height)throw Error(`Glyph must have ${a.height} rows, received ${e.length}.`);return e.map((e,t)=>{if(e.length!==a.width)throw Error(`Glyph row ${t} must have ${a.width} columns, received ${e.length}.`);return Array.from(e,(e,n)=>{let r=i[e];if(!r)throw Error(`Unknown glyph marker "${e}" at row ${t}, column ${n}.`);return r})})}function u(){return Array.from({length:a.height},()=>Array.from({length:a.width},()=>`off`))}var d={" ":[`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`],A:[`............`,`............`,`............`,`.....97.....`,`.....##.....`,`....####....`,`....#..#....`,`...##..##...`,`...##..##...`,`..########..`,`..##....##..`,`.##......##.`,`.##......##.`,`####....####`,`............`,`............`,`............`,`............`],E:[`............`,`............`,`............`,`..########..`,`..##........`,`..##........`,`..##........`,`..##........`,`..#######...`,`..##........`,`..##........`,`..##........`,`..##........`,`..########..`,`............`,`............`,`............`,`............`],H:[`............`,`............`,`............`,`.####..####.`,`..##....##..`,`..##....##..`,`..##....##..`,`..##....##..`,`..########..`,`..##....##..`,`..##....##..`,`..##....##..`,`..##....##..`,`.####..####.`,`............`,`............`,`............`,`............`],I:[`............`,`............`,`............`,`...######...`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`...######...`,`............`,`............`,`............`,`............`],L:[`............`,`............`,`............`,`.####.......`,`..##........`,`..##........`,`..##........`,`..##........`,`..##........`,`..##........`,`..##........`,`..##........`,`..##........`,`..########..`,`............`,`............`,`............`,`............`],O:[`............`,`............`,`............`,`...######...`,`.3#......#1.`,`.#........#.`,`##........##`,`##........##`,`##........##`,`##........##`,`##........##`,`.#........#.`,`.9#......#7.`,`...######...`,`............`,`............`,`............`,`............`],T:[`............`,`............`,`............`,`############`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`....####....`,`............`,`............`,`............`,`............`],l:[`............`,`............`,`............`,`....####....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`...######...`,`............`,`............`,`............`,`............`],o:[`............`,`............`,`............`,`............`,`............`,`............`,`....####....`,`...##..##...`,`..##....##..`,`..##....##..`,`..##....##..`,`..##....##..`,`...##..##...`,`....####....`,`............`,`............`,`............`,`............`],p:[`............`,`............`,`............`,`............`,`............`,`............`,`..######....`,`..##..##....`,`..##...##...`,`..##...##...`,`..##...##...`,`..##..##....`,`..######....`,`..##........`,`..##........`,`..##........`,`..##........`,`.####.......`],M:[`............`,`............`,`............`,`.##......##.`,`.###....###.`,`.####..####.`,`.##.####.##.`,`.##.####.##.`,`.##..##..##.`,`.##......##.`,`.##......##.`,`.##......##.`,`.##......##.`,`####....####`,`............`,`............`,`............`,`............`],a:[`............`,`............`,`............`,`............`,`............`,`............`,`...######...`,`..##....##..`,`........##..`,`...#######..`,`..##....##..`,`.##.....##..`,`..##....##..`,`..########..`,`............`,`............`,`............`,`............`],á:[`............`,`.......##...`,`......##....`,`............`,`............`,`............`,`...######...`,`..##....##..`,`........##..`,`...#######..`,`..##....##..`,`.##.....##..`,`..##....##..`,`..########..`,`............`,`............`,`............`,`............`],u:[`............`,`............`,`............`,`............`,`............`,`............`,`.####.####..`,`..##...##...`,`..##...##...`,`..##...##...`,`..##...##...`,`..##...##...`,`..##...##...`,`..#######...`,`............`,`............`,`............`,`............`],n:[`............`,`............`,`............`,`............`,`............`,`............`,`..#####.....`,`..##..##....`,`..##...##...`,`..##...##...`,`..##...##...`,`..##...##...`,`..##...##...`,`.####.####..`,`............`,`............`,`............`,`............`],d:[`............`,`............`,`............`,`.......###..`,`.......###..`,`.......##...`,`...####.##..`,`..##..####..`,`.##....###..`,`.##.....##..`,`.##.....##..`,`.##....###..`,`..##..####..`,`...####.##..`,`............`,`............`,`............`,`............`],r:[`............`,`............`,`............`,`............`,`............`,`............`,`..######....`,`..###..##...`,`..##........`,`..##........`,`..##........`,`..##........`,`..##........`,`.#####......`,`............`,`............`,`............`,`............`],s:[`............`,`............`,`............`,`............`,`............`,`............`,`..#####.....`,`.##...##....`,`.##.........`,`..####......`,`.....###....`,`.......##...`,`.##...##....`,`..#####.....`,`............`,`............`,`............`,`............`],v:[`............`,`............`,`............`,`............`,`............`,`............`,`.##......##.`,`.##......##.`,`..##....##..`,`..##....##..`,`...##..##...`,`...##..##...`,`....####....`,`.....##.....`,`............`,`............`,`............`,`............`],k:[`............`,`............`,`............`,`.##.........`,`.##.........`,`.##.........`,`.##....##...`,`.##...##....`,`.##..##.....`,`.#####......`,`.##.##......`,`.##..##.....`,`.##...##....`,`.##....##...`,`............`,`............`,`............`,`............`],g:[`............`,`............`,`............`,`............`,`............`,`............`,`..######....`,`.##....##...`,`.##....##...`,`.##....##...`,`.##....##...`,`.##....##...`,`..#######...`,`.......##...`,`.......##...`,`.#.....##...`,`.##...##....`,`..#####.....`],0:[`............`,`............`,`............`,`...######...`,`..##....##..`,`.##......##.`,`.##......##.`,`.##......##.`,`.##......##.`,`.##......##.`,`.##......##.`,`.##......##.`,`..##....##..`,`...######...`,`............`,`............`,`............`,`............`],9:[`............`,`............`,`............`,`...#####....`,`..##...##...`,`.##....##...`,`.##....##...`,`..##...##...`,`...######...`,`.......##...`,`.......##...`,`.......##...`,`.......##...`,`.......##...`,`............`,`............`,`............`,`............`],1:[`............`,`............`,`............`,`...####.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`...######...`,`............`,`............`,`............`,`............`],2:[`............`,`............`,`............`,`..######....`,`.##....##...`,`.......##...`,`......##....`,`.....##.....`,`....##......`,`...##.......`,`..##........`,`..##........`,`..##........`,`..########..`,`............`,`............`,`............`,`............`],3:[`............`,`............`,`............`,`..######....`,`.##....##...`,`.......##...`,`.......##...`,`....#####...`,`.......##...`,`.......##...`,`.......##...`,`.......##...`,`.##....##...`,`..######....`,`............`,`............`,`............`,`............`],4:[`............`,`............`,`............`,`.....###....`,`....####....`,`...##.##....`,`..##..##....`,`.##...##....`,`.########...`,`......##....`,`......##....`,`......##....`,`......##....`,`......##....`,`............`,`............`,`............`,`............`],5:[`............`,`............`,`............`,`..#######...`,`..##........`,`..##........`,`..######....`,`.......##...`,`.......##...`,`.......##...`,`.......##...`,`.......##...`,`.##....##...`,`..######....`,`............`,`............`,`............`,`............`],6:[`............`,`............`,`............`,`....####....`,`..###.......`,`.##.........`,`.##.........`,`.######.....`,`.##....##...`,`.##....##...`,`.##....##...`,`.##....##...`,`..##..##....`,`...####.....`,`............`,`............`,`............`,`............`],7:[`............`,`............`,`............`,`..########..`,`.......##...`,`......##....`,`.....##.....`,`.....##.....`,`....##......`,`....##......`,`....##......`,`...##.......`,`...##.......`,`...##.......`,`............`,`............`,`............`,`............`],8:[`............`,`............`,`............`,`..######....`,`.##....##...`,`.##....##...`,`.##....##...`,`..######....`,`.##....##...`,`.##....##...`,`.##....##...`,`.##....##...`,`.##....##...`,`..######....`,`............`,`............`,`............`,`............`],B:[`............`,`............`,`............`,`.#######....`,`.##....##...`,`.##....##...`,`.##...##....`,`.######.....`,`.##...##....`,`.##....##...`,`.##....##...`,`.##....##...`,`.##....##...`,`.#######....`,`............`,`............`,`............`,`............`],C:[`............`,`............`,`............`,`...#####....`,`.##.....##..`,`.##.........`,`##..........`,`##..........`,`##..........`,`##..........`,`.##.........`,`.##.....##..`,`...#####....`,`............`,`............`,`............`,`............`,`............`],D:[`............`,`............`,`............`,`.######.....`,`.##...##....`,`.##....##...`,`.##....##...`,`.##.....##..`,`.##.....##..`,`.##....##...`,`.##....##...`,`.##...##....`,`.######.....`,`............`,`............`,`............`,`............`,`............`],F:[`............`,`............`,`............`,`.########...`,`.##.........`,`.##.........`,`.##.........`,`.######.....`,`.##.........`,`.##.........`,`.##.........`,`.##.........`,`.##.........`,`.##.........`,`............`,`............`,`............`,`............`],G:[`............`,`............`,`............`,`...#####....`,`.##.....##..`,`.##.........`,`##..........`,`##..........`,`##..#####...`,`##......##..`,`##......##..`,`.##....##...`,`...#####....`,`............`,`............`,`............`,`............`,`............`],J:[`............`,`............`,`............`,`....######..`,`.......##...`,`.......##...`,`.......##...`,`.......##...`,`.......##...`,`.......##...`,`.......##...`,`##.....##...`,`.##...##....`,`..#####.....`,`............`,`............`,`............`,`............`],K:[`............`,`............`,`............`,`.##....##...`,`.##...##....`,`.##..##.....`,`.##.##......`,`.####.......`,`.####.......`,`.##.##......`,`.##..##.....`,`.##...##....`,`.##....##...`,`.##.....##..`,`............`,`............`,`............`,`............`],N:[`............`,`............`,`............`,`.##.....##..`,`.###....##..`,`.####...##..`,`.##.##..##..`,`.##..##.##..`,`.##...####..`,`.##....###..`,`.##.....##..`,`.##.....##..`,`.##.....##..`,`.##.....##..`,`............`,`............`,`............`,`............`],P:[`............`,`............`,`............`,`.######.....`,`.##...##....`,`.##....##...`,`.##....##...`,`.##...##....`,`.######.....`,`.##.........`,`.##.........`,`.##.........`,`.##.........`,`.##.........`,`............`,`............`,`............`,`............`],Q:[`............`,`............`,`............`,`...######...`,`.##......##.`,`##........##`,`##........##`,`##........##`,`##........##`,`##........##`,`.##......##.`,`...######...`,`.......###..`,`........###.`,`............`,`............`,`............`,`............`],R:[`............`,`............`,`............`,`.######.....`,`.##...##....`,`.##....##...`,`.##...##....`,`.######.....`,`.##.##......`,`.##..##.....`,`.##...##....`,`.##...##....`,`.##....##...`,`.##....##...`,`............`,`............`,`............`,`............`],S:[`............`,`............`,`............`,`..######....`,`.##....##...`,`.##.........`,`.##.........`,`..#####.....`,`.....###....`,`.......##...`,`.......##...`,`.##....##...`,`.##....##...`,`..######....`,`............`,`............`,`............`,`............`],U:[`............`,`............`,`............`,`.##.....##..`,`.##.....##..`,`.##.....##..`,`.##.....##..`,`.##.....##..`,`.##.....##..`,`.##.....##..`,`.##.....##..`,`.##....##...`,`..##...##...`,`...#####....`,`............`,`............`,`............`,`............`],V:[`............`,`............`,`............`,`##........##`,`.##......##.`,`.##......##.`,`..##....##..`,`..##....##..`,`...##..##...`,`...##..##...`,`....####....`,`....####....`,`.....##.....`,`.....##.....`,`............`,`............`,`............`,`............`],W:[`............`,`............`,`............`,`##........##`,`##........##`,`##........##`,`##........##`,`##...##...##`,`##..####..##`,`##.##..##.##`,`####....####`,`###......###`,`.##......##.`,`.##......##.`,`............`,`............`,`............`,`............`],X:[`............`,`............`,`............`,`##........##`,`.##......##.`,`..##....##..`,`...##..##...`,`....####....`,`.....##.....`,`....####....`,`...##..##...`,`..##....##..`,`.##......##.`,`##........##`,`............`,`............`,`............`,`............`],Y:[`............`,`............`,`............`,`##........##`,`.##......##.`,`..##....##..`,`...##..##...`,`....####....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`...######...`,`............`,`............`,`............`,`............`],Z:[`............`,`............`,`............`,`..########..`,`.......##...`,`......##....`,`.....##.....`,`....##......`,`...##.......`,`..##........`,`..##........`,`..##........`,`..##........`,`..########..`,`............`,`............`,`............`,`............`],b:[`............`,`............`,`............`,`.##.........`,`.##.........`,`.##.........`,`.#####......`,`.##..##.....`,`.##...##....`,`.##...##....`,`.##...##....`,`.##...##....`,`.##..##.....`,`.#####......`,`............`,`............`,`............`,`............`],c:[`............`,`............`,`............`,`............`,`............`,`............`,`...####.....`,`..##..##....`,`.##.........`,`.##.........`,`.##.........`,`.##.........`,`..##..##....`,`...####.....`,`............`,`............`,`............`,`............`],e:[`............`,`............`,`............`,`............`,`............`,`............`,`...####.....`,`..##..##....`,`.##....##...`,`.########...`,`.##.........`,`.##.........`,`..##..##....`,`...####.....`,`............`,`............`,`............`,`............`],f:[`............`,`............`,`............`,`....####....`,`...##..#....`,`...##.......`,`.#######....`,`...##.......`,`...##.......`,`...##.......`,`...##.......`,`...##.......`,`...##.......`,`...##.......`,`............`,`............`,`............`,`............`],h:[`............`,`............`,`............`,`.##.........`,`.##.........`,`.##.........`,`.#####......`,`.##..##.....`,`.##...##....`,`.##...##....`,`.##...##....`,`.##...##....`,`.##...##....`,`.##...##....`,`............`,`............`,`............`,`............`],i:[`............`,`............`,`............`,`............`,`.....##.....`,`............`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`...######...`,`............`,`............`,`............`,`............`],j:[`............`,`............`,`............`,`............`,`.....##.....`,`............`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`##...##.....`,`.##.##......`,`..###.......`],m:[`............`,`............`,`............`,`............`,`............`,`............`,`##########..`,`##..##..##..`,`##..##..##..`,`##..##..##..`,`##..##..##..`,`##..##..##..`,`##..##..##..`,`##..##..##..`,`............`,`............`,`............`,`............`],q:[`............`,`............`,`............`,`............`,`............`,`............`,`..######....`,`.##....##...`,`.##....##...`,`.##....##...`,`.##....##...`,`.##....##...`,`..#######...`,`.......##...`,`.......##...`,`.......##...`,`.......##...`,`.....#####..`],t:[`............`,`............`,`............`,`............`,`...##.......`,`...##.......`,`.######.....`,`...##.......`,`...##.......`,`...##.......`,`...##.......`,`...##.......`,`...##..##...`,`....####....`,`............`,`............`,`............`,`............`],w:[`............`,`............`,`............`,`............`,`............`,`............`,`##........##`,`##........##`,`##...##...##`,`##..####..##`,`##.##..##.##`,`####....####`,`.##......##.`,`.##......##.`,`............`,`............`,`............`,`............`],x:[`............`,`............`,`............`,`............`,`............`,`............`,`.##.....##..`,`..##...##...`,`...##.##....`,`....###.....`,`....###.....`,`...##.##....`,`..##...##...`,`.##.....##..`,`............`,`............`,`............`,`............`],y:[`............`,`............`,`............`,`............`,`............`,`............`,`.##.....##..`,`.##.....##..`,`.##.....##..`,`.##.....##..`,`..##...##...`,`..#######...`,`.......##...`,`.......##...`,`.......##...`,`.......##...`,`##.....##...`,`.######.....`],z:[`............`,`............`,`............`,`............`,`............`,`............`,`..######....`,`.....##.....`,`.....##.....`,`....##......`,`...##.......`,`..##........`,`..##........`,`..######....`,`............`,`............`,`............`,`............`],"?":[`............`,`............`,`............`,`..######....`,`.##....##...`,`.......##...`,`......##....`,`.....##.....`,`.....##.....`,`............`,`.....##.....`,`.....##.....`,`............`,`............`,`............`,`............`,`............`,`............`],":":[`............`,`............`,`............`,`............`,`............`,`............`,`.....##.....`,`.....##.....`,`............`,`............`,`............`,`.....##.....`,`.....##.....`,`............`,`............`,`............`,`............`,`............`],";":[`............`,`............`,`............`,`............`,`............`,`............`,`.....##.....`,`.....##.....`,`............`,`............`,`............`,`.....##.....`,`.....##.....`,`.....##.....`,`....##......`,`............`,`............`,`............`],"-":[`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`..######....`,`..######....`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`],"'":[`............`,`............`,`............`,`.....##.....`,`.....##.....`,`....##......`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`],'"':[`............`,`............`,`............`,`...##.##....`,`...##.##....`,`..##.##.....`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`],"(":[`............`,`............`,`............`,`....##......`,`...##.......`,`..##........`,`..##........`,`..##........`,`..##........`,`..##........`,`..##........`,`..##........`,`...##.......`,`....##......`,`............`,`............`,`............`,`............`],")":[`............`,`............`,`............`,`......##....`,`.......##...`,`........##..`,`........##..`,`........##..`,`........##..`,`........##..`,`........##..`,`........##..`,`.......##...`,`......##....`,`............`,`............`,`............`,`............`],"/":[`............`,`............`,`............`,`........##..`,`.......##...`,`......##....`,`......##....`,`.....##.....`,`.....##.....`,`....##......`,`....##......`,`...##.......`,`...##.......`,`..##........`,`............`,`............`,`............`,`............`],"@":[`............`,`............`,`............`,`..######....`,`.##....##...`,`##......##..`,`##..###.##..`,`##.##.#.##..`,`##.##.#.##..`,`##.##.#.##..`,`##..####.#..`,`##..........`,`.##....##...`,`..######....`,`............`,`............`,`............`,`............`],ç:[`............`,`............`,`............`,`............`,`............`,`............`,`...####.....`,`..##..##....`,`.##.........`,`.##.........`,`.##.........`,`..##..##....`,`...####.....`,`....##......`,`.....##.....`,`...###......`,`............`,`............`],Ç:[`............`,`............`,`............`,`...#####....`,`.##.....##..`,`.##.........`,`##..........`,`##..........`,`##..........`,`.##.........`,`.##.....##..`,`...#####....`,`....##......`,`.....##.....`,`...###......`,`............`,`............`,`............`],",":[`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`...##.......`,`...##.......`,`...##.......`,`..##........`,`............`,`............`],"!":[`............`,`............`,`............`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`.....##.....`,`............`,`.....##.....`,`.....##.....`,`............`,`............`,`............`,`............`],".":[`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`............`,`...##.......`,`...##.......`,`............`,`............`,`............`,`............`]},f={acute:[`.......##...`,`......##....`],grave:[`....##......`,`.....##.....`],circumflex:[`.....##.....`,`....#..#....`],tilde:[`...###.##...`,`..##.###....`],diaeresis:[`....#..#....`,`....#..#....`]};function p(e,t,n){return e.map((e,r)=>r===n?t[0]:r===n+1?t[1]:e)}var m=e=>e.map((e,t)=>t===4?`............`:e),h=(e,t)=>p(d[e],t,3),g=(e,t)=>p(d[e],t,0);Object.assign(d,{á:h(`a`,f.acute),à:h(`a`,f.grave),â:h(`a`,f.circumflex),ã:h(`a`,f.tilde),ä:h(`a`,f.diaeresis),é:h(`e`,f.acute),è:h(`e`,f.grave),ê:h(`e`,f.circumflex),í:p(m(d.i),f.acute,3),î:p(m(d.i),f.circumflex,3),ó:h(`o`,f.acute),ô:h(`o`,f.circumflex),õ:h(`o`,f.tilde),ú:h(`u`,f.acute),ü:h(`u`,f.diaeresis),ñ:h(`n`,f.tilde),Á:g(`A`,f.acute),À:g(`A`,f.grave),Â:g(`A`,f.circumflex),Ã:g(`A`,f.tilde),É:g(`E`,f.acute),Ê:g(`E`,f.circumflex),Í:g(`I`,f.acute),Ó:g(`O`,f.acute),Ô:g(`O`,f.circumflex),Õ:g(`O`,f.tilde),Ú:g(`U`,f.acute)});function _(e={...d}){let t=new Map;function n(n,r){if(n.length!==1)throw Error(`registerGlyph expects a single character, got "${n}".`);l(r),e[n]=r,t.delete(n)}function r(){return Object.keys(e)}function i(n){let r=e[n];if(!r)return;let i=t.get(n);if(i)return i;let a=l(r);return t.set(n,a),a}function a(t){return t in e}function o(e){return Array.from(e,e=>{let t=i(e);return t?{character:e,matrix:t,isFallback:!1}:{character:e,matrix:i(` `)??u(),isFallback:!0}})}return{registerGlyph:n,getCharacters:r,getGlyphMatrix:i,hasGlyph:a,renderText:o}}var{registerGlyph:v,getCharacters:y,getGlyphMatrix:b,hasGlyph:x,renderText:S}=_(d);function C(e){let t=1/0,n=-1/0;for(let r of e)for(let e=0;e<r.length;e++)o(r[e])&&(e<t&&(t=e),e>n&&(n=e));return n===-1/0?null:{start:t,end:n}}function w(e){return typeof e==`number`?`${e}px`:e}function T({text:t,pixelSize:i,gap:s,letterSpacing:l,color:u,offColor:d,pixelShape:f=`dot`,smartCorners:p=!1,smoothness:m=.6,proportional:h=!0,spaceWidth:g=4,renderOff:_=!0,fluid:v=!1,gapRatio:y=.16,letterSpacingRatio:b=.5,registry:x,className:T,style:E,...D}){let O=(x??{renderText:S}).renderText(t),k=D[`aria-label`]??t,A=a.width,j=O.map(e=>h?C(e.matrix):{start:0,end:A-1}),M={...E};v?(M[`--ph-units`]=r(j,{spaceWidth:g,gapRatio:y,letterSpacingRatio:b}),M[`--ph-gap-ratio`]=y,M[`--ph-letter-ratio`]=b):(i!==void 0&&(M[`--ph-pixel-size`]=w(i)),s!==void 0&&(M[`--ph-gap`]=w(s)),l!==void 0&&(M[`--ph-letter-spacing`]=w(l))),u!==void 0&&(M[`--ph-on-color`]=u),d!==void 0&&(M[`--ph-off-color`]=d);let N=p&&(f===`square`||f===`squircle`),P=`calc(var(--ph-pixel-size) * ${m/2})`,F=[`pharos`,`ph-shape-${f}`,v&&`pharos--fluid`,T].filter(Boolean).join(` `),I=O.reduce((e,t)=>e+c(t.matrix),0),L=0;return(0,e.jsx)(`span`,{...D,role:`img`,"aria-label":k,className:F,style:M,children:O.map((t,r)=>{let i=j[r];if(i===null)return(0,e.jsx)(`span`,{"aria-hidden":`true`,className:t.isFallback?`pharos__space pharos__space--fallback`:`pharos__space`,style:{width:`calc(var(--ph-pixel-size) * ${g})`}},`${t.character}-${r}`);let{start:s,end:c}=i;return(0,e.jsx)(`span`,{"aria-hidden":`true`,className:`pharos__char`,style:{"--ph-cols":c-s+1,"--ph-rows":a.height},children:t.matrix.flatMap((r,i)=>r.slice(s,c+1).map((r,a)=>{let c=s+a,l=o(r);if(!_&&!l)return null;let u=[`pharos__pixel`],d={"--ph-row":i,"--ph-col":c};return _||(d.gridColumn=c-s+1,d.gridRow=i+1),l&&(u.push(`pharos__pixel--on`),d[`--ph-i`]=L++,d[`--ph-n`]=I),r!==`on`&&r!==`off`?u.push(`ph-tri-${r}`):N&&r===`on`&&(d.borderRadius=n(t.matrix,i,c,P)),(0,e.jsx)(`span`,{className:u.join(` `),style:d},`${i}-${c}`)}))},`${t.character}-${r}`)})})}exports.GLYPHS=d,exports.METRICS=a,exports.PixelText=T,exports.countLit=c,exports.createGlyphRegistry=_,exports.getCharacters=y,exports.getGlyphMatrix=b,exports.glyphBounds=C,exports.hasGlyph=x,exports.isLit=o,exports.registerGlyph=v,exports.renderText=S;
package/dist/pharos.js CHANGED
@@ -1,13 +1,35 @@
1
1
  import { jsx as e } from "react/jsx-runtime";
2
+ //#region src/engine/corners.ts
3
+ function t(e, t, n) {
4
+ let r = e[t]?.[n];
5
+ return r !== void 0 && r !== "off";
6
+ }
7
+ function n(e, n, r, i) {
8
+ return `${!t(e, n - 1, r) && !t(e, n, r - 1) ? i : "0"} ${!t(e, n - 1, r) && !t(e, n, r + 1) ? i : "0"} ${!t(e, n + 1, r) && !t(e, n, r + 1) ? i : "0"} ${!t(e, n + 1, r) && !t(e, n, r - 1) ? i : "0"}`;
9
+ }
10
+ //#endregion
11
+ //#region src/engine/layout.ts
12
+ function r(e, { spaceWidth: t, gapRatio: n, letterSpacingRatio: r }) {
13
+ let i = 0;
14
+ return e.forEach((a, o) => {
15
+ if (a === null) i += t;
16
+ else {
17
+ let e = a.end - a.start + 1;
18
+ i += e + (e - 1) * n;
19
+ }
20
+ o < e.length - 1 && (i += r);
21
+ }), i > 0 ? i : 1;
22
+ }
23
+ //#endregion
2
24
  //#region src/engine/metrics.ts
3
- var t = {
25
+ var i = {
4
26
  "#": "on",
5
27
  ".": "off",
6
28
  7: "tl",
7
29
  9: "tr",
8
30
  1: "bl",
9
31
  3: "br"
10
- }, n = {
32
+ }, a = {
11
33
  width: 12,
12
34
  height: 18,
13
35
  accentTop: 0,
@@ -16,28 +38,37 @@ var t = {
16
38
  baseline: 13,
17
39
  descenderBottom: 17
18
40
  };
19
- function r(e) {
41
+ function o(e) {
20
42
  return e !== "off";
21
43
  }
22
44
  //#endregion
45
+ //#region src/engine/lit.ts
46
+ var s = /* @__PURE__ */ new WeakMap();
47
+ function c(e) {
48
+ let t = s.get(e);
49
+ if (t !== void 0) return t;
50
+ let n = e.reduce((e, t) => e + t.filter(o).length, 0);
51
+ return s.set(e, n), n;
52
+ }
53
+ //#endregion
23
54
  //#region src/engine/parse-glyph.ts
24
- function i(e) {
25
- if (e.length !== n.height) throw Error(`Glyph must have ${n.height} rows, received ${e.length}.`);
26
- return e.map((e, r) => {
27
- if (e.length !== n.width) throw Error(`Glyph row ${r} must have ${n.width} columns, received ${e.length}.`);
55
+ function l(e) {
56
+ if (e.length !== a.height) throw Error(`Glyph must have ${a.height} rows, received ${e.length}.`);
57
+ return e.map((e, t) => {
58
+ if (e.length !== a.width) throw Error(`Glyph row ${t} must have ${a.width} columns, received ${e.length}.`);
28
59
  return Array.from(e, (e, n) => {
29
- let i = t[e];
30
- if (!i) throw Error(`Unknown glyph marker "${e}" at row ${r}, column ${n}.`);
31
- return i;
60
+ let r = i[e];
61
+ if (!r) throw Error(`Unknown glyph marker "${e}" at row ${t}, column ${n}.`);
62
+ return r;
32
63
  });
33
64
  });
34
65
  }
35
- function a() {
36
- return Array.from({ length: n.height }, () => Array.from({ length: n.width }, () => "off"));
66
+ function u() {
67
+ return Array.from({ length: a.height }, () => Array.from({ length: a.width }, () => "off"));
37
68
  }
38
69
  //#endregion
39
70
  //#region src/glyphs/registry.ts
40
- var o = {
71
+ var d = {
41
72
  " ": [
42
73
  "............",
43
74
  "............",
@@ -1618,86 +1649,96 @@ var o = {
1618
1649
  "............",
1619
1650
  "............"
1620
1651
  ]
1621
- }, s = {
1652
+ }, f = {
1622
1653
  acute: [".......##...", "......##...."],
1623
1654
  grave: ["....##......", ".....##....."],
1624
1655
  circumflex: [".....##.....", "....#..#...."],
1625
1656
  tilde: ["...###.##...", "..##.###...."],
1626
1657
  diaeresis: ["....#..#....", "....#..#...."]
1627
1658
  };
1628
- function c(e, t, n) {
1659
+ function p(e, t, n) {
1629
1660
  return e.map((e, r) => r === n ? t[0] : r === n + 1 ? t[1] : e);
1630
1661
  }
1631
- var l = (e) => e.map((e, t) => t === 4 ? "............" : e), u = (e, t) => c(o[e], t, 3), d = (e, t) => c(o[e], t, 0);
1632
- Object.assign(o, {
1633
- á: u("a", s.acute),
1634
- à: u("a", s.grave),
1635
- â: u("a", s.circumflex),
1636
- ã: u("a", s.tilde),
1637
- ä: u("a", s.diaeresis),
1638
- é: u("e", s.acute),
1639
- è: u("e", s.grave),
1640
- ê: u("e", s.circumflex),
1641
- í: c(l(o.i), s.acute, 3),
1642
- î: c(l(o.i), s.circumflex, 3),
1643
- ó: u("o", s.acute),
1644
- ô: u("o", s.circumflex),
1645
- õ: u("o", s.tilde),
1646
- ú: u("u", s.acute),
1647
- ü: u("u", s.diaeresis),
1648
- ñ: u("n", s.tilde),
1649
- Á: d("A", s.acute),
1650
- À: d("A", s.grave),
1651
- Â: d("A", s.circumflex),
1652
- Ã: d("A", s.tilde),
1653
- É: d("E", s.acute),
1654
- Ê: d("E", s.circumflex),
1655
- Í: d("I", s.acute),
1656
- Ó: d("O", s.acute),
1657
- Ô: d("O", s.circumflex),
1658
- Õ: d("O", s.tilde),
1659
- Ú: d("U", s.acute)
1662
+ var m = (e) => e.map((e, t) => t === 4 ? "............" : e), h = (e, t) => p(d[e], t, 3), g = (e, t) => p(d[e], t, 0);
1663
+ Object.assign(d, {
1664
+ á: h("a", f.acute),
1665
+ à: h("a", f.grave),
1666
+ â: h("a", f.circumflex),
1667
+ ã: h("a", f.tilde),
1668
+ ä: h("a", f.diaeresis),
1669
+ é: h("e", f.acute),
1670
+ è: h("e", f.grave),
1671
+ ê: h("e", f.circumflex),
1672
+ í: p(m(d.i), f.acute, 3),
1673
+ î: p(m(d.i), f.circumflex, 3),
1674
+ ó: h("o", f.acute),
1675
+ ô: h("o", f.circumflex),
1676
+ õ: h("o", f.tilde),
1677
+ ú: h("u", f.acute),
1678
+ ü: h("u", f.diaeresis),
1679
+ ñ: h("n", f.tilde),
1680
+ Á: g("A", f.acute),
1681
+ À: g("A", f.grave),
1682
+ Â: g("A", f.circumflex),
1683
+ Ã: g("A", f.tilde),
1684
+ É: g("E", f.acute),
1685
+ Ê: g("E", f.circumflex),
1686
+ Í: g("I", f.acute),
1687
+ Ó: g("O", f.acute),
1688
+ Ô: g("O", f.circumflex),
1689
+ Õ: g("O", f.tilde),
1690
+ Ú: g("U", f.acute)
1660
1691
  });
1661
1692
  //#endregion
1662
- //#region src/engine/render-text.ts
1663
- var f = /* @__PURE__ */ new Map();
1664
- function p(e, t) {
1665
- if (e.length !== 1) throw Error(`registerGlyph expects a single character, got "${e}".`);
1666
- i(t), o[e] = t, f.delete(e);
1667
- }
1668
- function m() {
1669
- return Object.keys(o);
1670
- }
1671
- function h(e) {
1672
- let t = o[e];
1673
- if (!t) return;
1674
- let n = f.get(e);
1675
- if (n) return n;
1676
- let r = i(t);
1677
- return f.set(e, r), r;
1678
- }
1679
- function g(e) {
1680
- return e in o;
1681
- }
1682
- function _(e) {
1683
- return Array.from(e, (e) => {
1684
- let t = h(e);
1685
- return t ? {
1686
- character: e,
1687
- matrix: t,
1688
- isFallback: !1
1689
- } : {
1690
- character: e,
1691
- matrix: h(" ") ?? a(),
1692
- isFallback: !0
1693
- };
1694
- });
1693
+ //#region src/engine/glyph-registry.ts
1694
+ function _(e = { ...d }) {
1695
+ let t = /* @__PURE__ */ new Map();
1696
+ function n(n, r) {
1697
+ if (n.length !== 1) throw Error(`registerGlyph expects a single character, got "${n}".`);
1698
+ l(r), e[n] = r, t.delete(n);
1699
+ }
1700
+ function r() {
1701
+ return Object.keys(e);
1702
+ }
1703
+ function i(n) {
1704
+ let r = e[n];
1705
+ if (!r) return;
1706
+ let i = t.get(n);
1707
+ if (i) return i;
1708
+ let a = l(r);
1709
+ return t.set(n, a), a;
1710
+ }
1711
+ function a(t) {
1712
+ return t in e;
1713
+ }
1714
+ function o(e) {
1715
+ return Array.from(e, (e) => {
1716
+ let t = i(e);
1717
+ return t ? {
1718
+ character: e,
1719
+ matrix: t,
1720
+ isFallback: !1
1721
+ } : {
1722
+ character: e,
1723
+ matrix: i(" ") ?? u(),
1724
+ isFallback: !0
1725
+ };
1726
+ });
1727
+ }
1728
+ return {
1729
+ registerGlyph: n,
1730
+ getCharacters: r,
1731
+ getGlyphMatrix: i,
1732
+ hasGlyph: a,
1733
+ renderText: o
1734
+ };
1695
1735
  }
1736
+ var { registerGlyph: v, getCharacters: y, getGlyphMatrix: b, hasGlyph: x, renderText: S } = _(d);
1696
1737
  //#endregion
1697
1738
  //#region src/engine/spacing.ts
1698
- function v(e) {
1739
+ function C(e) {
1699
1740
  let t = Infinity, n = -Infinity;
1700
- for (let i of e) for (let e = 0; e < i.length; e++) r(i[e]) && (e < t && (t = e), e > n && (n = e));
1741
+ for (let r of e) for (let e = 0; e < r.length; e++) o(r[e]) && (e < t && (t = e), e > n && (n = e));
1701
1742
  return n === -Infinity ? null : {
1702
1743
  start: t,
1703
1744
  end: n
@@ -1705,74 +1746,61 @@ function v(e) {
1705
1746
  }
1706
1747
  //#endregion
1707
1748
  //#region src/components/PixelText.tsx
1708
- function y(e) {
1749
+ function w(e) {
1709
1750
  return typeof e == "number" ? `${e}px` : e;
1710
1751
  }
1711
- function b(e, t, n) {
1712
- return !!e[t]?.[n] && e[t][n] !== "off";
1713
- }
1714
- function x(e) {
1715
- return e.reduce((e, t) => e + t.filter(r).length, 0);
1716
- }
1717
- function S({ text: t, pixelSize: i, gap: a, letterSpacing: o, color: s, offColor: c, pixelShape: l = "dot", smartCorners: u = !1, smoothness: d = .6, proportional: f = !0, spaceWidth: p = 4, renderOff: m = !0, fluid: h = !1, gapRatio: g = .16, letterSpacingRatio: S = .5, className: C, style: w, ...T }) {
1718
- let E = _(t), D = T["aria-label"] ?? t, O = n.width, k = E.map((e) => f ? v(e.matrix) : {
1752
+ function T({ text: t, pixelSize: i, gap: s, letterSpacing: l, color: u, offColor: d, pixelShape: f = "dot", smartCorners: p = !1, smoothness: m = .6, proportional: h = !0, spaceWidth: g = 4, renderOff: _ = !0, fluid: v = !1, gapRatio: y = .16, letterSpacingRatio: b = .5, registry: x, className: T, style: E, ...D }) {
1753
+ let O = (x ?? { renderText: S }).renderText(t), k = D["aria-label"] ?? t, A = a.width, j = O.map((e) => h ? C(e.matrix) : {
1719
1754
  start: 0,
1720
- end: O - 1
1721
- }), A = { ...w };
1722
- if (h) {
1723
- let e = 0;
1724
- k.forEach((t, n) => {
1725
- if (t === null) e += p;
1726
- else {
1727
- let n = t.end - t.start + 1;
1728
- e += n + (n - 1) * g;
1729
- }
1730
- n < E.length - 1 && (e += S);
1731
- }), A["--ph-units"] = e > 0 ? e : 1, A["--ph-gap-ratio"] = g, A["--ph-letter-ratio"] = S;
1732
- } else i !== void 0 && (A["--ph-pixel-size"] = y(i)), a !== void 0 && (A["--ph-gap"] = y(a)), o !== void 0 && (A["--ph-letter-spacing"] = y(o));
1733
- s !== void 0 && (A["--ph-on-color"] = s), c !== void 0 && (A["--ph-off-color"] = c);
1734
- let j = u && (l === "square" || l === "squircle"), M = `calc(var(--ph-pixel-size) * ${d / 2})`, N = [
1755
+ end: A - 1
1756
+ }), M = { ...E };
1757
+ v ? (M["--ph-units"] = r(j, {
1758
+ spaceWidth: g,
1759
+ gapRatio: y,
1760
+ letterSpacingRatio: b
1761
+ }), M["--ph-gap-ratio"] = y, M["--ph-letter-ratio"] = b) : (i !== void 0 && (M["--ph-pixel-size"] = w(i)), s !== void 0 && (M["--ph-gap"] = w(s)), l !== void 0 && (M["--ph-letter-spacing"] = w(l))), u !== void 0 && (M["--ph-on-color"] = u), d !== void 0 && (M["--ph-off-color"] = d);
1762
+ let N = p && (f === "square" || f === "squircle"), P = `calc(var(--ph-pixel-size) * ${m / 2})`, F = [
1735
1763
  "pharos",
1736
- `ph-shape-${l}`,
1737
- h && "pharos--fluid",
1738
- C
1739
- ].filter(Boolean).join(" "), P = E.reduce((e, t) => e + x(t.matrix), 0), F = 0;
1764
+ `ph-shape-${f}`,
1765
+ v && "pharos--fluid",
1766
+ T
1767
+ ].filter(Boolean).join(" "), I = O.reduce((e, t) => e + c(t.matrix), 0), L = 0;
1740
1768
  return /* @__PURE__ */ e("span", {
1741
- ...T,
1769
+ ...D,
1742
1770
  role: "img",
1743
- "aria-label": D,
1744
- className: N,
1745
- style: A,
1746
- children: E.map((t, i) => {
1747
- let a = k[i];
1748
- if (a === null) return /* @__PURE__ */ e("span", {
1771
+ "aria-label": k,
1772
+ className: F,
1773
+ style: M,
1774
+ children: O.map((t, r) => {
1775
+ let i = j[r];
1776
+ if (i === null) return /* @__PURE__ */ e("span", {
1749
1777
  "aria-hidden": "true",
1750
- className: "pharos__space",
1751
- style: { width: `calc(var(--ph-pixel-size) * ${p})` }
1752
- }, `${t.character}-${i}`);
1753
- let { start: o, end: s } = a;
1778
+ className: t.isFallback ? "pharos__space pharos__space--fallback" : "pharos__space",
1779
+ style: { width: `calc(var(--ph-pixel-size) * ${g})` }
1780
+ }, `${t.character}-${r}`);
1781
+ let { start: s, end: c } = i;
1754
1782
  return /* @__PURE__ */ e("span", {
1755
1783
  "aria-hidden": "true",
1756
1784
  className: "pharos__char",
1757
1785
  style: {
1758
- "--ph-cols": s - o + 1,
1759
- "--ph-rows": n.height
1786
+ "--ph-cols": c - s + 1,
1787
+ "--ph-rows": a.height
1760
1788
  },
1761
- children: t.matrix.flatMap((n, i) => n.slice(o, s + 1).map((n, a) => {
1762
- let s = o + a, c = r(n);
1763
- if (!m && !c) return null;
1764
- let l = ["pharos__pixel"], u = {
1789
+ children: t.matrix.flatMap((r, i) => r.slice(s, c + 1).map((r, a) => {
1790
+ let c = s + a, l = o(r);
1791
+ if (!_ && !l) return null;
1792
+ let u = ["pharos__pixel"], d = {
1765
1793
  "--ph-row": i,
1766
- "--ph-col": s
1794
+ "--ph-col": c
1767
1795
  };
1768
- return m || (u.gridColumn = s - o + 1, u.gridRow = i + 1), c && (l.push("pharos__pixel--on"), u["--ph-i"] = F++, u["--ph-n"] = P), n !== "on" && n !== "off" ? l.push(`ph-tri-${n}`) : j && n === "on" && (u.borderRadius = `${!b(t.matrix, i - 1, s) && !b(t.matrix, i, s - 1) ? M : "0"} ${!b(t.matrix, i - 1, s) && !b(t.matrix, i, s + 1) ? M : "0"} ${!b(t.matrix, i + 1, s) && !b(t.matrix, i, s + 1) ? M : "0"} ${!b(t.matrix, i + 1, s) && !b(t.matrix, i, s - 1) ? M : "0"}`), /* @__PURE__ */ e("span", {
1769
- className: l.join(" "),
1770
- style: u
1771
- }, `${i}-${s}`);
1796
+ return _ || (d.gridColumn = c - s + 1, d.gridRow = i + 1), l && (u.push("pharos__pixel--on"), d["--ph-i"] = L++, d["--ph-n"] = I), r !== "on" && r !== "off" ? u.push(`ph-tri-${r}`) : N && r === "on" && (d.borderRadius = n(t.matrix, i, c, P)), /* @__PURE__ */ e("span", {
1797
+ className: u.join(" "),
1798
+ style: d
1799
+ }, `${i}-${c}`);
1772
1800
  }))
1773
- }, `${t.character}-${i}`);
1801
+ }, `${t.character}-${r}`);
1774
1802
  })
1775
1803
  });
1776
1804
  }
1777
1805
  //#endregion
1778
- export { o as GLYPHS, n as METRICS, S as PixelText, m as getCharacters, h as getGlyphMatrix, v as glyphBounds, g as hasGlyph, r as isLit, p as registerGlyph, _ as renderText };
1806
+ export { d as GLYPHS, a as METRICS, T as PixelText, c as countLit, _ as createGlyphRegistry, y as getCharacters, b as getGlyphMatrix, C as glyphBounds, x as hasGlyph, o as isLit, v as registerGlyph, S as renderText };
@@ -1,3 +1,4 @@
1
+ import { GlyphRegistry } from '../../engine/glyph-registry';
1
2
  import { PixelShape } from '../../domain/index';
2
3
  import { HTMLAttributes } from 'react';
3
4
  export interface PixelTextProps extends Omit<HTMLAttributes<HTMLSpanElement>, "children"> {
@@ -16,6 +17,7 @@ export interface PixelTextProps extends Omit<HTMLAttributes<HTMLSpanElement>, "c
16
17
  fluid?: boolean;
17
18
  gapRatio?: number;
18
19
  letterSpacingRatio?: number;
20
+ registry?: GlyphRegistry;
19
21
  "aria-label"?: string;
20
22
  }
21
- export declare function PixelText({ text, pixelSize, gap, letterSpacing, color, offColor, pixelShape, smartCorners, smoothness, proportional, spaceWidth, renderOff, fluid, gapRatio, letterSpacingRatio, className, style, ...rest }: PixelTextProps): import("react").JSX.Element;
23
+ export declare function PixelText({ text, pixelSize, gap, letterSpacing, color, offColor, pixelShape, smartCorners, smoothness, proportional, spaceWidth, renderOff, fluid, gapRatio, letterSpacingRatio, registry, className, style, ...rest }: PixelTextProps): import("react").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import { PixelMatrix } from '../../domain/index';
2
+ /**
3
+ * Whether the cell at (row, column) is lit. Out-of-bounds cells count as empty,
4
+ * so edge pixels are treated as outer corners.
5
+ */
6
+ export declare function isFilled(matrix: PixelMatrix, row: number, column: number): boolean;
7
+ /**
8
+ * `border-radius` shorthand for smart corners: each corner is rounded only when
9
+ * both of its orthogonal neighbours are empty, i.e. it is an outer corner of
10
+ * the glyph silhouette.
11
+ */
12
+ export declare function smartCornerRadius(matrix: PixelMatrix, row: number, column: number, radius: string): string;
@@ -0,0 +1,17 @@
1
+ import { GlyphSource, PixelMatrix, RenderedGlyph } from '../../domain/index';
2
+ export interface GlyphRegistry {
3
+ registerGlyph(character: string, source: GlyphSource): void;
4
+ getCharacters(): string[];
5
+ getGlyphMatrix(character: string): PixelMatrix | undefined;
6
+ hasGlyph(character: string): boolean;
7
+ renderText(text: string): RenderedGlyph[];
8
+ }
9
+ /**
10
+ * Create an isolated glyph registry with its own glyph table and parse cache.
11
+ * Useful for SSR or for consumers that need to register glyphs without touching
12
+ * shared global state. Defaults to a copy of the built-in glyphs.
13
+ *
14
+ * The library's default registry passes `GLYPHS` by reference, so the global
15
+ * `registerGlyph` keeps mutating the exported `GLYPHS` as before.
16
+ */
17
+ export declare function createGlyphRegistry(glyphs?: Record<string, GlyphSource>): GlyphRegistry;
@@ -0,0 +1,13 @@
1
+ import { GlyphBounds } from '../../engine/spacing';
2
+ export interface FluidUnitsOptions {
3
+ spaceWidth: number;
4
+ gapRatio: number;
5
+ letterSpacingRatio: number;
6
+ }
7
+ /**
8
+ * Total horizontal units of a line in fluid mode, expressed as multiples of one
9
+ * pixel cell. Lit glyphs contribute their ink width plus inter-pixel gaps;
10
+ * `null` bounds (spaces) contribute `spaceWidth`; letters are separated by
11
+ * `letterSpacingRatio`. Always at least 1 to avoid a zero-width container.
12
+ */
13
+ export declare function computeFluidUnits(advances: ReadonlyArray<GlyphBounds | null>, { spaceWidth, gapRatio, letterSpacingRatio }: FluidUnitsOptions): number;
@@ -0,0 +1,7 @@
1
+ import { PixelMatrix } from '../../domain/index';
2
+ /**
3
+ * Number of lit cells in a glyph matrix. Memoized per matrix reference: because
4
+ * parsed matrices are cached and shared, repeated characters reuse the count
5
+ * instead of scanning the grid again.
6
+ */
7
+ export declare function countLit(matrix: PixelMatrix): number;
@@ -1,10 +1,7 @@
1
- import { GlyphSource, PixelMatrix, RenderedGlyph } from '../../domain/index';
2
1
  /**
3
- * Register (or override) a glyph at runtime. The source is validated against
4
- * the canvas metrics and the parsed matrix cache is invalidated.
2
+ * Default registry shared by the library. It operates on the exported `GLYPHS`
3
+ * by reference, so `registerGlyph` keeps mutating the global glyph table and
4
+ * `import { GLYPHS }` reflects runtime registrations.
5
5
  */
6
- export declare function registerGlyph(character: string, source: GlyphSource): void;
7
- export declare function getCharacters(): string[];
8
- export declare function getGlyphMatrix(character: string): PixelMatrix | undefined;
9
- export declare function hasGlyph(character: string): boolean;
10
- export declare function renderText(text: string): RenderedGlyph[];
6
+ export declare const defaultRegistry: import('../../engine/glyph-registry').GlyphRegistry;
7
+ export declare const registerGlyph: (character: string, source: import('..').GlyphSource) => void, getCharacters: () => string[], getGlyphMatrix: (character: string) => import('..').PixelMatrix | undefined, hasGlyph: (character: string) => boolean, renderText: (text: string) => import('..').RenderedGlyph[];
@@ -1,6 +1,9 @@
1
1
  export { PixelText } from '../components/PixelText';
2
2
  export type { PixelTextProps } from '../components/PixelText';
3
3
  export { METRICS, isLit } from '../engine/metrics';
4
+ export { countLit } from '../engine/lit';
5
+ export { createGlyphRegistry } from '../engine/glyph-registry';
6
+ export type { GlyphRegistry } from '../engine/glyph-registry';
4
7
  export { renderText, getGlyphMatrix, hasGlyph, registerGlyph, getCharacters, } from '../engine/render-text';
5
8
  export { glyphBounds } from '../engine/spacing';
6
9
  export type { GlyphBounds } from '../engine/spacing';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skvggor/pharos",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "A serif pixel display font for React — text as a configurable grid of pixels.",
5
5
  "type": "module",
6
6
  "license": "MIT",