import type { CjkLineBreak } from '../types.js'; /** * Character classes of Chinese (and Japanese) text layout, after the W3C * "Requirements for Chinese Text Layout" (clreq §3.1 and §6.1) and GB/T * 15834—2011: what a line may not start or end with at each strictness * level, which marks never part (—— ……), and which characters take no * inter-character space when a justified line is spread. * * Japanese line breaking (kinsoku shori, JLReq §3.1.7–§3.1.10, JIS X 4051) * tells apart characters these classes merge: the small kana and ー (ideograph * and iteration here), 々 among the iteration marks, the hyphens among the * connectors, ?! among the stops, :; among the pauses. The Japanese * levels read them from the grapheme ({@link breakClassOf}); every other * use of a class (widths, spacing, justification) and the Chinese levels * see only the classes below. * * A class is read from the first code point of a grapheme. The marks Latin * text shares with Chinese (— … · “ ” ‘ ’) are classed as Chinese marks * here: the table is only consulted for paragraphs set by the CJK composer * (`cjkCompose.ts`) and for the joints of words that hold CJK, where they * are Chinese punctuation. The apostrophe of a Latin word ("don’t") and the * interpunct inside one ("l·l") are kept in their word by the unit builder. */ /** How strictly lines avoid starting or ending with punctuation. The * Chinese levels (clreq §6.1.1): `none`: anywhere between characters * (Taiwan and Hong Kong newspapers). `basic`: no pause or stop mark, * closing bracket or quote, connector, interpunct or iteration mark opens * a line, and no opening bracket or quote closes one. `gb`: `basic` plus * the solidus at either end (GB/T 15834—2011 §5.1.9). `strict`: `gb` plus * the two-em dash and the ellipsis at the start of a line. The Japanese * levels (JLReq Appendix C.3): `ja-very-strict` (JIS X 4051), `ja-strict` * (small kana, ー and 々 may open a line) and `ja-loose` (newspapers); see * {@link isLineStartProhibited}. */ export type CjkLineBreakLevel = CjkLineBreak; export declare const CJK_LINE_BREAK_LEVELS: readonly CjkLineBreakLevel[]; /** Whether a level is one of the Japanese ones (`ja-…`). */ export declare function isJapaneseLineBreak(level: CjkLineBreakLevel): boolean; export type CjkClass = /** Han, kana, hangul, bopomofo, fullwidth letters and digits, 〇, emoji * and the CJK symbols: a line may break before and after each (the * composer keeps a run of fullwidth digits or letters together, see * {@link isFullwidthAlnum}). */ 'ideograph' /** Opening brackets and quotes: (〔[{【〖《〈「『“‘ and ASCII ( [ {. */ | 'opening' /** Closing brackets and quotes: )〕]}】〗》〉」』”’ and ASCII ) ] }. */ | 'closing' /** Pause marks: 、,;: and ASCII , ; : */ | 'pause' /** Stop marks: 。.!?‼⁇⁈⁉ and ASCII . ! ? */ | 'stop' /** Interpuncts: · ‧ ・ ・ */ | 'interpunct' /** Iteration marks and the prolonged sound mark: 々〻ゝゞヽヾー */ | 'iteration' /** Dashes: — ― ⸺ ⸻ (two U+2014 in a row are one unit, 破折号). */ | 'dash' /** Ellipses: … ‥ ⋯ (two in a row are one unit, 省略号). */ | 'ellipsis' /** Connectors: – ~ 〜 ~ 〰 ゠ */ | 'connector' /** Solidus: / / */ | 'solidus' /** The ideographic space U+3000: a fixed character one em wide; a line * may break after it, never before. */ | 'ideoSpace' /** Signs a number takes before it: ¥ $ € £ ₩ ¥ $ £ ± − + (the ASCII * plus is Western text: `C++` may end a line). */ | 'prefix' /** Signs a number takes after it: % ‰ ‱ ° ℃ ℉ ′ ″ % and the unit * squares ㎡ ㎏ ㎞ ㏄ (U+3371–337A, U+3380–33DF, U+33FF), which are set * in the Western run of their number. */ | 'postfix' /** Latin, Greek, Cyrillic letters, digits and everything else: set in * runs a line never breaks inside. */ | 'western' /** U+200B, the zero-width space: a break opportunity, not printed. */ | 'zwsp'; /** The classes the Japanese levels break by: the {@link CjkClass} of a * grapheme, or one of the JLReq classes (Appendix A) a Chinese class holds * together with others, which {@link breakClassOf} reads from the * grapheme under a Japanese level only. */ export type CjkBreakClass = CjkClass /** Small kana, cl-11: ぁぃぅぇぉっゃゅょゎゕゖ ァィゥェォッャュョヮヵヶ ㇰ–ㇿ * ァ–ッ and the small kana of the Kana Extended blocks (ideographs to * the Chinese levels). */ | 'smallKana' /** The prolonged sound mark ー (ー), cl-10. */ | 'prolonged' /** 々, the one iteration mark `ja-strict` lets open a line. */ | 'kanjiIteration' /** Hyphens, cl-03: ‐ – ゠ 〜 and ~ (U+FF5E, which Japanese text types for * 〜; JLReq §3.1.7 note). */ | 'hyphen' /** Dividing punctuation, cl-04: ?!‼⁇⁈⁉ (stops to the Chinese levels). */ | 'dividing' /** Middle dots, cl-05: ・ : ; and the other interpuncts (pauses or * interpuncts to the Chinese levels). */ | 'middleDot' /** 〳 〴 〵, the halves of the vertical kana repeat mark: cl-08 * inseparable characters, which may open a line but never part from * each other (iteration marks to the Chinese levels). */ | 'inseparable'; /** Set the level {@link getCjkLineBreak} returns (the build does, from the * resolved `cjk.lineBreak`). */ export declare function setCjkLineBreak(level: CjkLineBreakLevel): void; /** The document's line-break level for CJK text (see * {@link setCjkLineBreak}); `gb` until a build sets another. */ export declare function getCjkLineBreak(): CjkLineBreakLevel; /** Whether a line may break between two graphemes that touch: `a` (class * `aCls`, a CJK grapheme when `aCjk`) and `b` after it. Only next to a CJK * grapheme — two Western graphemes never part here — and never before the * ideographic space; at `level`, no prohibited mark opens or closes a * line. Under a Japanese level the graphemes, when given (`aG`, `bG`: the * last of the text before and the first after), refine the classes * ({@link breakClassOf}) and keep the inseparable pairs whole * ({@link isInseparablePair}). */ export declare function cjkBreakAllowed(aCls: CjkClass, aCjk: boolean, bCls: CjkClass, bCjk: boolean, level: CjkLineBreakLevel, aG?: string, bG?: string): boolean; /** Whether a grapheme of `cls` may not open a line at `level`. Under a * Japanese level `grapheme`, when given, refines the class * ({@link breakClassOf}); the Chinese levels never read it. * * The Japanese levels (JLReq §3.1.7 and Appendix C.3). At all three no * line opens with a closing bracket or quote (cl-02, and the warichu's * cl-29), 、, (cl-07) or 。. (cl-06). `ja-very-strict` (JIS X 4051's * default) adds the hyphens (cl-03), ?! (cl-04), the middle dots (cl-05), * the iteration marks (cl-09), ー (cl-10), the small kana (cl-11) and a unit * sign; `ja-strict` lets a small kana, ー and 々 open a line (JLReq's * convention for books in general); `ja-loose` (the newspapers' very * loose convention) lets all of them but the first group. The two-em * dash and the ellipsis (cl-08) may open a line at every Japanese level, * and the solidus has no rule (GB/T's only). */ export declare function isLineStartProhibited(cls: CjkBreakClass, level: CjkLineBreakLevel, grapheme?: string): boolean; /** Whether a grapheme of `cls` may not close a line at `level` (`grapheme` * as for {@link isLineStartProhibited}). At every Japanese level an * opening bracket or quote (cl-01, and the warichu's cl-28); a currency * sign (cl-12) too, but at `ja-loose`, which lets one end a line away * from a number (a number keeps its signs at every level). */ export declare function isLineEndProhibited(cls: CjkBreakClass, level: CjkLineBreakLevel, grapheme?: string): boolean; /** * The class a Japanese level breaks `grapheme` by, given its class `cls` * (as the composer set it on the grapheme's unit): the JLReq class * (Appendix A) where the clreq class merges several, else `cls`. Under a * Chinese level, `cls` unchanged. Only a grapheme whose `cls` is the one * {@link cjkClassOf} gives it is refined, so a unit whose class the * composer set (an upright number cell, a single em dash read as a * connector) keeps what the composer meant: * - an ideograph that is a small kana → `smallKana`; * - ー → `prolonged`; 々 → `kanjiIteration`; 〳 〴 〵 → `inseparable`; * - a hyphen, connector or Western grapheme in {@link HYPHEN} → `hyphen`; * a single — or ― (a connector to clreq) → `dash`, which may open a * Japanese line; * - ?! → `dividing`; :; and the interpuncts → `middleDot`. */ export declare function breakClassOf(grapheme: string, cls: CjkBreakClass, level: CjkLineBreakLevel): CjkBreakClass; /** Two graphemes a Japanese line never breaks between (分離禁止, JLReq * §3.1.10): the same inseparable character twice (―― —— …… ‥‥, cl-08; * the composer sets ――, —— and …… as one unit already, this keeps a third * with them and ‥‥ whole), and the two halves of the vertical kana repeat * mark (〳〵, 〴〵). Two different ones may part. */ export declare function isInseparablePair(a: string, b: string): boolean; /** The squared Latin abbreviations of units in the CJK compatibility * block: ㍱ hPa to ㍺ IU, ㎀ pA to ㏟ A∕m, ㏿ gal. They follow a number as * % does, in any script, and are no CJK text. */ export declare function isUnitSquare(cp: number): boolean; /** Fullwidth digits 0–9. */ export declare function isFullwidthDigit(cp: number): boolean; /** Fullwidth digits and Latin letters (0–9, A–Z, a–z): set one em * wide like ideographs, but a number or a word a line never breaks * inside. */ export declare function isFullwidthAlnum(cp: number): boolean; /** The circled, parenthesized and full-stop numbers and letters of * Enclosed Alphanumerics (①–⑳, ⑴–⒇, ⒈–⒛, ⒜–⒵, Ⓐ–ⓩ, ⓪, ⓫–⓿) and the * dingbat circled numbers (❶–❿, ➀–➓): East Asian Width ambiguous, wide * in East Asian text, where they number senses, items and steps. */ export declare function isEnclosedAlphanumeric(cp: number): boolean; /** Set whether circled numbers are set as Chinese characters (see * {@link isEnclosedAlphanumeric}); returns the setting it replaces. */ export declare function setCjkCircledNumbers(asCjk: boolean): boolean; /** See {@link setCjkCircledNumbers}; true until a build sets it. */ export declare function getCjkCircledNumbers(): boolean; /** Whether a line may not end on `grapheme` at `level` because it is a * circled number set as a Chinese character (#637): it labels the text * after it (`①天也`), as a currency sign does its number, and is kept off * a line end at the levels that keep the prefix signs off one: `basic`, * `gb`, `strict`, `ja-very-strict` and `ja-strict`; `none` and * `ja-loose` let it end a line. */ export declare function isLabelEndProhibited(grapheme: string | undefined, level: CjkLineBreakLevel): boolean; /** The class of a grapheme, read from its first code point. */ export declare function cjkClassOf(grapheme: string): CjkClass; /** Whether a grapheme is set as a Chinese character in a CJK paragraph: it * opens a unit of its own instead of joining a Western run. The ASCII * marks (`,` `.` `(` `%`…) and the signs of numbers stay in the Western * run they touch; the marks Chinese shares with Latin text (— … · “ ” ‘ ’ * – ~) are Chinese marks, except the apostrophe or the interpunct of a * Latin word, which the unit builder keeps in it. */ export declare function isCjkGrapheme(grapheme: string): boolean; /** Whether a grapheme is a letter or digit of Western text (the neighbours * of an apostrophe or an interpunct kept inside a word). */ export declare function isWesternWordChar(grapheme: string | undefined): boolean; /** Whether an apostrophe or an interpunct sits inside a Latin word * ("don’t", "l·l"): between two letters or digits of Western text. It * belongs to the word then — the composer keeps it in the word's run, and * vertical text sets it sideways with the word — not to the Chinese text * around it. */ export declare function isWordInnerMark(grapheme: string, prev: string | undefined, next: string | undefined): boolean; /** Whether a code point is a mark a browser sets half width when it meets * another (CSS `text-spacing-trim`, OpenType `chws`/`halt`): an opening or * closing bracket or quote, a pause or stop mark, an interpunct, the * ideographic space. The marks of the CJK blocks always; the marks Latin * text shares with Chinese (“ ” ‘ ’ · ‧ « »…) only when `shared` is set * (the text is Chinese). ASCII never. */ export declare function isTrimmableMark(cp: number, shared: boolean): boolean; /** * Where to cut `text` so that no piece holds two CJK marks side by side: * the offsets (UTF-16) between each such pair. Chrome (CSS * `text-spacing-trim: normal`, and fonts with `chws`) sets the first of * `)》`, `”“`, `》。` or `。《` half width when a run is measured or painted * whole — `本)》录` in Noto Serif SC is 3.5 em as one run and 4 em * character by character — while the CJK composer measures every * character alone and adjusts the marks itself (`cjk.punctuationWidth`). * Measuring and painting such text piece by piece keeps the browser out of * it. `shared` counts the marks Latin text shares with Chinese (“ ” ‘ ’ ·): * set it for Chinese text only, so a Latin `’”` is never cut. Empty for * text with no such pair. */ export declare function cjkMarkCuts(text: string, shared: boolean): number[]; /** `text` cut at {@link cjkMarkCuts}: one piece when there is no cut. */ export declare function cjkMarkPieces(text: string, shared: boolean): string[]; //# sourceMappingURL=cjkClasses.d.ts.map