From 64bbe431b5174e2ed360bceb4141b274bbe7fcb9 Mon Sep 17 00:00:00 2001 From: Rodrigo Tobar Date: Tue, 31 Jan 2023 23:55:26 +0800 Subject: LibPDF: Add char_code -> name mapping function We already keep both mappings internally, now it's time to actually use it. --- Userland/Libraries/LibPDF/Encoding.cpp | 8 ++++++++ Userland/Libraries/LibPDF/Encoding.h | 2 ++ 2 files changed, 10 insertions(+) (limited to 'Userland/Libraries/LibPDF') diff --git a/Userland/Libraries/LibPDF/Encoding.cpp b/Userland/Libraries/LibPDF/Encoding.cpp index c21767afa3..de4a826d7d 100644 --- a/Userland/Libraries/LibPDF/Encoding.cpp +++ b/Userland/Libraries/LibPDF/Encoding.cpp @@ -168,4 +168,12 @@ u16 Encoding::get_char_code(DeprecatedString const& name) const return 0; } +DeprecatedFlyString Encoding::get_name(u8 char_code) const +{ + auto name_iterator = m_descriptors.find(char_code); + if (name_iterator != m_descriptors.end()) + return name_iterator->value; + return 0; +} + } diff --git a/Userland/Libraries/LibPDF/Encoding.h b/Userland/Libraries/LibPDF/Encoding.h index d25a52b82c..0116867130 100644 --- a/Userland/Libraries/LibPDF/Encoding.h +++ b/Userland/Libraries/LibPDF/Encoding.h @@ -641,6 +641,8 @@ public: HashMap const& name_mapping() const { return m_name_mapping; } u16 get_char_code(DeprecatedString const&) const; + DeprecatedFlyString get_name(u8 char_code) const; + void set(CharCodeType char_code, DeprecatedFlyString const& glyph_name); protected: -- cgit v1.2.3