Explorar o código

LibPDF: Add char_code -> name mapping function

We already keep both mappings internally, now it's time to actually use
it.
Rodrigo Tobar %!s(int64=2) %!d(string=hai) anos
pai
achega
64bbe431b5

+ 8 - 0
Userland/Libraries/LibPDF/Encoding.cpp

@@ -168,4 +168,12 @@ u16 Encoding::get_char_code(DeprecatedString const& name) const
     return 0;
     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;
+}
+
 }
 }

+ 2 - 0
Userland/Libraries/LibPDF/Encoding.h

@@ -641,6 +641,8 @@ public:
     HashMap<DeprecatedString, CharCodeType> const& name_mapping() const { return m_name_mapping; }
     HashMap<DeprecatedString, CharCodeType> const& name_mapping() const { return m_name_mapping; }
 
 
     u16 get_char_code(DeprecatedString const&) const;
     u16 get_char_code(DeprecatedString const&) const;
+    DeprecatedFlyString get_name(u8 char_code) const;
+
     void set(CharCodeType char_code, DeprecatedFlyString const& glyph_name);
     void set(CharCodeType char_code, DeprecatedFlyString const& glyph_name);
 
 
 protected:
 protected: