Use FXSYS_UINT32_GET_MSBFIRST() in CFX_Win32FontInfo::IsSupportedFont().
Avoid duplicating the logic in FXSYS_UINT32_GET_MSBFIRST().
Change-Id: I7c1b8f62a8eedcccd9b8d84273c60421a95cde4d
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/91853
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxge/win32/cwin32_platform.cpp b/core/fxge/win32/cwin32_platform.cpp
index a50fd0f..bc9f5eb 100644
--- a/core/fxge/win32/cwin32_platform.cpp
+++ b/core/fxge/win32/cwin32_platform.cpp
@@ -141,19 +141,16 @@
bool ret = false;
size_t font_size = GetFontData(hFont, 0, {});
if (font_size != GDI_ERROR && font_size >= sizeof(uint32_t)) {
- uint32_t lVersion = 0;
- GetFontData(hFont, 0, {(uint8_t*)(&lVersion), sizeof(lVersion)});
- lVersion = (((uint32_t)(uint8_t)(lVersion)) << 24) |
- ((uint32_t)((uint8_t)(lVersion >> 8))) << 16 |
- ((uint32_t)((uint8_t)(lVersion >> 16))) << 8 |
- ((uint8_t)(lVersion >> 24));
- if (lVersion == FXBSTR_ID('O', 'T', 'T', 'O') || lVersion == 0x00010000 ||
- lVersion == FXBSTR_ID('t', 't', 'c', 'f') ||
- lVersion == FXBSTR_ID('t', 'r', 'u', 'e') || lVersion == 0x00020000 ||
- (lVersion & 0xFFFF0000) == FXBSTR_ID(0x80, 0x01, 0x00, 0x00) ||
- (lVersion & 0xFFFF0000) == FXBSTR_ID('%', '!', 0, 0)) {
- ret = true;
- }
+ uint32_t header;
+ auto span = pdfium::as_writable_bytes(pdfium::make_span(&header, 1));
+ GetFontData(hFont, 0, span);
+ header = FXSYS_UINT32_GET_MSBFIRST(span);
+ ret = header == FXBSTR_ID('O', 'T', 'T', 'O') ||
+ header == FXBSTR_ID('t', 't', 'c', 'f') ||
+ header == FXBSTR_ID('t', 'r', 'u', 'e') || header == 0x00010000 ||
+ header == 0x00020000 ||
+ (header & 0xFFFF0000) == FXBSTR_ID(0x80, 0x01, 0x00, 0x00) ||
+ (header & 0xFFFF0000) == FXBSTR_ID('%', '!', 0, 0);
}
DeleteFont(hFont);
return ret;