summaryrefslogtreecommitdiff
path: root/core/fpdfdoc
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfdoc')
-rw-r--r--core/fpdfdoc/cpvt_fontmap.cpp2
-rw-r--r--core/fpdfdoc/cpvt_wordinfo.h4
-rw-r--r--core/fpdfdoc/doc_form.cpp9
-rw-r--r--core/fpdfdoc/doc_utils.cpp22
-rw-r--r--core/fpdfdoc/include/cpdf_variabletext.h7
5 files changed, 24 insertions, 20 deletions
diff --git a/core/fpdfdoc/cpvt_fontmap.cpp b/core/fpdfdoc/cpvt_fontmap.cpp
index d4171bd147..35a56f811d 100644
--- a/core/fpdfdoc/cpvt_fontmap.cpp
+++ b/core/fpdfdoc/cpvt_fontmap.cpp
@@ -88,5 +88,5 @@ int32_t CPVT_FontMap::CharCodeFromUnicode(int32_t nFontIndex, uint16_t word) {
int32_t CPVT_FontMap::CharSetFromUnicode(uint16_t word, int32_t nOldCharset) {
ASSERT(false);
- return 0;
+ return FXFONT_ANSI_CHARSET;
}
diff --git a/core/fpdfdoc/cpvt_wordinfo.h b/core/fpdfdoc/cpvt_wordinfo.h
index 3eb980f3af..1ab0df21af 100644
--- a/core/fpdfdoc/cpvt_wordinfo.h
+++ b/core/fpdfdoc/cpvt_wordinfo.h
@@ -13,7 +13,7 @@
struct CPVT_WordInfo {
CPVT_WordInfo()
: Word(0),
- nCharset(0),
+ nCharset(FXFONT_ANSI_CHARSET),
fWordX(0.0f),
fWordY(0.0f),
fWordTail(0.0f),
@@ -34,7 +34,7 @@ struct CPVT_WordInfo {
CPVT_WordInfo(const CPVT_WordInfo& word)
: Word(0),
- nCharset(0),
+ nCharset(FXFONT_ANSI_CHARSET),
fWordX(0.0f),
fWordY(0.0f),
fWordTail(0.0f),
diff --git a/core/fpdfdoc/doc_form.cpp b/core/fpdfdoc/doc_form.cpp
index b2c5d8cdf7..82fcd4ceeb 100644
--- a/core/fpdfdoc/doc_form.cpp
+++ b/core/fpdfdoc/doc_form.cpp
@@ -416,12 +416,11 @@ CFX_ByteString CPDF_InterForm::GetNativeFont(uint8_t charSet, void* pLogFont) {
CFX_ByteString csFontName;
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
LOGFONTA lf = {};
- FX_BOOL bRet;
if (charSet == ANSI_CHARSET) {
csFontName = "Helvetica";
return csFontName;
}
- bRet = FALSE;
+ FX_BOOL bRet = FALSE;
if (charSet == SHIFTJIS_CHARSET) {
bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE,
"MS Mincho", lf);
@@ -454,14 +453,16 @@ CFX_ByteString CPDF_InterForm::GetNativeFont(uint8_t charSet, void* pLogFont) {
#endif
return csFontName;
}
+
CFX_ByteString CPDF_InterForm::GetNativeFont(void* pLogFont) {
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
- uint8_t charSet = GetNativeCharSet();
- return GetNativeFont(charSet, pLogFont);
+ return GetNativeFont(GetNativeCharSet(), pLogFont);
#else
return CFX_ByteString();
#endif
}
+
+// static
uint8_t CPDF_InterForm::GetNativeCharSet() {
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
uint8_t charSet = ANSI_CHARSET;
diff --git a/core/fpdfdoc/doc_utils.cpp b/core/fpdfdoc/doc_utils.cpp
index ccef7feb57..7f79a34245 100644
--- a/core/fpdfdoc/doc_utils.cpp
+++ b/core/fpdfdoc/doc_utils.cpp
@@ -267,10 +267,11 @@ CFX_Matrix CPDF_DefaultAppearance::GetTextMatrix() {
}
return tm;
}
+
void InitInterFormDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument) {
- if (!pDocument) {
+ if (!pDocument)
return;
- }
+
if (!pFormDict) {
pFormDict = new CPDF_Dictionary;
uint32_t dwObjNum = pDocument->AddIndirectObject(pFormDict);
@@ -287,7 +288,7 @@ void InitInterFormDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument) {
AddInterFormFont(pFormDict, pDocument, pFont, csBaseName);
csDefault = csBaseName;
}
- if (charSet != 0) {
+ if (charSet != FXFONT_ANSI_CHARSET) {
CFX_ByteString csFontName =
CPDF_InterForm::GetNativeFont(charSet, nullptr);
if (!pFont || csFontName != "Helvetica") {
@@ -478,15 +479,15 @@ CPDF_Font* GetNativeInterFormFont(CPDF_Dictionary* pFormDict,
}
return nullptr;
}
+
CPDF_Font* GetNativeInterFormFont(CPDF_Dictionary* pFormDict,
CPDF_Document* pDocument,
CFX_ByteString& csNameTag) {
- csNameTag = "";
+ csNameTag.clear();
uint8_t charSet = CPDF_InterForm::GetNativeCharSet();
- CFX_SubstFont* pSubst;
CPDF_Font* pFont = GetDefaultInterFormFont(pFormDict, pDocument);
if (pFont) {
- pSubst = pFont->GetSubstFont();
+ CFX_SubstFont* pSubst = pFont->GetSubstFont();
if (pSubst && pSubst->m_Charset == (int)charSet) {
FindInterFormFont(pFormDict, pFont, csNameTag);
return pFont;
@@ -494,6 +495,7 @@ CPDF_Font* GetNativeInterFormFont(CPDF_Dictionary* pFormDict,
}
return GetNativeInterFormFont(pFormDict, pDocument, charSet, csNameTag);
}
+
FX_BOOL FindInterFormFont(CPDF_Dictionary* pFormDict,
const CPDF_Font* pFont,
CFX_ByteString& csNameTag) {
@@ -623,10 +625,9 @@ CPDF_Font* AddNativeInterFormFont(CPDF_Dictionary*& pFormDict,
return pFont;
}
CFX_ByteString csFontName = CPDF_InterForm::GetNativeFont(charSet);
- if (!csFontName.IsEmpty()) {
- if (FindInterFormFont(pFormDict, pDocument, csFontName, pFont, csNameTag)) {
- return pFont;
- }
+ if (!csFontName.IsEmpty() &&
+ FindInterFormFont(pFormDict, pDocument, csFontName, pFont, csNameTag)) {
+ return pFont;
}
pFont = CPDF_InterForm::AddNativeFont(charSet, pDocument);
if (pFont) {
@@ -652,6 +653,7 @@ void RemoveInterFormFont(CPDF_Dictionary* pFormDict, const CPDF_Font* pFont) {
CPDF_Dictionary* pFonts = pDR->GetDictBy("Font");
pFonts->RemoveAt(csTag);
}
+
void RemoveInterFormFont(CPDF_Dictionary* pFormDict, CFX_ByteString csNameTag) {
if (!pFormDict || csNameTag.IsEmpty()) {
return;
diff --git a/core/fpdfdoc/include/cpdf_variabletext.h b/core/fpdfdoc/include/cpdf_variabletext.h
index 5e64ab29a9..36b2eb46a5 100644
--- a/core/fpdfdoc/include/cpdf_variabletext.h
+++ b/core/fpdfdoc/include/cpdf_variabletext.h
@@ -18,6 +18,7 @@
#include "core/fxcrt/include/fx_coordinates.h"
#include "core/fxcrt/include/fx_string.h"
#include "core/fxcrt/include/fx_system.h"
+#include "core/fxge/include/fx_font.h"
class CSection;
class IPVT_FontMap;
@@ -112,19 +113,19 @@ class CPDF_VariableText : private CPDF_EditContainer {
void RearrangePart(const CPVT_WordRange& PlaceRange);
void ResetAll();
void SetText(const FX_WCHAR* text,
- int32_t charset = 1,
+ int32_t charset = FXFONT_DEFAULT_CHARSET,
const CPVT_SecProps* pSecProps = nullptr,
const CPVT_WordProps* pWordProps = nullptr);
CPVT_WordPlace InsertWord(const CPVT_WordPlace& place,
uint16_t word,
- int32_t charset = 1,
+ int32_t charset = FXFONT_DEFAULT_CHARSET,
const CPVT_WordProps* pWordProps = nullptr);
CPVT_WordPlace InsertSection(const CPVT_WordPlace& place,
const CPVT_SecProps* pSecProps = nullptr,
const CPVT_WordProps* pWordProps = nullptr);
CPVT_WordPlace InsertText(const CPVT_WordPlace& place,
const FX_WCHAR* text,
- int32_t charset = 1,
+ int32_t charset = FXFONT_DEFAULT_CHARSET,
const CPVT_SecProps* pSecProps = nullptr,
const CPVT_WordProps* pWordProps = nullptr);
CPVT_WordPlace DeleteWords(const CPVT_WordRange& PlaceRange);