mirror of
https://github.com/SerenityOS/serenity.git
synced 2026-11-07 04:29:30 -10:00
LibPDF: Extract Type1Font::char_name_for_char_code()
No behavior change.
This commit is contained in:
1 parent
d0ddbf3ccd
commit
ca08ac270f
2 files changed
+13
-6
No files matched your search
@@ -104,6 +104,16 @@ void Type1Font::set_font_size(float font_size)
|
||||
m_fallback_font_painter->set_font_size(font_size);
|
||||
}
|
||||
|
||||
DeprecatedFlyString Type1Font::char_name_for_char_code(u8 char_code) const
|
||||
{
|
||||
auto effective_encoding = encoding();
|
||||
if (!effective_encoding)
|
||||
effective_encoding = m_font_program->encoding();
|
||||
if (!effective_encoding)
|
||||
effective_encoding = Encoding::standard_encoding();
|
||||
return effective_encoding->get_name(char_code);
|
||||
}
|
||||
|
||||
PDFErrorOr<void> Type1Font::draw_glyph(Gfx::Painter& painter, Gfx::FloatPoint point, float width, u8 char_code, Renderer const& renderer)
|
||||
{
|
||||
auto color = TRY(renderer.state().paint_color.visit(
|
||||
@@ -117,12 +127,7 @@ PDFErrorOr<void> Type1Font::draw_glyph(Gfx::Painter& painter, Gfx::FloatPoint po
|
||||
if (!m_font_program)
|
||||
return m_fallback_font_painter->draw_glyph(painter, point, char_code, renderer);
|
||||
|
||||
auto effective_encoding = encoding();
|
||||
if (!effective_encoding)
|
||||
effective_encoding = m_font_program->encoding();
|
||||
if (!effective_encoding)
|
||||
effective_encoding = Encoding::standard_encoding();
|
||||
auto char_name = effective_encoding->get_name(char_code);
|
||||
auto char_name = char_name_for_char_code(char_code);
|
||||
auto translation = m_font_program->glyph_translation(char_name, width);
|
||||
point = point.translated(translation);
|
||||
|
||||
|
||||
@@ -35,6 +35,8 @@ protected:
|
||||
PDFErrorOr<void> initialize(Document*, NonnullRefPtr<DictObject> const&, float font_size) override;
|
||||
|
||||
private:
|
||||
DeprecatedFlyString char_name_for_char_code(u8 char_code) const;
|
||||
|
||||
DeprecatedFlyString m_base_font_name;
|
||||
RefPtr<Type1FontProgram> m_font_program;
|
||||
OwnPtr<TrueTypePainter> m_fallback_font_painter;
|
||||
|
||||
Reference in new issue
Block a user