diff --git a/Userland/Libraries/LibPDF/Fonts/Type1FontProgram.cpp b/Userland/Libraries/LibPDF/Fonts/Type1FontProgram.cpp index b325b97dc0..8a94bf9290 100644 --- a/Userland/Libraries/LibPDF/Fonts/Type1FontProgram.cpp +++ b/Userland/Libraries/LibPDF/Fonts/Type1FontProgram.cpp @@ -244,15 +244,16 @@ PDFErrorOr Type1FontProgram::parse_glyph(ReadonlyBytes }; // Potential font width parsing for some commands (type2 only) - bool is_first_command = true; enum EvenOrOdd { Even, Odd }; auto maybe_read_width = [&](EvenOrOdd required_argument_count) { - if (!is_type2 || !is_first_command || state.sp % 2 != required_argument_count) + if (!is_type2 || !state.is_first_command) return; - state.glyph.set_width(pop_front()); + state.is_first_command = false; + if (state.sp % 2 == required_argument_count) + state.glyph.set_width(pop_front()); }; // Parse the stream of parameters and commands that make up a glyph outline. @@ -717,8 +718,6 @@ PDFErrorOr Type1FontProgram::parse_glyph(ReadonlyBytes dbgln("Unhandled command: {}", v); return error("Unhandled command"); } - - is_first_command = false; } } diff --git a/Userland/Libraries/LibPDF/Fonts/Type1FontProgram.h b/Userland/Libraries/LibPDF/Fonts/Type1FontProgram.h index 714babb41d..8462e6611d 100644 --- a/Userland/Libraries/LibPDF/Fonts/Type1FontProgram.h +++ b/Userland/Libraries/LibPDF/Fonts/Type1FontProgram.h @@ -79,6 +79,8 @@ protected: size_t postscript_sp { 0 }; Array postscript_stack; + + bool is_first_command { true }; }; static PDFErrorOr parse_glyph(ReadonlyBytes const&, Vector const& local_subroutines, Vector const& global_subroutines, GlyphParserState&, bool is_type2);