98 pdfium::span<
const float> char_pos,
101 std::vector<TextCharPos> results;
102 results.reserve(char_codes.size());
106 bool has_to_unicode = !!font->GetFontDict()->GetStreamFor(
"ToUnicode");
107 for (size_t i = 0; i < char_codes.size(); ++i) {
108 uint32_t char_code = char_codes[i];
109 if (char_code ==
static_cast<uint32_t>(-1))
112 bool is_vertical_glyph =
false;
113 results.emplace_back();
118 text_char_pos.m_Unicode = !unicode.IsEmpty() ? unicode[0] : char_code;
122#if BUILDFLAG(IS_APPLE)
123 text_char_pos.m_ExtGID = font->GlyphFromCharCodeExt(char_code);
124 glyph_id = text_char_pos.m_ExtGID !=
static_cast<uint32_t>(-1)
125 ? text_char_pos.m_ExtGID
126 : text_char_pos.m_GlyphIndex;
129 if (ShouldUseExistingFont(font, glyph_id, has_to_unicode)) {
138#if BUILDFLAG(IS_APPLE)
139 text_char_pos.m_ExtGID = text_char_pos.m_GlyphIndex;
148 text_char_pos.m_Origin =
CFX_PointF(i > 0 ? char_pos[i - 1] : 0, 0);
151 float scaling_factor = 1.0f;
152 if (ApplyGlyphSpacingHeuristic(font, current_font, is_vertical_writing)) {
154 int font_glyph_width =
156 if (font_glyph_width && pdf_glyph_width > font_glyph_width + 1) {
159 text_char_pos.m_Origin.x +=
160 (pdf_glyph_width - font_glyph_width) * font_size / 2000.0f;
161 }
else if (pdf_glyph_width && font_glyph_width &&
162 pdf_glyph_width < font_glyph_width) {
163 scaling_factor =
static_cast<
float>(pdf_glyph_width) / font_glyph_width;
164 text_char_pos.m_AdjustMatrix[0] = scaling_factor;
165 text_char_pos.m_AdjustMatrix[1] = 0.0f;
166 text_char_pos.m_AdjustMatrix[2] = 0.0f;
167 text_char_pos.m_AdjustMatrix[3] = 1.0f;
175 if (is_vertical_writing) {
176 text_char_pos.m_Origin =
CFX_PointF(0, text_char_pos.m_Origin.x);
178 CFX_Point16 vertical_origin = cid_font->GetVertOrigin(cid);
179 text_char_pos.m_Origin.x -= font_size * vertical_origin.x / 1000;
180 text_char_pos.m_Origin.y -= font_size * vertical_origin.y / 1000;
184 if (cid_transform && !is_vertical_glyph) {
185 text_char_pos.m_AdjustMatrix[0] =
187 text_char_pos.m_AdjustMatrix[1] =
189 text_char_pos.m_AdjustMatrix[2] =
191 text_char_pos.m_AdjustMatrix[3] =
193 text_char_pos.m_Origin.x +=
195 text_char_pos.m_Origin.y +=
int32_t m_FallbackFontPosition