Skip to content

Commit

Permalink
Merge pull request #6760 from cb1kenobi/timob-18156_4_0_X
Browse files Browse the repository at this point in the history
[TIMOB-18156] Fixed support for web fonts.
  • Loading branch information
feons committed Apr 13, 2015
2 parents 0d8d857 + baf5715 commit d4865a3
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions mobileweb/cli/commands/_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ MobileWebBuilder.prototype.assembleTitaniumCSS = function assembleTitaniumCSS(ne
fontFormats = {
'ttf': 'truetype'
},
prefix = this.projectResDir + '/';
prefix = this.projectResDir.replace(/\\/g, '/') + '/';

(function walk(dir, isMobileWebDir, isRoot) {
fs.existsSync(dir) && fs.readdirSync(dir).forEach(function (name) {
Expand All @@ -878,30 +878,30 @@ MobileWebBuilder.prototype.assembleTitaniumCSS = function assembleTitaniumCSS(ne

var m = name.match(/^(.+)\.(otf|woff|ttf|svg)$/);
if (m) {
var p = file.replace(prefix, '').replace(/\\/g, '/');
fonts[m[1]] || (fonts[m[1]] = []);
fonts[m[1]].push({
var p = file.replace(/\\/g, '/').replace(prefix, '');
fonts[m[1]] || (fonts[m[1]] = {});
fonts[m[1]][m[2]] = {
path: isMobileWebDir ? p.replace('mobileweb/', '') : p,
format: fontFormats[m[2]] || m[2]
});
};
}
});
}(this.projectResDir, false, true));

Object.keys(fonts).forEach(function (name) {
var font = fonts[name],
i = 0,
l = font.length,
src = [];

this.logger.debug(__('Found font: %s', name.cyan));

for (; i < l; i++) {
this.prefetch.push(font[i].path);
src.push('url("' + font[i].path + '") format("' + font[i].format + '")');
}
['woff', 'otf', 'ttf', 'svg'].forEach(function (type) {
if (font[type]) {
// this.prefetch.push(font[type].path);
src.push('url("' + font[type].path + '") format("' + font[type].format + '")');
}
}, this);

tiCSS.push('@font-face{font-family:"' + name + '";' + src.join(',') + ';}\n');
tiCSS.push('@font-face{font-family:"' + name + '";src:' + src.join(',') + ';}\n');
}, this);

// write the titanium.css
Expand Down

0 comments on commit d4865a3

Please sign in to comment.