Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
cpdf_textstate.cpp
Go to the documentation of this file.
1
// Copyright 2016 The PDFium Authors
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
"core/fpdfapi/page/cpdf_textstate.h"
8
9
#
include
<
math
.
h
>
10
11
#
include
<
utility
>
12
13
#
include
"core/fpdfapi/font/cpdf_font.h"
14
#
include
"core/fpdfapi/page/cpdf_docpagedata.h"
15
16
CPDF_TextState
::
CPDF_TextState
() =
default
;
17
18
CPDF_TextState
::
CPDF_TextState
(
const
CPDF_TextState
&) =
default
;
19
20
CPDF_TextState
&
CPDF_TextState
::
operator
=(
const
CPDF_TextState
&) =
default
;
21
22
CPDF_TextState
::~
CPDF_TextState
() =
default
;
23
24
void
CPDF_TextState
::
Emplace
() {
25
m_Ref.Emplace();
26
}
27
28
RetainPtr
<
CPDF_Font
>
CPDF_TextState
::
GetFont
()
const
{
29
return
m_Ref.GetObject()->font_;
30
}
31
32
void
CPDF_TextState
::
SetFont
(
RetainPtr
<
CPDF_Font
> pFont) {
33
m_Ref.GetPrivateCopy()->SetFont(std::move(pFont));
34
}
35
36
float
CPDF_TextState
::
GetFontSize
()
const
{
37
return
m_Ref.GetObject()->font_size_;
38
}
39
40
void
CPDF_TextState
::
SetFontSize
(
float
size) {
41
if
(!m_Ref || GetFontSize() != size) {
42
m_Ref.GetPrivateCopy()->font_size_ = size;
43
}
44
}
45
46
pdfium
::
span
<
const
float
>
CPDF_TextState
::
GetMatrix
()
const
{
47
return
m_Ref.GetObject()->matrix_;
48
}
49
50
pdfium
::
span
<
float
>
CPDF_TextState
::
GetMutableMatrix
() {
51
return
m_Ref.GetPrivateCopy()->matrix_;
52
}
53
54
float
CPDF_TextState
::
GetCharSpace
()
const
{
55
return
m_Ref.GetObject()->char_space_;
56
}
57
58
void
CPDF_TextState
::
SetCharSpace
(
float
sp) {
59
if
(!m_Ref || GetCharSpace() != sp) {
60
m_Ref.GetPrivateCopy()->char_space_ = sp;
61
}
62
}
63
64
float
CPDF_TextState
::
GetWordSpace
()
const
{
65
return
m_Ref.GetObject()->word_space_;
66
}
67
68
void
CPDF_TextState
::
SetWordSpace
(
float
sp) {
69
if
(!m_Ref || GetWordSpace() != sp) {
70
m_Ref.GetPrivateCopy()->word_space_ = sp;
71
}
72
}
73
74
float
CPDF_TextState
::
GetFontSizeH
()
const
{
75
return
m_Ref.GetObject()->GetFontSizeH();
76
}
77
78
TextRenderingMode
CPDF_TextState
::
GetTextMode
()
const
{
79
return
m_Ref.GetObject()->text_rendering_mode_;
80
}
81
82
void
CPDF_TextState
::
SetTextMode
(
TextRenderingMode
mode) {
83
if
(!m_Ref || GetTextMode() != mode) {
84
m_Ref.GetPrivateCopy()->text_rendering_mode_ = mode;
85
}
86
}
87
88
pdfium
::
span
<
const
float
>
CPDF_TextState
::
GetCTM
()
const
{
89
return
m_Ref.GetObject()->ctm_;
90
}
91
92
pdfium
::
span
<
float
>
CPDF_TextState
::
GetMutableCTM
() {
93
return
m_Ref.GetPrivateCopy()->ctm_;
94
}
95
96
CPDF_TextState
::TextData::TextData() =
default
;
97
98
CPDF_TextState
::TextData::TextData(
const
TextData& that)
99
: font_(that.font_),
100
document_(that.document_),
101
font_size_(that.font_size_),
102
char_space_(that.char_space_),
103
word_space_(that.word_space_),
104
text_rendering_mode_(that.text_rendering_mode_),
105
matrix_(that.matrix_),
106
ctm_(that.ctm_) {
107
if
(document_ && font_) {
108
auto
* page_data = CPDF_DocPageData
::
FromDocument
(document_);
109
font_ = page_data->GetFont(font_->GetMutableFontDict());
110
}
111
}
112
113
CPDF_TextState
::TextData::~TextData() =
default
;
114
115
RetainPtr
<
CPDF_TextState
::TextData>
CPDF_TextState
::TextData::Clone()
const
{
116
return
pdfium
::MakeRetain<
CPDF_TextState
::TextData>(*
this
);
117
}
118
119
void
CPDF_TextState
::TextData::SetFont(
RetainPtr
<
CPDF_Font
> pFont) {
120
document_ = pFont ? pFont->GetDocument() :
nullptr
;
121
font_ = std::move(pFont);
122
}
123
124
float
CPDF_TextState
::TextData::GetFontSizeH()
const
{
125
return
fabs(hypotf(matrix_[0], matrix_[2]) * font_size_);
126
}
127
128
bool
SetTextRenderingModeFromInt
(
int
iMode,
TextRenderingMode
* mode) {
129
if
(iMode < 0 || iMode > 7)
130
return
false
;
131
*mode =
static_cast
<
TextRenderingMode
>(iMode);
132
return
true
;
133
}
134
135
bool
TextRenderingModeIsClipMode
(
const
TextRenderingMode
& mode) {
136
switch
(mode) {
137
case
TextRenderingMode
::
MODE_FILL_CLIP
:
138
case
TextRenderingMode
::
MODE_STROKE_CLIP
:
139
case
TextRenderingMode
::
MODE_FILL_STROKE_CLIP
:
140
case
TextRenderingMode
::
MODE_CLIP
:
141
return
true
;
142
default
:
143
return
false
;
144
}
145
}
146
147
bool
TextRenderingModeIsStrokeMode
(
const
TextRenderingMode
& mode) {
148
switch
(mode) {
149
case
TextRenderingMode
::
MODE_STROKE
:
150
case
TextRenderingMode
::
MODE_FILL_STROKE
:
151
case
TextRenderingMode
::
MODE_STROKE_CLIP
:
152
case
TextRenderingMode
::
MODE_FILL_STROKE_CLIP
:
153
return
true
;
154
default
:
155
return
false
;
156
}
157
}
CPDF_DocPageData::FromDocument
static CPDF_DocPageData * FromDocument(const CPDF_Document *pDoc)
Definition
cpdf_docpagedata.cpp:166
CPDF_Font
Definition
cpdf_font.h:37
CPDF_TextState
Definition
cpdf_textstate.h:34
CPDF_TextState::GetMutableMatrix
pdfium::span< float > GetMutableMatrix()
Definition
cpdf_textstate.cpp:50
CPDF_TextState::Emplace
void Emplace()
Definition
cpdf_textstate.cpp:24
CPDF_TextState::GetTextMode
TextRenderingMode GetTextMode() const
Definition
cpdf_textstate.cpp:78
CPDF_TextState::CPDF_TextState
CPDF_TextState(const CPDF_TextState &that)
CPDF_TextState::GetFont
RetainPtr< CPDF_Font > GetFont() const
Definition
cpdf_textstate.cpp:28
CPDF_TextState::GetWordSpace
float GetWordSpace() const
Definition
cpdf_textstate.cpp:64
CPDF_TextState::~CPDF_TextState
~CPDF_TextState()
CPDF_TextState::GetFontSize
float GetFontSize() const
Definition
cpdf_textstate.cpp:36
CPDF_TextState::GetCharSpace
float GetCharSpace() const
Definition
cpdf_textstate.cpp:54
CPDF_TextState::SetTextMode
void SetTextMode(TextRenderingMode mode)
Definition
cpdf_textstate.cpp:82
CPDF_TextState::SetWordSpace
void SetWordSpace(float sp)
Definition
cpdf_textstate.cpp:68
CPDF_TextState::SetFont
void SetFont(RetainPtr< CPDF_Font > pFont)
Definition
cpdf_textstate.cpp:32
CPDF_TextState::GetFontSizeH
float GetFontSizeH() const
Definition
cpdf_textstate.cpp:74
CPDF_TextState::SetFontSize
void SetFontSize(float size)
Definition
cpdf_textstate.cpp:40
CPDF_TextState::SetCharSpace
void SetCharSpace(float sp)
Definition
cpdf_textstate.cpp:58
CPDF_TextState::GetMutableCTM
pdfium::span< float > GetMutableCTM()
Definition
cpdf_textstate.cpp:92
CPDF_TextState::CPDF_TextState
CPDF_TextState()
CPDF_TextState::operator=
CPDF_TextState & operator=(const CPDF_TextState &that)
CPDF_TextState::GetMatrix
pdfium::span< const float > GetMatrix() const
Definition
cpdf_textstate.cpp:46
CPDF_TextState::GetCTM
pdfium::span< const float > GetCTM() const
Definition
cpdf_textstate.cpp:88
fxcrt::RetainPtr
Definition
retain_ptr.h:28
pdfium::CFDETextOutLargeBitmapTest
Definition
cfde_textout_unittest.cpp:117
TextRenderingModeIsStrokeMode
bool TextRenderingModeIsStrokeMode(const TextRenderingMode &mode)
Definition
cpdf_textstate.cpp:147
SetTextRenderingModeFromInt
bool SetTextRenderingModeFromInt(int iMode, TextRenderingMode *mode)
Definition
cpdf_textstate.cpp:128
TextRenderingModeIsClipMode
bool TextRenderingModeIsClipMode(const TextRenderingMode &mode)
Definition
cpdf_textstate.cpp:135
TextRenderingMode
TextRenderingMode
Definition
cpdf_textstate.h:21
TextRenderingMode::MODE_FILL_STROKE
@ MODE_FILL_STROKE
Definition
cpdf_textstate.h:25
TextRenderingMode::MODE_FILL_STROKE_CLIP
@ MODE_FILL_STROKE_CLIP
Definition
cpdf_textstate.h:29
TextRenderingMode::MODE_FILL_CLIP
@ MODE_FILL_CLIP
Definition
cpdf_textstate.h:27
TextRenderingMode::MODE_CLIP
@ MODE_CLIP
Definition
cpdf_textstate.h:30
TextRenderingMode::MODE_STROKE
@ MODE_STROKE
Definition
cpdf_textstate.h:24
TextRenderingMode::MODE_STROKE_CLIP
@ MODE_STROKE_CLIP
Definition
cpdf_textstate.h:28
qtwebengine
src
3rdparty
chromium
third_party
pdfium
core
fpdfapi
page
cpdf_textstate.cpp
Generated on
for Qt by
1.18.0