Remove dependence from cjs_field.cpp to fpdfapi/font
Push some functionality back into the cpdf_formcontrol, which
already has knowlege of CPDF_Font. This removes the last
dependence between fxjs and fpdfapi/font, so update build rules.
Change-Id: I50bc778ca831c95477b4d10fe879a0a47e7a6ba8
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/58630
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/fxjs/cjs_field.cpp b/fxjs/cjs_field.cpp
index a15781c..45e5ad7 100644
--- a/fxjs/cjs_field.cpp
+++ b/fxjs/cjs_field.cpp
@@ -12,7 +12,6 @@
#include "constants/annotation_flags.h"
#include "constants/form_flags.h"
-#include "core/fpdfapi/font/cpdf_font.h"
#include "core/fpdfdoc/cpdf_formcontrol.h"
#include "core/fpdfdoc/cpdf_formfield.h"
#include "core/fpdfdoc/cpdf_interactiveform.h"
@@ -1984,13 +1983,12 @@
return CJS_Result::Failure(JSMessage::kObjectTypeError);
}
- RetainPtr<CPDF_Font> pFont = pFormControl->GetDefaultControlFont();
- if (!pFont)
+ Optional<WideString> wsFontName = pFormControl->GetDefaultControlFontName();
+ if (!wsFontName.has_value())
return CJS_Result::Failure(JSMessage::kBadObjectError);
- return CJS_Result::Success(pRuntime->NewString(
- WideString::FromDefANSI(pFont->GetBaseFontName().AsStringView())
- .AsStringView()));
+ return CJS_Result::Success(
+ pRuntime->NewString(wsFontName.value().AsStringView()));
}
CJS_Result CJS_Field::set_text_font(CJS_Runtime* pRuntime,