font-finder
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -0,1 +1,8 @@ | ||
## [1.0.5](https://github.com/princjef/font-finder/compare/v1.0.4...v1.0.5) (2020-11-26) | ||
### Bug Fixes | ||
* **parse:** handle incomplete OS/2 tables ([#9](https://github.com/princjef/font-finder/issues/9)) ([24fbd9f](https://github.com/princjef/font-finder/commit/24fbd9f)) | ||
## [1.0.4](https://github.com/princjef/font-finder/compare/v1.0.3...v1.0.4) (2018-08-11) | ||
@@ -2,0 +9,0 @@ |
@@ -41,2 +41,2 @@ /// <reference types="node" /> | ||
} | ||
export default function parseOS2Table(data: Buffer): OS2Table; | ||
export default function parseOS2Table(data: Buffer): OS2Table | undefined; |
@@ -8,2 +8,6 @@ "use strict"; | ||
function parseOS2Table(data) { | ||
// The OS/2 table must be at least 78 bytes long | ||
if (data.length < 78) { | ||
return undefined; | ||
} | ||
const os2 = { | ||
@@ -52,7 +56,7 @@ version: data.readUInt16BE(0), | ||
}; | ||
if (os2.version >= 1) { | ||
if (os2.version >= 1 && data.length >= 86) { | ||
os2.ulCodePageRange1 = data.readUInt32BE(78); | ||
os2.ulCodePageRange2 = data.readUInt32BE(82); | ||
} | ||
if (os2.version >= 2) { | ||
if (os2.version >= 2 && data.length >= 96) { | ||
os2.sxHeight = data.readInt16BE(86); | ||
@@ -59,0 +63,0 @@ os2.sCapHeight = data.readInt16BE(88); |
{ | ||
"name": "font-finder", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Quickly find system font names and metadata without native dependencies", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/princjef/font-finder#readme", |
@@ -49,3 +49,8 @@ // This file is modified from opentype.js. All credit for the capabilities | ||
// Parse the OS/2 and Windows metrics `OS/2` table | ||
export default function parseOS2Table(data: Buffer): OS2Table { | ||
export default function parseOS2Table(data: Buffer): OS2Table | undefined { | ||
// The OS/2 table must be at least 78 bytes long | ||
if (data.length < 78) { | ||
return undefined; | ||
} | ||
const os2: OS2Table = { | ||
@@ -100,3 +105,3 @@ version: data.readUInt16BE(0), | ||
if (os2.version >= 1) { | ||
if (os2.version >= 1 && data.length >= 86) { | ||
os2.ulCodePageRange1 = data.readUInt32BE(78); | ||
@@ -106,3 +111,3 @@ os2.ulCodePageRange2 = data.readUInt32BE(82); | ||
if (os2.version >= 2) { | ||
if (os2.version >= 2 && data.length >= 96) { | ||
os2.sxHeight = data.readInt16BE(86); | ||
@@ -109,0 +114,0 @@ os2.sCapHeight = data.readInt16BE(88); |
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
137371
2742