summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BUILD.gn19
-rw-r--r--core/include/fxge/fx_freetype.h15
-rw-r--r--core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/openjpeg.h24
-rw-r--r--core/src/fxge/ge/fx_ge_text.cpp14
-rw-r--r--pdfium.gyp21
-rw-r--r--third_party/BUILD.gn1
6 files changed, 42 insertions, 52 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 4e3a00d03a..761e1522e2 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -6,15 +6,19 @@ import("//testing/test.gni")
pdf_use_skia = false
+declare_args() {
+ # On Android there's no system FreeType. On Windows and Mac, only a few
+ # methods are used from it.
+ bundle_freetype = !is_linux
+}
+
config("pdfium_config") {
cflags = []
- include_dirs = [
- "third_party/freetype/include"
- ]
+ include_dirs = [ "third_party/freetype/include" ]
defines = [
- "FT2_BUILD_LIBRARY",
"_FPDFSDK_LIB",
"_NO_GDIPLUS_", # workaround text rendering issues on Windows
+ "OPJ_STATIC",
]
if (pdf_use_skia) {
@@ -91,7 +95,6 @@ static_library("pdfium") {
deps = [
"third_party:bigint",
- "third_party:freetype",
"third_party:safemath",
":fdrm",
":formfiller",
@@ -116,6 +119,12 @@ static_library("pdfium") {
if (is_mac) {
libs += [ "AppKit.framework", "CoreFoundation.framework" ]
}
+
+ if (bundle_freetype) {
+ deps += [ "third_party:freetype" ]
+ } else {
+ libs += [ "freetype" ]
+ }
}
# Targets below this are only visible within this file.
diff --git a/core/include/fxge/fx_freetype.h b/core/include/fxge/fx_freetype.h
index 6419c6b6c2..4b49d5f6ea 100644
--- a/core/include/fxge/fx_freetype.h
+++ b/core/include/fxge/fx_freetype.h
@@ -4,12 +4,13 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "../../../third_party/freetype/include/ft2build.h"
-#include "../../../third_party/freetype/include/freetype.h"
-#include "../../../third_party/freetype/include/ftoutln.h"
-#include "../../../third_party/freetype/include/ftmm.h"
-#include "../../../third_party/freetype/include/internal/ftobjs.h"
-#include "../../../third_party/freetype/include/tttables.h"
+#include <ft2build.h>
+#include <freetype.h>
+#include <ftglyph.h>
+#include <ftlcdfil.h>
+#include <ftmm.h>
+#include <ftoutln.h>
+#include <tttables.h>
#ifdef __cplusplus
extern "C" {
#endif
@@ -111,8 +112,6 @@ typedef FT_CharMap FXFT_CharMap;
#define FXFT_Get_MM_Axis_Min(axis) ((FT_Var_Axis*)axis)->minimum
#define FXFT_Get_MM_Axis_Max(axis) ((FT_Var_Axis*)axis)->maximum
#define FXFT_Get_MM_Axis_Def(axis) ((FT_Var_Axis*)axis)->def
-#define FXFT_Get_Face_Internal_Flag(face) ((FT_Face)face)->internal->transform_flags
-#define FXFT_Set_Face_Internal_Flag(face, flag) (((FT_Face)face)->internal->transform_flags = flag)
#define FXFT_Alloc(library, size) ((FT_Library)library)->memory->alloc(((FT_Library)library)->memory, size)
#define FXFT_Free(face, p) ((FT_Face)face)->memory->free(((FT_Face)face)->memory, p)
#define FXFT_Get_Glyph_Outline(face) &((FT_Face)face)->glyph->outline
diff --git a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/openjpeg.h b/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/openjpeg.h
index 988db72009..b1e1c294c8 100644
--- a/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/openjpeg.h
+++ b/core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/openjpeg.h
@@ -76,32 +76,10 @@ Most compilers implement their own version of this keyword ...
#define OPJ_DEPRECATED(func) func
#endif
-#if defined(OPJ_STATIC) || !defined(_WIN32)
-/* http://gcc.gnu.org/wiki/Visibility */
-#if __GNUC__ >= 4
-#define OPJ_API __attribute__ ((visibility ("default")))
-#define OPJ_LOCAL __attribute__ ((visibility ("hidden")))
-#else
+// PDFium doesn't need to export any of these methods.
#define OPJ_API
#define OPJ_LOCAL
-#endif
#define OPJ_CALLCONV
-#else
-#define OPJ_CALLCONV __stdcall
-/*
-The following ifdef block is the standard way of creating macros which make exporting
-from a DLL simpler. All files within this DLL are compiled with the OPJ_EXPORTS
-symbol defined on the command line. this symbol should not be defined on any project
-that uses this DLL. This way any other project whose source files include this file see
-OPJ_API functions as being imported from a DLL, wheras this DLL sees symbols
-defined with this macro as being exported.
-*/
-#if defined(OPJ_EXPORTS) || defined(DLL_EXPORT)
-#define OPJ_API __declspec(dllexport)
-#else
-#define OPJ_API __declspec(dllimport)
-#endif /* OPJ_EXPORTS */
-#endif /* !OPJ_STATIC || !_WIN32 */
typedef int OPJ_BOOL;
#define OPJ_TRUE 1
diff --git a/core/src/fxge/ge/fx_ge_text.cpp b/core/src/fxge/ge/fx_ge_text.cpp
index 0724c10edf..59bd351822 100644
--- a/core/src/fxge/ge/fx_ge_text.cpp
+++ b/core/src/fxge/ge/fx_ge_text.cpp
@@ -1328,12 +1328,10 @@ CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph(CFX_Font* pFont, FX_DWORD glyph_inde
pFont->AdjustMMParams(glyph_index, dest_width, pFont->GetSubstFont()->m_Weight);
}
}
- int transflag = FXFT_Get_Face_Internal_Flag(m_Face);
FXFT_Set_Transform(m_Face, &ft_matrix, 0);
int load_flags = (m_Face->face_flags & FT_FACE_FLAG_SFNT) ? FXFT_LOAD_NO_BITMAP : (FXFT_LOAD_NO_BITMAP | FT_LOAD_NO_HINTING);
int error = FXFT_Load_Glyph(m_Face, glyph_index, load_flags);
if (error) {
- FXFT_Set_Face_Internal_Flag(m_Face, transflag);
return NULL;
}
int weight = 0;
@@ -1345,7 +1343,6 @@ CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph(CFX_Font* pFont, FX_DWORD glyph_inde
if (pSubstFont && !(pSubstFont->m_SubstFlags & FXFONT_SUBST_MM) && weight > 400) {
int index = (weight - 400) / 10;
if (index >= WEIGHTPOW_ARRAY_SIZE) {
- FXFT_Set_Face_Internal_Flag(m_Face, transflag);
return NULL;
}
int level = 0;
@@ -1359,13 +1356,11 @@ CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph(CFX_Font* pFont, FX_DWORD glyph_inde
FXFT_Library_SetLcdFilter(CFX_GEModule::Get()->GetFontMgr()->m_FTLibrary, FT_LCD_FILTER_DEFAULT);
error = FXFT_Render_Glyph(m_Face, anti_alias);
if (error) {
- FXFT_Set_Face_Internal_Flag(m_Face, transflag);
return NULL;
}
int bmwidth = FXFT_Get_Bitmap_Width(FXFT_Get_Glyph_Bitmap(m_Face));
int bmheight = FXFT_Get_Bitmap_Rows(FXFT_Get_Glyph_Bitmap(m_Face));
if (bmwidth > 2048 || bmheight > 2048) {
- FXFT_Set_Face_Internal_Flag(m_Face, transflag);
return NULL;
}
int dib_width = bmwidth;
@@ -1402,7 +1397,6 @@ CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph(CFX_Font* pFont, FX_DWORD glyph_inde
_GammaAdjust(pDestBuf, bmwidth, bmheight, dest_pitch, CFX_GEModule::Get()->GetTextGammaTable());
}
}
- FXFT_Set_Face_Internal_Flag(m_Face, transflag);
return pGlyphBitmap;
}
FX_BOOL _OutputGlyph(void* dib, int x, int y, CFX_Font* pFont,
@@ -1444,7 +1438,6 @@ FX_BOOL OutputText(void* dib, int x, int y, CFX_Font* pFont, double font_size,
}
FXFT_Face face = pFont->GetFace();
FXFT_Select_Charmap(pFont->m_Face, FXFT_ENCODING_UNICODE);
- int transflag = FXFT_Get_Face_Internal_Flag(pFont->m_Face);
if (pText_matrix) {
FXFT_Matrix ft_matrix;
ft_matrix.xx = (signed long)(pText_matrix->a / 64 * 65536);
@@ -1472,7 +1465,6 @@ FX_BOOL OutputText(void* dib, int x, int y, CFX_Font* pFont, double font_size,
glyph_index, argb);
x_pos += (FX_FLOAT)w / em;
}
- FXFT_Set_Face_Internal_Flag(pFont->m_Face, transflag);
return TRUE;
}
FX_BOOL OutputGlyph(void* dib, int x, int y, CFX_Font* pFont, double font_size,
@@ -1489,11 +1481,9 @@ FX_BOOL OutputGlyph(void* dib, int x, int y, CFX_Font* pFont, double font_size,
ft_matrix.xy = ft_matrix.yx = 0;
ft_matrix.yy = (signed long)(font_size / 64 * 65536);
}
- int transflag = FXFT_Get_Face_Internal_Flag(pFont->m_Face);
FXFT_Set_Transform(pFont->m_Face, &ft_matrix, 0);
FX_BOOL ret = _OutputGlyph(dib, x, y, pFont,
glyph_index, argb);
- FXFT_Set_Face_Internal_Flag(pFont->m_Face, transflag);
return ret;
}
const CFX_PathData* CFX_FaceCache::LoadGlyphPath(CFX_Font* pFont, FX_DWORD glyph_index, int dest_width)
@@ -1640,12 +1630,10 @@ CFX_PathData* CFX_Font::LoadGlyphPath(FX_DWORD glyph_index, int dest_width)
AdjustMMParams(glyph_index, dest_width, m_pSubstFont->m_Weight);
}
}
- int transflag = FXFT_Get_Face_Internal_Flag(m_Face);
FXFT_Set_Transform(m_Face, &ft_matrix, 0);
int load_flags = (m_Face->face_flags & FT_FACE_FLAG_SFNT) ? FXFT_LOAD_NO_BITMAP : FXFT_LOAD_NO_BITMAP | FT_LOAD_NO_HINTING;
int error = FXFT_Load_Glyph(m_Face, glyph_index, load_flags);
if (error) {
- FXFT_Set_Face_Internal_Flag(m_Face, transflag);
return NULL;
}
if (m_pSubstFont && !(m_pSubstFont->m_SubstFlags & FXFONT_SUBST_MM) && m_pSubstFont->m_Weight > 400) {
@@ -1672,7 +1660,6 @@ CFX_PathData* CFX_Font::LoadGlyphPath(FX_DWORD glyph_index, int dest_width)
params.m_PointCount = 0;
FXFT_Outline_Decompose(FXFT_Get_Glyph_Outline(m_Face), &funcs, &params);
if (params.m_PointCount == 0) {
- FXFT_Set_Face_Internal_Flag(m_Face, transflag);
return NULL;
}
CFX_PathData* pPath = FX_NEW CFX_PathData;
@@ -1691,7 +1678,6 @@ CFX_PathData* CFX_Font::LoadGlyphPath(FX_DWORD glyph_index, int dest_width)
if (params.m_PointCount) {
pPath->GetPoints()[params.m_PointCount - 1].m_Flag |= FXPT_CLOSEFIGURE;
}
- FXFT_Set_Face_Internal_Flag(m_Face, transflag);
return pPath;
}
void _CFX_UniqueKeyGen::Generate(int count, ...)
diff --git a/pdfium.gyp b/pdfium.gyp
index 425327ed0f..c9f54d7d2a 100644
--- a/pdfium.gyp
+++ b/pdfium.gyp
@@ -1,10 +1,17 @@
{
'variables': {
'pdf_use_skia%': 0,
+ 'conditions': [
+ ['OS=="linux"', {
+ 'bundle_freetype%': 0,
+ }, { # On Android there's no system FreeType. On Windows and Mac, only a
+ # few methods are used from it.
+ 'bundle_freetype%': 1,
+ }],
+ ],
},
'target_defaults': {
'defines' : [
- 'FT2_BUILD_LIBRARY',
'_FPDFSDK_LIB',
'_NO_GDIPLUS_', # workaround text rendering issues on Windows
'OPJ_STATIC',
@@ -38,7 +45,6 @@
'type': 'static_library',
'dependencies': [
'third_party/third_party.gyp:bigint',
- 'third_party/third_party.gyp:freetype',
'third_party/third_party.gyp:safemath',
'fdrm',
'fpdfdoc',
@@ -103,6 +109,17 @@
'fpdfsdk/src/fpdfsdkdll.rc',
],
}],
+ ['bundle_freetype==1', {
+ 'dependencies': [
+ 'third_party/third_party.gyp:freetype',
+ ],
+ }, {
+ 'link_settings': {
+ 'libraries': [
+ '-lfreetype',
+ ],
+ },
+ }],
],
'all_dependent_settings': {
'msvs_settings': {
diff --git a/third_party/BUILD.gn b/third_party/BUILD.gn
index e6340c6401..df02938a93 100644
--- a/third_party/BUILD.gn
+++ b/third_party/BUILD.gn
@@ -36,6 +36,7 @@ static_library("freetype") {
"//third_party/pdfium:pdfium_config",
"//build/config/compiler:no_chromium_code",
]
+ defines = [ "FT2_BUILD_LIBRARY" ]
sources = [
"freetype/include/freetype.h",
"freetype/include/ft2build.h",