39 bool bStarted =
false;
40 for (
const TextGlyphPos& glyph : glyphs) {
44 std::optional<CFX_Point> point = glyph.GetOrigin({0, 0});
45 if (!point.has_value())
48 int char_width = glyph.m_pGlyph->GetBitmap()->GetWidth();
49 if (anti_alias == FT_RENDER_MODE_LCD)
52 FX_SAFE_INT32 char_right = point.value().x;
53 char_right += char_width;
54 if (!char_right.IsValid())
57 FX_SAFE_INT32 char_bottom = point.value().y;
58 char_bottom += glyph.m_pGlyph->GetBitmap()->GetHeight();
59 if (!char_bottom.IsValid())
63 rect.left = std::min(rect.left, point.value().x);
64 rect.top = std::min(rect.top, point.value().y);
65 rect.right = pdfium::ValueOrDieForType<int32_t>(
66 pdfium::CheckMax(rect.right, char_right));
67 rect.bottom = pdfium::ValueOrDieForType<int32_t>(
68 pdfium::CheckMax(rect.bottom, char_bottom));
72 rect.left = point.value().x;
73 rect.top = point.value().y;
74 rect.right = char_right.ValueOrDie();
75 rect.bottom = char_bottom.ValueOrDie();
83 if (name_table.size() < 6)
86 uint32_t name_count = fxcrt::GetUInt16MSBFirst(name_table.subspan(2));
87 uint32_t string_offset = fxcrt::GetUInt16MSBFirst(name_table.subspan(4));
90 if (name_table.size() < string_offset)
93 pdfium::span<
const uint8_t> string_span = name_table.subspan(string_offset);
94 name_table = name_table.subspan(6);
95 if (name_table.size() < name_count * 12)
98 for (uint32_t i = 0; i < name_count;
99 i++, name_table = name_table.subspan(12)) {
101 const uint16_t platform_identifier = fxcrt::GetUInt16MSBFirst(name_table);
102 const uint16_t platform_encoding =
103 fxcrt::GetUInt16MSBFirst(name_table.subspan(2));
106 platform_encoding == kNameMacEncodingRoman) {
107 return GetStringFromTable(
108 string_span, fxcrt::GetUInt16MSBFirst(name_table.subspan(10)),
109 fxcrt::GetUInt16MSBFirst(name_table.subspan(8)));
112 platform_encoding == kNameWindowsEncodingUnicode) {
115 string_span, fxcrt::GetUInt16MSBFirst(name_table.subspan(10)),
116 fxcrt::GetUInt16MSBFirst(name_table.subspan(8)));
117 if (utf16_be.IsEmpty() || utf16_be.GetLength() % 2 != 0) {
121 return WideString::FromUTF16BE(utf16_be.unsigned_span()).ToUTF8();
129 pdfium::span<
const uint8_t> p = pFontData.subspan(8);
130 size_t nfont = fxcrt::GetUInt32MSBFirst(p);
131 for (size_t index = 0; index < nfont; index++) {
132 p = pFontData.subspan(12 + index * 4);