From c5fa7f2a36ebd4c92c935e1332a2f7db4f3594d9 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 21 Jul 2015 16:41:48 -0700 Subject: Move extern fpdf_font_charset.cpp function prototypes to header. Make others static while we're at it. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1241173004 . --- core/include/fpdfapi/fpdf_resource.h | 16 +++++++-- core/src/fpdfapi/fpdf_font/fpdf_font.cpp | 10 +++--- core/src/fpdfapi/fpdf_font/fpdf_font_charset.cpp | 41 ++++++++++++------------ core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp | 11 ++++--- core/src/fpdftext/fpdf_text.cpp | 2 +- 5 files changed, 45 insertions(+), 35 deletions(-) diff --git a/core/include/fpdfapi/fpdf_resource.h b/core/include/fpdfapi/fpdf_resource.h index a73b2cd1a2..5c8cc85217 100644 --- a/core/include/fpdfapi/fpdf_resource.h +++ b/core/include/fpdfapi/fpdf_resource.h @@ -38,6 +38,19 @@ class CPDF_Type1Font; class CPDF_Type3Font; typedef struct FT_FaceRec_* FXFT_Face; +FX_WCHAR PDF_UnicodeFromAdobeName(const FX_CHAR* name); +CFX_ByteString PDF_AdobeNameFromUnicode(FX_WCHAR unicode); +const FX_CHAR* FCS_GetAltStr(FX_WCHAR unicode); +const FX_CHAR* PDF_CharNameFromPredefinedCharSet(int encoding, + uint8_t charcode); + +FX_WCHAR FT_UnicodeFromCharCode(int encoding, FX_DWORD charcode); +FX_DWORD FT_CharCodeFromUnicode(int encoding, FX_WCHAR unicode); +const FX_WORD* PDF_UnicodesForPredefinedCharSet(int encoding); +const FX_CHAR* GetAdobeCharName(int iBaseEncoding, + const CFX_ByteString* pCharNames, + int charcode); + template class CPDF_CountedObject { public: @@ -61,7 +74,6 @@ protected: }; using CPDF_CountedColorSpace = CPDF_CountedObject; using CPDF_CountedPattern = CPDF_CountedObject; - #define PDFFONT_TYPE1 1 #define PDFFONT_TRUETYPE 2 #define PDFFONT_TYPE3 3 @@ -76,8 +88,6 @@ using CPDF_CountedPattern = CPDF_CountedObject; #define PDFFONT_SMALLCAP 0x20000 #define PDFFONT_FORCEBOLD 0x40000 #define PDFFONT_USEEXTERNATTR 0x80000 -FX_WCHAR PDF_UnicodeFromAdobeName(const FX_CHAR* name); -CFX_ByteString PDF_AdobeNameFromUnicode(FX_WCHAR unicode); class CPDF_Font { public: diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp index e7072e8d55..9ed5d8ff1c 100644 --- a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp +++ b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp @@ -4,12 +4,13 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "../../../include/fpdfapi/fpdf_page.h" #include "../../../include/fpdfapi/fpdf_module.h" +#include "../../../include/fpdfapi/fpdf_page.h" #include "../../../include/fpdfapi/fpdf_pageobj.h" -#include "font_int.h" -#include "../fpdf_page/pageint.h" +#include "../../../include/fpdfapi/fpdf_resource.h" #include "../../../include/fxge/fx_freetype.h" +#include "../fpdf_page/pageint.h" +#include "font_int.h" FX_BOOL FT_UseTTCharmap(FXFT_Face face, int platform_id, int encoding_id) { @@ -22,7 +23,6 @@ FX_BOOL FT_UseTTCharmap(FXFT_Face face, int platform_id, int encoding_id) } return FALSE; } -extern const FX_WORD* PDF_UnicodesForPredefinedCharSet(int); CPDF_FontGlobals::CPDF_FontGlobals() : m_pContrastRamps(NULL) { @@ -816,7 +816,6 @@ FX_BOOL CPDF_Font::IsStandardFont() const } return TRUE; } -extern const FX_CHAR* PDF_CharNameFromPredefinedCharSet(int encoding, uint8_t charcode); CPDF_SimpleFont::CPDF_SimpleFont(int fonttype) : CPDF_Font(fonttype) { FXSYS_memset(m_CharBBox, 0xff, sizeof m_CharBBox); @@ -1419,7 +1418,6 @@ FX_BOOL CPDF_TrueTypeFont::_Load() { return LoadCommon(); } -extern FX_DWORD FT_CharCodeFromUnicode(int encoding, FX_WCHAR unicode); void CPDF_TrueTypeFont::LoadGlyphMap() { if (m_Font.m_Face == NULL) { diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font_charset.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font_charset.cpp index 3e1b46ac34..bf5b757a75 100644 --- a/core/src/fpdfapi/fpdf_font/fpdf_font_charset.cpp +++ b/core/src/fpdfapi/fpdf_font/fpdf_font_charset.cpp @@ -5,13 +5,16 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "../../../include/fpdfapi/fpdf_page.h" +#include "../../../include/fpdfapi/fpdf_resource.h" #include "../../../include/fxge/fx_freetype.h" -extern FX_WCHAR PDF_UnicodeFromAdobeName(const FX_CHAR*); -const struct _UnicodeAlt { + +// TODO(tsepez): These belong in headers, too. +extern const FX_WORD PDFDocEncoding[256]; + +static const struct _UnicodeAlt { FX_WORD m_Unicode; const FX_CHAR* m_Alter; -} -UnicodeAlts[] = { +} UnicodeAlts[] = { {0x00a0, " "}, {0x00a1, "!"}, {0x00a2, "c"}, {0x00a3, "P"}, {0x00a4, "o"}, {0x00a5, "Y"}, {0x00a6, "|"}, {0x00a7, "S"}, {0x00a9, "(C)"}, {0x00aa, "a"}, {0x00ab, "<<"}, {0x00ac, "-|"}, {0x00ae, "(R)"}, {0x00af, "-"}, @@ -57,7 +60,6 @@ UnicodeAlts[] = { {0x266f, "#"}, {0XF6D9, "(C)"}, {0XF6DA, "(C)"}, {0XF6DB, "(TM)"}, {0XF8E8, "(C)"}, {0xf8e9, "(C)"}, {0XF8EA, "(TM)"}, - {0xfb01, "fi"}, {0xfb02, "fl"} }; const FX_CHAR* FCS_GetAltStr(FX_WCHAR unicode) @@ -77,7 +79,7 @@ const FX_CHAR* FCS_GetAltStr(FX_WCHAR unicode) } return NULL; } -const FX_WORD StandardEncoding[256] = { +static const FX_WORD StandardEncoding[256] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, @@ -105,7 +107,7 @@ const FX_WORD StandardEncoding[256] = { 0x0000, 0x00e6, 0x0000, 0x0000, 0x0000, 0x0131, 0x0000, 0x0000, 0x0142, 0x00f8, 0x0153, 0x00df, 0x0000, 0x0000, 0x0000, 0x0000 }; -const FX_WORD MacRomanEncoding[256] = { +static const FX_WORD MacRomanEncoding[256] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, @@ -133,7 +135,7 @@ const FX_WORD MacRomanEncoding[256] = { 0x0000, 0x00d2, 0x00da, 0x00db, 0x00d9, 0x0131, 0x02c6, 0x02dc, 0x00af, 0x02d8, 0x02d9, 0x02da, 0x00b8, 0x02dd, 0x02db, 0x02c7 }; -const FX_WORD AdobeWinAnsiEncoding[256] = { +static const FX_WORD AdobeWinAnsiEncoding[256] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, @@ -167,8 +169,7 @@ const FX_WORD AdobeWinAnsiEncoding[256] = { 0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7, 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff }; -extern const FX_WORD PDFDocEncoding[256]; -const FX_WORD MacExpertEncoding[256] = { +static const FX_WORD MacExpertEncoding[256] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, @@ -196,7 +197,7 @@ const FX_WORD MacExpertEncoding[256] = { 0x0000, 0xf6ee, 0xf6fb, 0xf6f4, 0xf7af, 0xf6ea, 0x207f, 0xf6ef, 0xf6e2, 0xf6e8, 0xf6f7, 0xf6fc, 0x0000, 0x0000, 0x0000, 0x0000 }; -const FX_WORD AdobeSymbolEncoding[256] = { +static const FX_WORD AdobeSymbolEncoding[256] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, @@ -230,7 +231,7 @@ const FX_WORD AdobeSymbolEncoding[256] = { 0x0000, 0x232A, 0x222B, 0x2320, 0xF8F5, 0x2321, 0xF8F6, 0xF8F7, 0xF8F8, 0xF8F9, 0xF8FA, 0xF8FB, 0xF8FC, 0xF8FD, 0xF8FE, 0x0000, }; -const FX_WORD ZapfEncoding[256] = { +static const FX_WORD ZapfEncoding[256] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, @@ -264,7 +265,7 @@ const FX_WORD ZapfEncoding[256] = { 0x0000, 0x27B1, 0x27B2, 0x27B3, 0x27B4, 0x27B5, 0x27B6, 0x27B7, 0x27B8, 0x27B9, 0x27BA, 0x27BB, 0x27BC, 0x27BD, 0x27BE, 0x0000, }; -const FX_CHAR* const StandardEncodingNames[224] = { +static const FX_CHAR* const StandardEncodingNames[224] = { "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quoteright", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", @@ -294,7 +295,7 @@ const FX_CHAR* const StandardEncodingNames[224] = { NULL, "ae", NULL, NULL, NULL, "dotlessi", NULL, NULL, "lslash", "oslash", "oe", "germandbls", NULL, NULL, NULL, NULL, }; -const FX_CHAR* const AdobeWinAnsiEncodingNames[224] = { +static const FX_CHAR* const AdobeWinAnsiEncodingNames[224] = { "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quotesingle", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", @@ -324,7 +325,7 @@ const FX_CHAR* const AdobeWinAnsiEncodingNames[224] = { "eth", "ntilde", "ograve", "oacute", "ocircumflex", "otilde", "odieresis", "divide", "oslash", "ugrave", "uacute", "ucircumflex", "udieresis", "yacute", "thorn", "ydieresis", }; -const FX_CHAR* const MacRomanEncodingNames[224] = { +static const FX_CHAR* const MacRomanEncodingNames[224] = { "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quotesingle", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", @@ -354,7 +355,7 @@ const FX_CHAR* const MacRomanEncodingNames[224] = { "apple", "Ograve", "Uacute", "Ucircumflex", "Ugrave", "dotlessi", "circumflex", "tilde", "macron", "breve", "dotaccent", "ring", "cedilla", "hungarumlaut", "ogonek", "caron", }; -const FX_CHAR* const MacExpertEncodingNames[224] = { +static const FX_CHAR* const MacExpertEncodingNames[224] = { "space", "exclamsmall", "Hungarumlautsmall", "centoldstyle", "dollaroldstyle", "dollarsuperior", "ampersandsmall", "Acutesmall", "parenleftsuperior", "parenrightsuperior", "twodotenleader", "onedotenleader", "comma", "hyphen", "period", "fraction", "zerooldstyle", "oneoldstyle", "twooldstyle", "threeoldstyle", "fouroldstyle", "fiveoldstyle", "sixoldstyle", "sevenoldstyle", @@ -384,7 +385,7 @@ const FX_CHAR* const MacExpertEncodingNames[224] = { NULL, "lsuperior", "Ogoneksmall", "Brevesmall", "Macronsmall", "bsuperior", "nsuperior", "msuperior", "commasuperior", "periodsuperior", "Dotaccentsmall", "Ringsmall", NULL, NULL, NULL, NULL, }; -const FX_CHAR* const PDFDocEncodingNames[232] = { +static const FX_CHAR* const PDFDocEncodingNames[232] = { "breve", "caron", "circumflex", "dotaccent", "hungarumlaut", "ogonek", "ring", "tilde", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quotesingle", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", @@ -415,7 +416,7 @@ const FX_CHAR* const PDFDocEncodingNames[232] = { "eth", "ntilde", "ograve", "oacute", "ocircumflex", "otilde", "odieresis", "divide", "oslash", "ugrave", "uacute", "ucircumflex", "udieresis", "yacute", "thorn", "ydieresis", }; -const FX_CHAR* const AdobeSymbolEncodingNames[224] = { +static const FX_CHAR* const AdobeSymbolEncodingNames[224] = { "space", "exclam", "universal", "numbersign", "existential", "percent", "ampersand", "suchthat", "parenleft", "parenright", "asteriskmath", "plus", "comma", "minus", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", @@ -445,7 +446,7 @@ const FX_CHAR* const AdobeSymbolEncodingNames[224] = { NULL, "angleright", "integral", "integraltp", "integralex", "integralbt", "parenrighttp", "parenrightex", "parenrightbt", "bracketrighttp", "bracketrightex", "bracketrightbt", "bracerighttp", "bracerightmid", "bracerightbt", NULL, }; -const FX_CHAR* const ZapfEncodingNames[224] = { +static const FX_CHAR* const ZapfEncodingNames[224] = { "space", "a1", "a2", "a202", "a3", "a4", "a5", "a119", "a118", "a117", "a11", "a12", "a13", "a14", "a15", "a16", "a105", "a17", "a18", "a19", "a20", "a21", "a22", "a23", @@ -532,7 +533,7 @@ static FX_DWORD PDF_FindCode(const FX_WORD* pCodes, FX_WORD unicode) } return 0; } -const FX_WORD MSSymbolEncoding[256] = { +static const FX_WORD MSSymbolEncoding[256] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp index 7dd019da85..7a01bba97a 100644 --- a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp +++ b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp @@ -6,14 +6,15 @@ #include "../../../include/fpdfapi/fpdf_module.h" #include "../../../include/fpdfapi/fpdf_page.h" -#include "font_int.h" -#include "../fpdf_cmaps/cmap_int.h" -#include "../../../include/fxge/fx_ge.h" +#include "../../../include/fpdfapi/fpdf_resource.h" #include "../../../include/fxge/fx_freetype.h" -extern FX_DWORD FT_CharCodeFromUnicode(int encoding, FX_WCHAR unicode); +#include "../../../include/fxge/fx_ge.h" +#include "../fpdf_cmaps/cmap_int.h" +#include "font_int.h" + extern short TT2PDF(int m, FXFT_Face face); extern FX_BOOL FT_UseTTCharmap(FXFT_Face face, int platform_id, int encoding_id); -extern const FX_CHAR* GetAdobeCharName(int iBaseEncoding, const CFX_ByteString* pCharNames, int charcode); + CPDF_CMapManager::CPDF_CMapManager() { m_bPrompted = FALSE; diff --git a/core/src/fpdftext/fpdf_text.cpp b/core/src/fpdftext/fpdf_text.cpp index 91d0e41b8d..c5e064a60a 100644 --- a/core/src/fpdftext/fpdf_text.cpp +++ b/core/src/fpdftext/fpdf_text.cpp @@ -7,13 +7,13 @@ #include "../../../third_party/base/nonstd_unique_ptr.h" #include "../../include/fpdfapi/fpdf_page.h" #include "../../include/fpdfapi/fpdf_pageobj.h" +#include "../../include/fpdfapi/fpdf_resource.h" #include "../../include/fpdftext/fpdf_text.h" #include "../../include/fxcrt/fx_arb.h" #include "../../include/fxcrt/fx_ucd.h" #include "text_int.h" #include "txtproc.h" -extern const FX_CHAR* FCS_GetAltStr(FX_WCHAR); CFX_ByteString CharFromUnicodeAlt(FX_WCHAR unicode, int destcp, const FX_CHAR* defchar) { if (destcp == 0) { -- cgit v1.2.3