ladybird/Libraries/LibGfx/ShapeFeature.h
Andreas Kling 66601f7d59 LibWeb: Cache results of harfbuzz text shaping
This patch introduces a per-Gfx::Font cache for harfbuzz text shaping
results. As long as the same OpenType features are used, we now cache
the results of harfbuzz shaping, saving massive amounts of time during
text layout.

As an example, it saves multiple seconds when loading the ECMAScript
specification at <https://tc39.es/ecma262>. Before this change, harfbuzz
shaping was taking up roughly 11% of a profile of loading that page.
The cache brings it down to 1.8%.

Note that the cache currently grows unbounded. I've left a FIXME about
adding some limits.
2025-09-21 13:22:38 +02:00

21 lines
368 B
C++

/*
* Copyright (c) 2025, Andreas Kling <andreas@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
namespace Gfx {
struct ShapeFeature {
char tag[4];
u32 value;
bool operator==(ShapeFeature const&) const = default;
bool operator!=(ShapeFeature const&) const = default;
};
using ShapeFeatures = Vector<ShapeFeature, 4>;
}