}
+namespace {
+int const outOfLimitMetric = -10000;
+}
+
+
int GuiFontMetrics::lbearing(char_type c) const
{
- if (!is_utf16(c))
+ 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:
- //return metrics_.leftBearing(toqstr(docstring(1, c)));
- return 0;
-
- return metrics_.leftBearing(ucs4_to_qchar(c));
-}
+ // metrics_.leftBearing(toqstr(docstring(1, c)));
+ value = 0;
+ }
+ lbearing_cache_.insert(c, value);
-namespace {
-int const outOfLimitMetric = -10000;
+ return value;
}
/// fill in \c metrics_cache_ at specified value.
AscendDescend const fillMetricsCache(char_type) const;
+ /// Cache of char leftt bearings
+ mutable QHash<char_type, int> lbearing_cache_;
/// Cache of char right bearings
mutable QHash<char_type, int> rbearing_cache_;