You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be very helpful to allow the user to manually set the
ID used for the text measuring cache, currently calculated by
`Clay__HashTextWithConfig', to avoid conflicts when you have
strings with the same font and size but differing properties
external to Clay.
Basically, change
uint32_t id = Clay__HashTextWithConfig(text, config);
These are some properties from HarfBuzz that could make the same string
with the same font and size be measured differently: language and script
(may change glyphs), direction (may reorder glyphs), OpenType features
(may change glyphs in arbitrary ranges).
There's certainly an argument to add some of these properties to Clay,
but ultimately this is all implementation-specific, depending on your
needs you may need more or fewer properties or they may need to be
represented in different ways. This is why I believe the simplest
answer is to shift the responsibility to the user - if you have a
complex string, you're in charge of providing its unique identifier.
I have worked around this by writing my string ID to the font ID and size,
which is then hashed (again) by Clay and this presumably avoids any conflict,
but it's a hack: my hash is bigger than a uint16, so it needs to be spread
across two fields. While that part would be fixed by using a larger width
it would still be a misuse of those fields since we're not actually talking
about fonts or sizes.
Mildly related: I see there is an option to hash string contents, this is the
exact kind of issue that could have been alternatively solved by letting the
user provide his own hash.
The text was updated successfully, but these errors were encountered:
It would be very helpful to allow the user to manually set the
ID used for the text measuring cache, currently calculated by
`Clay__HashTextWithConfig', to avoid conflicts when you have
strings with the same font and size but differing properties
external to Clay.
Basically, change
...to something like...
These are some properties from HarfBuzz that could make the same string
with the same font and size be measured differently: language and script
(may change glyphs), direction (may reorder glyphs), OpenType features
(may change glyphs in arbitrary ranges).
There's certainly an argument to add some of these properties to Clay,
but ultimately this is all implementation-specific, depending on your
needs you may need more or fewer properties or they may need to be
represented in different ways. This is why I believe the simplest
answer is to shift the responsibility to the user - if you have a
complex string, you're in charge of providing its unique identifier.
I have worked around this by writing my string ID to the font ID and size,
which is then hashed (again) by Clay and this presumably avoids any conflict,
but it's a hack: my hash is bigger than a uint16, so it needs to be spread
across two fields. While that part would be fixed by using a larger width
it would still be a misuse of those fields since we're not actually talking
about fonts or sizes.
Mildly related: I see there is an option to hash string contents, this is the
exact kind of issue that could have been alternatively solved by letting the
user provide his own hash.
The text was updated successfully, but these errors were encountered: