mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 03:11:59 +00:00
Cache the value of GuiFontMetrics::lbearing().
This seems to be necessary on windows, where math editing can get very
slow. Note that other methods like rbearing already use a cache.
In the future all these caches for single characters shall be unified.
(cherry picked from commit d3979e798c
)
This commit is contained in:
parent
f94cdf6e1c
commit
e0879b1460
@ -135,20 +135,29 @@ int GuiFontMetrics::strikeoutPos() const
|
||||
}
|
||||
|
||||
|
||||
int GuiFontMetrics::lbearing(char_type c) const
|
||||
{
|
||||
if (!is_utf16(c))
|
||||
// FIXME: QFontMetrics::leftBearing does not support the
|
||||
// full unicode range. Once it does, we could use:
|
||||
//return metrics_.leftBearing(toqstr(docstring(1, c)));
|
||||
return 0;
|
||||
|
||||
return metrics_.leftBearing(ucs4_to_qchar(c));
|
||||
namespace {
|
||||
int const outOfLimitMetric = -10000;
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
int const outOfLimitMetric = -10000;
|
||||
int GuiFontMetrics::lbearing(char_type c) const
|
||||
{
|
||||
int value = lbearing_cache_.value(c, outOfLimitMetric);
|
||||
if (value != outOfLimitMetric)
|
||||
return value;
|
||||
|
||||
if (is_utf16(c))
|
||||
value = metrics_.leftBearing(ucs4_to_qchar(c));
|
||||
else {
|
||||
// FIXME: QFontMetrics::leftBearing does not support the
|
||||
// full unicode range. Once it does, we could use:
|
||||
// metrics_.leftBearing(toqstr(docstring(1, c)));
|
||||
value = 0;
|
||||
}
|
||||
|
||||
lbearing_cache_.insert(c, value);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
|
@ -101,6 +101,8 @@ private:
|
||||
/// fill in \c metrics_cache_ at specified value.
|
||||
AscendDescend const fillMetricsCache(char_type) const;
|
||||
|
||||
/// Cache of char left bearings
|
||||
mutable QHash<char_type, int> lbearing_cache_;
|
||||
/// Cache of char right bearings
|
||||
mutable QHash<char_type, int> rbearing_cache_;
|
||||
|
||||
|
@ -51,6 +51,8 @@ What's new
|
||||
|
||||
- Fix bad error message (bug 11486).
|
||||
|
||||
- Improve performance on Windows with lots of math insets.
|
||||
|
||||
|
||||
* DOCUMENTATION AND LOCALIZATION
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user