summaryrefslogtreecommitdiff
path: root/external/pdfium/0015-svx-set-the-font-name-of-imported-PDF-text.patch.2
blob: 798b2b6c1ef85ca5cd4c4235c95f5141d39fde64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
From 04f9899ddf5f9691ffaca5091082183f167e95d3 Mon Sep 17 00:00:00 2001
From: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
Date: Wed, 6 Jun 2018 06:34:56 +0200
Subject: [PATCH] svx: set the font name of imported PDF text

---
 pdfium/fpdfsdk/fpdf_editpage.cpp | 23 +++++++++++++++++++++++
 pdfium/public/fpdf_edit.h        | 11 +++++++++++
 2 files changed, 34 insertions(+)

diff --git a/pdfium/fpdfsdk/fpdf_editpage.cpp b/pdfium/fpdfsdk/fpdf_editpage.cpp
index a52e1a9..9daffc0 100644
--- a/pdfium/fpdfsdk/fpdf_editpage.cpp
+++ b/pdfium/fpdfsdk/fpdf_editpage.cpp
@@ -648,6 +648,29 @@ FPDFTextObj_GetFontSize(FPDF_PAGEOBJECT text_object)
   return pTxtObj->GetFontSize();
 }
 
+FPDF_EXPORT int FPDF_CALLCONV
+FPDFTextObj_GetFontName(FPDF_PAGEOBJECT text_object, char* result)
+{
+  if (!text_object)
+    return 0;
+
+  CPDF_TextObject* pTxtObj = CPDFTextObjectFromFPDFPageObject(text_object);
+  CPDF_Font* pPdfFont = pTxtObj->GetFont();
+  if (!pPdfFont)
+    return 0;
+
+  CFX_Font* pFont = pPdfFont->GetFont();
+  if (!pFont)
+    return 0;
+
+  ByteString byte_str = pFont->GetFamilyName();
+  const size_t byte_str_len = byte_str.GetLength();
+
+  memcpy(result, byte_str.GetBuffer(byte_str_len).data(), byte_str_len);
+  result[byte_str_len] = '\0';
+  return byte_str_len;
+}
+
 FPDF_EXPORT void FPDF_CALLCONV
 FPDFTextObj_GetMatrix(FPDF_PAGEOBJECT text_object,
                       double* a,
diff --git a/pdfium/public/fpdf_edit.h b/pdfium/public/fpdf_edit.h
index 4351649..f858ab2 100644
--- a/pdfium/public/fpdf_edit.h
+++ b/pdfium/public/fpdf_edit.h
@@ -1030,6 +1030,17 @@ FPDFTextObj_CountChars(FPDF_PAGEOBJECT text_object);
 FPDF_EXPORT int FPDF_CALLCONV
 FPDFTextObj_GetFontSize(FPDF_PAGEOBJECT text_object);
 
+// Get the font name of a text object.
+//
+// text_object - Handle of text object returned by FPDFPageObj_NewTextObj
+//               or FPDFPageObj_NewTextObjEx.
+// result - The result in ascii.
+//
+// Return Value:
+// The number of characters / bytes written in result.
+FPDF_EXPORT int FPDF_CALLCONV
+FPDFTextObj_GetFontName(FPDF_PAGEOBJECT text_object, char* result);
+
 // Get the matrix of a particular text object.
 //
 // text_object - Handle of text object returned by FPDFPageObj_NewTextObj
-- 
2.16.3