Yaku Han JP Documentation
repository·main·Indexed 19 days ago
https://github.com/qrac/yakuhanjpA font project that converts full-width Japanese punctuation and symbols (yakumono) into half-width versions to improve visual density and spacing. It provides specialized packages for browser use (yakuhanjp), raw font data (core), merged fonts for OGP image generation or game development (merged), and Unicode generation scripts (unicode). Supports installation via npm or CDN and includes integration tools for Vite and Satori.
What's inside Yaku Han JP
- Yaku Han JP (ヤクハンジェイピー) is a font project designed to convert full-width punctuation and symbols (約物 - yakumono) within Japanese text into half-width characters. This is useful for tightening visual spacing in specific UI contexts, such as Open Graph (OGP) images or web typography.
Available Yaku Han JP Packages
mainThe project is split into several specialized packages depending on your use case:
yakuhanjp: The package intended for use directly in browsers.core: Contains the raw YakuHanJP font data.merged: Contains data for YakuHanJP merged into base fonts.unicode: Scripts for generating Unicode values for the included characters.
Import yakuhanjp CSS files
mainAfter installing the package, import the specific CSS file corresponding to the version of Yaku Han JP you wish to use in your application's entry point or CSS file.
/* YakuHanJP */ import "yakuhanjp" /* YakuHanJPs */ import "yakuhanjp/dist/css/yakuhanjp_s.css" /* YakuHanMP */ import "yakuhanjp/dist/css/yakuhanmp.css" /* YakuHanMPs */ import "yakuhanjp/dist/css/yakuhanmp_s.css" /* YakuHanRP */ import "yakuhanjp/dist/css/yakuhanrp.css" /* YakuHanRPs */ import "yakuhanjp/dist/css/yakuhanrp_s.css"Use Noto Sans JP in your application
mainOnce the font files are installed, use your application's font picker to select the Noto Sans JP font family.
- If using the Variable Font, you can adjust the
wghtaxis to achieve any weight between the available extremes. - If using Static Fonts, select the specific weight file (e.g.,
NotoSansJP-Bold.ttf) required for your design.
- If using the Variable Font, you can adjust the
Use Yaku Han JP via CDN
mainYou can include Yaku Han JP fonts in your project without local installation by using the jsDelivr CDN. Follow these steps:
- Select the specific font type you wish to use (e.g., via the simulator).
- Copy the provided
<link>tag and place it inside the<head>section of your HTML document. - Update your CSS to prioritize the Yaku Han JP font by placing
YakuHanJP(or the specific font name) before your fallback Japanese font families in thefont-familydeclaration.
<!-- 1. Place the link tag in your <head> --> <link href="https://cdn.jsdelivr.net/npm/yakuhanjp/dist/yakuhanjp-regular.css" rel="stylesheet"> <!-- 2. Use in your CSS --> <style> body { font-family: "YakuHanJP", "Noto Sans JP", sans-serif; } </style>Use merged fonts for OGP image generation or game development
mainIn environments where CSS fallback mechanisms are unavailable (such as OG image generation with
satorior game development), use the merged fonts provided by YakuHanJP. These fonts have the YakuHanJP logic integrated directly into the original Google Fonts.To use them:
- Download the required font from the merged directory in the repository.
- Place the font files in your environment and configure the appropriate file paths.
For a concrete implementation example using
satoriand@resvg/resvg-jsfor OG image generation, refer to the Playground implementation.Install Noto Sans JP fonts
mainTo use Noto Sans JP, install the font files into your system or application. This package provides two ways to use the font:
- Variable Font: Use
NotoSansJP-VariableFont_wght.ttfif your application supports variable fonts. This single file contains all weight styles via thewghtaxis, allowing you to select intermediate styles. - Static Fonts: If your application does not support variable fonts, use the individual files located in the
static/directory.
# Variable Font (Single file for all weights) NotoSansJP-VariableFont_wght.ttf # Static Fonts (Individual files per weight) static/NotoSansJP-Thin.ttf static/NotoSansJP-ExtraLight.ttf static/NotoSansJP-Light.ttf static/NotoSansJP-Regular.ttf static/NotoSansJP-Medium.ttf static/NotoSansJP-SemiBold.ttf static/NotoSansJP-Bold.ttf static/NotoSansJP-ExtraBold.ttf static/NotoSansJP-Black.ttf- Variable Font: Use
Install yakuhanjp via npm
mainInstall the
yakuhanjppackage using npm to use the Yaku Han JP font styles in your project.$ npm install yakuhanjpConfigure Minista assets and partials
mainThe
minista.config.tsfile allows you to configure the Minista build process. Within theassetsobject, you can configurepartialsettings. SettingusePreact: trueenables the use of Preact for partials, which can be used to optimize performance or compatibility when rendering components within your Minista site.import { defineConfig } from "minista" export default defineConfig({ assets: { partial: { usePreact: true, }, }, })Yaku Han JP Licensing
mainYaku Han JP is dual-licensed under SIL OFL 1.1 and MIT.
Note that the underlying fonts used in the project have their own licenses:
- Gothic fonts: Based on Noto Sans JP (SIL OFL 1.1).
- Mincho fonts: Based on Noto Serif JP (SIL OFL 1.1).
- Round Gothic fonts: Based on M PLUS Rounded 1c (SIL OFL 1.1).
License information for Noto Sans JP
mainNoto Sans JP is provided under the OFL (Open Font License).
- You may use the fonts in your products and projects (print, digital, commercial, or otherwise).
- For full details regarding permissions, restrictions, and requirements for usage, redistribution, and modification, you must read the
OFL.txtfile included in this package.
Use pluginOgp() in Vite
mainThe
pluginOgp()function provides a Vite plugin that exposes an API endpoint for generating Open Graph Protocol (OGP) images. When the plugin is active, it adds a middleware that listens for requests to/api/generate-ogp.To use this plugin, include it in your Vite configuration. The endpoint accepts query parameters to customize the generated image, specifically the text content, the font name, and the font weight.
import { pluginOgp } from './path/to/plugin'; export default { plugins: [ pluginOgp() ] };