Encapsulate font charmap code inside CFX_Face
Add a variety of charmap methods to CFX_Face to encapsulate access to
FreeType charmap data. Then delete the FXFT_Get_Charmap_* macros.
Bug: pdfium:2037
Change-Id: I390bad2c30b62ff9ce600a4e7f102928e7816925
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/114792
Reviewed-by: Dominik Röttsches <drott@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/font/cpdf_cidfont.cpp b/core/fpdfapi/font/cpdf_cidfont.cpp
index 9d494b7..26caef9 100644
--- a/core/fpdfapi/font/cpdf_cidfont.cpp
+++ b/core/fpdfapi/font/cpdf_cidfont.cpp
@@ -216,9 +216,8 @@
if (!result) {
result = face->SelectCharMap(fxge::FontEncoding::kUnicode);
}
- FXFT_FaceRec* face_rec = face->GetRec();
- if (!result && face_rec->charmaps) {
- FT_Set_Charmap(face_rec, face_rec->charmaps[0]);
+ if (!result && face->GetCharMapCount()) {
+ face->SetCharMapByIndex(0);
}
}
@@ -723,8 +722,9 @@
return charcode ? static_cast<int>(charcode) : -1;
charcode += 31;
- bool bMSUnicode = UseTTCharmapMSUnicode(face_rec);
- bool bMacRoman = !bMSUnicode && UseTTCharmapMacRoman(face_rec);
+ RetainPtr<CFX_Face> face = m_Font.GetFace();
+ bool bMSUnicode = UseTTCharmapMSUnicode(face);
+ bool bMacRoman = !bMSUnicode && UseTTCharmapMacRoman(face);
FontEncoding base_encoding = FontEncoding::kStandard;
if (bMSUnicode)
base_encoding = FontEncoding::kWinAnsi;
@@ -769,25 +769,25 @@
return unicode;
}
- if (!m_Font.GetFace()->SelectCharMap(fxge::FontEncoding::kUnicode)) {
- int i;
- for (i = 0; i < face_rec->num_charmaps; i++) {
+ RetainPtr<CFX_Face> face = m_Font.GetFace();
+ size_t num_charmaps = face->GetCharMapCount();
+ if (!face->SelectCharMap(fxge::FontEncoding::kUnicode)) {
+ size_t i;
+ for (i = 0; i < num_charmaps; i++) {
uint32_t ret = CharCodeFromUnicodeForEncoding(
- static_cast<fxge::FontEncoding>(
- FXFT_Get_Charmap_Encoding(face_rec->charmaps[i])),
- static_cast<wchar_t>(charcode));
+ face->GetCharMapEncodingByIndex(i), static_cast<wchar_t>(charcode));
if (ret == 0)
continue;
- FT_Set_Charmap(face_rec, face_rec->charmaps[i]);
+ face->SetCharMapByIndex(i);
unicode = static_cast<wchar_t>(ret);
break;
}
- if (i == face_rec->num_charmaps && i) {
- FT_Set_Charmap(face_rec, face_rec->charmaps[0]);
+ if (i == num_charmaps && i) {
+ face->SetCharMapByIndex(0);
unicode = static_cast<wchar_t>(charcode);
}
}
- if (face_rec->charmap) {
+ if (num_charmaps) {
int index = GetGlyphIndex(unicode, pVertGlyph);
return index != 0 ? index : -1;
}
@@ -799,17 +799,23 @@
uint16_t cid = CIDFromCharCode(charcode);
if (!m_pStreamAcc) {
- if (m_FontType == CIDFontType::kType1)
+ if (m_FontType == CIDFontType::kType1) {
return cid;
- if (m_pFontFile && m_pCMap->IsDirectCharcodeToCIDTableIsEmpty())
+ }
+ if (m_pFontFile && m_pCMap->IsDirectCharcodeToCIDTableIsEmpty()) {
return cid;
+ }
+ if (m_pCMap->GetCoding() == CIDCoding::kUNKNOWN) {
+ return cid;
+ }
- FT_CharMap charmap = m_Font.GetFaceRec()->charmap;
- if (!charmap || m_pCMap->GetCoding() == CIDCoding::kUNKNOWN)
+ absl::optional<fxge::FontEncoding> charmap =
+ m_Font.GetFace()->GetCurrentCharMapEncoding();
+ if (!charmap.has_value()) {
return cid;
+ }
- if (FXFT_Get_Charmap_Encoding(charmap) ==
- static_cast<FT_Encoding>(fxge::FontEncoding::kUnicode)) {
+ if (charmap.value() == fxge::FontEncoding::kUnicode) {
WideString unicode_str = UnicodeFromCharCode(charcode);
if (unicode_str.IsEmpty())
return -1;
diff --git a/core/fpdfapi/font/cpdf_font.cpp b/core/fpdfapi/font/cpdf_font.cpp
index 3c5d1b6..2f88a69 100644
--- a/core/fpdfapi/font/cpdf_font.cpp
+++ b/core/fpdfapi/font/cpdf_font.cpp
@@ -428,13 +428,13 @@
}
// static
-bool CPDF_Font::UseTTCharmap(FXFT_FaceRec* face,
+bool CPDF_Font::UseTTCharmap(const RetainPtr<CFX_Face>& face,
int platform_id,
int encoding_id) {
- for (int i = 0; i < face->num_charmaps; i++) {
- if (FXFT_Get_Charmap_PlatformID(face->charmaps[i]) == platform_id &&
- FXFT_Get_Charmap_EncodingID(face->charmaps[i]) == encoding_id) {
- FT_Set_Charmap(face, face->charmaps[i]);
+ for (size_t i = 0; i < face->GetCharMapCount(); i++) {
+ if (face->GetCharMapPlatformIdByIndex(i) == platform_id &&
+ face->GetCharMapEncodingIdByIndex(i) == encoding_id) {
+ face->SetCharMapByIndex(i);
return true;
}
}
diff --git a/core/fpdfapi/font/cpdf_font.h b/core/fpdfapi/font/cpdf_font.h
index c8c46b1..5adce94 100644
--- a/core/fpdfapi/font/cpdf_font.h
+++ b/core/fpdfapi/font/cpdf_font.h
@@ -143,16 +143,16 @@
static FX_RECT GetCharBBoxForFace(const RetainPtr<CFX_Face>& face);
// Commonly used wrappers for UseTTCharmap().
- static bool UseTTCharmapMSUnicode(FXFT_FaceRec* face) {
+ static bool UseTTCharmapMSUnicode(const RetainPtr<CFX_Face>& face) {
return UseTTCharmap(face, 3, 1);
}
- static bool UseTTCharmapMSSymbol(FXFT_FaceRec* face) {
+ static bool UseTTCharmapMSSymbol(const RetainPtr<CFX_Face>& face) {
return UseTTCharmap(face, 3, 0);
}
- static bool UseTTCharmapMacRoman(FXFT_FaceRec* face) {
+ static bool UseTTCharmapMacRoman(const RetainPtr<CFX_Face>& face) {
return UseTTCharmap(face, 1, 0);
}
- static bool UseTTCharmap(FXFT_FaceRec* face,
+ static bool UseTTCharmap(const RetainPtr<CFX_Face>& face,
int platform_id,
int encoding_id);
diff --git a/core/fpdfapi/font/cpdf_fontencoding.h b/core/fpdfapi/font/cpdf_fontencoding.h
index c0a5e6c..cab4b3f 100644
--- a/core/fpdfapi/font/cpdf_fontencoding.h
+++ b/core/fpdfapi/font/cpdf_fontencoding.h
@@ -26,10 +26,6 @@
kMsSymbol = 8,
};
-// For `encoding`, the caller can safely cast any FreeType FT_ENCODING_* value
-// into fxge::FontEncoding.
-// TODO(crbug.com/pdfium/2037): Always pass in fxge::FontEncoding values and
-// remove this comment.
uint32_t CharCodeFromUnicodeForEncoding(fxge::FontEncoding encoding,
wchar_t unicode);
diff --git a/core/fpdfapi/font/cpdf_truetypefont.cpp b/core/fpdfapi/font/cpdf_truetypefont.cpp
index e2c9dee..5c6505f 100644
--- a/core/fpdfapi/font/cpdf_truetypefont.cpp
+++ b/core/fpdfapi/font/cpdf_truetypefont.cpp
@@ -56,15 +56,16 @@
}
void CPDF_TrueTypeFont::LoadGlyphMap() {
- FXFT_FaceRec* face = m_Font.GetFaceRec();
- if (!face)
+ FXFT_FaceRec* face_rec = m_Font.GetFaceRec();
+ if (!face_rec) {
return;
+ }
+ RetainPtr<CFX_Face> face = m_Font.GetFace();
const FontEncoding base_encoding = DetermineEncoding();
if ((IsWinAnsiOrMacRomanEncoding(base_encoding) && m_CharNames.empty()) ||
FontStyleIsNonSymbolic(m_Flags)) {
- if (m_Font.GetFace()->HasGlyphNames() &&
- (!face->num_charmaps || !face->charmaps)) {
+ if (m_Font.GetFace()->HasGlyphNames() && face->GetCharMapCount() == 0) {
SetGlyphIndicesFromFirstChar();
return;
}
@@ -75,24 +76,24 @@
const char* name = GetAdobeCharName(base_encoding, m_CharNames, charcode);
if (!name) {
m_GlyphIndex[charcode] =
- m_pFontFile ? FT_Get_Char_Index(face, charcode) : -1;
+ m_pFontFile ? FT_Get_Char_Index(face_rec, charcode) : -1;
continue;
}
m_Encoding.SetUnicode(charcode, UnicodeFromAdobeName(name));
if (charmap_type == CharmapType::kMSSymbol) {
- m_GlyphIndex[charcode] = GetGlyphIndexForMSSymbol(face, charcode);
+ m_GlyphIndex[charcode] = GetGlyphIndexForMSSymbol(face_rec, charcode);
} else if (m_Encoding.UnicodeFromCharCode(charcode)) {
if (charmap_type == CharmapType::kMSUnicode) {
- m_GlyphIndex[charcode] =
- FT_Get_Char_Index(face, m_Encoding.UnicodeFromCharCode(charcode));
+ m_GlyphIndex[charcode] = FT_Get_Char_Index(
+ face_rec, m_Encoding.UnicodeFromCharCode(charcode));
} else if (charmap_type == CharmapType::kMacRoman) {
uint32_t maccode = CharCodeFromUnicodeForEncoding(
fxge::FontEncoding::kAppleRoman,
m_Encoding.UnicodeFromCharCode(charcode));
if (!maccode) {
- m_GlyphIndex[charcode] = FT_Get_Name_Index(face, name);
+ m_GlyphIndex[charcode] = FT_Get_Name_Index(face_rec, name);
} else {
- m_GlyphIndex[charcode] = FT_Get_Char_Index(face, maccode);
+ m_GlyphIndex[charcode] = FT_Get_Char_Index(face_rec, maccode);
}
}
}
@@ -101,16 +102,16 @@
continue;
}
if (strcmp(name, ".notdef") == 0) {
- m_GlyphIndex[charcode] = FT_Get_Char_Index(face, 32);
+ m_GlyphIndex[charcode] = FT_Get_Char_Index(face_rec, 32);
continue;
}
- m_GlyphIndex[charcode] = FT_Get_Name_Index(face, name);
+ m_GlyphIndex[charcode] = FT_Get_Name_Index(face_rec, name);
if (m_GlyphIndex[charcode] != 0 || !bToUnicode)
continue;
WideString wsUnicode = UnicodeFromCharCode(charcode);
if (!wsUnicode.IsEmpty()) {
- m_GlyphIndex[charcode] = FT_Get_Char_Index(face, wsUnicode[0]);
+ m_GlyphIndex[charcode] = FT_Get_Char_Index(face_rec, wsUnicode[0]);
m_Encoding.SetUnicode(charcode, wsUnicode[0]);
}
}
@@ -118,7 +119,7 @@
}
if (UseTTCharmapMSSymbol(face)) {
for (uint32_t charcode = 0; charcode < 256; charcode++)
- m_GlyphIndex[charcode] = GetGlyphIndexForMSSymbol(face, charcode);
+ m_GlyphIndex[charcode] = GetGlyphIndexForMSSymbol(face_rec, charcode);
if (HasAnyGlyphIndex()) {
if (base_encoding != FontEncoding::kBuiltin) {
for (uint32_t charcode = 0; charcode < 256; charcode++) {
@@ -138,7 +139,7 @@
}
if (UseTTCharmapMacRoman(face)) {
for (uint32_t charcode = 0; charcode < 256; charcode++) {
- m_GlyphIndex[charcode] = FT_Get_Char_Index(face, charcode);
+ m_GlyphIndex[charcode] = FT_Get_Char_Index(face_rec, charcode);
m_Encoding.SetUnicode(charcode, UnicodeFromAppleRomanCharCode(charcode));
}
if (m_pFontFile || HasAnyGlyphIndex())
@@ -160,7 +161,7 @@
}
}
m_GlyphIndex[charcode] =
- FT_Get_Char_Index(face, m_Encoding.UnicodeFromCharCode(charcode));
+ FT_Get_Char_Index(face_rec, m_Encoding.UnicodeFromCharCode(charcode));
}
if (HasAnyGlyphIndex())
return;
@@ -178,19 +179,24 @@
}
CPDF_TrueTypeFont::CharmapType CPDF_TrueTypeFont::DetermineCharmapType() const {
- if (UseTTCharmapMSUnicode(m_Font.GetFaceRec()))
+ if (UseTTCharmapMSUnicode(m_Font.GetFace())) {
return CharmapType::kMSUnicode;
+ }
if (FontStyleIsNonSymbolic(m_Flags)) {
- if (UseTTCharmapMacRoman(m_Font.GetFaceRec()))
+ if (UseTTCharmapMacRoman(m_Font.GetFace())) {
return CharmapType::kMacRoman;
- if (UseTTCharmapMSSymbol(m_Font.GetFaceRec()))
+ }
+ if (UseTTCharmapMSSymbol(m_Font.GetFace())) {
return CharmapType::kMSSymbol;
+ }
} else {
- if (UseTTCharmapMSSymbol(m_Font.GetFaceRec()))
+ if (UseTTCharmapMSSymbol(m_Font.GetFace())) {
return CharmapType::kMSSymbol;
- if (UseTTCharmapMacRoman(m_Font.GetFaceRec()))
+ }
+ if (UseTTCharmapMacRoman(m_Font.GetFace())) {
return CharmapType::kMacRoman;
+ }
}
return CharmapType::kOther;
}
@@ -202,14 +208,16 @@
}
// Not null - caller checked.
- FXFT_FaceRec* face = m_Font.GetFaceRec();
- if (face->num_charmaps <= 0)
+ RetainPtr<CFX_Face> face = m_Font.GetFace();
+ const size_t num_charmaps = face->GetCharMapCount();
+ if (num_charmaps == 0) {
return m_BaseEncoding;
+ }
bool support_win = false;
bool support_mac = false;
- for (int i = 0; i < face->num_charmaps; i++) {
- int platform_id = FXFT_Get_Charmap_PlatformID(face->charmaps[i]);
+ for (size_t i = 0; i < num_charmaps; i++) {
+ int platform_id = face->GetCharMapPlatformIdByIndex(i);
if (platform_id == kNamePlatformAppleUnicode ||
platform_id == kNamePlatformWindows) {
support_win = true;
diff --git a/core/fpdfapi/font/cpdf_type1font.cpp b/core/fpdfapi/font/cpdf_type1font.cpp
index 63ca6da..a556c11 100644
--- a/core/fpdfapi/font/cpdf_type1font.cpp
+++ b/core/fpdfapi/font/cpdf_type1font.cpp
@@ -48,18 +48,20 @@
#endif // BUILDFLAG(IS_APPLE)
-bool FT_UseType1Charmap(FXFT_FaceRec* face) {
- if (face->num_charmaps == 0)
+bool UseType1Charmap(const RetainPtr<CFX_Face>& face) {
+ size_t num_charmaps = face->GetCharMapCount();
+ if (num_charmaps == 0) {
return false;
+ }
bool is_first_charmap_unicode =
- FXFT_Get_Charmap_Encoding(face->charmaps[0]) ==
- static_cast<FT_Encoding>(fxge::FontEncoding::kUnicode);
- if (face->num_charmaps == 1 && is_first_charmap_unicode)
+ face->GetCharMapEncodingByIndex(0) == fxge::FontEncoding::kUnicode;
+ if (num_charmaps == 1 && is_first_charmap_unicode) {
return false;
+ }
int index = is_first_charmap_unicode ? 1 : 0;
- FT_Set_Charmap(face, face->charmaps[index]);
+ face->SetCharMapByIndex(index);
return true;
}
@@ -141,7 +143,7 @@
}
#endif
if (!IsEmbedded() && !IsSymbolicFont() && m_Font.IsTTFont()) {
- if (UseTTCharmapMSSymbol(m_Font.GetFaceRec())) {
+ if (UseTTCharmapMSSymbol(m_Font.GetFace())) {
bool bGotOne = false;
for (uint32_t charcode = 0; charcode < kInternalTableSize; charcode++) {
const uint8_t prefix[4] = {0x00, 0xf0, 0xf1, 0xf2};
@@ -198,7 +200,7 @@
#endif
return;
}
- FT_UseType1Charmap(m_Font.GetFaceRec());
+ UseType1Charmap(m_Font.GetFace());
#if BUILDFLAG(IS_APPLE)
if (bCoreText) {
if (FontStyleIsSymbolic(m_Flags)) {
diff --git a/core/fxge/cfx_face.cpp b/core/fxge/cfx_face.cpp
index 075ae82..ad80937 100644
--- a/core/fxge/cfx_face.cpp
+++ b/core/fxge/cfx_face.cpp
@@ -525,6 +525,47 @@
return static_cast<int>(EM_ADJUST(GetUnitsPerEm(), horizontal_advance));
}
+CFX_Face::CharMap CFX_Face::GetCurrentCharMap() const {
+ return GetRec()->charmap;
+}
+
+absl::optional<fxge::FontEncoding> CFX_Face::GetCurrentCharMapEncoding() const {
+ if (!GetRec()->charmap) {
+ return absl::nullopt;
+ }
+ return static_cast<fxge::FontEncoding>(GetRec()->charmap->encoding);
+}
+
+int CFX_Face::GetCharMapPlatformIdByIndex(size_t index) const {
+ CHECK_LT(index, GetCharMapCount());
+ return GetRec()->charmaps[index]->platform_id;
+}
+
+int CFX_Face::GetCharMapEncodingIdByIndex(size_t index) const {
+ CHECK_LT(index, GetCharMapCount());
+ return GetRec()->charmaps[index]->encoding_id;
+}
+
+fxge::FontEncoding CFX_Face::GetCharMapEncodingByIndex(size_t index) const {
+ CHECK_LT(index, GetCharMapCount());
+ return static_cast<fxge::FontEncoding>(GetRec()->charmaps[index]->encoding);
+}
+
+size_t CFX_Face::GetCharMapCount() const {
+ return GetRec()->charmaps
+ ? pdfium::base::checked_cast<size_t>(GetRec()->num_charmaps)
+ : 0;
+}
+
+void CFX_Face::SetCharMap(CharMap map) {
+ FT_Set_Charmap(GetRec(), static_cast<FT_CharMap>(map));
+}
+
+void CFX_Face::SetCharMapByIndex(size_t index) {
+ CHECK_LT(index, GetCharMapCount());
+ SetCharMap(GetRec()->charmaps[index]);
+}
+
bool CFX_Face::SelectCharMap(fxge::FontEncoding encoding) {
FT_Error error =
FT_Select_Charmap(GetRec(), static_cast<FT_Encoding>(encoding));
diff --git a/core/fxge/cfx_face.h b/core/fxge/cfx_face.h
index 5b85a46..3d0f5b7 100644
--- a/core/fxge/cfx_face.h
+++ b/core/fxge/cfx_face.h
@@ -15,6 +15,7 @@
#include "core/fxcrt/observed_ptr.h"
#include "core/fxcrt/retain_ptr.h"
#include "core/fxge/freetype/fx_freetype.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/base/containers/span.h"
namespace fxge {
@@ -28,6 +29,8 @@
class CFX_Face final : public Retainable, public Observable {
public:
+ using CharMap = void*;
+
static RetainPtr<CFX_Face> New(FT_Library library,
RetainPtr<Retainable> pDesc,
pdfium::span<const FT_Byte> data,
@@ -80,6 +83,14 @@
int weight,
const CFX_SubstFont* subst_font);
+ CharMap GetCurrentCharMap() const;
+ absl::optional<fxge::FontEncoding> GetCurrentCharMapEncoding() const;
+ int GetCharMapPlatformIdByIndex(size_t index) const;
+ int GetCharMapEncodingIdByIndex(size_t index) const;
+ fxge::FontEncoding GetCharMapEncodingByIndex(size_t index) const;
+ size_t GetCharMapCount() const;
+ void SetCharMap(CharMap map);
+ void SetCharMapByIndex(size_t index);
bool SelectCharMap(fxge::FontEncoding encoding);
FXFT_FaceRec* GetRec() { return m_pRec.get(); }
diff --git a/core/fxge/cfx_unicodeencodingex.cpp b/core/fxge/cfx_unicodeencodingex.cpp
index 379ae2c..03cdf3b 100644
--- a/core/fxge/cfx_unicodeencodingex.cpp
+++ b/core/fxge/cfx_unicodeencodingex.cpp
@@ -43,27 +43,29 @@
CFX_UnicodeEncodingEx::~CFX_UnicodeEncodingEx() = default;
uint32_t CFX_UnicodeEncodingEx::GlyphFromCharCode(uint32_t charcode) {
- FXFT_FaceRec* face = m_pFont->GetFaceRec();
- FT_UInt nIndex = FT_Get_Char_Index(face, charcode);
+ FXFT_FaceRec* face_rec = m_pFont->GetFaceRec();
+ FT_UInt nIndex = FT_Get_Char_Index(face_rec, charcode);
if (nIndex > 0)
return nIndex;
- int m = 0;
- while (m < face->num_charmaps) {
- auto encoding_id = static_cast<fxge::FontEncoding>(
- FXFT_Get_Charmap_Encoding(face->charmaps[m++]));
+
+ RetainPtr<CFX_Face> face = m_pFont->GetFace();
+ size_t map_index = 0;
+ while (map_index < face->GetCharMapCount()) {
+ fxge::FontEncoding encoding_id =
+ face->GetCharMapEncodingByIndex(map_index++);
if (encoding_id_ == encoding_id) {
continue;
}
- if (!m_pFont->GetFace()->SelectCharMap(encoding_id)) {
+ if (!face->SelectCharMap(encoding_id)) {
continue;
}
- nIndex = FT_Get_Char_Index(face, charcode);
+ nIndex = FT_Get_Char_Index(face_rec, charcode);
if (nIndex > 0) {
encoding_id_ = encoding_id;
return nIndex;
}
}
- m_pFont->GetFace()->SelectCharMap(encoding_id_);
+ face->SelectCharMap(encoding_id_);
return 0;
}
@@ -72,10 +74,9 @@
encoding_id_ == fxge::FontEncoding::kSymbol) {
return Unicode;
}
- FXFT_FaceRec* face = m_pFont->GetFaceRec();
- for (int i = 0; i < face->num_charmaps; i++) {
- auto encoding_id = static_cast<fxge::FontEncoding>(
- FXFT_Get_Charmap_Encoding(face->charmaps[i]));
+ RetainPtr<CFX_Face> face = m_pFont->GetFace();
+ for (size_t i = 0; i < face->GetCharMapCount(); i++) {
+ fxge::FontEncoding encoding_id = face->GetCharMapEncodingByIndex(i);
if (encoding_id == fxge::FontEncoding::kUnicode ||
encoding_id == fxge::FontEncoding::kSymbol) {
return Unicode;
diff --git a/core/fxge/freetype/fx_freetype.h b/core/fxge/freetype/fx_freetype.h
index c2c1d72..06b4a0e 100644
--- a/core/fxge/freetype/fx_freetype.h
+++ b/core/fxge/freetype/fx_freetype.h
@@ -57,9 +57,6 @@
#define FXFT_Get_Glyph_HoriBearingY(face) (face)->glyph->metrics.horiBearingY
#define FXFT_Get_Glyph_Width(face) (face)->glyph->metrics.width
#define FXFT_Get_Glyph_Height(face) (face)->glyph->metrics.height
-#define FXFT_Get_Charmap_Encoding(charmap) (charmap)->encoding
-#define FXFT_Get_Charmap_PlatformID(charmap) (charmap)->platform_id
-#define FXFT_Get_Charmap_EncodingID(charmap) (charmap)->encoding_id
#define FXFT_Get_Glyph_HoriAdvance(face) (face)->glyph->metrics.horiAdvance
int FXFT_unicode_from_adobe_name(const char* glyph_name);
diff --git a/xfa/fgas/font/cfgas_fontmgr.cpp b/xfa/fgas/font/cfgas_fontmgr.cpp
index c8d3dd2..7ba38a0 100644
--- a/xfa/fgas/font/cfgas_fontmgr.cpp
+++ b/xfa/fgas/font/cfgas_fontmgr.cpp
@@ -41,14 +41,14 @@
if (!pFace)
return false;
- FXFT_FaceRec* pFaceRec = pFace->GetRec();
- FT_CharMap charmap = pFaceRec->charmap;
+ CFX_Face::CharMap charmap = pFace->GetCurrentCharMap();
if (!pFace->SelectCharMap(fxge::FontEncoding::kUnicode)) {
return false;
}
+ FXFT_FaceRec* pFaceRec = pFace->GetRec();
if (FT_Get_Char_Index(pFaceRec, wcUnicode) == 0) {
- FT_Set_Charmap(pFaceRec, charmap);
+ pFace->SetCharMap(charmap);
return false;
}
return true;