10000 [svgPathPen] Improve writing out numbers · Issue #3547 · fonttools/fonttools · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[svgPathPen] Improve writing out numbers #3547

8000 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

Open
behdad opened this issue May 30, 2024 · 1 comment
Open

[svgPathPen] Improve writing out numbers #3547

behdad opened this issue May 30, 2024 · 1 comment

Comments

@behdad
Copy link
Member
behdad commented May 30, 2024

See:
#3543 (comment)

@behdad
Copy link
Member Author
behdad commented May 30, 2024

Currently:

fonttools pens.svgPathPen AdobeVFPrototype.otf A

generates output using integers only:

<g transform="translate(0 918) scale(1 -1)"><path d="M5 0H235V40L125 55H105L5 40V0ZM71 0H118L322 599H299L500 0H593L363 675H303L71 0ZM170 219H472L456 265H186L170 219ZM383 0H653V40L529 55H509L383 40V0Z"/></g>

As soon as I set any --variations, even to the default, it switches to float because the variation calculations happen in float:

fonttools pens.svgPathPen AdobeVFPrototype.otf A --variations wght=100
<g transform="translate(0 918) scale(1 -1)"><path d="M12.0 0H210.0V20.0L113.0 26.0H99.0L12.0 20.0V0.0ZM85.0 0.0H114.0L325.0 667.0L308.0 657.0L524.0 0.0H556.0L327.0 684.0H307.0L85.0 0.0ZM173.0 247.0H468.0L460.0 267.0H182.0L173.0 247.0ZM403.0 0.0H651.0V20.0L537.0 26.0H523.0L403.0 20.0V0.0Z"/></g>

And if I set non-default location, I get multiple unnecessary digits of float:

fonttools pens.svgPathPen AdobeVFPrototype.otf A --variations wght=400
<g transform="translate(0 918) scale(1 -1)"><path d="M5.205617204267097 0H234.3831483871987V40.781345376214965L125.24674064512051 55.781345376214965H105.37011096768077L5.205617204267099 40.781345376214965V0.0ZM70.75325935487949 0.0H118.45235784938762L321.7121359140261 598.3420249463453L297.8896670969577 595.463384086606L497.1624825811141 0.0H594.6038141932834L364.8916782792573 674.0541608603713H302.42427182805216L70.7532593548795 0.0ZM169.91775311829318 217.39618580671666H472.3289875268274L455.95887655914663 264.0952843012248H185.95887655914663L169.9177531182932 217.3961858067167ZM381.3139389250099 2.842170943040401e-14H653.4934812902411V40.65797505365474L529.2467406451206 55.65797505365474H506.5737169896483L381.31393892500984 40.65797505365474V2.842170943040401e-14Z"/></g>

That's clearly not ideal. Before I committed (accidentally actually) the following change: 42d6b6b but it was reverted.

Cosimo wanted me to update the callsites, not change default behavior. I realized now that I didn't actually change the default behavior of the pen, just the cmdline tool. And I still think that was the correct change. CORRECTION: I had changed the pen default.

But I also propose adding a new named argument to the pen to Do The Right Thing, without each client having to write this lambda.

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

No branches or pull requests

1 participant
0