Skip to content

Commit

Permalink
Fix FT_Load_Sfnt_Table() return code check in tryExtractDataFromTTC
Browse files Browse the repository at this point in the history
rc == 0 is success. Also finally tested TTC extraction. Should fix #150
  • Loading branch information
ceztko committed Apr 6, 2024
1 parent 4b6d1a1 commit d22584c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion extern/resources
2 changes: 1 addition & 1 deletion src/podofo/private/FreetypePrivate.cpp
Expand Up @@ -182,7 +182,7 @@ bool tryExtractDataFromTTC(FT_Face face, charbuff& buffer)
uint32_t tag;
size = sizeof(FT_ULong);
rc = FT_Load_Sfnt_Table(face, 0, 0, (FT_Byte*)&tag, &size);
if (rc == 0 || FROM_BIG_ENDIAN(tag) != TTAG_ttcf)
if (rc != 0 || FROM_BIG_ENDIAN(tag) != TTAG_ttcf)
return false;

// First read the TTC font header and then determine the face offset
Expand Down
6 changes: 3 additions & 3 deletions test/unit/DeviceTest.cpp
Expand Up @@ -41,11 +41,11 @@ TEST_CASE("TestStreamedDocument")
auto testPath = TestUtils::GetTestOutputFilePath("TestStreamedDocument.pdf");
PdfStreamedDocument document(testPath);
auto& page = document.GetPages().CreatePage(PdfPage::CreateStandardPageSize(PdfPageSize::A4));
auto font = document.GetFonts().SearchFont("LiberationSans");
REQUIRE(font != nullptr);
// NOTE: use a TTC version of the LiberationSans format to test TTC extraction
auto& font = document.GetFonts().GetOrCreateFont(TestUtils::GetTestInputFilePath("Fonts", "LiberationSans.ttc"), 2);
PdfPainter painter;
painter.SetCanvas(page);
painter.TextState.SetFont(*font, 18);
painter.TextState.SetFont(font, 18);
painter.DrawText("Hello World!", 56.69, page.GetRect().Height - 56.69);
painter.FinishDrawing();
}

0 comments on commit d22584c

Please sign in to comment.