Add another test for FPDFText_GetFontWeight().
Illustrate the existing behavior and add a TODO to fix it. Rearrange
font_weight.in to make adding new fonts for testing more of an append
operation inside the .in file, to avoid renumbering the /Contents object
every time a font gets added.
Bug: pdfium:1420
Change-Id: I3ceb64eeb342803a2d1f47989d6209d70ed157e3
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/62354
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/fpdfsdk/fpdf_text_embeddertest.cpp b/fpdfsdk/fpdf_text_embeddertest.cpp
index 7cbd27a..ff3c2cb 100644
--- a/fpdfsdk/fpdf_text_embeddertest.cpp
+++ b/fpdfsdk/fpdf_text_embeddertest.cpp
@@ -1353,7 +1353,7 @@
FPDF_TEXTPAGE text_page = FPDFText_LoadPage(page);
ASSERT_TRUE(text_page);
- EXPECT_EQ(1, FPDFText_CountChars(text_page));
+ EXPECT_EQ(2, FPDFText_CountChars(text_page));
EXPECT_EQ(-1, FPDFText_GetFontWeight(nullptr, 0));
EXPECT_EQ(-1, FPDFText_GetFontWeight(text_page, -1));
@@ -1361,8 +1361,12 @@
// The font used for this text only specifies /StemV (80); the weight value
// that is returned should be calculated from that (80*5 == 400).
- int weight = FPDFText_GetFontWeight(text_page, 0);
- EXPECT_EQ(400, weight);
+ EXPECT_EQ(400, FPDFText_GetFontWeight(text_page, 0));
+
+ // Using a /StemV value of 82, the estimate comes out to 410, even though
+ // /FontWeight is 400.
+ // TODO(crbug.com/pdfium/1420): Fix this the return value here.
+ EXPECT_EQ(410, FPDFText_GetFontWeight(text_page, 1));
FPDFText_ClosePage(text_page);
UnloadPage(page);