
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
font-manager-nw
Advanced tools
A C++ module for NW.js (formerly Node Webkit) providing access to the system font catalog. This is a fork of the great font-manager package by Devon Govett. But this version has been retooled to work with NW. If something is not working, please file an issue and/or issue a pull request. Thanks!
npm install -g nw
libfontconfig-dev
package: sudo apt-get install libfontconfig-dev
Install via npm:
npm install font-manager-nw
You load the font-manager
module using require
as with all Node modules:
var fontManager = require('font-manager-nw');
All of the methods exported by font-manager
have both synchronous and asynchronous versions available.
You should generally prefer the asynchronous version as it will allow your program to continue doing other
processing while a request for fonts is processing in the background, which may be expensive depending on
the platform APIs that are available.
getAvailableFonts()
findFonts(fontDescriptor)
findFont(fontDescriptor)
substituteFont(postscriptName, text)
Returns an array of all font descriptors available on the system.
// asynchronous API
fontManager.getAvailableFonts(function(fonts) { ... });
// synchronous API
var fonts = fontManager.getAvailableFontsSync();
// output
[ { path: '/Library/Fonts/Arial.ttf',
postscriptName: 'ArialMT',
family: 'Arial',
style: 'Regular',
weight: 400,
width: 5,
italic: false,
monospace: false },
... ]
Returns an array of font descriptors matching a query font descriptor. The returned array may be empty if no fonts match the font descriptor.
// asynchronous API
fontManager.findFonts({ family: 'Arial' }, function(fonts) { ... });
// synchronous API
var fonts = fontManager.findFontsSync({ family: 'Arial' });
// output
[ { path: '/Library/Fonts/Arial.ttf',
postscriptName: 'ArialMT',
family: 'Arial',
style: 'Regular',
weight: 400,
width: 5,
italic: false,
monospace: false },
{ path: '/Library/Fonts/Arial Bold.ttf',
postscriptName: 'Arial-BoldMT',
family: 'Arial',
style: 'Bold',
weight: 700,
width: 5,
italic: false,
monospace: false } ]
Returns a single font descriptors matching a query
font descriptors as well as possible. This method
always returns a result (never null
), so sometimes the output will not
exactly match the input font descriptor if not all input parameters
could be met.
// asynchronous API
fontManager.findFont({ family: 'Arial', weight: 700 }, function(font) { ... });
// synchronous API
var font = fontManager.findFontSync({ family: 'Arial', weight: 700 });
// output
{ path: '/Library/Fonts/Arial Bold.ttf',
postscriptName: 'Arial-BoldMT',
family: 'Arial',
style: 'Bold',
weight: 700,
width: 5,
italic: false,
monospace: false }
Substitutes the font with the given postscriptName
with another font
that contains the characters in text
. If a font matching postscriptName
is not found, a font containing the given characters is still returned. If
a font matching postscriptName
is found, its characteristics (bold, italic, etc.)
are used to find a suitable replacement. If the font already contains the characters
in text
, it is not replaced and the font descriptor for the original font is returned.
// asynchronous API
fontManager.substituteFont('TimesNewRomanPSMT', '汉字', function(font) { ... });
// synchronous API
var font = fontManager.substituteFontSync('TimesNewRomanPSMT', '汉字');
// output
{ path: '/Library/Fonts/Songti.ttc',
postscriptName: 'STSongti-SC-Regular',
family: 'Songti SC',
style: 'Regular',
weight: 400,
width: 5,
italic: false,
monospace: false }
Font descriptors are normal JavaScript objects that describe characteristics of
a font. They are passed to the findFonts
and findFont
methods and returned by
all of the methods. Any combination of the fields documented below can be used to
find fonts, but all methods return full font descriptors.
Name | Type | Description |
---|---|---|
path | string | The path to the font file in the filesystem. (not applicable for queries, only for results) |
postscriptName | string | The PostScript name of the font (e.g 'Arial-BoldMT' ). This uniquely identities a font in most cases. |
family | string | The font family name (e.g 'Arial' ) |
style | string | The font style name (e.g. 'Bold' ) |
weight | number | The font weight (e.g. 400 for normal weight). Should be a multiple of 100, between 100 and 900. See below for weight documentation. |
width | number | The font width (e.g. 5 for normal width). Should be an integer between 1 and 9. See below for width documentation. |
italic | boolean | Whether the font is italic or not. |
monospace | boolean | Whether the font is monospace or not. |
Value | Name |
---|---|
100 | Thin |
200 | Ultra Light |
300 | Light |
400 | Normal |
500 | Medium |
600 | Semi Bold |
700 | Bold |
800 | Ultra Bold |
900 | Heavy |
Value | Name |
---|---|
1 | Ultra Condensed |
2 | Extra Condensed |
3 | Condensed |
4 | Semi Condensed |
5 | Normal |
6 | Semi Expanded |
7 | Expanded |
8 | Extra Expanded |
9 | Ultra Expanded |
MIT
FAQs
Provides access to the system font catalog using nw.js
The npm package font-manager-nw receives a total of 0 weekly downloads. As such, font-manager-nw popularity was classified as not popular.
We found that font-manager-nw demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.