summaryrefslogtreecommitdiff
path: root/core/fxge/cfx_fontmgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxge/cfx_fontmgr.cpp')
-rw-r--r--core/fxge/cfx_fontmgr.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/core/fxge/cfx_fontmgr.cpp b/core/fxge/cfx_fontmgr.cpp
index 85999a1976..0a19156b46 100644
--- a/core/fxge/cfx_fontmgr.cpp
+++ b/core/fxge/cfx_fontmgr.cpp
@@ -167,8 +167,9 @@ FXFT_Face CFX_FontMgr::GetCachedTTCFace(int ttc_size,
*pFontData = pFontDesc->FontData();
int face_index = GetTTCIndex(pFontDesc->FontData(), ttc_size, font_offset);
if (!pFontDesc->GetFace(face_index)) {
- pFontDesc->SetFace(
- face_index, GetFixedFace(pFontDesc->FontData(), ttc_size, face_index));
+ pFontDesc->SetFace(face_index, GetFixedFace({pFontDesc->FontData(),
+ static_cast<size_t>(ttc_size)},
+ face_index));
}
pFontDesc->AddRef();
return pFontDesc->GetFace(face_index);
@@ -181,20 +182,22 @@ FXFT_Face CFX_FontMgr::AddCachedTTCFace(
uint32_t size,
int font_offset) {
int face_index = GetTTCIndex(pData.get(), ttc_size, font_offset);
- FXFT_Face face = GetFixedFace(pData.get(), ttc_size, face_index);
+ FXFT_Face face =
+ GetFixedFace({pData.get(), static_cast<size_t>(ttc_size)}, face_index);
auto pFontDesc = pdfium::MakeUnique<CTTFontDesc>(std::move(pData));
pFontDesc->SetFace(face_index, face);
m_FaceMap[KeyNameFromSize(ttc_size, checksum)] = std::move(pFontDesc);
return face;
}
-FXFT_Face CFX_FontMgr::GetFixedFace(const uint8_t* pData,
- uint32_t size,
+FXFT_Face CFX_FontMgr::GetFixedFace(pdfium::span<const uint8_t> span,
int face_index) {
InitFTLibrary();
FXFT_Face face = nullptr;
- if (FXFT_New_Memory_Face(m_FTLibrary, pData, size, face_index, &face))
+ if (FXFT_New_Memory_Face(m_FTLibrary, span.data(), span.size(), face_index,
+ &face)) {
return nullptr;
+ }
return FXFT_Set_Pixel_Sizes(face, 64, 64) ? nullptr : face;
}
@@ -223,21 +226,18 @@ void CFX_FontMgr::ReleaseFace(FXFT_Face face) {
FXFT_Done_Face(face);
}
-bool CFX_FontMgr::GetBuiltinFont(size_t index,
- const uint8_t** pFontData,
- uint32_t* size) {
+Optional<pdfium::span<const uint8_t>> CFX_FontMgr::GetBuiltinFont(
+ size_t index) {
if (index < FX_ArraySize(g_FoxitFonts)) {
- *pFontData = g_FoxitFonts[index].m_pFontData;
- *size = g_FoxitFonts[index].m_dwSize;
- return true;
+ return pdfium::make_span(g_FoxitFonts[index].m_pFontData,
+ g_FoxitFonts[index].m_dwSize);
}
size_t mm_index = index - FX_ArraySize(g_FoxitFonts);
if (mm_index < FX_ArraySize(g_MMFonts)) {
- *pFontData = g_MMFonts[mm_index].m_pFontData;
- *size = g_MMFonts[mm_index].m_dwSize;
- return true;
+ return pdfium::make_span(g_MMFonts[mm_index].m_pFontData,
+ g_MMFonts[mm_index].m_dwSize);
}
- return false;
+ return {};
}
bool CFX_FontMgr::FreeTypeVersionSupportsHinting() const {