Skip to content

Conversation

@Saw-mon-and-Natalie
Copy link
Contributor

This PR focuses on gas optimizing the silkscreen font.

Strategy

  • Subset the font to use only lowercase letters plus the non-alphabetic characters. Since both upper and lower case characters for silkscreen use the same glyphs, we can get rid of uppercase characters.
  • Change the file name to f and delete the other metadata.

MirakaiScrollsRenderer.sol has been changed to use the new font name in the svg's style section. The new font name is f. Also SCROLL #X on line 403 has been changed to scroll #X (Note that both would render uppercase glyphs).

A new test file test/MirakaiSaveFile.t.sol has also been added to compare gas consumption by the saveFile of src/MirakaiScrollsRenderer.sol. This test file uses a new forge cheat code readFile. So to run this test, forge needs to be updated. Here are the results:

(gas: 1,432,215) subsetted and renamed font / silkscreen-op2.txt
(gas: 1,481,615) subsetted font / silkscreen-op.txt
(gas: 2,213,383) original font / slkscreen.txt

This result shows that we can save a quite a lot of gas for the initialization of the MirakaiScrollsRenderer.sol

Warning
Since the font cannot render uppercase characters, we need to make sure no uppercase characters are used for the svg text boxes.

PS: The code formatting for the src/MirakaiScrollsRenderer.sol was removed by someone else's commit. The formatting is reintroduced again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant