فهرست منبع

LibGfx/OpenType: Undo minor deletion in #23225

Check if we have a cmap before dereferencing it again.

Fixes a crash on page 8 of 0000188.pdf now that the font no
longer fails to load to due to a missing name table.

Looks like this is a Type2 truetype font, where we don't provide
an external cmap. How this font is supposed to work without a cmap
I don't know -- but for now, we no longer crash on it, and draw
some of the text with the previous font (which happens to work
fine in this particular case).
Nico Weber 1 سال پیش
والد
کامیت
e8133c8297
1فایلهای تغییر یافته به همراه2 افزوده شده و 0 حذف شده
  1. 2 0
      Userland/Libraries/LibGfx/Font/OpenType/Font.cpp

+ 2 - 0
Userland/Libraries/LibGfx/Font/OpenType/Font.cpp

@@ -278,6 +278,8 @@ ErrorOr<NonnullRefPtr<Font>> Font::try_load_from_offset(ReadonlyBytes buffer, u3
         hmtx = TRY(Hmtx::from_slice(opt_hmtx_slice.value(), maxp.num_glyphs(), hhea.number_of_h_metrics()));
     }
 
+    if (!options.external_cmap && !opt_cmap_slice.has_value())
+        return Error::from_string_literal("Font is missing Cmap");
     NonnullOwnPtr<CharCodeToGlyphIndex> cmap = options.external_cmap ? options.external_cmap.release_nonnull() : TRY(CmapCharCodeToGlyphIndex::from_slice(opt_cmap_slice.value()));
 
     Optional<Loca> loca;