kaplayjs / kaplay

🦖 A JavaScript/TypeScript Game Library that feels like a game, fun
https://kaplayjs.com
MIT License
575 stars 41 forks source link

feat: Font options #449

Closed amyspark-ng closed 1 month ago

amyspark-ng commented 1 month ago

I want to be able to add options when adding text like in font options, where you can add outline to a font, but if you want different texts to have, let's say different colored outlines you'd have to load the same font multiple times only changing the outline object, would it be possible to do this?

eg:

add([
    text("hello world", { outline: { width: 10, color: RED }, align: "center", }),
    pos(center()),
    anchor("center"),
])
mflerackers commented 1 month ago

Not really. The problem is that fonts need to be baked in order to be performant. That's why it is fixed at load. If you would like different colors at runtime, you could try making two fonts, one with fill and another with outline, both in white. Then draw them using the desired colors. You might have trouble aligning them though.

On Sun, 13 Oct 2024 at 10:29, amyspark-ng @.***> wrote:

I want to be able to add options when adding text like in font options, where you can add outline to a font, but if you want different texts to have, let's say different colored outlines you'd have to load the same font multiple times only changing the outline object, would it be possible to do this?

eg:

add([ text("hello world", { outline: { width: 10, color: RED }, align: "center", }), pos(center()), anchor("center"),])

— Reply to this email directly, view it on GitHub https://github.com/kaplayjs/kaplay/issues/449, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHIYW4VWJ5F5DKT2RSYAX3Z3HEGTAVCNFSM6AAAAABP25PTV6VHI2DSMVQWIX3LMV43ASLTON2WKOZSGU4DGNJVHE2DIMA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Kind Regards,

Marc Flerackers Software Engineer

amyspark-ng commented 1 month ago

i see, so i guess that's a no, sad, but it makes sense i was thinking abotu that