Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(368)

Side by Side Diff: xfa/fxfa/parser/cxfa_font.cpp

Issue 1861353002: Split fxfa_objectacc.h into pieces. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxfa/parser/cxfa_font.h ('k') | xfa/fxfa/parser/cxfa_image.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #include "xfa/fxfa/parser/cxfa_font.h"
8
9 #include "core/fxge/include/fx_dib.h"
10 #include "xfa/fxfa/parser/cxfa_fill.h"
11 #include "xfa/fxfa/parser/xfa_object.h"
12
13 CXFA_Font::CXFA_Font(CXFA_Node* pNode) : CXFA_Data(pNode) {}
14
15 FX_FLOAT CXFA_Font::GetBaselineShift() {
16 return m_pNode->GetMeasure(XFA_ATTRIBUTE_BaselineShift).ToUnit(XFA_UNIT_Pt);
17 }
18
19 FX_FLOAT CXFA_Font::GetHorizontalScale() {
20 CFX_WideString wsValue;
21 m_pNode->TryCData(XFA_ATTRIBUTE_FontHorizontalScale, wsValue);
22 int32_t iScale = FXSYS_wtoi((const FX_WCHAR*)wsValue);
23 return iScale > 0 ? (FX_FLOAT)iScale : 100.0f;
24 }
25
26 FX_FLOAT CXFA_Font::GetVerticalScale() {
27 CFX_WideString wsValue;
28 m_pNode->TryCData(XFA_ATTRIBUTE_FontVerticalScale, wsValue);
29 int32_t iScale = FXSYS_wtoi((const FX_WCHAR*)wsValue);
30 return iScale > 0 ? (FX_FLOAT)iScale : 100.0f;
31 }
32
33 FX_FLOAT CXFA_Font::GetLetterSpacing() {
34 CFX_WideStringC wsValue;
35 if (!m_pNode->TryCData(XFA_ATTRIBUTE_LetterSpacing, wsValue))
36 return 0;
37
38 CXFA_Measurement ms(wsValue);
39 if (ms.GetUnit() == XFA_UNIT_Em)
40 return ms.GetValue() * GetFontSize();
41 return ms.ToUnit(XFA_UNIT_Pt);
42 }
43
44 int32_t CXFA_Font::GetLineThrough() {
45 int32_t iValue = 0;
46 m_pNode->TryInteger(XFA_ATTRIBUTE_LineThrough, iValue);
47 return iValue;
48 }
49
50 int32_t CXFA_Font::GetUnderline() {
51 int32_t iValue = 0;
52 m_pNode->TryInteger(XFA_ATTRIBUTE_Underline, iValue);
53 return iValue;
54 }
55
56 int32_t CXFA_Font::GetUnderlinePeriod() {
57 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_All;
58 m_pNode->TryEnum(XFA_ATTRIBUTE_UnderlinePeriod, eAttr);
59 return eAttr;
60 }
61
62 FX_FLOAT CXFA_Font::GetFontSize() {
63 CXFA_Measurement ms;
64 m_pNode->TryMeasure(XFA_ATTRIBUTE_Size, ms);
65 return ms.ToUnit(XFA_UNIT_Pt);
66 }
67
68 void CXFA_Font::GetTypeface(CFX_WideStringC& wsTypeFace) {
69 m_pNode->TryCData(XFA_ATTRIBUTE_Typeface, wsTypeFace);
70 }
71
72 FX_BOOL CXFA_Font::IsBold() {
73 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Normal;
74 m_pNode->TryEnum(XFA_ATTRIBUTE_Weight, eAttr);
75 return eAttr == XFA_ATTRIBUTEENUM_Bold;
76 }
77
78 FX_BOOL CXFA_Font::IsItalic() {
79 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_Normal;
80 m_pNode->TryEnum(XFA_ATTRIBUTE_Posture, eAttr);
81 return eAttr == XFA_ATTRIBUTEENUM_Italic;
82 }
83
84 void CXFA_Font::SetColor(FX_ARGB color) {
85 CXFA_Fill fill(m_pNode->GetProperty(0, XFA_ELEMENT_Fill));
86 fill.SetColor(color);
87 }
88
89 FX_ARGB CXFA_Font::GetColor() {
90 CXFA_Fill fill(m_pNode->GetChild(0, XFA_ELEMENT_Fill));
91 return fill ? fill.GetColor(TRUE) : 0xFF000000;
92 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/cxfa_font.h ('k') | xfa/fxfa/parser/cxfa_image.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698