diff --git a/DesktopEditor/fontengine/FontFile.cpp b/DesktopEditor/fontengine/FontFile.cpp index f6075cfb79..e3840f70b7 100644 --- a/DesktopEditor/fontengine/FontFile.cpp +++ b/DesktopEditor/fontengine/FontFile.cpp @@ -1046,6 +1046,28 @@ int CFontFile::GetGIDByUnicode(int code) return unGID; } +int CFontFile::GetUnicodeByGID(int gid) +{ + if (!m_pFace) + return 0; + + FT_ULong charcode; + FT_UInt gindex; + + charcode = FT_Get_First_Char(m_pFace, &gindex); + + while (gindex != 0) + { + if (gindex == gid) + { + return charcode; + } + charcode = FT_Get_Next_Char(m_pFace, charcode, &gindex); + } + + return 0; +} + INT CFontFile::GetString(CGlyphString& oString) { int nCountGlyph = oString.GetLength(); diff --git a/DesktopEditor/fontengine/FontFile.h b/DesktopEditor/fontengine/FontFile.h index e271978bad..da0ea7ff65 100644 --- a/DesktopEditor/fontengine/FontFile.h +++ b/DesktopEditor/fontengine/FontFile.h @@ -254,6 +254,7 @@ public: double GetCharWidth(int gid); int GetGIDByUnicode(int code); + int GetUnicodeByGID(int gid); int GetKerning(FT_UInt unPrevGID, FT_UInt unGID); void SetStringGID(const INT& bGID); diff --git a/DesktopEditor/fontengine/FontManager.cpp b/DesktopEditor/fontengine/FontManager.cpp index 875691f15b..6db559cd1e 100644 --- a/DesktopEditor/fontengine/FontManager.cpp +++ b/DesktopEditor/fontengine/FontManager.cpp @@ -851,6 +851,14 @@ unsigned int CFontManager::GetGIDByUnicode(const unsigned int& unCode) return m_pFont->GetGIDByUnicode(unCode); } +int CFontManager::GetUnicodeByGID(const int& gid) +{ + if (!m_pFont) + return 0; + + return m_pFont->GetUnicodeByGID(gid); +} + void CFontManager::SetSubpixelRendering(const bool& hmul, const bool& vmul) { if (hmul) diff --git a/DesktopEditor/fontengine/FontManager.h b/DesktopEditor/fontengine/FontManager.h index 1b88d218cf..553e8300fd 100644 --- a/DesktopEditor/fontengine/FontManager.h +++ b/DesktopEditor/fontengine/FontManager.h @@ -186,6 +186,7 @@ public: virtual std::wstring GetFontType(); virtual unsigned int GetNameIndex(const std::wstring& wsName); virtual unsigned int GetGIDByUnicode(const unsigned int& unCode); + virtual int GetUnicodeByGID(const int& gid); virtual void SetSubpixelRendering(const bool& hmul, const bool& vmul);