Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ttfjs

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ttfjs - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

20

lib/ttf.js

@@ -101,16 +101,16 @@ var Directory = require('./directory')

this.widths = []
for (var code in this.codeMap) {
if (code < 32) continue
var gid = this.codeMap[code]
this.widths.push(Math.round(this.tables.hmtx.metrics[gid] * this.scaleFactor))
}
this.avgCharWidth = this.tables.os2 && (this.tables.os2.xAvgCharWidth * this.scaleFactor) || 0
this.avgCharWidth = this.tables.os2 && this.tables.os2.xAvgCharWidth || 0
}
TTFFont.prototype.stringWidth = function(string, size) {
var width = 0, scale = size / 1000
var width = 0, scale = size / this.tables.head.unitsPerEm
for (var i = 0, len = string.length; i < len; ++i) {
var code = string.charCodeAt(i) - 32 // - 32 because of non AFM font
width += this.widths[code] || this.avgCharWidth
var code = string.charCodeAt(i) //- 32 // - 32 because of non AFM font
if (code < 32) {
continue
}
var gid = this.codeMap[code]
width += this.tables.hmtx.metrics[gid] || this.avgCharWidth
}

@@ -117,0 +117,0 @@ return width * scale

@@ -8,3 +8,3 @@ {

"description": "TTFjs is a TrueType font parser entirely written in JavaScript and compatible to both Node.js and the Browser.",
"version": "0.3.0",
"version": "0.4.0",
"main": "./lib/ttf",

@@ -11,0 +11,0 @@ "homepage": "https://github.com/rkusa/ttfjs",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc