92 pdfium::span<
const float> char_pos,
95 std::vector<TextCharPos> results;
96 results.reserve(char_codes.size());
100 bool has_to_unicode = !!font->GetFontDict()->GetStreamFor(
"ToUnicode");
101 for (size_t i = 0; i < char_codes.size(); ++i) {
102 uint32_t char_code = char_codes[i];
103 if (char_code ==
static_cast<uint32_t>(-1))
106 bool is_vertical_glyph =
false;
107 results.emplace_back();
116#if BUILDFLAG(IS_APPLE)
117 text_char_pos.m_ExtGID = font->GlyphFromCharCodeExt(char_code);
118 glyph_id = text_char_pos.m_ExtGID !=
static_cast<uint32_t>(-1)
119 ? text_char_pos.m_ExtGID
120 : text_char_pos.m_GlyphIndex;
123 if (ShouldUseExistingFont(font, glyph_id, has_to_unicode)) {
132#if BUILDFLAG(IS_APPLE)
133 text_char_pos.m_ExtGID = text_char_pos.m_GlyphIndex;
142 text_char_pos.m_Origin = CFX_PointF(i > 0 ? char_pos[i - 1] : 0, 0);
145 float scaling_factor = 1.0f;
146 if (ApplyGlyphSpacingHeuristic(font, current_font, is_vertical_writing)) {
148 int font_glyph_width =
150 if (font_glyph_width && pdf_glyph_width > font_glyph_width + 1) {
153 text_char_pos.m_Origin.x +=
154 (pdf_glyph_width - font_glyph_width) * font_size / 2000.0f;
155 }
else if (pdf_glyph_width && font_glyph_width &&
156 pdf_glyph_width < font_glyph_width) {
157 scaling_factor =
static_cast<
float>(pdf_glyph_width) / font_glyph_width;
169 if (is_vertical_writing) {
170 text_char_pos.m_Origin = CFX_PointF(0, text_char_pos.m_Origin.x);
172 CFX_Point16 vertical_origin = cid_font->GetVertOrigin(cid);
173 text_char_pos.m_Origin.x -= font_size * vertical_origin.x / 1000;
174 text_char_pos.m_Origin.y -= font_size * vertical_origin.y / 1000;
178 if (cid_transform && !is_vertical_glyph) {
187 text_char_pos.m_Origin.x +=
189 text_char_pos.m_Origin.y +=
int32_t m_FallbackFontPosition