summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-10-04 21:13:59 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-10-04 21:13:59 +0000
commit7cabaf136b2aa671768c9d8ee3645c9444afc700 (patch)
tree4aec57e31e1a7207e8009e9d33c9b738a3e8288b
parentce6eb642dbaf96fc2a9d4e97a205a0a12e7154a4 (diff)
downloadpdfium-7cabaf136b2aa671768c9d8ee3645c9444afc700.tar.xz
CPDF_VariableText::m_nHorzScale is always 100
Remove the member and simplify logic in all the places this is passed. Change-Id: I39b979793fe84f0dc460261223655dd7f50555cc Reviewed-on: https://pdfium-review.googlesource.com/c/43474 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
-rw-r--r--core/fpdfapi/render/cpdf_textrenderer.cpp14
-rw-r--r--core/fpdfapi/render/cpdf_textrenderer.h2
-rw-r--r--core/fpdfdoc/cpdf_variabletext.cpp11
-rw-r--r--core/fpdfdoc/cpdf_variabletext.h3
-rw-r--r--core/fpdfdoc/ctypeset.cpp3
-rw-r--r--fpdfsdk/pwl/cpwl_appstream.cpp10
-rw-r--r--fpdfsdk/pwl/cpwl_edit_impl.cpp34
-rw-r--r--fpdfsdk/pwl/cpwl_edit_impl.h1
8 files changed, 20 insertions, 58 deletions
diff --git a/core/fpdfapi/render/cpdf_textrenderer.cpp b/core/fpdfapi/render/cpdf_textrenderer.cpp
index dd25d03f7b..05807321ae 100644
--- a/core/fpdfapi/render/cpdf_textrenderer.cpp
+++ b/core/fpdfapi/render/cpdf_textrenderer.cpp
@@ -75,7 +75,7 @@ void CPDF_TextRenderer::DrawTextString(CFX_RenderDevice* pDevice,
float origin_y,
CPDF_Font* pFont,
float font_size,
- const CFX_Matrix* pMatrix,
+ const CFX_Matrix& matrix,
const ByteString& str,
FX_ARGB fill_argb,
const CFX_GraphStateData* pGraphState,
@@ -99,14 +99,10 @@ void CPDF_TextRenderer::DrawTextString(CFX_RenderDevice* pDevice,
positions[i - 1] = cur_pos;
cur_pos += pFont->GetCharWidthF(codes[i]) * font_size / 1000;
}
- CFX_Matrix matrix;
- if (pMatrix)
- matrix = *pMatrix;
-
- matrix.e = origin_x;
- matrix.f = origin_y;
-
- DrawNormalText(pDevice, codes, positions, pFont, font_size, &matrix,
+ CFX_Matrix new_matrix = matrix;
+ new_matrix.e = origin_x;
+ new_matrix.f = origin_y;
+ DrawNormalText(pDevice, codes, positions, pFont, font_size, &new_matrix,
fill_argb, pOptions);
}
diff --git a/core/fpdfapi/render/cpdf_textrenderer.h b/core/fpdfapi/render/cpdf_textrenderer.h
index ac8c8c5568..d7a2f157e0 100644
--- a/core/fpdfapi/render/cpdf_textrenderer.h
+++ b/core/fpdfapi/render/cpdf_textrenderer.h
@@ -27,7 +27,7 @@ class CPDF_TextRenderer {
float origin_y,
CPDF_Font* pFont,
float font_size,
- const CFX_Matrix* matrix,
+ const CFX_Matrix& matrix,
const ByteString& str,
FX_ARGB fill_argb,
const CFX_GraphStateData* pGraphState,
diff --git a/core/fpdfdoc/cpdf_variabletext.cpp b/core/fpdfdoc/cpdf_variabletext.cpp
index 994a7a184f..fea74445d9 100644
--- a/core/fpdfdoc/cpdf_variabletext.cpp
+++ b/core/fpdfdoc/cpdf_variabletext.cpp
@@ -24,7 +24,6 @@ namespace {
const float kFontScale = 0.001f;
const uint8_t kReturnLength = 1;
-const float kScalePercent = 0.01f;
const uint8_t gFontSizeSteps[] = {4, 6, 8, 9, 10, 12, 14, 18, 20,
25, 30, 35, 40, 45, 50, 55, 60, 70,
@@ -600,19 +599,15 @@ float CPDF_VariableText::GetWordWidth(int32_t nFontIndex,
uint16_t Word,
uint16_t SubWord,
float fCharSpace,
- int32_t nHorzScale,
float fFontSize,
float fWordTail) {
- return (GetCharWidth(nFontIndex, Word, SubWord) * fFontSize * kFontScale +
- fCharSpace) *
- nHorzScale * kScalePercent +
- fWordTail;
+ return GetCharWidth(nFontIndex, Word, SubWord) * fFontSize * kFontScale +
+ fCharSpace + fWordTail;
}
float CPDF_VariableText::GetWordWidth(const CPVT_WordInfo& WordInfo) {
return GetWordWidth(GetWordFontIndex(WordInfo), WordInfo.Word, GetSubWord(),
- GetCharSpace(), GetHorzScale(), GetWordFontSize(),
- WordInfo.fWordTail);
+ GetCharSpace(), GetWordFontSize(), WordInfo.fWordTail);
}
float CPDF_VariableText::GetLineAscent() {
diff --git a/core/fpdfdoc/cpdf_variabletext.h b/core/fpdfdoc/cpdf_variabletext.h
index 46d92e5d23..aa4701551f 100644
--- a/core/fpdfdoc/cpdf_variabletext.h
+++ b/core/fpdfdoc/cpdf_variabletext.h
@@ -108,7 +108,6 @@ class CPDF_VariableText {
int32_t GetCharArray() const { return m_nCharArray; }
int32_t GetLimitChar() const { return m_nLimitChar; }
bool IsMultiLine() const { return m_bMultiLine; }
- int32_t GetHorzScale() const { return m_nHorzScale; }
float GetCharSpace() const { return m_fCharSpace; }
bool IsAutoReturn() const { return m_bLimitWidth; }
@@ -153,7 +152,6 @@ class CPDF_VariableText {
uint16_t Word,
uint16_t SubWord,
float fCharSpace,
- int32_t nHorzScale,
float fFontSize,
float fWordTail);
float GetWordAscent(const CPVT_WordInfo& WordInfo);
@@ -201,7 +199,6 @@ class CPDF_VariableText {
int32_t m_nLimitChar = 0;
int32_t m_nCharArray = 0;
int32_t m_nAlignment = 0;
- int32_t m_nHorzScale = 100;
float m_fLineLeading = 0.0f;
float m_fCharSpace = 0.0f;
float m_fFontSize = 0.0f;
diff --git a/core/fpdfdoc/ctypeset.cpp b/core/fpdfdoc/ctypeset.cpp
index 290b95e9b4..551173162b 100644
--- a/core/fpdfdoc/ctypeset.cpp
+++ b/core/fpdfdoc/ctypeset.cpp
@@ -315,8 +315,7 @@ void CTypeset::SplitLines(bool bTypeset, float fFontSize) {
std::min(fLineDescent, m_pVT->GetWordDescent(*pWord, fFontSize));
fWordWidth = m_pVT->GetWordWidth(
pWord->nFontIndex, pWord->Word, m_pVT->GetSubWord(),
- m_pVT->GetCharSpace(), m_pVT->GetHorzScale(), fFontSize,
- pWord->fWordTail);
+ m_pVT->GetCharSpace(), fFontSize, pWord->fWordTail);
}
if (!bOpened) {
if (IsOpenStylePunctuation(pWord->Word)) {
diff --git a/fpdfsdk/pwl/cpwl_appstream.cpp b/fpdfsdk/pwl/cpwl_appstream.cpp
index 4175b8ef2a..aa007b8d6f 100644
--- a/fpdfsdk/pwl/cpwl_appstream.cpp
+++ b/fpdfsdk/pwl/cpwl_appstream.cpp
@@ -68,7 +68,6 @@ const char kSetNonZeroWindingClipOperator[] = "W";
const char kSetRGBOperator[] = "rg";
const char kSetRGBStrokedOperator[] = "RG";
const char kSetTextFontAndSizeOperator[] = "Tf";
-const char kSetTextScaleHorizontalOperator[] = "Tz";
const char kShowTextOperator[] = "Tj";
const char kStateRestoreOperator[] = "Q";
const char kStateSaveOperator[] = "q";
@@ -667,16 +666,9 @@ ByteString GetEditAppStream(CPWL_EditImpl* pEdit,
std::ostringstream sAppStream;
if (sEditStream.tellp() > 0) {
- int32_t nHorzScale = pEdit->GetHorzScale();
- if (nHorzScale != 100) {
- sAppStream << nHorzScale << " " << kSetTextScaleHorizontalOperator
- << "\n";
- }
-
float fCharSpace = pEdit->GetCharSpace();
- if (!IsFloatZero(fCharSpace)) {
+ if (!IsFloatZero(fCharSpace))
sAppStream << fCharSpace << " " << kSetCharacterSpacingOperator << "\n";
- }
sAppStream << sEditStream.str();
}
diff --git a/fpdfsdk/pwl/cpwl_edit_impl.cpp b/fpdfsdk/pwl/cpwl_edit_impl.cpp
index fb0e8afa16..c0eccfec8e 100644
--- a/fpdfsdk/pwl/cpwl_edit_impl.cpp
+++ b/fpdfsdk/pwl/cpwl_edit_impl.cpp
@@ -43,26 +43,17 @@ void DrawTextString(CFX_RenderDevice* pDevice,
float fFontSize,
const CFX_Matrix& mtUser2Device,
const ByteString& str,
- FX_ARGB crTextFill,
- int32_t nHorzScale) {
+ FX_ARGB crTextFill) {
if (!pFont)
return;
CFX_PointF pos = mtUser2Device.Transform(pt);
- CFX_Matrix mt;
- if (nHorzScale == 100) {
- mt = mtUser2Device;
- } else {
- mt = CFX_Matrix(nHorzScale / 100.0f, 0, 0, 1, 0, 0);
- mt.Concat(mtUser2Device);
- }
-
CPDF_RenderOptions ro;
ro.SetFlags(RENDER_CLEARTYPE);
-
ro.SetColorMode(CPDF_RenderOptions::kNormal);
CPDF_TextRenderer::DrawTextString(pDevice, pos.x, pos.y, pFont, fFontSize,
- &mt, str, crTextFill, nullptr, &ro);
+ mtUser2Device, str, crTextFill, nullptr,
+ &ro);
}
} // namespace
@@ -437,11 +428,8 @@ void CPWL_EditImpl::DrawEdit(CFX_RenderDevice* pDevice,
uint16_t SubWord = pEdit->GetPasswordChar();
float fFontSize = pEdit->GetFontSize();
CPVT_WordRange wrSelect = pEdit->GetSelectWordRange();
- int32_t nHorzScale = pEdit->GetHorzScale();
-
FX_COLORREF crCurFill = crTextFill;
FX_COLORREF crOldFill = crCurFill;
-
bool bSelect = false;
const FX_COLORREF crWhite = ArgbEncode(255, 255, 255, 255);
const FX_COLORREF crSelBK = ArgbEncode(255, 0, 51, 113);
@@ -504,10 +492,10 @@ void CPWL_EditImpl::DrawEdit(CFX_RenderDevice* pDevice,
if (place.LineCmp(oldplace) != 0 || word.nFontIndex != nFontIndex ||
crOldFill != crCurFill) {
if (sTextBuf.tellp() > 0) {
- DrawTextString(
- pDevice, CFX_PointF(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
- pFontMap->GetPDFFont(nFontIndex), fFontSize, mtUser2Device,
- ByteString(sTextBuf), crOldFill, nHorzScale);
+ DrawTextString(pDevice,
+ CFX_PointF(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
+ pFontMap->GetPDFFont(nFontIndex), fFontSize,
+ mtUser2Device, ByteString(sTextBuf), crOldFill);
sTextBuf.str("");
}
@@ -524,7 +512,7 @@ void CPWL_EditImpl::DrawEdit(CFX_RenderDevice* pDevice,
CFX_PointF(word.ptWord.x + ptOffset.x, word.ptWord.y + ptOffset.y),
pFontMap->GetPDFFont(word.nFontIndex), fFontSize, mtUser2Device,
pEdit->GetPDFWordString(word.nFontIndex, word.Word, SubWord),
- crCurFill, nHorzScale);
+ crCurFill);
}
oldplace = place;
}
@@ -534,7 +522,7 @@ void CPWL_EditImpl::DrawEdit(CFX_RenderDevice* pDevice,
DrawTextString(pDevice,
CFX_PointF(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
pFontMap->GetPDFFont(nFontIndex), fFontSize, mtUser2Device,
- ByteString(sTextBuf), crOldFill, nHorzScale);
+ ByteString(sTextBuf), crOldFill);
}
}
@@ -829,10 +817,6 @@ CFX_FloatRect CPWL_EditImpl::GetContentRect() const {
return VTToEdit(m_pVT->GetContentRect());
}
-int32_t CPWL_EditImpl::GetHorzScale() const {
- return m_pVT->GetHorzScale();
-}
-
float CPWL_EditImpl::GetCharSpace() const {
return m_pVT->GetCharSpace();
}
diff --git a/fpdfsdk/pwl/cpwl_edit_impl.h b/fpdfsdk/pwl/cpwl_edit_impl.h
index 743afae6b6..7f14ade66a 100644
--- a/fpdfsdk/pwl/cpwl_edit_impl.h
+++ b/fpdfsdk/pwl/cpwl_edit_impl.h
@@ -303,7 +303,6 @@ class CPWL_EditImpl {
int32_t GetCharArray() const;
CFX_FloatRect GetContentRect() const;
WideString GetRangeText(const CPVT_WordRange& range) const;
- int32_t GetHorzScale() const;
float GetCharSpace() const;
void SetSelection(int32_t nStartChar, int32_t nEndChar);
void GetSelection(int32_t& nStartChar, int32_t& nEndChar) const;