60 RetainPtr<CFX_Face> face = m_Font.GetFace();
66 if ((IsWinAnsiOrMacRomanEncoding(base_encoding) && m_CharNames.empty()) ||
67 FontStyleIsNonSymbolic(m_Flags)) {
68 if (m_Font.GetFace()->HasGlyphNames() && face->GetCharMapCount() == 0) {
69 SetGlyphIndicesFromFirstChar();
73 const CharmapType charmap_type = DetermineCharmapType();
74 bool bToUnicode = m_pFontDict->KeyExist(
"ToUnicode");
75 for (uint32_t charcode = 0; charcode < 256; charcode++) {
76 const char* name = GetAdobeCharName(base_encoding, m_CharNames, charcode);
78 m_GlyphIndex[charcode] =
79 m_pFontFile ? face->GetCharIndex(charcode) : -1;
82 m_Encoding.SetUnicode(charcode, UnicodeFromAdobeName(name));
83 if (charmap_type == CharmapType::kMSSymbol) {
84 m_GlyphIndex[charcode] = GetGlyphIndexForMSSymbol(face, charcode);
85 }
else if (m_Encoding.UnicodeFromCharCode(charcode)) {
86 if (charmap_type == CharmapType::kMSUnicode) {
87 m_GlyphIndex[charcode] =
88 face->GetCharIndex(m_Encoding.UnicodeFromCharCode(charcode));
89 }
else if (charmap_type == CharmapType::kMacRoman) {
90 uint32_t maccode = CharCodeFromUnicodeForEncoding(
91 fxge::FontEncoding::kAppleRoman,
92 m_Encoding.UnicodeFromCharCode(charcode));
94 m_GlyphIndex[charcode] = face->GetNameIndex((FT_String*)name);
96 m_GlyphIndex[charcode] = face->GetCharIndex(maccode);
100 if ((m_GlyphIndex[charcode] != 0 && m_GlyphIndex[charcode] != 0xffff) ||
104 if (strcmp(name,
".notdef") == 0) {
105 m_GlyphIndex[charcode] = face->GetCharIndex(32);
108 m_GlyphIndex[charcode] = face->GetNameIndex((FT_String*)name);
109 if (m_GlyphIndex[charcode] != 0 || !bToUnicode)
114 m_GlyphIndex[charcode] = face->GetCharIndex(wsUnicode[0]);
115 m_Encoding.SetUnicode(charcode, wsUnicode[0]);
121 for (uint32_t charcode = 0; charcode < 256; charcode++)
122 m_GlyphIndex[charcode] = GetGlyphIndexForMSSymbol(face, charcode);
123 if (HasAnyGlyphIndex()) {
125 for (uint32_t charcode = 0; charcode < 256; charcode++) {
127 GetAdobeCharName(base_encoding, m_CharNames, charcode);
129 m_Encoding.SetUnicode(charcode, UnicodeFromAdobeName(name));
132 for (uint32_t charcode = 0; charcode < 256; charcode++) {
133 m_Encoding.SetUnicode(charcode,
134 UnicodeFromAppleRomanCharCode(charcode));
141 for (uint32_t charcode = 0; charcode < 256; charcode++) {
142 m_GlyphIndex[charcode] = face->GetCharIndex(charcode);
143 m_Encoding.SetUnicode(charcode, UnicodeFromAppleRomanCharCode(charcode));
145 if (m_pFontFile || HasAnyGlyphIndex())
148 if (m_Font.GetFace()->SelectCharMap(fxge::FontEncoding::kUnicode)) {
149 pdfium::span<
const uint16_t> unicodes =
150 UnicodesForPredefinedCharSet(base_encoding);
151 for (uint32_t charcode = 0; charcode < 256; charcode++) {
153 m_Encoding.SetUnicode(charcode, charcode);
156 GetAdobeCharName(FontEncoding::kBuiltin, m_CharNames, charcode);
158 m_Encoding.SetUnicode(charcode, UnicodeFromAdobeName(name));
159 }
else if (!unicodes.empty()) {
160 m_Encoding.SetUnicode(charcode, unicodes[charcode]);
163 m_GlyphIndex[charcode] =
164 face->GetCharIndex(m_Encoding.UnicodeFromCharCode(charcode));
166 if (HasAnyGlyphIndex())
169 for (
int charcode = 0; charcode < 256; charcode++)
170 m_GlyphIndex[charcode] = charcode;