mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 02:14:50 +00:00
Cache char right bearings
* 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
This commit is contained in:
parent
a016215367
commit
333040706b
@ -59,9 +59,13 @@ int GuiFontMetrics::lbearing(char_type c) const
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -75,6 +75,9 @@ private:
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user