Skip to content

Commit abaa9e6

Browse files
committed
remove non-Pango font code and FreeType code
* this commit gets rid of the HAVE_PANGO pragma and HAVE_FREETYPE, preferring the Pango sections of HAVE_PANGO. using Cairo methods for fonts [is discouraged](http://cairographics.org/FAQ/#using_pango). and freetype was only ever needed for cairo font rendering, so that code was running in the Pango build for no reason at all. * it also gets rid of context2d's `addFont`, which was never compatible with the Pango build. `FontFace` is completely removed since it was never used by the Pango build either, and instead of parsing the fonts with FreeType we will instead prefer to let the OS do that in succeeding commits * the Windows build has been updated to work with Pango, which it did not before TL;DR - Pango is now required and and as of this commit custom fonts are removed
1 parent c02a6f1 commit abaa9e6

File tree

9 files changed

+37
-453
lines changed

9 files changed

+37
-453
lines changed

binding.gyp

Lines changed: 26 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@
44
'variables': {
55
'GTK_Root%': 'C:/GTK', # Set the location of GTK all-in-one bundle
66
'with_jpeg%': 'false',
7-
'with_gif%': 'false',
8-
'with_pango%': 'false',
9-
'with_freetype%': 'false'
7+
'with_gif%': 'false'
108
}
119
}, { # 'OS!="win"'
1210
'variables': {
1311
'with_jpeg%': '<!(./util/has_lib.sh jpeg)',
14-
'with_gif%': '<!(./util/has_lib.sh gif)',
15-
'with_pango%': '<!(./util/has_lib.sh pango)',
16-
'with_freetype%': '<!(./util/has_lib.sh freetype)'
12+
'with_gif%': '<!(./util/has_lib.sh gif)'
1713
}
1814
}]
1915
],
@@ -26,12 +22,21 @@
2622
'copies': [{
2723
'destination': '<(PRODUCT_DIR)',
2824
'files': [
25+
'<(GTK_Root)/bin/zlib1.dll',
26+
'<(GTK_Root)/bin/libintl-8.dll',
27+
'<(GTK_Root)/bin/libpng14-14.dll',
28+
'<(GTK_Root)/bin/libpangocairo-1.0-0.dll',
29+
'<(GTK_Root)/bin/libpango-1.0-0.dll',
30+
'<(GTK_Root)/bin/libpangoft2-1.0-0.dll',
31+
'<(GTK_Root)/bin/libpangowin32-1.0-0.dll',
2932
'<(GTK_Root)/bin/libcairo-2.dll',
30-
'<(GTK_Root)/bin/libexpat-1.dll',
3133
'<(GTK_Root)/bin/libfontconfig-1.dll',
3234
'<(GTK_Root)/bin/libfreetype-6.dll',
33-
'<(GTK_Root)/bin/libpng14-14.dll',
34-
'<(GTK_Root)/bin/zlib1.dll',
35+
'<(GTK_Root)/bin/libglib-2.0-0.dll',
36+
'<(GTK_Root)/bin/libgobject-2.0-0.dll',
37+
'<(GTK_Root)/bin/libgmodule-2.0-0.dll',
38+
'<(GTK_Root)/bin/libgthread-2.0-0.dll',
39+
'<(GTK_Root)/bin/libexpat-1.dll'
3540
]
3641
}]
3742
}]
@@ -54,11 +59,18 @@
5459
['OS=="win"', {
5560
'libraries': [
5661
'-l<(GTK_Root)/lib/cairo.lib',
57-
'-l<(GTK_Root)/lib/libpng.lib'
62+
'-l<(GTK_Root)/lib/libpng.lib',
63+
'-l<(GTK_Root)/lib/pangocairo-1.0.lib',
64+
'-l<(GTK_Root)/lib/pango-1.0.lib',
65+
'-l<(GTK_Root)/lib/glib-2.0.lib',
66+
'-l<(GTK_Root)/lib/gobject-2.0.lib'
5867
],
5968
'include_dirs': [
6069
'<(GTK_Root)/include',
6170
'<(GTK_Root)/include/cairo',
71+
'<(GTK_Root)/include/pango-1.0',
72+
'<(GTK_Root)/include/glib-2.0',
73+
'<(GTK_Root)/lib/glib-2.0/include'
6274
],
6375
'defines': [
6476
'_USE_MATH_DEFINES' # for M_PI
@@ -87,49 +99,13 @@
8799
'libraries': [
88100
'<!@(pkg-config pixman-1 --libs)',
89101
'<!@(pkg-config cairo --libs)',
90-
'<!@(pkg-config libpng --libs)'
102+
'<!@(pkg-config libpng --libs)',
103+
'<!@(pkg-config pangocairo --libs)'
91104
],
92105
'include_dirs': [
93106
'<!@(pkg-config cairo --cflags-only-I | sed s/-I//g)',
94-
'<!@(pkg-config libpng --cflags-only-I | sed s/-I//g)'
95-
]
96-
}],
97-
['with_freetype=="true"', {
98-
'defines': [
99-
'HAVE_FREETYPE'
100-
],
101-
'sources': [
102-
'src/FontFace.cc'
103-
],
104-
'conditions': [
105-
['OS=="win"', {
106-
# No support for windows right now.
107-
}, { # 'OS!="win"'
108-
'include_dirs': [ # tried to pass through cflags but failed.
109-
# Need to include the header files of cairo AND freetype.
110-
# Looking up the includes of cairo does both.
111-
'<!@(pkg-config cairo --cflags-only-I | sed s/-I//g)'
112-
]
113-
}]
114-
]
115-
}],
116-
['with_pango=="true"', {
117-
'defines': [
118-
'HAVE_PANGO'
119-
],
120-
'conditions': [
121-
['OS=="win"', {
122-
'libraries': [
123-
'-l<(GTK_Root)/lib/pangocairo.lib'
124-
]
125-
}, { # 'OS!="win"'
126-
'include_dirs': [ # tried to pass through cflags but failed
127-
'<!@(pkg-config pangocairo --cflags-only-I | sed s/-I//g)'
128-
],
129-
'libraries': [
130-
'<!@(pkg-config pangocairo --libs)'
131-
]
132-
}]
107+
'<!@(pkg-config libpng --cflags-only-I | sed s/-I//g)',
108+
'<!@(pkg-config pangocairo --cflags-only-I | sed s/-I//g)'
133109
]
134110
}],
135111
['with_jpeg=="true"', {

lib/context2d.js

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -233,19 +233,6 @@ Context2d.prototype.__defineGetter__('strokeStyle', function(){
233233
return this.lastStrokeStyle || this.strokeColor;
234234
});
235235

236-
/**
237-
* Register `font` for usage.
238-
*
239-
* @param {Font} font
240-
* @api public
241-
*/
242-
243-
Context2d.prototype.addFont = function(font) {
244-
this._fonts = this._fonts || {};
245-
if (this._fonts[font.name]) return;
246-
this._fonts[font.name] = font;
247-
};
248-
249236
/**
250237
* Set font.
251238
*
@@ -259,22 +246,12 @@ Context2d.prototype.__defineSetter__('font', function(val){
259246
var font;
260247
if (font = parseFont(val)) {
261248
this.lastFontString = val;
262-
263-
var fonts = this._fonts;
264-
if (fonts && fonts[font.family]) {
265-
var fontObj = fonts[font.family];
266-
var type = font.weight + '-' + font.style;
267-
268-
var fontFace = fontObj.getFace(type);
269-
this._setFontFace(fontFace, font.size);
270-
} else {
271-
this._setFont(
272-
font.weight
273-
, font.style
274-
, font.size
275-
, font.unit
276-
, font.family);
277-
}
249+
this._setFont(
250+
font.weight
251+
, font.style
252+
, font.size
253+
, font.unit
254+
, font.family);
278255
}
279256
}
280257
});

src/Canvas.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,8 @@
1212
#include <node.h>
1313
#include <node_object_wrap.h>
1414
#include <node_version.h>
15-
16-
#if HAVE_PANGO
1715
#include <pango/pangocairo.h>
18-
#else
1916
#include <cairo.h>
20-
#endif
21-
2217
#include <nan.h>
2318

2419
using namespace v8;

0 commit comments

Comments
 (0)