VivaRado / SYFF

Think of it as CSS for fonts.
GNU General Public License v3.0
8 stars 0 forks source link

Test SSTORE reconstruction. #6

Open VivaRado opened 1 year ago

VivaRado commented 1 year ago

@eliheuer @davelab6

The size of a font on SSTORE:

This is from FontRegistry codebase:

    // our font is 115KB
    // contract storage is < 24KB
    // we need to chunk our font into 5 partitions to store it fully

From the email, identified chunks:

We get all that build the font on the client with Javascript like with fontkit and varLib models that exists in JS already with client-side code.

Or we provide an API service that builds the font with Python or whatnot, but this defeats the purpose cause KBs on the net, while it could be done on the client with no bandwidth. Hints at SYFF but in JS.

Cost $13.82/KB? Advise on GAS please. The font would be about 35KB reconstructed a lot bigger but client side. 483.7$ per font. But keep in mind the alterations also cost in case we have to change the content.

VivaRado commented 1 year ago

image

ctrlcctrlv commented 1 year ago

This is much smarter than the last proposal I saw. (0xBeans/FontRegistry#3)

Probably what you want to do is use Python via wasm: https://testdriven.io/blog/python-webassembly/

This would benefit free fonts community as a whole as a working fontmake that runs in wasm is broadly useful.

Another thought is that what you are doing here is essentially just recreating METAFONT. You could instead use METAPOST (via, perhaps, wasm once again, this time made through e.g. emscripten).

VivaRado commented 1 year ago

Rendering VS Assembling, Combining or Sýnthesi

As for metafont, I do notice what you mean, specifically that it includes drawing equations, like maybe:

A ["A_lpha"]{
   /* Setup Coordinates */
   coordinates : [1,2],[2,4] ...etc [1,3,4] ... JK just 2D for now )))
   /* Style */
   stroke-style  : 2em;
   cap-start : "some_partial";
   cap-end : "some_partial";
}

We do have considered the idea of adding initial shapes not from existing files but from lists of coordinates existing in the instructions themselves, and be able to manipulate some individual coordinates for minor fixes, but we have no capacity yet to do things like draw a variable stroke single line letter ( Metafont 😲), someday? maybe?

At the moment I try to keep it at "plumbing" level, just connecting the letter partials, modular stuff, and letting the user figure out the connections system. This allows me to also invest my time in a way that the team will not be overwhelmed.

Basically we try to remove duplication wherever we see it, without creating a very demanding rendering system, more of a recombining system.

Node Editor

I would also consider the idea of a node editor to help visualize the results and also make drag and drop adjustments.

PyGUI Node Editor from PyGui

enSYFFying Existing Fonts

Then maybe, from our existing codebase, we could use the Similarity Extractor that checks for letters that are similar, funny enough it's the same used for kerning compression, and one could throw in an existing font, and the SMEX could suggest what letters could be removed as they are dups and add the SYFF code for their generation from other letters or partials.

Current Needs and Plan

I am trying to work on this while working on AEOLUM font, here is the plan and the needs of the font and how I am thinking of using SYFF to generate the letters.

On or Off

Truthfully whether this will be used #onchain or off, it is still a good method as it is a size reduction and also a design system, that could be beneficial as CSS is for the web.

@ctrlcctrlv thank you for your evaluation, and MFEK, and others who are interested, we will try to put some traction into this one, your help is appreciated. Have an awesome weekend!

metafont #metapost #wasm #emscripten

ctrlcctrlv commented 1 year ago

METAFONT is a programming language. So you could very well write exactly what you've done here in it. Some METAFONT fonts are even written this way.

ctrlcctrlv commented 1 year ago

Here's an example from file /usr/share/texlive/texmf-dist/fonts/source/public/cm/sym.mf on my system:

iff known o_plus: cmchar "Circle-plus operator";
beginarithchar(o_plus); pickup light_rule.nib; autorounded;
lft x6=hround u; x2=w-x6; y2=math_axis; top y8=h;
circle_points; draw_circle;  % circle
draw z2--z6; draw z4--z8;  % bar and stem
labels(1,2,3,4,5,6,7,8); endchar;

If I run...

mpost '&mfplain' "\\mode:=localfont; mag := 20.0; outputtemplate := \"%j-%c.svg\"; outputformat := \"svg\"; input /usr/share/texlive/texmf-dist/fonts/source/public/cm/cmsy10.mf;"

cmsy10-8.svg

cmsy10-8

VivaRado commented 1 year ago

https://user-images.githubusercontent.com/42037103/203709206-aabb8644-275e-4213-9299-3713515d15d7.mp4