-
-
Notifications
You must be signed in to change notification settings - Fork 12
fix(dashboard): scale Cozette sixel text #1454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # Third-Party Licenses | ||
|
|
||
| ## Cozette | ||
|
|
||
| The Sixel dashboard includes a generated subset of Cozette bitmap glyph data, | ||
| version 1.30.0. Source: <https://github.com/the-moonwitch/Cozette>. | ||
|
|
||
| MIT License | ||
|
|
||
| Copyright (c) 2020, Ines <ines@moonwit.ch> | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| /*! | ||
| * Cozette bitmap font subset, version 1.30.0. | ||
| * Copyright (c) 2020, Ines <ines@moonwit.ch> | ||
| * https://github.com/the-moonwitch/Cozette | ||
| * | ||
| * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| * of this software and associated documentation files (the "Software"), to deal | ||
| * in the Software without restriction, including without limitation the rights | ||
| * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| * copies of the Software, and to permit persons to whom the Software is | ||
| * furnished to do so, subject to the following conditions: | ||
| * | ||
| * The above copyright notice and this permission notice shall be included in all | ||
| * copies or substantial portions of the Software. | ||
| * | ||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| * SOFTWARE. | ||
| */ | ||
|
|
||
| import { Buffer } from "node:buffer"; | ||
|
|
||
| /** Cozette's native monospaced cell width. */ | ||
| export const COZETTE_CELL_WIDTH = 6; | ||
|
|
||
| /** Cozette's native cell height, including descenders. */ | ||
| export const COZETTE_CELL_HEIGHT = 13; | ||
|
|
||
| const FIRST_ASCII_CODE_POINT = 32; | ||
| const LAST_ASCII_CODE_POINT = 126; | ||
| const FULL_BLOCK_CODE_POINT = 0x25_88; | ||
| const BLACK_SQUARE_CODE_POINT = 0x25_a0; | ||
| const FULL_BLOCK_INDEX = LAST_ASCII_CODE_POINT - FIRST_ASCII_CODE_POINT + 1; | ||
| const BLACK_SQUARE_INDEX = FULL_BLOCK_INDEX + 1; | ||
|
|
||
| /** Visible fallback for a Unicode glyph outside the embedded Cozette subset. */ | ||
| const UNKNOWN_GLYPH = new Uint8Array([ | ||
| 63, 33, 45, 45, 45, 45, 45, 45, 45, 45, 33, 63, 0, | ||
| ]); | ||
|
|
||
| /** | ||
| * Printable ASCII, full block, and black square raster rows generated from | ||
| * Cozette's v1.30.0 BDF release. Each glyph has 13 rows packed into the low | ||
| * six bits of a byte, with bit 5 as the leftmost pixel. Source SHA-256: | ||
| * 8d740166af3a14053773ac7a8846bf288c8818a44f73ab28d4725d91b03a5639. | ||
| */ | ||
| const GLYPH_ROWS = Uint8Array.from( | ||
| Buffer.from( | ||
| "AAAAAAAAAAAAAAAAAAAABAQEBAQEAAQAAAAACgoKAAAAAAAAAAAAAAAKCh8KCh8KCgAAAAAEDhUUDgUFFQ4EAAAACBQJAgQIEgUCAAAAAAQKCgQNEhISDQAAAAAEBAQAAAAAAAAAAAAAAgQECAgICAgEBAIAAAgEBAICAgICBAQIAAAAAAAKBB8ECgAAAAAAAAAABAQfBAQAAAAAAAAAAAAAAAAMDAQIAAAAAAAAAB8AAAAAAAAAAAAAAAAAAAwMAAAAAAEBAgIEBAgIEBAAAAAADhERFRUREQ4AAAAAAAQMFAQEBAQfAAAAAAAOEQECBAgQHwAAAAAADhEBBgEBEQ4AAAAAAAEDBQkRHwEBAAAAAAAfEBAeAQERDgAAAAAABggQHhEREQ4AAAAAAB8BAgIEBAgIAAAAAAAOEREOERERDgAAAAAADhEREQ8BAgwAAAAAAAAADAwAAAwMAAAAAAAAAAwMAAAMDAQIAAAAAAECBAgEAgEAAAAAAAAAAB8AHwAAAAAAAAAAEAgEAgQIEAAAAAAADhEBAgQEAAQAAAAAAA4RERcVFxAPAAAAAAAOERERHxEREQAAAAAAHhERHhERER4AAAAAAA4REBAQEBEOAAAAAAAcEhERERESHAAAAAAAHxAQHhAQEB8AAAAAAB8QEB4QEBAQAAAAAAAOERAQExERDgAAAAAAERERHxEREREAAAAAAA4EBAQEBAQOAAAAAAAHAQEBARERDgAAAAAAERIUHBISEREAAAAAABAQEBAQEBAfAAAAAAARGxUVEREREQAAAAAAERkZFRUTExEAAAAAAA4REREREREOAAAAAAAeERERHhAQEAAAAAAADhEREREREg0BAAAAAB4RER4SERERAAAAAAAOERAOAQERDgAAAAAAHwQEBAQEBAQAAAAAABEREREREREOAAAAAAAREREKCgoEBAAAAAAAERERFRUOCgoAAAAAABERCgQEChERAAAAAAAREREKBAQEBAAAAAAAHwIEBAgIEB8AAAAADggICAgICAgICA4AABAQCAgEBAICAQEAAAAOAgICAgICAgICDgAEChEAAAAAAAAAAAAAAAAAAAAAAAAAAB8AAAAIBAAAAAAAAAAAAAAAAAAADxERERMNAAAAABAQEB4RERERHgAAAAAAAAAOERAQEQ4AAAAAAQEBDxEREREPAAAAAAAAAA4RHxARDgAAAAAHCAgeCAgICAgAAAAAAAAADxEREREPAQEOABAQEB4REREREQAAAAAABAAMBAQEBAMAAAAAAAIABgICAgICCgQAABAQEBESFBwSEQAAAAAMBAQEBAQEBAYAAAAAAAAAGhUVFRUVAAAAAAAAAB4REREREQAAAAAAAAAOEREREQ4AAAAAAAAAHhEREREeEBAQAAAAAA8RERERDwEBAQAAAAAeERAQEBAAAAAAAAAADxAOAQEeAAAAAAAICB4ICAgIBwAAAAAAAAAREREREQ8AAAAAAAAAEREKCgQEAAAAAAAAABERFRUKCgAAAAAAAAARCgQEChEAAAAAAAAAEREREREPAQEOAAAAAB8CBAgQHwAAAAADBAQEBBgEBAQEAwAABAQEBAQEBAQEBAQAABgEBAQEAwQEBAQYAAAAAAAACRUSAAAAAAA/Pz8/Pz8/Pz8/Pz8/AAAAPz8/Pz8/PwAAAA==", | ||
| "base64" | ||
| ) | ||
| ); | ||
|
|
||
| /** Look up a Cozette glyph by character without parsing or rasterizing a font. */ | ||
| export function getCozetteGlyph(character: string): Uint8Array { | ||
| const codePoint = character.codePointAt(0); | ||
| const index = getGlyphIndex(codePoint); | ||
| if (index === undefined) { | ||
| return UNKNOWN_GLYPH; | ||
| } | ||
| const start = index * COZETTE_CELL_HEIGHT; | ||
| return GLYPH_ROWS.subarray(start, start + COZETTE_CELL_HEIGHT); | ||
| } | ||
|
|
||
| function getGlyphIndex(codePoint: number | undefined): number | undefined { | ||
| if ( | ||
| codePoint !== undefined && | ||
| codePoint >= FIRST_ASCII_CODE_POINT && | ||
| codePoint <= LAST_ASCII_CODE_POINT | ||
| ) { | ||
| return codePoint - FIRST_ASCII_CODE_POINT; | ||
| } | ||
| if (codePoint === FULL_BLOCK_CODE_POINT) { | ||
| return FULL_BLOCK_INDEX; | ||
| } | ||
| if (codePoint === BLACK_SQUARE_CODE_POINT) { | ||
| return BLACK_SQUARE_INDEX; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.