mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-26 22:17:41 +00:00
* GuiFontMetrics: new metrics(QString) method
* QLPainter::paintText(): use GuiFontMetrics::metrics(QString) to avoid an ucs4 to QString conversion. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15584 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
f43176aebc
commit
7f94f08bbe
@ -134,6 +134,24 @@ int GuiFontMetrics::width(char_type const * s, size_t ls) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int GuiFontMetrics::width(QString const & ucs2) const
|
||||||
|
{
|
||||||
|
int const ls = ucs2.size();
|
||||||
|
if (ls == 1 && !smallcaps_shape_) {
|
||||||
|
return width(ucs2[0].unicode());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (smallcaps_shape_)
|
||||||
|
return smallcapsWidth(ucs2);
|
||||||
|
|
||||||
|
int w = 0;
|
||||||
|
for (int i = 0; i < ls; ++i)
|
||||||
|
w += width(ucs2[i].unicode());
|
||||||
|
|
||||||
|
return w;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int GuiFontMetrics::signedWidth(docstring const & s) const
|
int GuiFontMetrics::signedWidth(docstring const & s) const
|
||||||
{
|
{
|
||||||
if (s[0] == '-')
|
if (s[0] == '-')
|
||||||
|
@ -53,6 +53,8 @@ public:
|
|||||||
int & width,
|
int & width,
|
||||||
int & ascent,
|
int & ascent,
|
||||||
int & descent) const;
|
int & descent) const;
|
||||||
|
///
|
||||||
|
int width(QString const & str) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int smallcapsWidth(QString const & s) const;
|
int smallcapsWidth(QString const & s) const;
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "QLPainter.h"
|
#include "QLPainter.h"
|
||||||
|
|
||||||
#include "GuiApplication.h"
|
#include "GuiApplication.h"
|
||||||
|
#include "GuiFontMetrics.h"
|
||||||
#include "GuiWorkArea.h"
|
#include "GuiWorkArea.h"
|
||||||
#include "QLImage.h"
|
#include "QLImage.h"
|
||||||
|
|
||||||
@ -24,7 +25,6 @@
|
|||||||
#include "language.h"
|
#include "language.h"
|
||||||
#include "LColor.h"
|
#include "LColor.h"
|
||||||
|
|
||||||
#include "frontends/FontMetrics.h"
|
|
||||||
|
|
||||||
#include "support/unicode.h"
|
#include "support/unicode.h"
|
||||||
|
|
||||||
@ -245,7 +245,7 @@ int QLPainter::text(int x, int y, char_type const * s, size_t ls,
|
|||||||
// Here we use the font width cache instead of
|
// Here we use the font width cache instead of
|
||||||
// textwidth = fontMetrics().width(str);
|
// textwidth = fontMetrics().width(str);
|
||||||
// because the above is awfully expensive on MacOSX
|
// because the above is awfully expensive on MacOSX
|
||||||
textwidth = guiApp->guiFontLoader().metrics(f).width(s, ls);
|
textwidth = fi.metrics->width(str);
|
||||||
} else {
|
} else {
|
||||||
textwidth = smallCapsText(x, y, str, f);
|
textwidth = smallCapsText(x, y, str, f);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user