Commit af3805f0 authored by Albert Astals Cid's avatar Albert Astals Cid Committed by Albert Astals Cid

[cpp] new enum poppler::text_box::writing_mode_enum

parent 65053f43
......@@ -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++) {
......
......@@ -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.
......
......@@ -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;
/*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment