summaryrefslogtreecommitdiff
path: root/external/pdfium/0015-svx-set-the-font-name-of-imported-PDF-text.patch.2
blob: 9ce208578d0b63ee54ebf83b7307eb6d3ec33d0d (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
70
71
72
73
74
75
76
77
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
@@ -20,6 +20,7 @@
 #include "core/fpdfapi/page/cpdf_pageobject.h"
 #include "core/fpdfapi/page/cpdf_pathobject.h"
 #include "core/fpdfapi/page/cpdf_shadingobject.h"
+#include "core/fpdfapi/page/cpdf_textobject.h"
 #include "core/fpdfapi/parser/cpdf_array.h"
 #include "core/fpdfapi/parser/cpdf_document.h"
 #include "core/fpdfapi/parser/cpdf_number.h"
@@ -452,6 +453,29 @@ FPDFTextObj_CountChars(FPDF_PAGEOBJECT text_object)
   return pTxtObj->CountChars();
 }
 
+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
 FPDFPageObj_SetBlendMode(FPDF_PAGEOBJECT page_object,
                          FPDF_BYTESTRING blend_mode) {
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
@@ -1142,6 +1142,17 @@ FPDF_EXPORT int FPDF_CALLCONV FPDFText_GetTextRenderMode(FPDF_PAGEOBJECT text);
 FPDF_EXPORT int FPDF_CALLCONV
 FPDFFormObj_CountObjects(FPDF_PAGEOBJECT form_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 number of characters from a text object.
 //
 // text_object - Handle of text object returned by FPDFPageObj_NewTextObj
-- 
2.16.3