npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mfont

v0.0.9

Published

install font without reboot and remove font in windows

Downloads

4

Readme

windows安装字体不重启

本人在开发electron-vue的一个项目中需要将字体本地化,mac和linux中直接复制字体到默认字体库内即可使用,但是windows却不行,需要写入信息到注册表,并且还需要通过api发送已经更新了字体的消息,才能达到字体使用无需重启的目的,所以才有了这个项目。

项目使用NodeJs中的N-Api的方式,用C++的代码实现注册表写入和字体更新api消息推送。

安装字体无需重启; 卸载字体则需要重启才能生效,卸载字体也不会去删除字体文件,只会删除其注册表项目。

要求:

  1. 只用于windows系统, 非windows系统返回都是0,错误提示为系统不是windows
  2. 需要保证字体文件存在于windows的默认字体库内;
  3. 文件名必须和字体文件内设置的字体名称一致(因为本人项目中的字体文件名称是md5值,所以和字体文件内设置的字体名是不一致的,不一致的情况很可能造成注册成功也无法使用字体);
  4. 字体文件必须是正常能使用的字体文件

开发环境

  • Visual Studio 2015 with c++ installed
  • Python 2.7

安装


npm install mfont

使用范例

// 引用

import MFont from 'mfont'

// 查询字体-字体在系统中是否可用 (只支持字体名称为英文的查询)

let temp0 = MFont.hasFont('SimSun')
if (temp0 === '1') {
    return '字体在系统中可用'
} else {
    return MFont.getError()
}

// 安装字体

// 情况1:字体文件内设置的字体名称 === 字体文件名称
// 使用方法:installFont(字体文件名称)
// 返回结果:String  成功返回1,失败返回0,使用getError方法获取错误信息
let temp1 = MFont.installFont('temp1.ttf')
if (temp1 === '1') {
    return '注册字体成功'
} else {
    return MFont.getError()
}

// 情况2:字体文件内设置的字体名称 !== 字体文件名称
// 使用方法:installFont(字体文件名称, 预注册的字体名)
// 返回结果:String  成功返回1,失败返回0,使用getError方法获取错误信息
let temp2 = MFont.installFont('temp2.ttf', 't2')
if (temp2 === '1') {
    return '注册字体成功'
} else {
    return MFont.getError()
}

// 卸载字体

// 情况1:字体文件内设置的字体名称 === 字体文件名称
// 使用方法:removeFont(字体文件名称)
// 返回结果:String  成功返回1,失败返回0,使用getError方法获取错误信息
let temp3 = MFont.removeFont('temp3.ttf')
if (temp3 === '1') {
    return '卸载字体成功'
} else {
    return MFont.getError()
}

// 情况2:字体文件内设置的字体名称 !== 字体文件名称
// 使用方法:removeFont(字体文件名称, 预注册的字体名)
// 返回结果:String  成功返回1,失败返回0,使用getError方法获取错误信息
let temp4 = MFont.removeFont('temp4.ttf', 't4')
if (temp4 === '1') {
    return '卸载字体成功'
} else {
    return MFont.getError()
}

项目地址