mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:27:44 +00:00
LibPDF: Honor writing mode in TJ operator as well
This commit is contained in:
parent
c69797fda9
commit
9e502dcfe4
3 changed files with 12 additions and 6 deletions
|
@ -20,6 +20,11 @@ class Renderer;
|
||||||
// these tables in some cases. Skip reading these tables.
|
// these tables in some cases. Skip reading these tables.
|
||||||
constexpr u32 pdf_skipped_opentype_tables = OpenType::FontOptions::SkipTables::Name | OpenType::FontOptions::SkipTables::Hmtx | OpenType::FontOptions::SkipTables::OS2;
|
constexpr u32 pdf_skipped_opentype_tables = OpenType::FontOptions::SkipTables::Name | OpenType::FontOptions::SkipTables::Hmtx | OpenType::FontOptions::SkipTables::OS2;
|
||||||
|
|
||||||
|
enum class WritingMode {
|
||||||
|
Horizontal,
|
||||||
|
Vertical,
|
||||||
|
};
|
||||||
|
|
||||||
class PDFFont : public RefCounted<PDFFont> {
|
class PDFFont : public RefCounted<PDFFont> {
|
||||||
public:
|
public:
|
||||||
static PDFErrorOr<NonnullRefPtr<PDFFont>> create(Document*, NonnullRefPtr<DictObject> const&, float font_size);
|
static PDFErrorOr<NonnullRefPtr<PDFFont>> create(Document*, NonnullRefPtr<DictObject> const&, float font_size);
|
||||||
|
@ -29,6 +34,8 @@ public:
|
||||||
virtual void set_font_size(float font_size) = 0;
|
virtual void set_font_size(float font_size) = 0;
|
||||||
virtual PDFErrorOr<Gfx::FloatPoint> draw_string(Gfx::Painter&, Gfx::FloatPoint, ByteString const&, Renderer const&) = 0;
|
virtual PDFErrorOr<Gfx::FloatPoint> draw_string(Gfx::Painter&, Gfx::FloatPoint, ByteString const&, Renderer const&) = 0;
|
||||||
|
|
||||||
|
virtual WritingMode writing_mode() const { return WritingMode::Horizontal; }
|
||||||
|
|
||||||
// TABLE 5.20 Font flags
|
// TABLE 5.20 Font flags
|
||||||
bool is_fixed_pitch() const { return m_flags & (1 << (1 - 1)); }
|
bool is_fixed_pitch() const { return m_flags & (1 << (1 - 1)); }
|
||||||
bool is_serif() const { return m_flags & (1 << (2 - 1)); }
|
bool is_serif() const { return m_flags & (1 << (2 - 1)); }
|
||||||
|
|
|
@ -27,11 +27,6 @@ public:
|
||||||
virtual u32 next() = 0;
|
virtual u32 next() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class WritingMode {
|
|
||||||
Horizontal,
|
|
||||||
Vertical,
|
|
||||||
};
|
|
||||||
|
|
||||||
class Type0CMap {
|
class Type0CMap {
|
||||||
public:
|
public:
|
||||||
virtual ~Type0CMap() = default;
|
virtual ~Type0CMap() = default;
|
||||||
|
@ -58,6 +53,7 @@ public:
|
||||||
|
|
||||||
void set_font_size(float font_size) override;
|
void set_font_size(float font_size) override;
|
||||||
PDFErrorOr<Gfx::FloatPoint> draw_string(Gfx::Painter&, Gfx::FloatPoint, ByteString const&, Renderer const&) override;
|
PDFErrorOr<Gfx::FloatPoint> draw_string(Gfx::Painter&, Gfx::FloatPoint, ByteString const&, Renderer const&) override;
|
||||||
|
WritingMode writing_mode() const override { return m_cmap->writing_mode(); }
|
||||||
|
|
||||||
DeprecatedFlyString base_font_name() const { return m_base_font_name; }
|
DeprecatedFlyString base_font_name() const { return m_base_font_name; }
|
||||||
|
|
||||||
|
|
|
@ -598,7 +598,10 @@ RENDERER_HANDLER(text_show_string_array)
|
||||||
for (auto& element : elements) {
|
for (auto& element : elements) {
|
||||||
if (element.has_number()) {
|
if (element.has_number()) {
|
||||||
float shift = element.to_float() / 1000.0f;
|
float shift = element.to_float() / 1000.0f;
|
||||||
m_text_matrix.translate(-shift * text_state().font_size * text_state().horizontal_scaling, 0.0f);
|
if (text_state().font->writing_mode() == WritingMode::Horizontal)
|
||||||
|
m_text_matrix.translate(-shift * text_state().font_size * text_state().horizontal_scaling, 0.0f);
|
||||||
|
else
|
||||||
|
m_text_matrix.translate(0.0f, -shift * text_state().font_size);
|
||||||
m_text_rendering_matrix_is_dirty = true;
|
m_text_rendering_matrix_is_dirty = true;
|
||||||
} else {
|
} else {
|
||||||
auto str = element.get<NonnullRefPtr<Object>>()->cast<StringObject>()->string();
|
auto str = element.get<NonnullRefPtr<Object>>()->cast<StringObject>()->string();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue