Skip to content

Commit

Permalink
Don't include Google "khmer" fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
Donna Peplinskie committed Apr 21, 2016
1 parent 15c84f6 commit 6966d0e
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 19 deletions.
10 changes: 6 additions & 4 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "widget-settings-ui-core",
"version": "0.4.2",
"version": "0.4.3",
"homepage": "https://github.com/Rise-Vision/widget-settings-ui-core",
"authors": [
"Xiyang Chen <settinghead@gmail.com>"
Expand All @@ -22,14 +22,16 @@
"tests"
],
"devDependencies": {
"angular": "1.2.18",
"angular-load": "~0.4.1",
"q": "1.0.1",
"jquery": "1.11.0",
"sinon": "~1.10.2"
},
"dependencies": {
"angular": "1.2.18",
"angular-mocks": "1.2.18"
"angular": "~1.3.0",
"angular-mocks": "^1.5.5"
},
"resolutions": {
"angular": "~1.3.0"
}
}
7 changes: 1 addition & 6 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
machine:
pre:
- sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 10
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 10
- sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 20
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 20
node:
version: 4.2.2
version: 4.4.3
dependencies:
pre:
- npm install -g gulp
Expand Down
13 changes: 11 additions & 2 deletions dist/widget-settings-ui-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,19 @@ angular.module("risevision.widget.common")
// Get list of Google fonts sorted alphabetically.
return $http.get("https://www.googleapis.com/webfonts/v1/webfonts?key=AIzaSyBXxVK_IOV7LNQMuVVo_l7ZvN53ejN86zY&sort=alpha", { cache: true })
.then(function(resp) {
var item = null;

if (resp.data && resp.data.items) {
// Save all Google fonts.
for (var i = 0, length = resp.data.items.length; i < length; i++) {
allFonts.push(resp.data.items[i].family);
item = resp.data.items[i];

// Don't return those fonts that have a subset of "khmer".
if (item.subsets && (item.subsets.length === 1) &&
(item.subsets[0].toLowerCase() === "khmer")) {
continue;
}

allFonts.push(item.family);
}

return loadFonts();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "widget-settings-ui-core",
"version": "0.4.2",
"version": "0.4.3",
"description": "Common components shared across Rise Vision widget settings UI",
"main": "gulpfile.js",
"directories": {
Expand Down
13 changes: 11 additions & 2 deletions src/js/svc-google-fonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,19 @@ angular.module("risevision.widget.common")
// Get list of Google fonts sorted alphabetically.
return $http.get("https://www.googleapis.com/webfonts/v1/webfonts?key=AIzaSyBXxVK_IOV7LNQMuVVo_l7ZvN53ejN86zY&sort=alpha", { cache: true })
.then(function(resp) {
var item = null;

if (resp.data && resp.data.items) {
// Save all Google fonts.
for (var i = 0, length = resp.data.items.length; i < length; i++) {
allFonts.push(resp.data.items[i].family);
item = resp.data.items[i];

// Don't return those fonts that have a subset of "khmer".
if (item.subsets && (item.subsets.length === 1) &&
(item.subsets[0].toLowerCase() === "khmer")) {
continue;
}

allFonts.push(item.family);
}

return loadFonts();
Expand Down
28 changes: 24 additions & 4 deletions test/unit/svc-google-fonts-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,21 @@ describe("Google Font Loader", function() {
$httpBackend = $injector.get("$httpBackend");

$httpBackend.when("GET", "https://www.googleapis.com/webfonts/v1/webfonts?key=AIzaSyBXxVK_IOV7LNQMuVVo_l7ZvN53ejN86zY&sort=alpha")
.respond({ items: [{ family: "ABeeZee" }, { family: "Buda" }, { family: "Slabo 27px" }] });
.respond({
items: [
{
family: "ABeeZee",
subsets: ["latin"]
},
{
family: "Buda",
subsets: ["latin", "latin-ext"]
},
{
family: "Slabo 27px",
subsets: ["khmer"]
}]
});
}));

beforeEach(inject(function(_googleFontLoader_) {
Expand All @@ -43,13 +57,19 @@ describe("Google Font Loader", function() {
expect(googleFontLoader.getGoogleFonts).to.be.a("function");
});

it("should not return fonts that have a subset of 'khmer'", function () {
googleFontLoader.getGoogleFonts();
$httpBackend.flush();

expect(googleFontLoader.getGoogleFonts().urls).to.have.lengthOf(1);
});

it("should return an object containing font families and URLs", function () {
var fonts =
{
fonts: "ABeeZee=ABeeZee,sans-serif;Slabo 27px='Slabo 27px',sans-serif;",
fonts: "ABeeZee=ABeeZee,sans-serif;",
urls: [
"//fonts.googleapis.com/css?family=ABeeZee",
"//fonts.googleapis.com/css?family=Slabo 27px"
"//fonts.googleapis.com/css?family=ABeeZee"
]
};

Expand Down

0 comments on commit 6966d0e

Please sign in to comment.