Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't return Google fonts that have a single subset of 'khmer' #55

Merged
merged 1 commit into from
Apr 25, 2016
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
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);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@donnapep Why isn't Buda returned since it doesn't have the 'khmer' subset?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stulees It's being explicitly filtered out here since Google returns it in their API, but it doesn't return the font when requested - https://fonts.googleapis.com/css?family=Buda.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@donnapep got it, thanks!


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