Shreygupta (Talk | contribs) |
Shreygupta (Talk | contribs) |
||
Line 38: | Line 38: | ||
cur = cur.parent; | cur = cur.parent; | ||
} | } | ||
+ | } | ||
+ | }; | ||
+ | |||
+ | lib.gfontAvailable = function(family, totalGoogleCount) { | ||
+ | lib.properties.webfonts[family] = true; | ||
+ | var txtInst = lib.webFontTxtInst && lib.webFontTxtInst[family] || []; | ||
+ | for(var f = 0; f < txtInst.length; ++f) | ||
+ | lib.addElementsToCache(txtInst[f], gFontsUpdateCacheList); | ||
+ | |||
+ | loadedGoogleCount++; | ||
+ | if(loadedGoogleCount == totalGoogleCount) { | ||
+ | lib.updateListCache(gFontsUpdateCacheList); | ||
+ | } | ||
+ | }; | ||
+ | |||
+ | lib.tfontAvailable = function(family, totalTypekitCount) { | ||
+ | lib.properties.webfonts[family] = true; | ||
+ | var txtInst = lib.webFontTxtInst && lib.webFontTxtInst[family] || []; | ||
+ | for(var f = 0; f < txtInst.length; ++f) | ||
+ | lib.addElementsToCache(txtInst[f], tFontsUpdateCacheList); | ||
+ | |||
+ | loadedTypekitCount++; | ||
+ | if(loadedTypekitCount == totalTypekitCount) { | ||
+ | lib.updateListCache(tFontsUpdateCacheList); | ||
} | } | ||
}; | }; |
Latest revision as of 12:54, 30 October 2017
(function (lib, img, cjs, ss, an) {
var p; // shortcut to reference prototypes lib.webFontTxtInst = {}; var loadedTypekitCount = 0; var loadedGoogleCount = 0; var gFontsUpdateCacheList = []; var tFontsUpdateCacheList = []; lib.ssMetadata = [];
lib.updateListCache = function (cacheList) { for(var i = 0; i < cacheList.length; i++) { if(cacheList[i].cacheCanvas) cacheList[i].updateCache(); } };
lib.addElementsToCache = function (textInst, cacheList) { var cur = textInst; while(cur != exportRoot) { if(cacheList.indexOf(cur) != -1) break; cur = cur.parent; } if(cur != exportRoot) { var cur2 = textInst; var index = cacheList.indexOf(cur); while(cur2 != cur) { cacheList.splice(index, 0, cur2); cur2 = cur2.parent; index++; } } else { cur = textInst; while(cur != exportRoot) { cacheList.push(cur); cur = cur.parent; } } };
lib.gfontAvailable = function(family, totalGoogleCount) { lib.properties.webfonts[family] = true; var txtInst = lib.webFontTxtInst && lib.webFontTxtInst[family] || []; for(var f = 0; f < txtInst.length; ++f) lib.addElementsToCache(txtInst[f], gFontsUpdateCacheList);
loadedGoogleCount++; if(loadedGoogleCount == totalGoogleCount) { lib.updateListCache(gFontsUpdateCacheList); } };
lib.tfontAvailable = function(family, totalTypekitCount) { lib.properties.webfonts[family] = true; var txtInst = lib.webFontTxtInst && lib.webFontTxtInst[family] || []; for(var f = 0; f < txtInst.length; ++f) lib.addElementsToCache(txtInst[f], tFontsUpdateCacheList);
loadedTypekitCount++; if(loadedTypekitCount == totalTypekitCount) { lib.updateListCache(tFontsUpdateCacheList); } };