Further tidy CFX_Face methods
- Make IsTricky() private.
- Make GetOs2UnicodeRange() XFA-only
- Make GetOs2Panose XFA/Android-only
Change-Id: I5b3da07ceb3ef6112db4ff302507a2c2ec2b84aa
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/139131
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxge/cfx_face.cpp b/core/fxge/cfx_face.cpp
index e565cde..ec0c244 100644
--- a/core/fxge/cfx_face.cpp
+++ b/core/fxge/cfx_face.cpp
@@ -503,6 +503,7 @@
return pdfium::checked_cast<size_t>(length);
}
+#if defined(PDF_ENABLE_XFA)
std::optional<std::array<uint32_t, 4>> CFX_Face::GetOs2UnicodeRange() {
auto* os2 = static_cast<TT_OS2*>(FT_Get_Sfnt_Table(GetRec(), FT_SFNT_OS2));
if (!os2) {
@@ -513,6 +514,7 @@
static_cast<uint32_t>(os2->ulUnicodeRange3),
static_cast<uint32_t>(os2->ulUnicodeRange4)};
}
+#endif // defined(PDF_ENABLE_XFA)
#if defined(PDF_ENABLE_XFA) || BUILDFLAG(IS_ANDROID)
std::optional<std::array<uint32_t, 2>> CFX_Face::GetOs2CodePageRange() {
@@ -523,7 +525,6 @@
return std::array<uint32_t, 2>{static_cast<uint32_t>(os2->ulCodePageRange1),
static_cast<uint32_t>(os2->ulCodePageRange2)};
}
-#endif // defined(PDF_ENABLE_XFA) || BUILDFLAG(IS_ANDROID)
std::optional<std::array<uint8_t, 2>> CFX_Face::GetOs2Panose() {
auto* os2 = static_cast<TT_OS2*>(FT_Get_Sfnt_Table(GetRec(), FT_SFNT_OS2));
@@ -533,6 +534,7 @@
// SAFETY: required from library.
return UNSAFE_BUFFERS(std::array<uint8_t, 2>{os2->panose[0], os2->panose[1]});
}
+#endif // defined(PDF_ENABLE_XFA) || BUILDFLAG(IS_ANDROID)
int CFX_Face::GetGlyphCount() const {
return pdfium::checked_cast<int>(GetRec()->num_glyphs);
diff --git a/core/fxge/cfx_face.h b/core/fxge/cfx_face.h
index e197c53..92b0030 100644
--- a/core/fxge/cfx_face.h
+++ b/core/fxge/cfx_face.h
@@ -73,7 +73,6 @@
#endif
bool HasGlyphNames() const;
bool IsTtOt() const;
- bool IsTricky() const;
bool IsFixedWidth() const;
bool IsItalic() const;
@@ -93,8 +92,6 @@
// it is large enough to hold the data.
size_t GetSfntTable(uint32_t table, pdfium::span<uint8_t> buffer);
- std::optional<std::array<uint32_t, 4>> GetOs2UnicodeRange();
-
int GetGlyphCount() const;
// TODO(crbug.com/pdfium/2037): Can this method be private?
FX_RECT GetGlyphBBox() const;
@@ -147,6 +144,7 @@
#if defined(PDF_ENABLE_XFA)
bool IsScalable() const;
int GetNumFaces() const;
+ std::optional<std::array<uint32_t, 4>> GetOs2UnicodeRange();
#endif
#if BUILDFLAG(IS_WIN)
@@ -164,12 +162,15 @@
FXFT_FaceRec* GetRec() { return rec_.get(); }
const FXFT_FaceRec* GetRec() const { return rec_.get(); }
+ bool IsTricky() const;
+
bool SetPixelSize(uint32_t width, uint32_t height);
void AdjustVariationParams(int glyph_index, int dest_width, int weight);
- std::optional<std::array<uint8_t, 2>> GetOs2Panose();
#if BUILDFLAG(IS_ANDROID) || defined(PDF_ENABLE_XFA)
+ std::optional<std::array<uint8_t, 2>> GetOs2Panose();
+
static RetainPtr<CFX_Face> Open(FT_Library library,
const FT_Open_Args* args,
uint32_t face_index);