font: fix hashing of descriptor strings

This commit is contained in:
Mitchell Hashimoto
2024-04-06 19:49:14 -07:00
parent 21605eaab7
commit 2f61f7d6a3
2 changed files with 4 additions and 3 deletions

View File

@ -556,7 +556,7 @@ pub const Key = struct {
const autoHash = std.hash.autoHash; const autoHash = std.hash.autoHash;
autoHash(hasher, self.descriptors.len); autoHash(hasher, self.descriptors.len);
for (self.descriptors) |d| d.hash(hasher); for (self.descriptors) |d| d.hash(hasher);
autoHash(hasher, self.codepoint_map); self.codepoint_map.hash(hasher);
autoHash(hasher, self.metric_modifiers.count()); autoHash(hasher, self.metric_modifiers.count());
if (self.metric_modifiers.count() > 0) { if (self.metric_modifiers.count() > 0) {
inline for (@typeInfo(Metrics.Key).Enum.fields) |field| { inline for (@typeInfo(Metrics.Key).Enum.fields) |field| {

View File

@ -60,8 +60,9 @@ pub const Descriptor = struct {
/// Hash the descriptor with the given hasher. /// Hash the descriptor with the given hasher.
pub fn hash(self: Descriptor, hasher: anytype) void { pub fn hash(self: Descriptor, hasher: anytype) void {
const autoHash = std.hash.autoHash; const autoHash = std.hash.autoHash;
autoHash(hasher, self.family); const autoHashStrat = std.hash.autoHashStrat;
autoHash(hasher, self.style); autoHashStrat(hasher, self.family, .Deep);
autoHashStrat(hasher, self.style, .Deep);
autoHash(hasher, self.codepoint); autoHash(hasher, self.codepoint);
autoHash(hasher, self.size); autoHash(hasher, self.size);
autoHash(hasher, self.bold); autoHash(hasher, self.bold);