summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BUILD.gn2
-rw-r--r--fxjs/xfa/cjx_object.cpp10
-rw-r--r--xfa/fxfa/cxfa_textlayout.cpp13
-rw-r--r--xfa/fxfa/cxfa_textparser.cpp85
-rw-r--r--xfa/fxfa/cxfa_textprovider.cpp6
-rw-r--r--xfa/fxfa/cxfa_textprovider.h4
-rw-r--r--xfa/fxfa/cxfa_widgetacc.cpp31
-rw-r--r--xfa/fxfa/parser/cxfa_caption.cpp4
-rw-r--r--xfa/fxfa/parser/cxfa_caption.h4
-rw-r--r--xfa/fxfa/parser/cxfa_font.cpp70
-rw-r--r--xfa/fxfa/parser/cxfa_font.h16
-rw-r--r--xfa/fxfa/parser/cxfa_fontdata.cpp88
-rw-r--r--xfa/fxfa/parser/cxfa_fontdata.h36
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.cpp6
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.h4
15 files changed, 167 insertions, 212 deletions
diff --git a/BUILD.gn b/BUILD.gn
index aa82d65c0b..c1b885f99f 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -2329,8 +2329,6 @@ if (pdf_enable_xfa) {
"xfa/fxfa/parser/cxfa_float.h",
"xfa/fxfa/parser/cxfa_font.cpp",
"xfa/fxfa/parser/cxfa_font.h",
- "xfa/fxfa/parser/cxfa_fontdata.cpp",
- "xfa/fxfa/parser/cxfa_fontdata.h",
"xfa/fxfa/parser/cxfa_fontinfo.cpp",
"xfa/fxfa/parser/cxfa_fontinfo.h",
"xfa/fxfa/parser/cxfa_form.cpp",
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp
index 81a6c2e64e..a168bfbe15 100644
--- a/fxjs/xfa/cjx_object.cpp
+++ b/fxjs/xfa/cjx_object.cpp
@@ -25,6 +25,7 @@
#include "xfa/fxfa/parser/cxfa_document.h"
#include "xfa/fxfa/parser/cxfa_edge.h"
#include "xfa/fxfa/parser/cxfa_fill.h"
+#include "xfa/fxfa/parser/cxfa_font.h"
#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
#include "xfa/fxfa/parser/cxfa_measurement.h"
#include "xfa/fxfa/parser/cxfa_node.h"
@@ -1309,9 +1310,8 @@ void CJX_Object::Script_Som_FontColor(CFXJSE_Value* pValue,
if (!widget_data_)
return;
- CXFA_FontData fontData = widget_data_->GetFontData(true);
- CXFA_Node* pNode = fontData.GetNode();
- if (!pNode)
+ CXFA_Font* font = widget_data_->GetFont(true);
+ if (!font)
return;
if (bSetting) {
@@ -1320,7 +1320,7 @@ void CJX_Object::Script_Som_FontColor(CFXJSE_Value* pValue,
int32_t b;
std::tie(r, g, b) = StrToRGB(pValue->ToWideString());
FX_ARGB color = ArgbEncode(0xff, r, g, b);
- fontData.SetColor(color);
+ font->SetColor(color);
return;
}
@@ -1328,7 +1328,7 @@ void CJX_Object::Script_Som_FontColor(CFXJSE_Value* pValue,
int32_t r;
int32_t g;
int32_t b;
- std::tie(a, r, g, b) = ArgbDecode(fontData.GetColor());
+ std::tie(a, r, g, b) = ArgbDecode(font->GetColor());
pValue->SetString(ByteString::Format("%d,%d,%d", r, g, b).AsStringView());
}
diff --git a/xfa/fxfa/cxfa_textlayout.cpp b/xfa/fxfa/cxfa_textlayout.cpp
index 133f564deb..6f19e8add1 100644
--- a/xfa/fxfa/cxfa_textlayout.cpp
+++ b/xfa/fxfa/cxfa_textlayout.cpp
@@ -27,7 +27,7 @@
#include "xfa/fxfa/cxfa_textprovider.h"
#include "xfa/fxfa/cxfa_texttabstopscontext.h"
#include "xfa/fxfa/cxfa_textuserdata.h"
-#include "xfa/fxfa/parser/cxfa_fontdata.h"
+#include "xfa/fxfa/parser/cxfa_font.h"
#include "xfa/fxfa/parser/cxfa_node.h"
#include "xfa/fxfa/parser/cxfa_para.h"
@@ -148,13 +148,12 @@ void CXFA_TextLayout::InitBreak(float fLineWidth) {
m_pBreak->SetLineBoundary(fStart, fLineWidth);
m_pBreak->SetLineStartPos(fStartPos);
- CXFA_FontData fontData = m_pTextProvider->GetFontData();
- if (fontData.HasValidNode()) {
+ CXFA_Font* font = m_pTextProvider->GetFont();
+ if (font) {
m_pBreak->SetHorizontalScale(
- static_cast<int32_t>(fontData.GetHorizontalScale()));
- m_pBreak->SetVerticalScale(
- static_cast<int32_t>(fontData.GetVerticalScale()));
- m_pBreak->SetCharSpace(fontData.GetLetterSpacing());
+ static_cast<int32_t>(font->GetHorizontalScale()));
+ m_pBreak->SetVerticalScale(static_cast<int32_t>(font->GetVerticalScale()));
+ m_pBreak->SetCharSpace(font->GetLetterSpacing());
}
float fFontSize = m_textParser.GetFontSize(m_pTextProvider, nullptr);
diff --git a/xfa/fxfa/cxfa_textparser.cpp b/xfa/fxfa/cxfa_textparser.cpp
index ecee36a9f1..b6538aa933 100644
--- a/xfa/fxfa/cxfa_textparser.cpp
+++ b/xfa/fxfa/cxfa_textparser.cpp
@@ -25,6 +25,7 @@
#include "xfa/fxfa/cxfa_textparsecontext.h"
#include "xfa/fxfa/cxfa_textprovider.h"
#include "xfa/fxfa/cxfa_texttabstopscontext.h"
+#include "xfa/fxfa/parser/cxfa_font.h"
#include "xfa/fxfa/parser/cxfa_measurement.h"
#include "xfa/fxfa/parser/cxfa_para.h"
@@ -59,9 +60,8 @@ void CXFA_TextParser::InitCSSData(CXFA_TextProvider* pTextProvider) {
if (!m_pSelector) {
m_pSelector = pdfium::MakeUnique<CFX_CSSStyleSelector>();
- CXFA_FontData fontData = pTextProvider->GetFontData();
- m_pSelector->SetDefFontSize(fontData.HasValidNode() ? fontData.GetFontSize()
- : 10.0f);
+ CXFA_Font* font = pTextProvider->GetFont();
+ m_pSelector->SetDefFontSize(font ? font->GetFontSize() : 10.0f);
}
if (m_cssInitialized)
@@ -132,24 +132,23 @@ RetainPtr<CFX_CSSComputedStyle> CXFA_TextParser::CreateRootStyle(
pStyle->SetMarginWidth(rtMarginWidth);
}
- CXFA_FontData fontData = pTextProvider->GetFontData();
- if (fontData.HasValidNode()) {
- pStyle->SetColor(fontData.GetColor());
- pStyle->SetFontStyle(fontData.IsItalic() ? CFX_CSSFontStyle::Italic
- : CFX_CSSFontStyle::Normal);
- pStyle->SetFontWeight(fontData.IsBold() ? FXFONT_FW_BOLD
- : FXFONT_FW_NORMAL);
- pStyle->SetNumberVerticalAlign(-fontData.GetBaselineShift());
- fFontSize = fontData.GetFontSize();
+ CXFA_Font* font = pTextProvider->GetFont();
+ if (font) {
+ pStyle->SetColor(font->GetColor());
+ pStyle->SetFontStyle(font->IsItalic() ? CFX_CSSFontStyle::Italic
+ : CFX_CSSFontStyle::Normal);
+ pStyle->SetFontWeight(font->IsBold() ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL);
+ pStyle->SetNumberVerticalAlign(-font->GetBaselineShift());
+ fFontSize = font->GetFontSize();
CFX_CSSLength letterSpacing;
- letterSpacing.Set(CFX_CSSLengthUnit::Point, fontData.GetLetterSpacing());
+ letterSpacing.Set(CFX_CSSLengthUnit::Point, font->GetLetterSpacing());
pStyle->SetLetterSpacing(letterSpacing);
uint32_t dwDecoration = 0;
- if (fontData.GetLineThrough() > 0)
+ if (font->GetLineThrough() > 0)
dwDecoration |= CFX_CSSTEXTDECORATION_LineThrough;
- if (fontData.GetUnderline() > 1)
+ if (font->GetUnderline() > 1)
dwDecoration |= CFX_CSSTEXTDECORATION_Double;
- else if (fontData.GetUnderline() > 0)
+ else if (font->GetUnderline() > 0)
dwDecoration |= CFX_CSSTEXTDECORATION_Underline;
pStyle->SetTextDecoration(dwDecoration);
@@ -330,12 +329,12 @@ RetainPtr<CFGAS_GEFont> CXFA_TextParser::GetFont(
CFX_CSSComputedStyle* pStyle) const {
WideString wsFamily = L"Courier";
uint32_t dwStyle = 0;
- CXFA_FontData fontData = pTextProvider->GetFontData();
- if (fontData.HasValidNode()) {
- wsFamily = fontData.GetTypeface();
- if (fontData.IsBold())
+ CXFA_Font* font = pTextProvider->GetFont();
+ if (font) {
+ wsFamily = font->GetTypeface();
+ if (font->IsBold())
dwStyle |= FXFONT_BOLD;
- if (fontData.IsItalic())
+ if (font->IsItalic())
dwStyle |= FXFONT_BOLD;
}
@@ -361,8 +360,8 @@ float CXFA_TextParser::GetFontSize(CXFA_TextProvider* pTextProvider,
if (pStyle)
return pStyle->GetFontSize();
- CXFA_FontData fontData = pTextProvider->GetFontData();
- return fontData.HasValidNode() ? fontData.GetFontSize() : 10;
+ CXFA_Font* font = pTextProvider->GetFont();
+ return font ? font->GetFontSize() : 10;
}
int32_t CXFA_TextParser::GetHorScale(CXFA_TextProvider* pTextProvider,
@@ -387,10 +386,8 @@ int32_t CXFA_TextParser::GetHorScale(CXFA_TextProvider* pTextProvider,
}
}
- CXFA_FontData fontData = pTextProvider->GetFontData();
- return fontData.HasValidNode()
- ? static_cast<int32_t>(fontData.GetHorizontalScale())
- : 100;
+ CXFA_Font* font = pTextProvider->GetFont();
+ return font ? static_cast<int32_t>(font->GetHorizontalScale()) : 100;
}
int32_t CXFA_TextParser::GetVerScale(CXFA_TextProvider* pTextProvider,
@@ -401,10 +398,8 @@ int32_t CXFA_TextParser::GetVerScale(CXFA_TextProvider* pTextProvider,
return wsValue.GetInteger();
}
- CXFA_FontData fontData = pTextProvider->GetFontData();
- return fontData.HasValidNode()
- ? static_cast<int32_t>(fontData.GetVerticalScale())
- : 100;
+ CXFA_Font* font = pTextProvider->GetFont();
+ return font ? static_cast<int32_t>(font->GetVerticalScale()) : 100;
}
void CXFA_TextParser::GetUnderline(CXFA_TextProvider* pTextProvider,
@@ -413,11 +408,11 @@ void CXFA_TextParser::GetUnderline(CXFA_TextProvider* pTextProvider,
XFA_AttributeEnum& iPeriod) const {
iUnderline = 0;
iPeriod = XFA_AttributeEnum::All;
- CXFA_FontData fontData = pTextProvider->GetFontData();
+ CXFA_Font* font = pTextProvider->GetFont();
if (!pStyle) {
- if (fontData.HasValidNode()) {
- iUnderline = fontData.GetUnderline();
- iPeriod = fontData.GetUnderlinePeriod();
+ if (font) {
+ iUnderline = font->GetUnderline();
+ iPeriod = font->GetUnderlinePeriod();
}
return;
}
@@ -432,8 +427,8 @@ void CXFA_TextParser::GetUnderline(CXFA_TextProvider* pTextProvider,
if (pStyle->GetCustomStyle(L"underlinePeriod", wsValue)) {
if (wsValue == L"word")
iPeriod = XFA_AttributeEnum::Word;
- } else if (fontData.HasValidNode()) {
- iPeriod = fontData.GetUnderlinePeriod();
+ } else if (font) {
+ iPeriod = font->GetUnderlinePeriod();
}
}
@@ -446,9 +441,9 @@ void CXFA_TextParser::GetLinethrough(CXFA_TextProvider* pTextProvider,
return;
}
- CXFA_FontData fontData = pTextProvider->GetFontData();
- if (fontData.HasValidNode())
- iLinethrough = fontData.GetLineThrough();
+ CXFA_Font* font = pTextProvider->GetFont();
+ if (font)
+ iLinethrough = font->GetLineThrough();
}
FX_ARGB CXFA_TextParser::GetColor(CXFA_TextProvider* pTextProvider,
@@ -456,8 +451,8 @@ FX_ARGB CXFA_TextParser::GetColor(CXFA_TextProvider* pTextProvider,
if (pStyle)
return pStyle->GetColor();
- CXFA_FontData fontData = pTextProvider->GetFontData();
- return fontData.HasValidNode() ? fontData.GetColor() : 0xFF000000;
+ CXFA_Font* font = pTextProvider->GetFont();
+ return font ? font->GetColor() : 0xFF000000;
}
float CXFA_TextParser::GetBaseline(CXFA_TextProvider* pTextProvider,
@@ -466,9 +461,9 @@ float CXFA_TextParser::GetBaseline(CXFA_TextProvider* pTextProvider,
if (pStyle->GetVerticalAlign() == CFX_CSSVerticalAlign::Number)
return pStyle->GetNumberVerticalAlign();
} else {
- CXFA_FontData fontData = pTextProvider->GetFontData();
- if (fontData.HasValidNode())
- return fontData.GetBaselineShift();
+ CXFA_Font* font = pTextProvider->GetFont();
+ if (font)
+ return font->GetBaselineShift();
}
return 0;
}
diff --git a/xfa/fxfa/cxfa_textprovider.cpp b/xfa/fxfa/cxfa_textprovider.cpp
index 461fa5dde4..b32241ea35 100644
--- a/xfa/fxfa/cxfa_textprovider.cpp
+++ b/xfa/fxfa/cxfa_textprovider.cpp
@@ -126,14 +126,14 @@ CXFA_Para* CXFA_TextProvider::GetPara() {
return pNode->GetChild<CXFA_Para>(0, XFA_Element::Para, false);
}
-CXFA_FontData CXFA_TextProvider::GetFontData() {
+CXFA_Font* CXFA_TextProvider::GetFont() {
if (m_eType == XFA_TEXTPROVIDERTYPE_Text)
- return m_pWidgetAcc->GetFontData(false);
+ return m_pWidgetAcc->GetFont(false);
CXFA_Caption* pNode = m_pWidgetAcc->GetNode()->GetChild<CXFA_Caption>(
0, XFA_Element::Caption, false);
CXFA_Font* font = pNode->GetChild<CXFA_Font>(0, XFA_Element::Font, false);
- return font ? CXFA_FontData(font) : m_pWidgetAcc->GetFontData(false);
+ return font ? font : m_pWidgetAcc->GetFont(false);
}
bool CXFA_TextProvider::IsCheckButtonAndAutoWidth() {
diff --git a/xfa/fxfa/cxfa_textprovider.h b/xfa/fxfa/cxfa_textprovider.h
index ae51fc318a..875355a27c 100644
--- a/xfa/fxfa/cxfa_textprovider.h
+++ b/xfa/fxfa/cxfa_textprovider.h
@@ -10,9 +10,9 @@
#include "core/fxcrt/fx_string.h"
#include "xfa/fxfa/cxfa_textlayout.h"
#include "xfa/fxfa/cxfa_widgetacc.h"
-#include "xfa/fxfa/parser/cxfa_fontdata.h"
class CXFA_FFDoc;
+class CXFA_Font;
class CXFA_Node;
enum XFA_TEXTPROVIDERTYPE {
@@ -33,7 +33,7 @@ class CXFA_TextProvider {
CXFA_Node* GetTextNode(bool& bRichText);
CXFA_Para* GetPara();
- CXFA_FontData GetFontData();
+ CXFA_Font* GetFont();
bool IsCheckButtonAndAutoWidth();
CXFA_FFDoc* GetDocNode() { return m_pWidgetAcc->GetDoc(); }
bool GetEmbbedObj(bool bURI,
diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp
index b9d89cdfd5..a811d37fa4 100644
--- a/xfa/fxfa/cxfa_widgetacc.cpp
+++ b/xfa/fxfa/cxfa_widgetacc.cpp
@@ -23,6 +23,7 @@
#include "xfa/fxfa/cxfa_textprovider.h"
#include "xfa/fxfa/parser/cxfa_calculate.h"
#include "xfa/fxfa/parser/cxfa_caption.h"
+#include "xfa/fxfa/parser/cxfa_font.h"
#include "xfa/fxfa/parser/cxfa_image.h"
#include "xfa/fxfa/parser/cxfa_items.h"
#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
@@ -709,13 +710,13 @@ void CXFA_WidgetAcc::CalcCaptionSize(CFX_SizeF& szCap) {
bVert ? szCap.height = fCapReserve : szCap.width = fCapReserve;
} else {
float fFontSize = 10.0f;
- CXFA_FontData fontData = caption->GetFontData();
- if (fontData.HasValidNode()) {
- fFontSize = fontData.GetFontSize();
+ CXFA_Font* font = caption->GetFont();
+ if (font) {
+ fFontSize = font->GetFontSize();
} else {
- CXFA_FontData widgetfontData = GetFontData(false);
- if (widgetfontData.HasValidNode())
- fFontSize = widgetfontData.GetFontSize();
+ CXFA_Font* widgetfont = GetFont(false);
+ if (widgetfont)
+ fFontSize = widgetfont->GetFontSize();
}
if (bVert) {
@@ -1483,14 +1484,14 @@ void CXFA_WidgetAcc::SetImageEditImage(
RetainPtr<CFGAS_GEFont> CXFA_WidgetAcc::GetFDEFont() {
WideString wsFontName = L"Courier";
uint32_t dwFontStyle = 0;
- CXFA_FontData fontData = GetFontData(false);
- if (fontData.HasValidNode()) {
- if (fontData.IsBold())
+ CXFA_Font* font = GetFont(false);
+ if (font) {
+ if (font->IsBold())
dwFontStyle |= FXFONT_BOLD;
- if (fontData.IsItalic())
+ if (font->IsItalic())
dwFontStyle |= FXFONT_ITALIC;
- wsFontName = fontData.GetTypeface();
+ wsFontName = font->GetTypeface();
}
auto* pDoc = GetDoc();
@@ -1499,8 +1500,8 @@ RetainPtr<CFGAS_GEFont> CXFA_WidgetAcc::GetFDEFont() {
}
float CXFA_WidgetAcc::GetFontSize() {
- CXFA_FontData fontData = GetFontData(false);
- float fFontSize = fontData.HasValidNode() ? fontData.GetFontSize() : 10.0f;
+ CXFA_Font* font = GetFont(false);
+ float fFontSize = font ? font->GetFontSize() : 10.0f;
return fFontSize < 0.1f ? 10.0f : fFontSize;
}
@@ -1515,6 +1516,6 @@ float CXFA_WidgetAcc::GetLineHeight() {
}
FX_ARGB CXFA_WidgetAcc::GetTextColor() {
- CXFA_FontData fontData = GetFontData(false);
- return fontData.HasValidNode() ? fontData.GetColor() : 0xFF000000;
+ CXFA_Font* font = GetFont(false);
+ return font ? font->GetColor() : 0xFF000000;
}
diff --git a/xfa/fxfa/parser/cxfa_caption.cpp b/xfa/fxfa/parser/cxfa_caption.cpp
index 1af834a277..4d4dde57e9 100644
--- a/xfa/fxfa/parser/cxfa_caption.cpp
+++ b/xfa/fxfa/parser/cxfa_caption.cpp
@@ -74,8 +74,8 @@ CXFA_Margin* CXFA_Caption::GetMargin() {
return GetChild<CXFA_Margin>(0, XFA_Element::Margin, false);
}
-CXFA_FontData CXFA_Caption::GetFontData() {
- return CXFA_FontData(GetChild<CXFA_Font>(0, XFA_Element::Font, false));
+CXFA_Font* CXFA_Caption::GetFont() {
+ return GetChild<CXFA_Font>(0, XFA_Element::Font, false);
}
CXFA_Value* CXFA_Caption::GetValue() {
diff --git a/xfa/fxfa/parser/cxfa_caption.h b/xfa/fxfa/parser/cxfa_caption.h
index 7a52254d77..11c1cec3f4 100644
--- a/xfa/fxfa/parser/cxfa_caption.h
+++ b/xfa/fxfa/parser/cxfa_caption.h
@@ -7,9 +7,9 @@
#ifndef XFA_FXFA_PARSER_CXFA_CAPTION_H_
#define XFA_FXFA_PARSER_CXFA_CAPTION_H_
-#include "xfa/fxfa/parser/cxfa_fontdata.h"
#include "xfa/fxfa/parser/cxfa_node.h"
+class CXFA_Font;
class CXFA_Margin;
class CXFA_Value;
@@ -23,7 +23,7 @@ class CXFA_Caption : public CXFA_Node {
XFA_AttributeEnum GetPlacementType();
float GetReserve() const;
CXFA_Margin* GetMargin();
- CXFA_FontData GetFontData();
+ CXFA_Font* GetFont();
CXFA_Value* GetValue();
};
diff --git a/xfa/fxfa/parser/cxfa_font.cpp b/xfa/fxfa/parser/cxfa_font.cpp
index eb5c312173..c78cbd14b8 100644
--- a/xfa/fxfa/parser/cxfa_font.cpp
+++ b/xfa/fxfa/parser/cxfa_font.cpp
@@ -8,6 +8,8 @@
#include "fxjs/xfa/cjx_font.h"
#include "third_party/base/ptr_util.h"
+#include "xfa/fxfa/parser/cxfa_fill.h"
+#include "xfa/fxfa/parser/cxfa_measurement.h"
namespace {
@@ -63,3 +65,71 @@ CXFA_Font::CXFA_Font(CXFA_Document* doc, XFA_PacketType packet)
pdfium::MakeUnique<CJX_Font>(this)) {}
CXFA_Font::~CXFA_Font() {}
+
+float CXFA_Font::GetBaselineShift() const {
+ return JSObject()
+ ->GetMeasure(XFA_Attribute::BaselineShift)
+ .ToUnit(XFA_Unit::Pt);
+}
+
+float CXFA_Font::GetHorizontalScale() {
+ WideString wsValue = JSObject()->GetCData(XFA_Attribute::FontHorizontalScale);
+ int32_t iScale = FXSYS_wtoi(wsValue.c_str());
+ return iScale > 0 ? (float)iScale : 100.0f;
+}
+
+float CXFA_Font::GetVerticalScale() {
+ WideString wsValue = JSObject()->GetCData(XFA_Attribute::FontVerticalScale);
+ int32_t iScale = FXSYS_wtoi(wsValue.c_str());
+ return iScale > 0 ? (float)iScale : 100.0f;
+}
+
+float CXFA_Font::GetLetterSpacing() {
+ WideString wsValue = JSObject()->GetCData(XFA_Attribute::LetterSpacing);
+ CXFA_Measurement ms(wsValue.AsStringView());
+ if (ms.GetUnit() == XFA_Unit::Em)
+ return ms.GetValue() * GetFontSize();
+ return ms.ToUnit(XFA_Unit::Pt);
+}
+
+int32_t CXFA_Font::GetLineThrough() {
+ return JSObject()->GetInteger(XFA_Attribute::LineThrough);
+}
+
+int32_t CXFA_Font::GetUnderline() {
+ return JSObject()->GetInteger(XFA_Attribute::Underline);
+}
+
+XFA_AttributeEnum CXFA_Font::GetUnderlinePeriod() {
+ return JSObject()
+ ->TryEnum(XFA_Attribute::UnderlinePeriod, true)
+ .value_or(XFA_AttributeEnum::All);
+}
+
+float CXFA_Font::GetFontSize() const {
+ return JSObject()->GetMeasure(XFA_Attribute::Size).ToUnit(XFA_Unit::Pt);
+}
+
+WideString CXFA_Font::GetTypeface() {
+ return JSObject()->GetCData(XFA_Attribute::Typeface);
+}
+
+bool CXFA_Font::IsBold() {
+ return JSObject()->GetEnum(XFA_Attribute::Weight) == XFA_AttributeEnum::Bold;
+}
+
+bool CXFA_Font::IsItalic() {
+ return JSObject()->GetEnum(XFA_Attribute::Posture) ==
+ XFA_AttributeEnum::Italic;
+}
+
+void CXFA_Font::SetColor(FX_ARGB color) {
+ JSObject()
+ ->GetProperty<CXFA_Fill>(0, XFA_Element::Fill, true)
+ ->SetColor(color);
+}
+
+FX_ARGB CXFA_Font::GetColor() {
+ CXFA_Fill* fill = GetChild<CXFA_Fill>(0, XFA_Element::Fill, false);
+ return fill ? fill->GetColor(true) : 0xFF000000;
+}
diff --git a/xfa/fxfa/parser/cxfa_font.h b/xfa/fxfa/parser/cxfa_font.h
index 59b0c71e8c..833c29a530 100644
--- a/xfa/fxfa/parser/cxfa_font.h
+++ b/xfa/fxfa/parser/cxfa_font.h
@@ -13,6 +13,22 @@ class CXFA_Font : public CXFA_Node {
public:
CXFA_Font(CXFA_Document* doc, XFA_PacketType packet);
~CXFA_Font() override;
+
+ float GetBaselineShift() const;
+ float GetHorizontalScale();
+ float GetVerticalScale();
+ float GetLetterSpacing();
+ int32_t GetLineThrough();
+ int32_t GetUnderline();
+ XFA_AttributeEnum GetUnderlinePeriod();
+ float GetFontSize() const;
+ WideString GetTypeface();
+
+ bool IsBold();
+ bool IsItalic();
+
+ FX_ARGB GetColor();
+ void SetColor(FX_ARGB color);
};
#endif // XFA_FXFA_PARSER_CXFA_FONT_H_
diff --git a/xfa/fxfa/parser/cxfa_fontdata.cpp b/xfa/fxfa/parser/cxfa_fontdata.cpp
deleted file mode 100644
index 64b5af0794..0000000000
--- a/xfa/fxfa/parser/cxfa_fontdata.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "xfa/fxfa/parser/cxfa_fontdata.h"
-
-#include "core/fxge/fx_dib.h"
-#include "xfa/fxfa/parser/cxfa_fill.h"
-#include "xfa/fxfa/parser/cxfa_measurement.h"
-#include "xfa/fxfa/parser/cxfa_node.h"
-
-CXFA_FontData::CXFA_FontData(CXFA_Node* pNode) : CXFA_DataData(pNode) {}
-
-float CXFA_FontData::GetBaselineShift() const {
- return m_pNode->JSObject()
- ->GetMeasure(XFA_Attribute::BaselineShift)
- .ToUnit(XFA_Unit::Pt);
-}
-
-float CXFA_FontData::GetHorizontalScale() const {
- WideString wsValue =
- m_pNode->JSObject()->GetCData(XFA_Attribute::FontHorizontalScale);
- int32_t iScale = FXSYS_wtoi(wsValue.c_str());
- return iScale > 0 ? (float)iScale : 100.0f;
-}
-
-float CXFA_FontData::GetVerticalScale() const {
- WideString wsValue =
- m_pNode->JSObject()->GetCData(XFA_Attribute::FontVerticalScale);
- int32_t iScale = FXSYS_wtoi(wsValue.c_str());
- return iScale > 0 ? (float)iScale : 100.0f;
-}
-
-float CXFA_FontData::GetLetterSpacing() const {
- WideString wsValue =
- m_pNode->JSObject()->GetCData(XFA_Attribute::LetterSpacing);
- CXFA_Measurement ms(wsValue.AsStringView());
- if (ms.GetUnit() == XFA_Unit::Em)
- return ms.GetValue() * GetFontSize();
- return ms.ToUnit(XFA_Unit::Pt);
-}
-
-int32_t CXFA_FontData::GetLineThrough() const {
- return m_pNode->JSObject()->GetInteger(XFA_Attribute::LineThrough);
-}
-
-int32_t CXFA_FontData::GetUnderline() const {
- return m_pNode->JSObject()->GetInteger(XFA_Attribute::Underline);
-}
-
-XFA_AttributeEnum CXFA_FontData::GetUnderlinePeriod() const {
- return m_pNode->JSObject()
- ->TryEnum(XFA_Attribute::UnderlinePeriod, true)
- .value_or(XFA_AttributeEnum::All);
-}
-
-float CXFA_FontData::GetFontSize() const {
- return m_pNode->JSObject()
- ->GetMeasure(XFA_Attribute::Size)
- .ToUnit(XFA_Unit::Pt);
-}
-
-WideString CXFA_FontData::GetTypeface() const {
- return m_pNode->JSObject()->GetCData(XFA_Attribute::Typeface);
-}
-
-bool CXFA_FontData::IsBold() const {
- return m_pNode->JSObject()->GetEnum(XFA_Attribute::Weight) ==
- XFA_AttributeEnum::Bold;
-}
-
-bool CXFA_FontData::IsItalic() const {
- return m_pNode->JSObject()->GetEnum(XFA_Attribute::Posture) ==
- XFA_AttributeEnum::Italic;
-}
-
-void CXFA_FontData::SetColor(FX_ARGB color) {
- m_pNode->JSObject()
- ->GetProperty<CXFA_Fill>(0, XFA_Element::Fill, true)
- ->SetColor(color);
-}
-
-FX_ARGB CXFA_FontData::GetColor() const {
- CXFA_Fill* fill = m_pNode->GetChild<CXFA_Fill>(0, XFA_Element::Fill, false);
- return fill ? fill->GetColor(true) : 0xFF000000;
-}
diff --git a/xfa/fxfa/parser/cxfa_fontdata.h b/xfa/fxfa/parser/cxfa_fontdata.h
deleted file mode 100644
index 45fbba6592..0000000000
--- a/xfa/fxfa/parser/cxfa_fontdata.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FXFA_PARSER_CXFA_FONTDATA_H_
-#define XFA_FXFA_PARSER_CXFA_FONTDATA_H_
-
-#include "core/fxge/fx_dib.h"
-#include "xfa/fxfa/parser/cxfa_datadata.h"
-
-class CXFA_Node;
-
-class CXFA_FontData : public CXFA_DataData {
- public:
- explicit CXFA_FontData(CXFA_Node* pNode);
-
- float GetBaselineShift() const;
- float GetHorizontalScale() const;
- float GetVerticalScale() const;
- float GetLetterSpacing() const;
- int32_t GetLineThrough() const;
- int32_t GetUnderline() const;
- XFA_AttributeEnum GetUnderlinePeriod() const;
- float GetFontSize() const;
- WideString GetTypeface() const;
-
- bool IsBold() const;
- bool IsItalic() const;
-
- FX_ARGB GetColor() const;
- void SetColor(FX_ARGB color);
-};
-
-#endif // XFA_FXFA_PARSER_CXFA_FONTDATA_H_
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp
index 9c08c1ac43..4a8817812f 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.cpp
+++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp
@@ -272,9 +272,9 @@ CXFA_Caption* CXFA_WidgetData::GetCaption() {
false);
}
-CXFA_FontData CXFA_WidgetData::GetFontData(bool bModified) {
- return CXFA_FontData(m_pNode->JSObject()->GetProperty<CXFA_Font>(
- 0, XFA_Element::Font, bModified));
+CXFA_Font* CXFA_WidgetData::GetFont(bool bModified) {
+ return m_pNode->JSObject()->GetProperty<CXFA_Font>(0, XFA_Element::Font,
+ bModified);
}
CXFA_Margin* CXFA_WidgetData::GetMargin() {
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.h b/xfa/fxfa/parser/cxfa_widgetdata.h
index c75225b5fe..30d64a09c5 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.h
+++ b/xfa/fxfa/parser/cxfa_widgetdata.h
@@ -15,7 +15,6 @@
#include "core/fxcrt/fx_system.h"
#include "fxbarcode/BC_Library.h"
#include "xfa/fxfa/parser/cxfa_datadata.h"
-#include "xfa/fxfa/parser/cxfa_fontdata.h"
enum XFA_CHECKSTATE {
XFA_CHECKSTATE_On = 0,
@@ -34,6 +33,7 @@ class CXFA_Bind;
class CXFA_Border;
class CXFA_Calculate;
class CXFA_Caption;
+class CXFA_Font;
class CXFA_Margin;
class CXFA_Node;
class CXFA_Para;
@@ -61,7 +61,7 @@ class CXFA_WidgetData : public CXFA_DataData {
CXFA_Border* GetBorder(bool bModified);
CXFA_Caption* GetCaption();
- CXFA_FontData GetFontData(bool bModified);
+ CXFA_Font* GetFont(bool bModified);
CXFA_Margin* GetMargin();
CXFA_Para* GetPara();
CXFA_Value* GetDefaultValue();