summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/font/cpdf_cidfont.cpp4
-rw-r--r--core/fpdfapi/font/cpdf_cidfont.h2
-rw-r--r--core/fpdfapi/font/cpdf_font.cpp4
-rw-r--r--core/fpdfapi/font/cpdf_font.h4
-rw-r--r--core/fpdfapi/font/cpdf_simplefont.cpp2
-rw-r--r--core/fpdfapi/font/cpdf_simplefont.h2
-rw-r--r--core/fpdfapi/font/cpdf_type3char.h4
-rw-r--r--core/fpdfapi/font/cpdf_type3font.cpp2
-rw-r--r--core/fpdfapi/font/cpdf_type3font.h4
-rw-r--r--core/fpdfapi/render/cpdf_charposlist.cpp5
10 files changed, 16 insertions, 17 deletions
diff --git a/core/fpdfapi/font/cpdf_cidfont.cpp b/core/fpdfapi/font/cpdf_cidfont.cpp
index 21f8addf8f..f17af41eda 100644
--- a/core/fpdfapi/font/cpdf_cidfont.cpp
+++ b/core/fpdfapi/font/cpdf_cidfont.cpp
@@ -514,7 +514,7 @@ FX_RECT CPDF_CIDFont::GetCharBBox(uint32_t charcode) {
return rect;
}
-int CPDF_CIDFont::GetCharWidthF(uint32_t charcode) {
+uint32_t CPDF_CIDFont::GetCharWidthF(uint32_t charcode) {
if (charcode < 0x80 && m_bAnsiWidthsFixed)
return (charcode >= 32 && charcode < 127) ? 500 : 0;
@@ -524,7 +524,7 @@ int CPDF_CIDFont::GetCharWidthF(uint32_t charcode) {
for (size_t i = 0; i < size; i += 3) {
const uint32_t* pEntry = pList + i;
if (IsMetricForCID(pEntry, cid))
- return static_cast<int>(pEntry[2]);
+ return pEntry[2];
}
return m_DefaultWidth;
}
diff --git a/core/fpdfapi/font/cpdf_cidfont.h b/core/fpdfapi/font/cpdf_cidfont.h
index f6ff83d8fa..68fce2ccb6 100644
--- a/core/fpdfapi/font/cpdf_cidfont.h
+++ b/core/fpdfapi/font/cpdf_cidfont.h
@@ -44,7 +44,7 @@ class CPDF_CIDFont : public CPDF_Font {
const CPDF_CIDFont* AsCIDFont() const override;
CPDF_CIDFont* AsCIDFont() override;
int GlyphFromCharCode(uint32_t charcode, bool* pVertGlyph) override;
- int GetCharWidthF(uint32_t charcode) override;
+ uint32_t GetCharWidthF(uint32_t charcode) override;
FX_RECT GetCharBBox(uint32_t charcode) override;
uint32_t GetNextChar(const char* pString,
int nStrLen,
diff --git a/core/fpdfapi/font/cpdf_font.cpp b/core/fpdfapi/font/cpdf_font.cpp
index 8d35739d78..013cdded20 100644
--- a/core/fpdfapi/font/cpdf_font.cpp
+++ b/core/fpdfapi/font/cpdf_font.cpp
@@ -285,9 +285,9 @@ void CPDF_Font::LoadUnicodeMap() const {
m_pToUnicodeMap->Load(pStream);
}
-int CPDF_Font::GetStringWidth(const char* pString, int size) {
+uint32_t CPDF_Font::GetStringWidth(const char* pString, int size) {
int offset = 0;
- int width = 0;
+ uint32_t width = 0;
while (offset < size) {
uint32_t charcode = GetNextChar(pString, size, offset);
width += GetCharWidthF(charcode);
diff --git a/core/fpdfapi/font/cpdf_font.h b/core/fpdfapi/font/cpdf_font.h
index 0468bcb32a..db99efdd1b 100644
--- a/core/fpdfapi/font/cpdf_font.h
+++ b/core/fpdfapi/font/cpdf_font.h
@@ -75,11 +75,11 @@ class CPDF_Font {
void GetFontBBox(FX_RECT& rect) const { rect = m_FontBBox; }
int GetTypeAscent() const { return m_Ascent; }
int GetTypeDescent() const { return m_Descent; }
- int GetStringWidth(const char* pString, int size);
+ uint32_t GetStringWidth(const char* pString, int size);
uint32_t FallbackFontFromCharcode(uint32_t charcode);
int FallbackGlyphFromCharcode(int fallbackFont, uint32_t charcode);
- virtual int GetCharWidthF(uint32_t charcode) = 0;
+ virtual uint32_t GetCharWidthF(uint32_t charcode) = 0;
virtual FX_RECT GetCharBBox(uint32_t charcode) = 0;
CPDF_Document* GetDocument() const { return m_pDocument.Get(); }
diff --git a/core/fpdfapi/font/cpdf_simplefont.cpp b/core/fpdfapi/font/cpdf_simplefont.cpp
index 92965b0948..89f6fe1205 100644
--- a/core/fpdfapi/font/cpdf_simplefont.cpp
+++ b/core/fpdfapi/font/cpdf_simplefont.cpp
@@ -80,7 +80,7 @@ void CPDF_SimpleFont::LoadCharMetrics(int charcode) {
}
}
-int CPDF_SimpleFont::GetCharWidthF(uint32_t charcode) {
+uint32_t CPDF_SimpleFont::GetCharWidthF(uint32_t charcode) {
if (charcode > 0xff)
charcode = 0;
diff --git a/core/fpdfapi/font/cpdf_simplefont.h b/core/fpdfapi/font/cpdf_simplefont.h
index 5291211b24..9cb730d1a1 100644
--- a/core/fpdfapi/font/cpdf_simplefont.h
+++ b/core/fpdfapi/font/cpdf_simplefont.h
@@ -20,7 +20,7 @@ class CPDF_SimpleFont : public CPDF_Font {
~CPDF_SimpleFont() override;
// CPDF_Font
- int GetCharWidthF(uint32_t charcode) override;
+ uint32_t GetCharWidthF(uint32_t charcode) override;
FX_RECT GetCharBBox(uint32_t charcode) override;
int GlyphFromCharCode(uint32_t charcode, bool* pVertGlyph) override;
bool IsUnicodeCompatible() const override;
diff --git a/core/fpdfapi/font/cpdf_type3char.h b/core/fpdfapi/font/cpdf_type3char.h
index c9c5555cf4..28baffed3a 100644
--- a/core/fpdfapi/font/cpdf_type3char.h
+++ b/core/fpdfapi/font/cpdf_type3char.h
@@ -38,7 +38,7 @@ class CPDF_Type3Char {
CPDF_Form* form() { return m_pForm.get(); }
bool colored() const { return m_bColored; }
- int width() const { return m_Width; }
+ uint32_t width() const { return m_Width; }
const CFX_Matrix& matrix() const { return m_ImageMatrix; }
const FX_RECT& bbox() const { return m_BBox; }
@@ -46,7 +46,7 @@ class CPDF_Type3Char {
std::unique_ptr<CPDF_Form> m_pForm;
RetainPtr<CFX_DIBitmap> m_pBitmap;
bool m_bColored = false;
- int m_Width = 0;
+ uint32_t m_Width = 0;
CFX_Matrix m_ImageMatrix;
FX_RECT m_BBox;
};
diff --git a/core/fpdfapi/font/cpdf_type3font.cpp b/core/fpdfapi/font/cpdf_type3font.cpp
index b3eaef0e06..824d6f45d0 100644
--- a/core/fpdfapi/font/cpdf_type3font.cpp
+++ b/core/fpdfapi/font/cpdf_type3font.cpp
@@ -130,7 +130,7 @@ CPDF_Type3Char* CPDF_Type3Font::LoadChar(uint32_t charcode) {
return pCachedChar;
}
-int CPDF_Type3Font::GetCharWidthF(uint32_t charcode) {
+uint32_t CPDF_Type3Font::GetCharWidthF(uint32_t charcode) {
if (charcode >= FX_ArraySize(m_CharWidthL))
charcode = 0;
diff --git a/core/fpdfapi/font/cpdf_type3font.h b/core/fpdfapi/font/cpdf_type3font.h
index 3f2e018c88..67400d5710 100644
--- a/core/fpdfapi/font/cpdf_type3font.h
+++ b/core/fpdfapi/font/cpdf_type3font.h
@@ -26,7 +26,7 @@ class CPDF_Type3Font : public CPDF_SimpleFont {
bool IsType3Font() const override;
const CPDF_Type3Font* AsType3Font() const override;
CPDF_Type3Font* AsType3Font() override;
- int GetCharWidthF(uint32_t charcode) override;
+ uint32_t GetCharWidthF(uint32_t charcode) override;
FX_RECT GetCharBBox(uint32_t charcode) override;
void SetPageResources(CPDF_Dictionary* pResources) {
@@ -47,7 +47,7 @@ class CPDF_Type3Font : public CPDF_SimpleFont {
// CPDF_SimpleFont:
void LoadGlyphMap() override;
- int m_CharWidthL[256];
+ uint32_t m_CharWidthL[256];
UnownedPtr<CPDF_Dictionary> m_pCharProcs;
UnownedPtr<CPDF_Dictionary> m_pPageResources;
UnownedPtr<CPDF_Dictionary> m_pFontResources;
diff --git a/core/fpdfapi/render/cpdf_charposlist.cpp b/core/fpdfapi/render/cpdf_charposlist.cpp
index c0c700c0ca..ddb215c48b 100644
--- a/core/fpdfapi/render/cpdf_charposlist.cpp
+++ b/core/fpdfapi/render/cpdf_charposlist.cpp
@@ -69,8 +69,8 @@ void CPDF_CharPosList::Load(const std::vector<uint32_t>& charCodes,
float scalingFactor = 1.0f;
if (!pFont->IsEmbedded() && pFont->HasFontWidths() && !bVertWriting &&
!pCurrentFont->GetSubstFont()->m_bFlagMM) {
- int pdfGlyphWidth = pFont->GetCharWidthF(CharCode);
- int ftGlyphWidth =
+ uint32_t pdfGlyphWidth = pFont->GetCharWidthF(CharCode);
+ uint32_t ftGlyphWidth =
pCurrentFont ? pCurrentFont->GetGlyphWidth(charpos.m_GlyphIndex) : 0;
if (ftGlyphWidth && pdfGlyphWidth > ftGlyphWidth + 1) {
// Move the initial x position by half of the excess (transformed to
@@ -80,7 +80,6 @@ void CPDF_CharPosList::Load(const std::vector<uint32_t>& charCodes,
} else if (pdfGlyphWidth && ftGlyphWidth &&
pdfGlyphWidth < ftGlyphWidth) {
scalingFactor = static_cast<float>(pdfGlyphWidth) / ftGlyphWidth;
- ASSERT(scalingFactor >= 0.0f);
charpos.m_AdjustMatrix[0] = scalingFactor;
charpos.m_AdjustMatrix[1] = 0.0f;
charpos.m_AdjustMatrix[2] = 0.0f;