* src/frontends/qt4/GuiFontMetrics.C
(GuiFontMetrics::rbearing): Cache char rbearing.
* src/frontends/qt4/GuiFontMetrics.h:
Implement rbearing_cache_ as a QHash.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17499
a592a061-630c-0410-9148-
cb99ea01b6c8
int GuiFontMetrics::rbearing(char_type c) const
{
- // Qt rbearing is from the right edge of the char's width().
- QChar sc = ucs4_to_qchar(c);
- return metrics_.width(sc) - metrics_.rightBearing(sc);
+ if (!rbearing_cache_.contains(c)) {
+ // Qt rbearing is from the right edge of the char's width().
+ QChar sc = ucs4_to_qchar(c);
+ int rb = metrics_.width(sc) - metrics_.rightBearing(sc);
+ rbearing_cache_.insert(c, rb);
+ }
+ return rbearing_cache_.value(c);
}
mutable QHash<char_type, AscendDescend> metrics_cache_;
/// fill in \c metrics_cache_ at specified value.
void fillMetricsCache(char_type) const;
+
+ /// Cache of char right bearings
+ mutable QHash<char_type, int> rbearing_cache_;
};
} // namespace frontend