7#include "core/fpdfapi/font/cpdf_cidfont.h"
15#include "build/build_config.h"
16#include "core/fpdfapi/cmaps/fpdf_cmaps.h"
17#include "core/fpdfapi/font/cfx_cttgsubtable.h"
18#include "core/fpdfapi/font/cpdf_cid2unicodemap.h"
19#include "core/fpdfapi/font/cpdf_cmap.h"
20#include "core/fpdfapi/font/cpdf_cmapparser.h"
21#include "core/fpdfapi/font/cpdf_fontencoding.h"
22#include "core/fpdfapi/font/cpdf_fontglobals.h"
23#include "core/fpdfapi/parser/cpdf_array.h"
24#include "core/fpdfapi/parser/cpdf_dictionary.h"
25#include "core/fpdfapi/parser/cpdf_stream.h"
26#include "core/fpdfapi/parser/cpdf_stream_acc.h"
27#include "core/fxcrt/check.h"
28#include "core/fxcrt/check_op.h"
29#include "core/fxcrt/fixed_size_data_vector.h"
30#include "core/fxcrt/fx_codepage.h"
31#include "core/fxcrt/fx_memory.h"
32#include "core/fxcrt/fx_safe_types.h"
33#include "core/fxcrt/fx_unicode.h"
34#include "core/fxcrt/span.h"
35#include "core/fxcrt/span_util.h"
36#include "core/fxcrt/stl_util.h"
37#include "core/fxge/fx_font.h"
47struct LowHighValXY : LowHighVal {
52bool IsMetricForCID(
const LowHighVal& val, uint16_t cid) {
53 return val.low <= cid && cid <= val.high;
66 {97, 129, 0, 0, 127, 55, 0}, {7887, 127, 0, 0, 127, 76, 89},
67 {7888, 127, 0, 0, 127, 79, 94}, {7889, 0, 129, 127, 0, 17, 127},
68 {7890, 0, 129, 127, 0, 17, 127}, {7891, 0, 129, 127, 0, 17, 127},
69 {7892, 0, 129, 127, 0, 17, 127}, {7893, 0, 129, 127, 0, 17, 127},
70 {7894, 0, 129, 127, 0, 17, 127}, {7895, 0, 129, 127, 0, 17, 127},
71 {7896, 0, 129, 127, 0, 17, 127}, {7897, 0, 129, 127, 0, 17, 127},
72 {7898, 0, 129, 127, 0, 17, 127}, {7899, 0, 129, 127, 0, 17, 104},
73 {7900, 0, 129, 127, 0, 17, 127}, {7901, 0, 129, 127, 0, 17, 104},
74 {7902, 0, 129, 127, 0, 17, 127}, {7903, 0, 129, 127, 0, 17, 127},
75 {7904, 0, 129, 127, 0, 17, 127}, {7905, 0, 129, 127, 0, 17, 114},
76 {7906, 0, 129, 127, 0, 17, 127}, {7907, 0, 129, 127, 0, 17, 127},
77 {7908, 0, 129, 127, 0, 17, 127}, {7909, 0, 129, 127, 0, 17, 127},
78 {7910, 0, 129, 127, 0, 17, 127}, {7911, 0, 129, 127, 0, 17, 127},
79 {7912, 0, 129, 127, 0, 17, 127}, {7913, 0, 129, 127, 0, 17, 127},
80 {7914, 0, 129, 127, 0, 17, 127}, {7915, 0, 129, 127, 0, 17, 114},
81 {7916, 0, 129, 127, 0, 17, 127}, {7917, 0, 129, 127, 0, 17, 127},
82 {7918, 127, 0, 0, 127, 18, 25}, {7919, 127, 0, 0, 127, 18, 25},
83 {7920, 127, 0, 0, 127, 18, 25}, {7921, 127, 0, 0, 127, 18, 25},
84 {7922, 127, 0, 0, 127, 18, 25}, {7923, 127, 0, 0, 127, 18, 25},
85 {7924, 127, 0, 0, 127, 18, 25}, {7925, 127, 0, 0, 127, 18, 25},
86 {7926, 127, 0, 0, 127, 18, 25}, {7927, 127, 0, 0, 127, 18, 25},
87 {7928, 127, 0, 0, 127, 18, 25}, {7929, 127, 0, 0, 127, 18, 25},
88 {7930, 127, 0, 0, 127, 18, 25}, {7931, 127, 0, 0, 127, 18, 25},
89 {7932, 127, 0, 0, 127, 18, 25}, {7933, 127, 0, 0, 127, 18, 25},
90 {7934, 127, 0, 0, 127, 18, 25}, {7935, 127, 0, 0, 127, 18, 25},
91 {7936, 127, 0, 0, 127, 18, 25}, {7937, 127, 0, 0, 127, 18, 25},
92 {7938, 127, 0, 0, 127, 18, 25}, {7939, 127, 0, 0, 127, 18, 25},
93 {8720, 0, 129, 127, 0, 19, 102}, {8721, 0, 129, 127, 0, 13, 127},
94 {8722, 0, 129, 127, 0, 19, 108}, {8723, 0, 129, 127, 0, 19, 102},
95 {8724, 0, 129, 127, 0, 19, 102}, {8725, 0, 129, 127, 0, 19, 102},
96 {8726, 0, 129, 127, 0, 19, 102}, {8727, 0, 129, 127, 0, 19, 102},
97 {8728, 0, 129, 127, 0, 19, 114}, {8729, 0, 129, 127, 0, 19, 114},
98 {8730, 0, 129, 127, 0, 38, 108}, {8731, 0, 129, 127, 0, 13, 108},
99 {8732, 0, 129, 127, 0, 19, 108}, {8733, 0, 129, 127, 0, 19, 108},
100 {8734, 0, 129, 127, 0, 19, 108}, {8735, 0, 129, 127, 0, 19, 108},
101 {8736, 0, 129, 127, 0, 19, 102}, {8737, 0, 129, 127, 0, 19, 102},
102 {8738, 0, 129, 127, 0, 19, 102}, {8739, 0, 129, 127, 0, 19, 102},
103 {8740, 0, 129, 127, 0, 19, 102}, {8741, 0, 129, 127, 0, 19, 102},
104 {8742, 0, 129, 127, 0, 19, 102}, {8743, 0, 129, 127, 0, 19, 102},
105 {8744, 0, 129, 127, 0, 19, 102}, {8745, 0, 129, 127, 0, 19, 102},
106 {8746, 0, 129, 127, 0, 19, 114}, {8747, 0, 129, 127, 0, 19, 114},
107 {8748, 0, 129, 127, 0, 19, 102}, {8749, 0, 129, 127, 0, 19, 102},
108 {8750, 0, 129, 127, 0, 19, 102}, {8751, 0, 129, 127, 0, 19, 102},
109 {8752, 0, 129, 127, 0, 19, 102}, {8753, 0, 129, 127, 0, 19, 102},
110 {8754, 0, 129, 127, 0, 19, 102}, {8755, 0, 129, 127, 0, 19, 102},
111 {8756, 0, 129, 127, 0, 19, 102}, {8757, 0, 129, 127, 0, 19, 102},
112 {8758, 0, 129, 127, 0, 19, 102}, {8759, 0, 129, 127, 0, 19, 102},
113 {8760, 0, 129, 127, 0, 19, 102}, {8761, 0, 129, 127, 0, 19, 102},
114 {8762, 0, 129, 127, 0, 19, 102}, {8763, 0, 129, 127, 0, 19, 102},
115 {8764, 0, 129, 127, 0, 19, 102}, {8765, 0, 129, 127, 0, 19, 102},
116 {8766, 0, 129, 127, 0, 19, 102}, {8767, 0, 129, 127, 0, 19, 102},
117 {8768, 0, 129, 127, 0, 19, 102}, {8769, 0, 129, 127, 0, 19, 102},
118 {8770, 0, 129, 127, 0, 19, 102}, {8771, 0, 129, 127, 0, 19, 102},
119 {8772, 0, 129, 127, 0, 19, 102}, {8773, 0, 129, 127, 0, 19, 102},
120 {8774, 0, 129, 127, 0, 19, 102}, {8775, 0, 129, 127, 0, 19, 102},
121 {8776, 0, 129, 127, 0, 19, 102}, {8777, 0, 129, 127, 0, 19, 102},
122 {8778, 0, 129, 127, 0, 19, 102}, {8779, 0, 129, 127, 0, 19, 114},
123 {8780, 0, 129, 127, 0, 19, 108}, {8781, 0, 129, 127, 0, 19, 114},
124 {8782, 0, 129, 127, 0, 13, 114}, {8783, 0, 129, 127, 0, 19, 108},
125 {8784, 0, 129, 127, 0, 13, 114}, {8785, 0, 129, 127, 0, 19, 108},
126 {8786, 0, 129, 127, 0, 19, 108}, {8787, 0, 129, 127, 0, 19, 108},
127 {8788, 0, 129, 127, 0, 19, 108}, {8789, 0, 129, 127, 0, 19, 108},
128 {8790, 0, 129, 127, 0, 19, 108}, {8791, 0, 129, 127, 0, 19, 108},
129 {8792, 0, 129, 127, 0, 19, 108}, {8793, 0, 129, 127, 0, 19, 108},
130 {8794, 0, 129, 127, 0, 19, 108}, {8795, 0, 129, 127, 0, 19, 108},
131 {8796, 0, 129, 127, 0, 19, 108}, {8797, 0, 129, 127, 0, 19, 108},
132 {8798, 0, 129, 127, 0, 19, 108}, {8799, 0, 129, 127, 0, 19, 108},
133 {8800, 0, 129, 127, 0, 19, 108}, {8801, 0, 129, 127, 0, 19, 108},
134 {8802, 0, 129, 127, 0, 19, 108}, {8803, 0, 129, 127, 0, 19, 108},
135 {8804, 0, 129, 127, 0, 19, 108}, {8805, 0, 129, 127, 0, 19, 108},
136 {8806, 0, 129, 127, 0, 19, 108}, {8807, 0, 129, 127, 0, 19, 108},
137 {8808, 0, 129, 127, 0, 19, 108}, {8809, 0, 129, 127, 0, 19, 108},
138 {8810, 0, 129, 127, 0, 19, 108}, {8811, 0, 129, 127, 0, 19, 114},
139 {8812, 0, 129, 127, 0, 19, 102}, {8813, 0, 129, 127, 0, 19, 114},
140 {8814, 0, 129, 127, 0, 76, 102}, {8815, 0, 129, 127, 0, 13, 121},
141 {8816, 0, 129, 127, 0, 19, 114}, {8817, 0, 129, 127, 0, 19, 127},
142 {8818, 0, 129, 127, 0, 19, 114}, {8819, 0, 129, 127, 0, 218, 108},
145#if !BUILDFLAG(IS_WIN)
147bool IsValidEmbeddedCharcodeFromUnicodeCharset(CIDSet charset) {
160wchar_t EmbeddedUnicodeFromCharcode(
const fxcmap::CMap* pEmbedMap,
163 if (!IsValidEmbeddedCharcodeFromUnicodeCharset(charset))
166 uint16_t cid = fxcmap::CIDFromCharCode(pEmbedMap, charcode);
170 pdfium::span<
const uint16_t> map =
171 CPDF_FontGlobals::GetInstance()->GetEmbeddedToUnicode(charset);
172 return cid < map.size() ? map[cid] : 0;
175uint32_t EmbeddedCharcodeFromUnicode(
const fxcmap::CMap* pEmbedMap,
178 if (!IsValidEmbeddedCharcodeFromUnicodeCharset(charset))
181 pdfium::span<
const uint16_t> map =
182 CPDF_FontGlobals::GetInstance()->GetEmbeddedToUnicode(charset);
183 for (uint32_t i = 0; i < map.size(); ++i) {
184 if (map[i] == unicode) {
185 uint32_t charCode = fxcmap::CharCodeFromCID(pEmbedMap, i);
213 bool result = face->SelectCharMap(encoding);
215 result = face->SelectCharMap(fxge::FontEncoding::kUnicode);
217 if (!result && face->GetCharMapCount()) {
218 face->SetCharMapByIndex(0);
223 std::vector<
int>* result,
225 int width_status = 0;
229 for (size_t i = 0; i < pArray->size(); i++) {
234 const CPDF_Array* pObjArray = pObj->AsArray();
236 if (width_status != 1)
238 if (first_code >
std::numeric_limits<
int>::max() -
239 fxcrt::CollectionSize<
int>(*pObjArray)) {
244 for (size_t j = 0; j < pObjArray->size(); j += nElements) {
245 result->push_back(first_code);
246 result->push_back(first_code);
247 for (
int k = 0; k < nElements; k++)
248 result->push_back(pObjArray->GetIntegerAt(j + k));
253 if (width_status == 0) {
254 first_code = pObj->GetInteger();
256 }
else if (width_status == 1) {
257 last_code = pObj->GetInteger();
262 result->push_back(first_code);
263 result->push_back(last_code);
265 result->push_back(pObj->GetInteger());
267 if (iCurElement == nElements)
279 for (size_t i = 0; i < std::size(m_CharBBox); ++i)
280 m_CharBBox[i] = FX_RECT(-1, -1, -1, -1);
298 return m_pCMap ? m_pCMap->CIDFromCharCode(charcode)
299 :
static_cast<uint16_t>(charcode);
303 return m_pCMap && m_pCMap->IsVertWriting();
310 wchar_t ret = GetUnicodeFromCharCode(charcode);
314wchar_t CPDF_CIDFont::GetUnicodeFromCharCode(uint32_t charcode)
const {
315 switch (m_pCMap->GetCoding()) {
316 case CIDCoding::kUCS2:
317 case CIDCoding::kUTF16:
318 return static_cast<
wchar_t>(charcode);
319 case CIDCoding::kCID:
320 if (!m_pCID2UnicodeMap || !m_pCID2UnicodeMap->IsLoaded())
322 return m_pCID2UnicodeMap->UnicodeFromCID(
static_cast<uint16_t>(charcode));
326 if (m_pCID2UnicodeMap && m_pCID2UnicodeMap->IsLoaded() && m_pCMap->IsLoaded())
327 return m_pCID2UnicodeMap->UnicodeFromCID(CIDFromCharCode(charcode));
330 uint8_t sequence[2] = {};
331 const int charsize = charcode < 256 ? 1 : 2;
333 sequence[0] = charcode;
335 sequence[0] = charcode / 256;
336 sequence[1] = charcode % 256;
339 size_t ret = FX_MultiByteToWideChar(
340 kCharsetCodePages[
static_cast<size_t>(m_pCMap->GetCoding())],
341 ByteStringView(pdfium::make_span(sequence).first(charsize)),
342 pdfium::span_from_ref(unicode));
343 return ret == 1 ? unicode : 0;
345 if (!m_pCMap->GetEmbedMap())
347 return EmbeddedUnicodeFromCharcode(m_pCMap->GetEmbedMap(),
348 m_pCMap->GetCharset(), charcode);
357 switch (m_pCMap->GetCoding()) {
358 case CIDCoding::kUNKNOWN:
360 case CIDCoding::kUCS2:
361 case CIDCoding::kUTF16:
363 case CIDCoding::kCID: {
364 if (!m_pCID2UnicodeMap || !m_pCID2UnicodeMap->IsLoaded())
367 while (cid < 65536) {
368 wchar_t this_unicode =
369 m_pCID2UnicodeMap->UnicodeFromCID(
static_cast<uint16_t>(cid));
370 if (this_unicode == unicode)
381 return static_cast<uint32_t>(unicode);
382 if (m_pCMap->GetCoding() == CIDCoding::kCID)
386 size_t ret = FX_WideCharToMultiByte(
387 kCharsetCodePages[
static_cast<size_t>(m_pCMap->GetCoding())],
388 WideStringView(unicode),
389 pdfium::as_writable_chars(pdfium::make_span(buffer).first(4u)));
393 return buffer[0] * 256 + buffer[1];
395 if (m_pCMap->GetEmbedMap()) {
396 return EmbeddedCharcodeFromUnicode(m_pCMap->GetEmbedMap(),
397 m_pCMap->GetCharset(), unicode);
404 if (m_pFontDict->GetByteStringFor(
"Subtype") ==
"TrueType") {
410 m_pFontDict->GetArrayFor(
"DescendantFonts");
411 if (!pFonts || pFonts->size() != 1)
418 m_BaseFontName = pCIDFontDict->GetByteStringFor(
"BaseFont");
419 if ((m_BaseFontName ==
"CourierStd" || m_BaseFontName ==
"CourierStd-Bold" ||
420 m_BaseFontName ==
"CourierStd-BoldOblique" ||
421 m_BaseFontName ==
"CourierStd-Oblique") &&
423 m_bAdobeCourierStd =
true;
427 m_pFontDict->GetDirectObjectFor(
"Encoding");
431 ByteString subtype = pCIDFontDict->GetByteStringFor(
"Subtype");
433 subtype
== "CIDFontType0" ? CIDFontType::kType1 : CIDFontType::kTrueType;
435 if (!pEncoding->IsName() && !pEncoding->IsStream())
439 const CPDF_Stream* pEncodingStream = pEncoding->AsStream();
440 if (pEncodingStream) {
442 pdfium::MakeRetain<CPDF_StreamAcc>(
pdfium::WrapRetain(pEncodingStream));
443 pAcc->LoadAllDataFiltered();
444 pdfium::span<
const uint8_t> span = pAcc->GetSpan();
445 m_pCMap = pdfium::MakeRetain<CPDF_CMap>(span);
447 DCHECK(pEncoding->IsName());
449 m_pCMap = pFontGlobals->GetPredefinedCMap(cmap);
453 pCIDFontDict->GetDictFor(
"FontDescriptor");
457 m_Charset = m_pCMap->GetCharset();
460 pCIDFontDict->GetDictFor(
"CIDSystemInfo");
463 pCIDInfo->GetByteStringFor(
"Ordering").AsStringView()
);
467 m_pCID2UnicodeMap = pFontGlobals->GetCID2UnicodeMap(m_Charset);
469 RetainPtr<CFX_Face> face = m_Font.GetFace();
471 if (m_FontType == CIDFontType::kType1) {
474 UseCIDCharmap(face, m_pCMap->GetCoding());
477 m_DefaultWidth = pCIDFontDict->GetIntegerFor(
"DW", 1000);
480 LoadMetricsArray(std::move(pWidthArray), &m_WidthList, 1);
486 pCIDFontDict->GetDirectObjectFor(
"CIDToGIDMap");
488 RetainPtr<
const CPDF_Stream> pMapStream(pmap->AsStream());
490 m_pStreamAcc = pdfium::MakeRetain<CPDF_StreamAcc>(std::move(pMapStream));
491 m_pStreamAcc->LoadAllDataFiltered();
492 }
else if (m_pFontFile && pmap->IsName() &&
493 pmap->GetString() ==
"Identity") {
502 LoadMetricsArray(std::move(pWidth2Array), &m_VertMetrics, 3);
505 pCIDFontDict->GetArrayFor(
"DW2");
507 m_DefaultVY = pDefaultArray->GetIntegerAt(0);
508 m_DefaultW1 = pDefaultArray->GetIntegerAt(1);
513 if (m_FontType == CIDFontType::kTrueType && IsEmbedded())
514 m_Font.SetFontType(CFX_Font::FontType::kCIDTrueType);
520 if (charcode < 256 && m_CharBBox[charcode].right != -1)
521 return m_CharBBox[charcode];
526 RetainPtr<CFX_Face> face = m_Font.GetFace();
528 rect = face->GetCharBBox(charcode, glyph_index);
530 if (!m_pFontFile && m_Charset == CIDSET_JAPAN1) {
533 if (pTransform && !bVert) {
544 m_CharBBox[charcode] = rect;
550 if (charcode < 0x80 && m_bAnsiWidthsFixed) {
551 return (charcode >= 32 && charcode < 127) ? 500 : 0;
555 fxcrt::reinterpret_span<
const LowHighVal>(pdfium::make_span(m_WidthList));
556 for (
const auto& lhv : lhv_span) {
557 if (IsMetricForCID(lhv, cid)) {
561 return m_DefaultWidth;
565 auto lhvxy_span = fxcrt::reinterpret_span<
const LowHighValXY>(
566 pdfium::make_span(m_VertMetrics));
567 for (
const auto& lhvxy : lhvxy_span) {
568 if (IsMetricForCID(lhvxy, cid)) {
576 auto lhvxy_span = fxcrt::reinterpret_span<
const LowHighValXY>(
577 pdfium::make_span(m_VertMetrics));
578 for (
const auto& lhvxy : lhvxy_span) {
579 if (IsMetricForCID(lhvxy, cid)) {
580 return {
static_cast<int16_t>(lhvxy.x),
static_cast<int16_t>(lhvxy.y)};
583 int width = m_DefaultWidth;
585 fxcrt::reinterpret_span<
const LowHighVal>(pdfium::make_span(m_WidthList));
586 for (
const auto& lhv : lhv_span) {
587 if (IsMetricForCID(lhv, cid)) {
592 return {
static_cast<int16_t>(width / 2), m_DefaultVY};
595int CPDF_CIDFont::GetGlyphIndex(uint32_t unicode,
bool* pVertGlyph) {
599 int index = m_Font.GetFace()->GetCharIndex(unicode);
607 return GetVerticalGlyph(index, pVertGlyph);
609 static constexpr uint32_t kGsubTag =
611 RetainPtr<CFX_Face> face = m_Font.GetFace();
612 size_t length = face->GetSfntTable(kGsubTag, {});
617 auto sub_data = FixedSizeDataVector<uint8_t>::Uninit(length);
618 if (!face->GetSfntTable(kGsubTag, sub_data.span())) {
624 m_pTTGSUBTable = std::make_unique<CFX_CTTGSUBTable>(sub_data.span());
625 return GetVerticalGlyph(index, pVertGlyph);
628int CPDF_CIDFont::GetVerticalGlyph(
int index,
bool* pVertGlyph) {
629 uint32_t vindex = m_pTTGSUBTable->GetVerticalGlyph(index);
643 if (!m_pFontFile && (!m_pStreamAcc || m_pCID2UnicodeMap)) {
647#if BUILDFLAG(IS_APPLE)
648 if (FontStyleIsSymbolic(m_Flags))
651 WideString uni_str = UnicodeFromCharCode(charcode);
652 if (uni_str.IsEmpty())
655 unicode = uni_str[0];
660 if (cid && m_pCID2UnicodeMap && m_pCID2UnicodeMap->IsLoaded())
661 unicode = m_pCID2UnicodeMap->UnicodeFromCID(cid);
663 unicode = GetUnicodeFromCharCode(charcode);
666 if (!unicode_str.IsEmpty())
667 unicode = unicode_str[0];
671 if (!m_bAdobeCourierStd)
672 return charcode ?
static_cast<
int>(charcode) : -1;
675 RetainPtr<CFX_Face> face = m_Font.GetFace();
684 GetAdobeCharName(base_encoding, std::vector<ByteString>(), charcode);
686 return charcode ?
static_cast<
int>(charcode) : -1;
691 return charcode ?
static_cast<
int>(charcode) : -1;
694 return face->GetCharIndex(name_unicode);
698 index = face->GetCharIndex(name_unicode);
704 maccode ? face->GetCharIndex(maccode)
705 : face->GetNameIndex((FT_String*)name);
707 if (index == 0 || index == 0xffff)
708 return charcode ?
static_cast<
int>(charcode) : -1;
712 if (unicode ==
'\\') {
714#if !BUILDFLAG(IS_APPLE)
715 }
else if (unicode == 0xa5) {
721 RetainPtr<CFX_Face> face = m_Font.GetFace();
726 size_t num_charmaps = face->GetCharMapCount();
729 for (i = 0; i < num_charmaps; i++) {
730 uint32_t ret = CharCodeFromUnicodeForEncoding(
731 face->GetCharMapEncodingByIndex(i),
static_cast<
wchar_t>(charcode));
734 face->SetCharMapByIndex(i);
735 unicode =
static_cast<
wchar_t>(ret);
738 if (i == num_charmaps && i) {
739 face->SetCharMapByIndex(0);
740 unicode =
static_cast<
wchar_t>(charcode);
744 int index = GetGlyphIndex(unicode, pVertGlyph);
745 return index != 0 ? index : -1;
750 RetainPtr<CFX_Face> face = m_Font.GetFace();
757 if (m_FontType == CIDFontType::kType1) {
760 if (m_pFontFile && m_pCMap->IsDirectCharcodeToCIDTableIsEmpty()) {
763 if (m_pCMap->GetCoding() == CIDCoding::kUNKNOWN) {
768 face->GetCurrentCharMapEncoding();
769 if (!charmap.has_value()) {
775 if (unicode_str.IsEmpty())
778 charcode = unicode_str[0];
780 return GetGlyphIndex(charcode, pVertGlyph);
782 uint32_t byte_pos = cid * 2;
783 if (byte_pos + 2 > m_pStreamAcc->GetSize())
786 pdfium::span<
const uint8_t> span = m_pStreamAcc->GetSpan().subspan(byte_pos);
787 return span[0] * 256 + span[1];
791 size_t* pOffset)
const {
792 return m_pCMap->GetNextChar(pString, pOffset);
796 return m_pCMap->GetCharSize(charcode);
800 return m_pCMap->CountChar(pString);
804 m_pCMap->AppendChar(str, charcode);
808 if (m_pCID2UnicodeMap && m_pCID2UnicodeMap->IsLoaded() && m_pCMap->IsLoaded())
810 return m_pCMap->GetCoding() != CIDCoding::kUNKNOWN;
813void CPDF_CIDFont::LoadSubstFont() {
816 m_Font.LoadSubst(m_BaseFontName, m_FontType == CIDFontType::kTrueType,
818 m_ItalicAngle, kCharsetCodePages[m_Charset],
824 return (ch < 128 ? ch : ch - 255) * (1.0f / 127);
827void CPDF_CIDFont::LoadGB2312() {
828 m_BaseFontName = m_pFontDict->GetByteStringFor(
"BaseFont");
832 m_pCMap = pFontGlobals->GetPredefinedCMap(
"GBK-EUC-H");
833 m_pCID2UnicodeMap = pFontGlobals->GetCID2UnicodeMap(m_Charset);
835 m_pFontDict->GetDictFor(
"FontDescriptor");
842 m_bAnsiWidthsFixed =
true;
846 if (m_Charset != CIDSET_JAPAN1 || m_pFontFile)
849 const auto* pBegin =
std::begin(kJapan1VerticalCIDs);
850 const auto* pEnd =
std::end(kJapan1VerticalCIDs);
851 const auto* pTransform =
std::lower_bound(
855 return pTransform < pEnd && cid == pTransform->cid ? pTransform :
nullptr;
fxcrt::ByteString ByteString
CFX_FloatRect(const FX_RECT &rect)
FX_RECT GetOuterRect() const
static constexpr uint32_t MakeTag(char c1, char c2, char c3, char c4)
CFX_FloatRect TransformRect(const CFX_FloatRect &rect) const
constexpr CFX_Matrix(float a1, float b1, float c1, float d1, float e1, float f1)
std::vector< RetainPtr< CPDF_Object > >::const_iterator const_iterator
size_t CountChar(ByteStringView pString) const override
uint32_t GetNextChar(ByteStringView pString, size_t *pOffset) const override
bool IsCIDFont() const override
bool IsUnicodeCompatible() const override
CFX_Point16 GetVertOrigin(uint16_t cid) const
int GetCharWidthF(uint32_t charcode) override
const CPDF_CIDFont * AsCIDFont() const override
uint16_t CIDFromCharCode(uint32_t charcode) const
const CIDTransform * GetCIDTransform(uint16_t cid) const
int GlyphFromCharCode(uint32_t charcode, bool *pVertGlyph) override
int16_t GetVertWidth(uint16_t cid) const
FX_RECT GetCharBBox(uint32_t charcode) override
static float CIDTransformToFloat(uint8_t ch)
void AppendChar(ByteString *str, uint32_t charcode) const override
bool IsVertWriting() const override
uint32_t CharCodeFromUnicode(wchar_t Unicode) const override
int GetCharSize(uint32_t charcode) const
WideString UnicodeFromCharCode(uint32_t charcode) const override
CPDF_CIDFont * AsCIDFont() override
static CIDSet CharsetFromOrdering(ByteStringView ordering)
std::map< ByteString, RetainPtr< CPDF_Object >, std::less<> > DictMap
static CPDF_FontGlobals * GetInstance()
void LoadFontDescriptor(const CPDF_Dictionary *pFontDesc)
virtual uint32_t CharCodeFromUnicode(wchar_t Unicode) const
static bool UseTTCharmapMacRoman(const RetainPtr< CFX_Face > &face)
static bool UseTTCharmapMSUnicode(const RetainPtr< CFX_Face > &face)
virtual WideString UnicodeFromCharCode(uint32_t charcode) const
bool operator==(const char *ptr) const
uint32_t CharCodeFromUnicodeForEncoding(fxge::FontEncoding encoding, wchar_t unicode)
CFX_PTemplate< int16_t > CFX_Point16
wchar_t UnicodeFromAdobeName(const char *name)
pdfium::CheckedNumeric< int32_t > FX_SAFE_INT32
constexpr wchar_t kBoxDrawingsLightVerical
fxcrt::ByteStringView ByteStringView
FX_RECT & operator=(const FX_RECT &that)=default
fxcrt::WideString WideString