font-finder
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -1,7 +0,7 @@ | ||
<a name="1.0.0"></a> | ||
# 1.0.0 (2018-04-30) | ||
<a name="1.0.1"></a> | ||
## [1.0.1](https://github.com/princjef/font-finder/compare/v1.0.0...v1.0.1) (2018-04-30) | ||
### Features | ||
### Bug Fixes | ||
* initial release ([b9fdd5a](https://github.com/princjef/font-finder/commit/b9fdd5a)) | ||
* **extract:** special name-ending logic is windows-sepcific ([94e45c4](https://github.com/princjef/font-finder/commit/94e45c4)) |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const os = require("os"); | ||
var Type; | ||
@@ -33,12 +34,28 @@ (function (Type) { | ||
: names.fontFamily[language]; | ||
const subfamily = names.preferredSubfamily && names.preferredSubfamily[language] | ||
? names.preferredSubfamily[language] | ||
: names.fontSubfamily[language]; | ||
const fullName = `${family} ${subfamily}`; | ||
for (const ending of standardEndings) { | ||
if (fullName.endsWith(ending)) { | ||
return fullName.substring(0, fullName.length - ending.length); | ||
// On Windows, if the full font name doesn't end with one of the standard | ||
// forms, the full name is needed to identify the font. Notably, this is not | ||
// the same thing as the subfamily matching it, as with 'Roboto Thin Italic' | ||
// where the subfamily is 'Thin Italic'. In this case, the 'Italic' should | ||
// be removed, but not the 'Thin'. | ||
// TODO: actually, 'Roboto' and 'Roboto Thin' seem to both work. This needs | ||
// more work to figure out the exact logic | ||
if (os.platform() === 'win32') { | ||
const subfamily = names.preferredSubfamily && names.preferredSubfamily[language] | ||
? names.preferredSubfamily[language] | ||
: names.fontSubfamily[language]; | ||
const fullName = `${family} ${subfamily}`; | ||
let endIndex = -1; | ||
for (const end of standardEndings) { | ||
const index = fullName.lastIndexOf(end); | ||
if (index !== -1) { | ||
endIndex = index; | ||
break; | ||
} | ||
} | ||
if (endIndex !== -1) { | ||
return fullName.substring(0, endIndex); | ||
} | ||
return fullName; | ||
} | ||
return fullName; | ||
return family; | ||
} | ||
@@ -45,0 +62,0 @@ exports.name = name; |
{ | ||
"name": "font-finder", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Quickly find system font names and metadata without native dependencies", | ||
@@ -50,2 +50,3 @@ "homepage": "https://github.com/princjef/font-finder#readme", | ||
"@semantic-release/changelog": "^2.0.1", | ||
"@semantic-release/git": "^4.0.2", | ||
"@semantic-release/github": "^4.2.13", | ||
@@ -125,2 +126,3 @@ "@semantic-release/npm": "^3.2.4", | ||
}, | ||
"@semantic-release/git", | ||
"@semantic-release/npm" | ||
@@ -127,0 +129,0 @@ ], |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
79720
1280
21