[Libreoffice-commits] core.git: desktop/source include/LibreOfficeKit
Henry Castro
hcastro at collabora.com
Mon Nov 14 13:07:15 UTC 2016
desktop/source/lib/init.cxx | 10 ++++++++--
include/LibreOfficeKit/LibreOfficeKit.h | 1 +
include/LibreOfficeKit/LibreOfficeKit.hxx | 5 +++--
3 files changed, 12 insertions(+), 4 deletions(-)
New commits:
commit 32d0378284a42f0eba1df92555767a43be079117
Author: Henry Castro <hcastro at collabora.com>
Date: Fri Nov 11 16:29:57 2016 -0400
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 at libreoffice.org>
Reviewed-by: Andras Timar <andras.timar at collabora.com>
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index ddbcc3c..ea543ed 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;
}
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index c97655f..c7a2130 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -225,6 +225,7 @@ struct _LibreOfficeKitDocumentClass
/// @see lok::Document::renderFont().
unsigned char* (*renderFont) (LibreOfficeKitDocument* pThis,
const char* pFontName,
+ const char* pChar,
int* pFontWidth,
int* pFontHeight);
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 7c90df5..1c9474f 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -404,14 +404,15 @@ public:
}
/**
- * Paints a font name to be displayed in the font list
+ * Paints a font name or character if provided to be displayed in the font list
* @param pFontName the font to be painted
*/
inline unsigned char* renderFont(const char *pFontName,
+ const char *pChar,
int *pFontWidth,
int *pFontHeight)
{
- return mpDoc->pClass->renderFont(mpDoc, pFontName, pFontWidth, pFontHeight);
+ return mpDoc->pClass->renderFont(mpDoc, pFontName, pChar, pFontWidth, pFontHeight);
}
/**
More information about the Libreoffice-commits
mailing list