From 4c22dd5690cdec725389055bb7c07c300a4b6fe4 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 3 Apr 2018 19:10:51 +0000 Subject: Use Optional to determine if appearance stream as font This CL changes the CPDF_DefaultAppearance code to remove the HasFont method and change GetFont to return an Optional. This forces all the call sites to verify a font was returned correctly and removes the need for the duplicate appearance stream parsing. Bug: chromium:827430 Change-Id: If09e0a7d3f7dd63ad77b97a5a388127e4a02da61 Reviewed-on: https://pdfium-review.googlesource.com/29610 Commit-Queue: Ryan Harrison Reviewed-by: Ryan Harrison --- fpdfsdk/pwl/cpwl_appstream.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'fpdfsdk/pwl/cpwl_appstream.cpp') diff --git a/fpdfsdk/pwl/cpwl_appstream.cpp b/fpdfsdk/pwl/cpwl_appstream.cpp index 0731398ae2..6e65831627 100644 --- a/fpdfsdk/pwl/cpwl_appstream.cpp +++ b/fpdfsdk/pwl/cpwl_appstream.cpp @@ -1184,9 +1184,13 @@ void CPWL_AppStream::SetAsPushButton() { iColorType = da.GetColor(fc); crText = CFX_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); } - float fFontSize = 12.0f; - if (da.HasFont()) - csNameTag = da.GetFont(&fFontSize); + + float fFontSize; + Optional font = da.GetFont(&fFontSize); + if (font) + csNameTag = *font; + else + fFontSize = 12.0f; WideString csWCaption; WideString csNormalCaption; -- cgit v1.2.3