servo / pathfinder

A fast, practical GPU rasterizer for fonts and vector graphics
Apache License 2.0
3.52k stars 198 forks source link

Use pf-text with wasm #519

Open AaronPorts opened 1 year ago

AaronPorts commented 1 year ago

Is it possible to use features = ["pf-text"] with wasm? I have the next error during compilation:

warning: In file included from harfbuzz/src/harfbuzz.cc:1:
warning: In file included from harfbuzz/src/hb-aat-layout.cc:28:
warning: harfbuzz/src/hb.hh:178:10: fatal error: 'math.h' file not found
warning: #include <math.h>
warning:          ^~~~~~~~
warning: 1 error generated.

error: failed to run custom build command for `harfbuzz-sys v0.3.4`
AaronPorts commented 1 year ago

Ok, it looks like the rust-harfbuzz dependency includes harfbuzz, which can be transpiled using wasm32-unknown-emscripten target, but I didn't manage to get it to work with wasm32-unknown-unknown. Maybe harfbuzz should be replaced with some rust port (like rustybuzz)?

s3bk commented 1 year ago

It is not possible.

I wrote a text render that works with pathfinder. It works on most latin an needs more testing for arabic and non-english scripts. The code lives here: https://github.com/s3bk/svg/blob/master/text/src/lib.rs

AaronPorts commented 1 year ago

@s3bk could you describe a little why it is not possible cause i am totally new in pathfinder and rust in general.

s3bk commented 1 year ago

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256

i guess it is possible if you manage to compile freetype and harfbuz for wasm.  I figured writing it from scratch in rust was easier...

Sent with Proton Mail secure email.

------- Original Message ------- On Friday, August 19th, 2022 at 22:10, Artyom @.***> wrote:

@s3bk could you describe a little why it is not possible cause i am totally new in pathfinder and rust in general.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned. -----BEGIN PGP SIGNATURE----- Version: ProtonMail

wsBzBAEBCAAGBQJjALa/ACEJEMG+L+m8iAfZFiEEgs/vNiVgFnBzKm9swb4v 6byIB9kCtAf9Hs7ad7/Sxnw3wf+QQCq7r7IbFWgvyiXNqW06cYRBd7IhRjib I8tftJ4qerPWmhFoBf8pABa0SuH8zZ/ha4n/nvF3AwzJz9sKolVi6SeTqeFu ZgOvfF/BVhd4CmPTJILdXxGxSYTcr9E+3SlUc9pXLYOK0TRd8Niaod5S9nEN kDzS2HxSnQ/APSaCm1TLxqlJV5j2+ZpquAtvjK3L6iIOsJJgjEmzy8l8z4tO QUMMqBarXtVx/wCVgN2Ip3Xq6y6oZNZl1/KvbPBpES0mZv3vuXi/ntCIhHcY 1hGOx+64WF70FyS8JyFd5iS/8f72HDHIL826HTdqzmq9ECoznCcz7A== =Vx7z -----END PGP SIGNATURE-----