cjk

command
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

CJK demonstrates PDF generation with Chinese, Japanese, and Korean text.

It exercises CJK-aware line breaking: ideographs, kana, and hangul characters break at character boundaries, while kinsoku shori rules keep opening punctuation grouped with the following character and closing punctuation grouped with the preceding character. Font embedding uses CIDFont Type0 with Identity-H encoding and ToUnicode mapping for copy/paste, so extracted text round-trips cleanly.

Required fonts (the example exits with a message if none resolve). SC-specific variants come first because the example body is in Simplified Chinese; pan-CJK collections (NotoSansCJK-Regular.ttc, msgothic.ttc) are accepted as fallbacks but their default face is JP and the rendered glyphs lean Japanese:

macOS   /Library/Fonts/Arial Unicode.ttf
        /System/Library/Fonts/STHeiti Light.ttc
        /System/Library/Fonts/Hiragino Sans GB.ttc
        /System/Library/Fonts/PingFang.ttc
Linux   /usr/share/fonts/opentype/noto/NotoSansSC-Regular.otf  (SC-specific)
        /usr/share/fonts/truetype/wqy/wqy-zenhei.ttc          (SC-specific)
        /usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc (pan-CJK fallback)
Windows C:\Windows\Fonts\simsun.ttc                            (SC-native)
        C:\Windows\Fonts\msyh.ttc                              (SC-native)
        C:\Windows\Fonts\msgothic.ttc                          (JP fallback)

Programmatic callers who load a TTC directly (without going through @font-face url()) can pick a non-default face by language using font.ParseFontForLanguage("zh-CN", data) instead of font.ParseFont(data); see the font package documentation.

Usage:

go run ./examples/cjk

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL