Yaku Han JP Documentation

repository·main·Indexed 19 days ago

https://github.com/qrac/yakuhanjp

A 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.

Tokens
3.2K
Snippets
12
Records
18
Agent score
65%

What's inside Yaku Han JP

  1. Overview of Yaku Han JP

    main
    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.
  2. Available Yaku Han JP Packages

    main

    The 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.
  3. Import yakuhanjp CSS files

    main

    After 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"
  4. Use Noto Sans JP in your application

    main

    Once 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 wght axis 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.
  5. Use Yaku Han JP via CDN

    main

    You can include Yaku Han JP fonts in your project without local installation by using the jsDelivr CDN. Follow these steps:

    1. Select the specific font type you wish to use (e.g., via the simulator).
    2. Copy the provided <link> tag and place it inside the <head> section of your HTML document.
    3. 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 the font-family declaration.
    <!-- 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>
  6. Use merged fonts for OGP image generation or game development

    main

    In environments where CSS fallback mechanisms are unavailable (such as OG image generation with satori or 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:

    1. Download the required font from the merged directory in the repository.
    2. Place the font files in your environment and configure the appropriate file paths.

    For a concrete implementation example using satori and @resvg/resvg-js for OG image generation, refer to the Playground implementation.

  7. Install Noto Sans JP fonts

    main

    To use Noto Sans JP, install the font files into your system or application. This package provides two ways to use the font:

    1. Variable Font: Use NotoSansJP-VariableFont_wght.ttf if your application supports variable fonts. This single file contains all weight styles via the wght axis, allowing you to select intermediate styles.
    2. 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
  8. Configure Minista assets and partials

    main

    The minista.config.ts file allows you to configure the Minista build process. Within the assets object, you can configure partial settings. Setting usePreact: true enables 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,
        },
      },
    })
  9. License information for Noto Sans JP

    main

    Noto 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.txt file included in this package.
  10. Use pluginOgp() in Vite

    main

    The 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()
      ]
    };