summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Astals Cid <aacid@kde.org>2020-05-04 04:32:27 +0000
committerAlbert Astals Cid <tsdgeos@yahoo.es>2020-05-19 21:06:58 +0000
commitaf3805f0b60289c7f522da29f9375119a1cd778a (patch)
tree294a682a19f165a447e84c712f9ef6d1789843d5
parent65053f43dbb83b66302bddda27732168fc74cca1 (diff)
[cpp] new enum poppler::text_box::writing_mode_enum
-rw-r--r--cpp/poppler-page.cpp15
-rw-r--r--cpp/poppler-page.h12
-rw-r--r--cpp/poppler-private.h3
3 files changed, 22 insertions, 8 deletions
diff --git a/cpp/poppler-page.cpp b/cpp/poppler-page.cpp
index 715c5ec4..3aa6222b 100644
--- a/cpp/poppler-page.cpp
+++ b/cpp/poppler-page.cpp
@@ -352,7 +352,7 @@ bool text_box::has_space_after() const
return m_data->has_space_after;
}
-int text_box::get_wmode(int i) const
+text_box::writing_mode_enum text_box::get_wmode(int i) const
{
return m_data->wmodes[i];
}
@@ -434,7 +434,18 @@ std::vector<text_box> page::text_list() const
tb.m_data->glyph_to_cache_index.reserve(word->getLength());
for (int j = 0; j < word->getLength(); j++) {
const TextFontInfo* cur_text_font_info = word->getFontInfo(j);
- tb.m_data->wmodes.push_back(cur_text_font_info->getWMode());
+
+ // filter-out the invalid WMode value here.
+ switch (cur_text_font_info->getWMode()) {
+ case 0:
+ tb.m_data->wmodes.push_back(text_box::horizontal_wmode);
+ break;
+ case 1:
+ tb.m_data->wmodes.push_back(text_box::vertical_wmode);
+ break;
+ default:
+ tb.m_data->wmodes.push_back(text_box::invalid_wmode);
+ };
tb.m_data->glyph_to_cache_index[j] = -1;
for (size_t k = 0; k < d->font_info_cache.size(); k++) {
diff --git a/cpp/poppler-page.h b/cpp/poppler-page.h
index 6f9e755d..9db6f87b 100644
--- a/cpp/poppler-page.h
+++ b/cpp/poppler-page.h
@@ -73,17 +73,19 @@ public:
/**
Get a writing mode for the i-th glyph
- This method returns an integer of the writing mode
+ This method returns an enum of the writing mode
for the i-th glyph in the text_box.
- 0 means the horizontal writing mode.
- 1 means the vertical writing mode.
-
\note Usually all glyphs in one text_box have the
same writing mode. Thus the default value of the
glyph index is 0.
*/
- int get_wmode(int i = 0) const;
+ enum writing_mode_enum {
+ invalid_wmode = -1,
+ horizontal_wmode = 0,
+ vertical_wmode = 1
+ };
+ writing_mode_enum get_wmode(int i = 0) const;
/**
Get a font size of this text_box instance.
diff --git a/cpp/poppler-private.h b/cpp/poppler-private.h
index 0fe33d3f..83e46319 100644
--- a/cpp/poppler-private.h
+++ b/cpp/poppler-private.h
@@ -28,6 +28,7 @@
#include "poppler-global.h"
#include "poppler-rectangle.h"
+#include "poppler-page.h" // to use text_box::writing_mode_enum
#include "Error.h"
#include "CharTypes.h"
@@ -82,7 +83,7 @@ struct text_box_data
std::vector<rectf> char_bboxes;
bool has_space_after;
- std::vector<int> wmodes;
+ std::vector<text_box::writing_mode_enum> wmodes;
double font_size;
/*