37 bool bStarted =
false;
38 for (
const TextGlyphPos& glyph : glyphs) {
42 absl::optional<CFX_Point> point = glyph.GetOrigin({0, 0});
43 if (!point.has_value())
46 int char_width = glyph.m_pGlyph->GetBitmap()->GetWidth();
47 if (anti_alias == FT_RENDER_MODE_LCD)
50 FX_SAFE_INT32 char_right = point.value().x;
51 char_right += char_width;
52 if (!char_right.IsValid())
55 FX_SAFE_INT32 char_bottom = point.value().y;
56 char_bottom += glyph.m_pGlyph->GetBitmap()->GetHeight();
57 if (!char_bottom.IsValid())
61 rect.left = std::min(rect.left, point.value().x);
62 rect.top = std::min(rect.top, point.value().y);
63 rect.right = pdfium::base::ValueOrDieForType<int32_t>(
64 pdfium::base::CheckMax(rect.right, char_right));
65 rect.bottom = pdfium::base::ValueOrDieForType<int32_t>(
66 pdfium::base::CheckMax(rect.bottom, char_bottom));
70 rect.left = point.value().x;
71 rect.top = point.value().y;
72 rect.right = char_right.ValueOrDie();
73 rect.bottom = char_bottom.ValueOrDie();
81 if (name_table.size() < 6)
84 uint32_t name_count = FXSYS_UINT16_GET_MSBFIRST(&name_table[2]);
85 uint32_t string_offset = FXSYS_UINT16_GET_MSBFIRST(&name_table[4]);
88 if (name_table.size() < string_offset)
91 pdfium::span<
const uint8_t> string_span = name_table.subspan(string_offset);
92 name_table = name_table.subspan(6);
93 if (name_table.size() < name_count * 12)
96 for (uint32_t i = 0; i < name_count;
97 i++, name_table = name_table.subspan(12)) {
98 if (FXSYS_UINT16_GET_MSBFIRST(&name_table[6]) == name_id) {
99 const uint16_t platform_identifier =
100 FXSYS_UINT16_GET_MSBFIRST(name_table);
101 const uint16_t platform_encoding =
102 FXSYS_UINT16_GET_MSBFIRST(&name_table[2]);
105 platform_encoding == kNameMacEncodingRoman) {
106 return GetStringFromTable(string_span,
107 FXSYS_UINT16_GET_MSBFIRST(&name_table[10]),
108 FXSYS_UINT16_GET_MSBFIRST(&name_table[8]));
111 platform_encoding == kNameWindowsEncodingUnicode) {
113 ByteString utf16_be = GetStringFromTable(
114 string_span, FXSYS_UINT16_GET_MSBFIRST(&name_table[10]),
115 FXSYS_UINT16_GET_MSBFIRST(&name_table[8]));
116 if (utf16_be
.IsEmpty() || utf16_be.GetLength() % 2 != 0) {
128 pdfium::span<
const uint8_t> p = pFontData.subspan(8);
129 size_t nfont = FXSYS_UINT32_GET_MSBFIRST(p.data());
130 for (size_t index = 0; index < nfont; index++) {
131 p = pFontData.subspan(12 + index * 4);
132 if (FXSYS_UINT32_GET_MSBFIRST(p.data()) == font_offset)