Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions cocos2d/core/platform/CCLoaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ cc._fontLoader = {
TYPE : {
".eot" : "embedded-opentype",
".ttf" : "truetype",
".ttc" : "truetype",
".woff" : "woff",
".svg" : "svg"
},
Expand All @@ -90,7 +91,11 @@ cc._fontLoader = {
fontStyle.type = "text/css";
doc.body.appendChild(fontStyle);

var fontStr = "@font-face { font-family:" + name + "; src:";
var fontStr = "";
if(isNaN(name - 0))
fontStr += "@font-face { font-family:" + name + "; src:";
else
fontStr += "@font-face { font-family:'" + name + "'; src:";
if(srcs instanceof Array){
for(var i = 0, li = srcs.length; i < li; i++){
var src = srcs[i];
Expand All @@ -99,9 +104,10 @@ cc._fontLoader = {
fontStr += (i === li - 1) ? ";" : ",";
}
}else{
type = type.toLowerCase();
fontStr += "url('" + srcs + "') format('" + TYPE[type] + "');";
}
fontStyle.textContent += fontStr + "};";
fontStyle.textContent += fontStr + "}";

//<div style="font-family: PressStart;">.</div>
var preloadDiv = cc.newElement("div");
Expand All @@ -126,7 +132,7 @@ cc._fontLoader = {
cb(null, true);
}
};
cc.loader.register(["font", "eot", "ttf", "woff", "svg"], cc._fontLoader);
cc.loader.register(["font", "eot", "ttf", "woff", "svg", "ttc"], cc._fontLoader);

cc._binaryLoader = {
load : function(realUrl, url, res, cb){
Expand Down
2 changes: 1 addition & 1 deletion extensions/cocostudio/loader/parsers/timelineParser-2.x.js
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@
if (cc.sys.isNative) {
fontName = cc.path.join(cc.loader.resPath, resourcePath, path);
} else {
fontName = path.match(/([^\/]+)\.ttf/);
fontName = path.match(/([^\/]+)\.(\S+)/);
fontName = fontName ? fontName[1] : "";
}
widget.setTitleFontName(fontName);
Expand Down