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

Side by Side Diff: core/fpdfdoc/cpdf_variabletext.cpp

Issue 2337973004: Wordstyle not being used to calculate word width (Closed)
Patch Set: Created 4 years, 3 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 | « no previous file | core/fpdfdoc/ctypeset.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "core/fpdfdoc/include/cpdf_variabletext.h" 7 #include "core/fpdfdoc/include/cpdf_variabletext.h"
8 8
9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" 9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h"
10 #include "core/fpdfdoc/cpvt_wordinfo.h" 10 #include "core/fpdfdoc/cpvt_wordinfo.h"
(...skipping 16 matching lines...) Expand all
27 } // namespace 27 } // namespace
28 28
29 CPDF_VariableText::Provider::Provider(IPVT_FontMap* pFontMap) 29 CPDF_VariableText::Provider::Provider(IPVT_FontMap* pFontMap)
30 : m_pFontMap(pFontMap) { 30 : m_pFontMap(pFontMap) {
31 ASSERT(m_pFontMap); 31 ASSERT(m_pFontMap);
32 } 32 }
33 33
34 CPDF_VariableText::Provider::~Provider() {} 34 CPDF_VariableText::Provider::~Provider() {}
35 35
36 int32_t CPDF_VariableText::Provider::GetCharWidth(int32_t nFontIndex, 36 int32_t CPDF_VariableText::Provider::GetCharWidth(int32_t nFontIndex,
37 uint16_t word, 37 uint16_t word) {
38 int32_t nWordStyle) {
39 if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex)) { 38 if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex)) {
40 uint32_t charcode = pPDFFont->CharCodeFromUnicode(word); 39 uint32_t charcode = pPDFFont->CharCodeFromUnicode(word);
41 if (charcode != CPDF_Font::kInvalidCharCode) 40 if (charcode != CPDF_Font::kInvalidCharCode)
42 return pPDFFont->GetCharWidthF(charcode); 41 return pPDFFont->GetCharWidthF(charcode);
43 } 42 }
44 return 0; 43 return 0;
45 } 44 }
46 45
47 int32_t CPDF_VariableText::Provider::GetTypeAscent(int32_t nFontIndex) { 46 int32_t CPDF_VariableText::Provider::GetTypeAscent(int32_t nFontIndex) {
48 if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex)) 47 if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex))
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 int32_t CPDF_VariableText::GetWordFontIndex(const CPVT_WordInfo& WordInfo) { 777 int32_t CPDF_VariableText::GetWordFontIndex(const CPVT_WordInfo& WordInfo) {
779 return WordInfo.nFontIndex; 778 return WordInfo.nFontIndex;
780 } 779 }
781 780
782 FX_FLOAT CPDF_VariableText::GetWordWidth(int32_t nFontIndex, 781 FX_FLOAT CPDF_VariableText::GetWordWidth(int32_t nFontIndex,
783 uint16_t Word, 782 uint16_t Word,
784 uint16_t SubWord, 783 uint16_t SubWord,
785 FX_FLOAT fCharSpace, 784 FX_FLOAT fCharSpace,
786 int32_t nHorzScale, 785 int32_t nHorzScale,
787 FX_FLOAT fFontSize, 786 FX_FLOAT fFontSize,
788 FX_FLOAT fWordTail, 787 FX_FLOAT fWordTail) {
789 int32_t nWordStyle) { 788 return (GetCharWidth(nFontIndex, Word, SubWord) * fFontSize * kFontScale +
790 return (GetCharWidth(nFontIndex, Word, SubWord, nWordStyle) * fFontSize *
791 kFontScale +
792 fCharSpace) * 789 fCharSpace) *
793 nHorzScale * kScalePercent + 790 nHorzScale * kScalePercent +
794 fWordTail; 791 fWordTail;
795 } 792 }
796 793
797 FX_FLOAT CPDF_VariableText::GetWordWidth(const CPVT_WordInfo& WordInfo) { 794 FX_FLOAT CPDF_VariableText::GetWordWidth(const CPVT_WordInfo& WordInfo) {
798 return GetWordWidth( 795 return GetWordWidth(GetWordFontIndex(WordInfo), WordInfo.Word, GetSubWord(),
799 GetWordFontIndex(WordInfo), WordInfo.Word, GetSubWord(), 796 GetCharSpace(WordInfo), GetHorzScale(WordInfo),
800 GetCharSpace(WordInfo), GetHorzScale(WordInfo), GetWordFontSize(WordInfo), 797 GetWordFontSize(WordInfo), WordInfo.fWordTail);
801 WordInfo.fWordTail,
802 WordInfo.pWordProps ? WordInfo.pWordProps->nWordStyle : 0);
803 } 798 }
804 799
805 FX_FLOAT CPDF_VariableText::GetLineAscent(const CPVT_SectionInfo& SecInfo) { 800 FX_FLOAT CPDF_VariableText::GetLineAscent(const CPVT_SectionInfo& SecInfo) {
806 return GetFontAscent(GetDefaultFontIndex(), GetFontSize()); 801 return GetFontAscent(GetDefaultFontIndex(), GetFontSize());
807 } 802 }
808 803
809 FX_FLOAT CPDF_VariableText::GetLineDescent(const CPVT_SectionInfo& SecInfo) { 804 FX_FLOAT CPDF_VariableText::GetLineDescent(const CPVT_SectionInfo& SecInfo) {
810 return GetFontDescent(GetDefaultFontIndex(), GetFontSize()); 805 return GetFontDescent(GetDefaultFontIndex(), GetFontSize());
811 } 806 }
812 807
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 rcRet.bottom = std::max(rcSec.bottom, rcRet.bottom); 1054 rcRet.bottom = std::max(rcSec.bottom, rcRet.bottom);
1060 } 1055 }
1061 fPosY += rcSec.Height(); 1056 fPosY += rcSec.Height();
1062 } 1057 }
1063 } 1058 }
1064 return rcRet; 1059 return rcRet;
1065 } 1060 }
1066 1061
1067 int32_t CPDF_VariableText::GetCharWidth(int32_t nFontIndex, 1062 int32_t CPDF_VariableText::GetCharWidth(int32_t nFontIndex,
1068 uint16_t Word, 1063 uint16_t Word,
1069 uint16_t SubWord, 1064 uint16_t SubWord) {
1070 int32_t nWordStyle) {
1071 if (!m_pVTProvider) 1065 if (!m_pVTProvider)
1072 return 0; 1066 return 0;
1073 uint16_t word = SubWord ? SubWord : Word; 1067 uint16_t word = SubWord ? SubWord : Word;
1074 return m_pVTProvider->GetCharWidth(nFontIndex, word, nWordStyle); 1068 return m_pVTProvider->GetCharWidth(nFontIndex, word);
1075 } 1069 }
1076 1070
1077 int32_t CPDF_VariableText::GetTypeAscent(int32_t nFontIndex) { 1071 int32_t CPDF_VariableText::GetTypeAscent(int32_t nFontIndex) {
1078 return m_pVTProvider ? m_pVTProvider->GetTypeAscent(nFontIndex) : 0; 1072 return m_pVTProvider ? m_pVTProvider->GetTypeAscent(nFontIndex) : 0;
1079 } 1073 }
1080 1074
1081 int32_t CPDF_VariableText::GetTypeDescent(int32_t nFontIndex) { 1075 int32_t CPDF_VariableText::GetTypeDescent(int32_t nFontIndex) {
1082 return m_pVTProvider ? m_pVTProvider->GetTypeDescent(nFontIndex) : 0; 1076 return m_pVTProvider ? m_pVTProvider->GetTypeDescent(nFontIndex) : 0;
1083 } 1077 }
1084 1078
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1136 ptLeftTop.y); 1130 ptLeftTop.y);
1137 } 1131 }
1138 1132
1139 CPVT_FloatRect CPDF_VariableText::OutToIn(const CFX_FloatRect& rect) const { 1133 CPVT_FloatRect CPDF_VariableText::OutToIn(const CFX_FloatRect& rect) const {
1140 CFX_FloatPoint ptLeftTop = OutToIn(CFX_FloatPoint(rect.left, rect.top)); 1134 CFX_FloatPoint ptLeftTop = OutToIn(CFX_FloatPoint(rect.left, rect.top));
1141 CFX_FloatPoint ptRightBottom = 1135 CFX_FloatPoint ptRightBottom =
1142 OutToIn(CFX_FloatPoint(rect.right, rect.bottom)); 1136 OutToIn(CFX_FloatPoint(rect.right, rect.bottom));
1143 return CPVT_FloatRect(ptLeftTop.x, ptLeftTop.y, ptRightBottom.x, 1137 return CPVT_FloatRect(ptLeftTop.x, ptLeftTop.y, ptRightBottom.x,
1144 ptRightBottom.y); 1138 ptRightBottom.y);
1145 } 1139 }
OLDNEW
« no previous file with comments | « no previous file | core/fpdfdoc/ctypeset.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698