summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2016-11-11 16:29:57 -0400
committerAndras Timar <andras.timar@collabora.com>2016-11-14 13:06:47 +0000
commit32d0378284a42f0eba1df92555767a43be079117 (patch)
tree95e7403be24a04d1f5c46c7d2440e2f0e94656bf /desktop
parent65ba7e4dc4eac174bbf02570d6a43803b7b681ff (diff)
lok: add character parameter to renderFont
When client side request special character, it is very useful to send a preview of the rendered font character Conflicts: desktop/source/lib/init.cxx Change-Id: I1f5727163dfcc861add121e616bdb17881c28197 Reviewed-on: https://gerrit.libreoffice.org/30784 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/lib/init.cxx10
1 files changed, 8 insertions, 2 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index ddbcc3ced57a..ea543ed2e3bf 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -484,6 +484,7 @@ static int doc_getViewsCount(LibreOfficeKitDocument* pThis);
static bool doc_getViewIds(LibreOfficeKitDocument* pThis, int* pArray, size_t nSize);
static unsigned char* doc_renderFont(LibreOfficeKitDocument* pThis,
const char *pFontName,
+ const char *pChar,
int* pFontWidth,
int* pFontHeight);
static char* doc_getPartHash(LibreOfficeKitDocument* pThis, int nPart);
@@ -2468,12 +2469,14 @@ static bool doc_getViewIds(LibreOfficeKitDocument* /*pThis*/, int* pArray, size_
unsigned char* doc_renderFont(LibreOfficeKitDocument* /*pThis*/,
const char* pFontName,
+ const char* pChar,
int* pFontWidth,
int* pFontHeight)
{
SolarMutexGuard aGuard;
OString aSearchedFontName(pFontName);
+ OUString aText(OStringToOUString(pChar, RTL_TEXTENCODING_UTF8));
SfxObjectShell* pDocSh = SfxObjectShell::Current();
const SvxFontListItem* pFonts = static_cast<const SvxFontListItem*>(
pDocSh->GetItem(SID_ATTR_CHAR_FONTLIST));
@@ -2489,6 +2492,9 @@ unsigned char* doc_renderFont(LibreOfficeKitDocument* /*pThis*/,
if (!aSearchedFontName.equals(aFontName.toUtf8().getStr()))
continue;
+ if (aText.isEmpty())
+ aText = rFontMetric.GetFamilyName();
+
auto aDevice(
VclPtr<VirtualDevice>::Create(
nullptr, Size(1, 1), DeviceFormat::DEFAULT));
@@ -2496,7 +2502,7 @@ unsigned char* doc_renderFont(LibreOfficeKitDocument* /*pThis*/,
vcl::Font aFont(rFontMetric);
aFont.SetFontSize(Size(0, 25));
aDevice->SetFont(aFont);
- aDevice->GetTextBoundRect(aRect, aFontName);
+ aDevice->GetTextBoundRect(aRect, aText);
int nFontWidth = aRect.BottomRight().X() + 1;
*pFontWidth = nFontWidth;
int nFontHeight = aRect.BottomRight().Y() + 1;
@@ -2509,7 +2515,7 @@ unsigned char* doc_renderFont(LibreOfficeKitDocument* /*pThis*/,
aDevice->SetOutputSizePixelScaleOffsetAndBuffer(
Size(nFontWidth, nFontHeight), Fraction(1.0), Point(),
pBuffer);
- aDevice->DrawText(Point(0,0), aFontName);
+ aDevice->DrawText(Point(0,0), aText);
return pBuffer;
}