@furifont/core 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +156 -139
- package/dist/index.mjs +545 -368
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -10,15 +10,8 @@ export declare const DEFAULTS: {
|
|
|
10
10
|
readonly plan: {
|
|
11
11
|
readonly family: "Furifont Sans";
|
|
12
12
|
readonly rubyScript: "hiragana";
|
|
13
|
-
/**
|
|
14
|
-
readonly
|
|
15
|
-
readonly nfMax: 48;
|
|
16
|
-
/** JMdict priority tags that select a word whatever its bucket: the first tier of each list, which JMdict marks as common. */
|
|
17
|
-
readonly selectTags: readonly ["ichi1", "news1", "spec1", "gai1"];
|
|
18
|
-
/** Uses in Tatoeba's example sentences that select a word whatever its bucket: about 1,000 more words, and 50 glyphs. */
|
|
19
|
-
readonly minTatoeba: 3;
|
|
20
|
-
readonly places: true;
|
|
21
|
-
readonly untagged: true;
|
|
13
|
+
/** No word is left bare for being common; every word of every source gets ruby. */
|
|
14
|
+
readonly skip: 0;
|
|
22
15
|
readonly isolated: true;
|
|
23
16
|
readonly isolatedMinShare: 0.8;
|
|
24
17
|
/** Sizes in em, relative to the base font. */
|
|
@@ -72,7 +65,7 @@ export declare const PREBUILT: {
|
|
|
72
65
|
readonly style: "VF";
|
|
73
66
|
readonly weights: readonly [250, 900];
|
|
74
67
|
};
|
|
75
|
-
/** Options set on every prebuilt font over the defaults above, such as `{
|
|
68
|
+
/** Options set on every prebuilt font over the defaults above, such as `{ take: 20000 }`. */
|
|
76
69
|
readonly options: {};
|
|
77
70
|
};
|
|
78
71
|
/**
|
|
@@ -86,80 +79,31 @@ export declare const VERSION_PROBE: {
|
|
|
86
79
|
readonly selector: 65024;
|
|
87
80
|
};
|
|
88
81
|
//#endregion
|
|
89
|
-
//#region src/dictionary.d.ts
|
|
90
|
-
/** One (written form, reading) pair, as compiled by `@furifont/dictionary`. */
|
|
91
|
-
interface DictionaryEntry {
|
|
92
|
-
form: string;
|
|
93
|
-
/** JmdictFurigana alignment: `0:に;1:ほん`, or `0-1:きょう` for a reading spanning characters. */
|
|
94
|
-
furigana: string;
|
|
95
|
-
/** The form's newspaper frequency bucket (nf01..nf48), 0 when unranked. */
|
|
96
|
-
nf: number;
|
|
97
|
-
/** The reading's JMdict priority tags, space separated; empty for uncommon readings. */
|
|
98
|
-
priority: string;
|
|
99
|
-
/** Position of the reading among the form's readings, in JMdict order. */
|
|
100
|
-
order: number;
|
|
101
|
-
/** `来る`-type verb, whose kanji reads differently as it conjugates. */
|
|
102
|
-
conjugatesReading?: boolean;
|
|
103
|
-
/** The JLPT level whose word list has this pair: 5 for N5 down to 1 for N1. */
|
|
104
|
-
jlpt?: number;
|
|
105
|
-
/** How many times Tatoeba's example sentences use the pair, spelled this way. */
|
|
106
|
-
tatoeba?: number;
|
|
107
|
-
}
|
|
108
|
-
interface Dictionary {
|
|
109
|
-
entries: DictionaryEntry[];
|
|
110
|
-
/** Kanji to its on'yomi, in hiragana. */
|
|
111
|
-
onyomi: Record<string, string[]>;
|
|
112
|
-
/** Source datasets and the version each was compiled from. */
|
|
113
|
-
sources: Record<string, string>;
|
|
114
|
-
/** Written forms never to annotate, such as 月, whose reading alone is a guess; users' removals add to them. */
|
|
115
|
-
bare?: string[];
|
|
116
|
-
/** Curated default readings in inline notation, for words the data ranks wrong; pins override them. */
|
|
117
|
-
defaults?: string[];
|
|
118
|
-
/** Place names, each with the one reading to show; common words take precedence over them. */
|
|
119
|
-
places?: {
|
|
120
|
-
form: string;
|
|
121
|
-
furigana: string;
|
|
122
|
-
}[];
|
|
123
|
-
/** Word lists kept by hand, by source name, in inline notation; like place names, they fill runs no common word claims. */
|
|
124
|
-
manual?: Record<string, string[]>;
|
|
125
|
-
}
|
|
126
|
-
/** A ruby annotation over characters `[start, end)` of a run. */
|
|
127
|
-
interface RubySpan {
|
|
128
|
-
start: number;
|
|
129
|
-
end: number;
|
|
130
|
-
ruby: string;
|
|
131
|
-
}
|
|
132
|
-
/** A maximal sequence of Han characters with its reading, the unit a shaper sees. */
|
|
133
|
-
interface HanRun {
|
|
134
|
-
text: string;
|
|
135
|
-
spans: RubySpan[];
|
|
136
|
-
}
|
|
137
|
-
export declare function isHan(char: string): boolean;
|
|
138
|
-
export declare function parseFurigana(furigana: string): RubySpan[];
|
|
139
|
-
/**
|
|
140
|
-
* Splits a form into its Han runs. Browsers itemize text by script before
|
|
141
|
-
* shaping, so a font only ever sees one run at a time: okurigana and other
|
|
142
|
-
* kana are never visible as context. Runs with an unannotated kanji or an
|
|
143
|
-
* annotation leaking outside the run are dropped.
|
|
144
|
-
*/
|
|
145
|
-
export declare function hanRuns(form: string, spans: readonly RubySpan[]): HanRun[];
|
|
146
|
-
/**
|
|
147
|
-
* Parses the inline notation for custom words: `日[に]本[ほん]` for one reading
|
|
148
|
-
* per kanji, `今日[きょう]` for a reading over several kanji, kana as written.
|
|
149
|
-
*/
|
|
150
|
-
export declare function parseNotation(notation: string): {
|
|
151
|
-
form: string;
|
|
152
|
-
spans: RubySpan[];
|
|
153
|
-
};
|
|
154
|
-
export declare function formatNotation(text: string, spans: readonly RubySpan[]): string;
|
|
155
|
-
//#endregion
|
|
156
82
|
//#region src/schema.d.ts
|
|
157
83
|
export declare const RUBY_SCRIPTS: readonly ["hiragana", "katakanaOn", "hepburn"];
|
|
158
|
-
|
|
84
|
+
/** The dictionary's manually maintained sources. */
|
|
85
|
+
export declare const MANUAL_SOURCES: readonly ["mahjong-yaku", "jr-stations", "yojijukugo", "japan-post"];
|
|
86
|
+
type ManualSource = typeof MANUAL_SOURCES[number];
|
|
87
|
+
/**
|
|
88
|
+
* The sources a plan takes words from: any JMdict word; JMdict's priority
|
|
89
|
+
* lists (both tiers of each) and its newspaper ranking; words Tatoeba's
|
|
90
|
+
* sentences use at least three times; JMnedict's place names; the manual lists.
|
|
91
|
+
*/
|
|
92
|
+
export declare const WORD_SOURCES: readonly ["jmdict", "ichi", "news", "spec", "gai", "nf", "tatoeba", "place", "mahjong-yaku", "jr-stations", "yojijukugo", "japan-post"];
|
|
93
|
+
type WordSource = typeof WORD_SOURCES[number];
|
|
159
94
|
/** Easiest first. */
|
|
160
|
-
/** The dictionary's manually maintained sources, which a plan may include by name. */
|
|
161
|
-
export declare const MANUAL_SOURCES: readonly ["mahjong-yaku", "jr-stations", "yojijukugo"];
|
|
162
95
|
export declare const JLPT_LEVELS: readonly ["N5", "N4", "N3", "N2", "N1"];
|
|
96
|
+
/**
|
|
97
|
+
* Every source a reading may have, a bit each in this order: the word
|
|
98
|
+
* sources, then the easiest JLPT level listing it, `inflecting` (a kanji read
|
|
99
|
+
* before okurigana in a JMdict word no list tags, such as 奉る) and `default`,
|
|
100
|
+
* the dictionary's curated default.
|
|
101
|
+
*/
|
|
102
|
+
export declare const SOURCES: readonly ["jmdict", "ichi", "news", "spec", "gai", "nf", "tatoeba", "place", "mahjong-yaku", "jr-stations", "yojijukugo", "japan-post", "N5", "N4", "N3", "N2", "N1", "inflecting", "default"];
|
|
103
|
+
type Source = typeof SOURCES[number];
|
|
104
|
+
export declare const sourceBit: (source: Source) => number;
|
|
105
|
+
/** The sources a mask of `SOURCES` bits names. */
|
|
106
|
+
export declare const sourcesIn: (mask: number) => Source[];
|
|
163
107
|
type RubyScript = typeof RUBY_SCRIPTS[number];
|
|
164
108
|
/** Sizes in em, relative to the base font. */
|
|
165
109
|
declare const RubyMetricsSchema: v.ObjectSchema<{
|
|
@@ -173,42 +117,17 @@ declare const RubyMetricsSchema: v.ObjectSchema<{
|
|
|
173
117
|
readonly maxRubyWidth: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, 3, undefined>]>, 1.5>;
|
|
174
118
|
}, undefined>;
|
|
175
119
|
type RubyMetrics = v.InferOutput<typeof RubyMetricsSchema>;
|
|
176
|
-
|
|
177
|
-
export declare function withNfWindow<T extends v.GenericSchema<unknown, {
|
|
178
|
-
nfMin: number;
|
|
179
|
-
nfMax: number;
|
|
180
|
-
}>>(schema: T): v.SchemaWithPipe<readonly [T, v.CheckAction<v.InferOutput<T>, string>]>;
|
|
181
|
-
export declare const PlanOptionsSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
120
|
+
export declare const PlanOptionsSchema: v.ObjectSchema<{
|
|
182
121
|
readonly family: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.NonEmptyAction<string, undefined>, v.CheckAction<string, "Source is a reserved font name of the base font">]>, "Furifont Sans">;
|
|
183
122
|
readonly rubyScript: v.OptionalSchema<v.PicklistSchema<readonly ["hiragana", "katakanaOn", "hepburn"], undefined>, "hiragana">;
|
|
184
|
-
/**
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
readonly nfMax: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, 48, undefined>]>, 48>;
|
|
191
|
-
/**
|
|
192
|
-
* JMdict priority tags that select a word whatever its frequency bucket:
|
|
193
|
-
* `spec1` catches words like 日本 that the newspaper ranking misses.
|
|
194
|
-
*/
|
|
195
|
-
readonly selectTags: v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["ichi1", "ichi2", "news1", "news2", "spec1", "spec2", "gai1", "gai2"], undefined>, undefined>, () => ("ichi1" | "news1" | "spec1" | "gai1")[]>;
|
|
196
|
-
/**
|
|
197
|
-
* Words of two or more kanji that Tatoeba's example sentences use at least
|
|
198
|
-
* this many times are annotated whatever their bucket: everyday words that
|
|
199
|
-
* no list tags, such as 留守中, which would otherwise be bare or read as a
|
|
200
|
-
* place name (国中 くになか, not くにじゅう). The sentences also decide how a
|
|
201
|
-
* lone kanji reads, where they use it alone often enough. 0 turns them off.
|
|
202
|
-
*/
|
|
203
|
-
readonly minTatoeba: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, 3>;
|
|
123
|
+
/** The sources whose words get ruby. */
|
|
124
|
+
readonly sources: v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["jmdict", "ichi", "news", "spec", "gai", "nf", "tatoeba", "place", "mahjong-yaku", "jr-stations", "yojijukugo", "japan-post"], undefined>, undefined>, () => ("mahjong-yaku" | "jr-stations" | "yojijukugo" | "japan-post" | "jmdict" | "ichi" | "news" | "spec" | "gai" | "nf" | "tatoeba" | "place")[]>;
|
|
125
|
+
/** The most common words left bare, by score: a reader knows them. Lone kanji count too. */
|
|
126
|
+
readonly skip: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, 0>;
|
|
127
|
+
/** How many words get ruby after those skipped, by score; all of them when left out. */
|
|
128
|
+
readonly take: v.OptionalSchema<v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, v.MinValueAction<number, 1, undefined>]>, undefined>;
|
|
204
129
|
/** Words on the JLPT lists of this level and every easier one stay bare. */
|
|
205
130
|
readonly skipJlpt: v.OptionalSchema<v.PicklistSchema<readonly ["N5", "N4", "N3", "N2", "N1"], undefined>, undefined>;
|
|
206
|
-
/** Annotate place names from the dictionary where no common word claims the run. */
|
|
207
|
-
readonly places: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
|
|
208
|
-
/** Annotate the words of JMdict that no list ranks or tags (such as 四字熟語), where no common word, manual list or place name claims the run; each gets its first reading. */
|
|
209
|
-
readonly untagged: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
|
|
210
|
-
/** The dictionary's manually maintained sources (such as `mahjong-yaku`) to annotate; all of them when left out. */
|
|
211
|
-
readonly manual: v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["mahjong-yaku", "jr-stations", "yojijukugo"], undefined>, undefined>, undefined>;
|
|
212
131
|
/** Annotate a kanji alone in its run, or one no word claims after another kanji (a suffix); when off, only selectors give them ruby. */
|
|
213
132
|
readonly isolated: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
|
|
214
133
|
/** A kanji alone in its run is annotated only when one reading has this share of the evidence. */
|
|
@@ -231,31 +150,7 @@ export declare const PlanOptionsSchema: v.SchemaWithPipe<readonly [v.ObjectSchem
|
|
|
231
150
|
/** Widest a ruby may get, overhanging its base symmetrically. */
|
|
232
151
|
readonly maxRubyWidth: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, 3, undefined>]>, 1.5>;
|
|
233
152
|
}, undefined>, {}>;
|
|
234
|
-
}, undefined
|
|
235
|
-
family: string;
|
|
236
|
-
rubyScript: "hiragana" | "hepburn" | "katakanaOn";
|
|
237
|
-
nfMin: number;
|
|
238
|
-
nfMax: number;
|
|
239
|
-
selectTags: ("ichi1" | "news1" | "spec1" | "gai1" | "ichi2" | "news2" | "spec2" | "gai2")[];
|
|
240
|
-
minTatoeba: number;
|
|
241
|
-
skipJlpt?: "N5" | "N4" | "N3" | "N2" | "N1" | undefined;
|
|
242
|
-
places: boolean;
|
|
243
|
-
untagged: boolean;
|
|
244
|
-
manual?: ("mahjong-yaku" | "jr-stations" | "yojijukugo")[] | undefined;
|
|
245
|
-
isolated: boolean;
|
|
246
|
-
isolatedMinShare: number;
|
|
247
|
-
words: {
|
|
248
|
-
add: string[];
|
|
249
|
-
remove: string[];
|
|
250
|
-
pin: string[];
|
|
251
|
-
};
|
|
252
|
-
metrics: {
|
|
253
|
-
rubyScale: number;
|
|
254
|
-
rubyGap: number;
|
|
255
|
-
compressionFloor: number;
|
|
256
|
-
maxRubyWidth: number;
|
|
257
|
-
};
|
|
258
|
-
}, string>]>;
|
|
153
|
+
}, undefined>;
|
|
259
154
|
type PlanOptions = v.InferOutput<typeof PlanOptionsSchema>;
|
|
260
155
|
type PlanOptionsInput = v.InferInput<typeof PlanOptionsSchema>;
|
|
261
156
|
export declare function resolveOptions(input?: PlanOptionsInput): PlanOptions;
|
|
@@ -309,6 +204,128 @@ export declare const PlanSchema: v.ObjectSchema<{
|
|
|
309
204
|
}, undefined>;
|
|
310
205
|
type Plan = v.InferOutput<typeof PlanSchema>;
|
|
311
206
|
type PlanGlyph = Plan['glyphs'][number];
|
|
207
|
+
/**
|
|
208
|
+
* The bounds of a reading's score, 0 to 100: above `tagged`, a word JMdict's
|
|
209
|
+
* lists tag, by its weight; above `used`, one Tatoeba's sentences use (20 and
|
|
210
|
+
* its uses, up to 50); above `listed`, one a manual list (15) or JMnedict (10)
|
|
211
|
+
* names; any other JMdict word scores `listed`.
|
|
212
|
+
*/
|
|
213
|
+
export declare const SCORE: {
|
|
214
|
+
readonly tagged: 50;
|
|
215
|
+
readonly used: 20;
|
|
216
|
+
readonly listed: 5;
|
|
217
|
+
};
|
|
218
|
+
/**
|
|
219
|
+
* The score of a tagged reading of corpus weight `weight`, at most 1: 1 / its
|
|
220
|
+
* newspaper bucket, or a lone kanji's share of its uses. It is 100 for 1, 92
|
|
221
|
+
* for 1/2, 54 for 1/48; a weight too small to score above `tagged` scores 0.
|
|
222
|
+
*/
|
|
223
|
+
export declare function scoreOf(weight: number): number;
|
|
224
|
+
/** The corpus weight of a reading's score, which `scoreOf` gives; 0 for one no list tags. */
|
|
225
|
+
export declare const weightOf: (score: number) => number;
|
|
226
|
+
/** A reading's score, higher for a more common one, and its sources as a mask of `SOURCES` bits. */
|
|
227
|
+
type Reading = [score: number, sources: number];
|
|
228
|
+
type Table = Record<string, Record<string, Reading>>;
|
|
229
|
+
/**
|
|
230
|
+
* The compiled dictionary, the contract between `@furifont/dictionary` and
|
|
231
|
+
* the planner: readings by the Han run a font sees, each with its score and
|
|
232
|
+
* sources. A run's readings come ranked, the default first. Run readings are
|
|
233
|
+
* JmdictFurigana alignments within the run.
|
|
234
|
+
*/
|
|
235
|
+
export declare const DictionarySchema: v.ObjectSchema<{
|
|
236
|
+
/** Source datasets and the version each was compiled from. */
|
|
237
|
+
readonly versions: v.RecordSchema<v.StringSchema<undefined>, v.StringSchema<undefined>, undefined>;
|
|
238
|
+
/** The bit of each source in the readings' masks. */
|
|
239
|
+
readonly sources: v.CustomSchema<Record<string, number>, v.ErrorMessage<v.CustomIssue> | undefined>;
|
|
240
|
+
/** Kanji to its on'yomi, in hiragana. */
|
|
241
|
+
readonly onyomi: v.RecordSchema<v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
242
|
+
/** Runs of two or more kanji, then their alignments: `{ 日本: { '0-1:にほん': [75, 61] } }`. */
|
|
243
|
+
readonly runs: v.CustomSchema<Table, v.ErrorMessage<v.CustomIssue> | undefined>;
|
|
244
|
+
/** Kanji alone in a run, then their readings: `{ 来: { く: [98, 2101] } }`. */
|
|
245
|
+
readonly kanji: v.CustomSchema<Table, v.ErrorMessage<v.CustomIssue> | undefined>;
|
|
246
|
+
/** Written forms never to annotate, such as 月, whose reading alone is a guess; users' removals add to them. */
|
|
247
|
+
readonly bare: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
248
|
+
}, undefined>;
|
|
249
|
+
type Dictionary = v.InferOutput<typeof DictionarySchema>;
|
|
250
|
+
/** The file `DictionarySchema` reads: an entry a line. */
|
|
251
|
+
export declare function formatDictionary(dictionary: Dictionary): string;
|
|
252
|
+
//#endregion
|
|
253
|
+
//#region src/dictionary.d.ts
|
|
254
|
+
/** One (written form, reading) pair of JMdict, aligned by JmdictFurigana. */
|
|
255
|
+
interface DictionaryEntry {
|
|
256
|
+
form: string;
|
|
257
|
+
/** JmdictFurigana alignment: `0:に;1:ほん`, or `0-1:きょう` for a reading spanning characters. */
|
|
258
|
+
furigana: string;
|
|
259
|
+
/** The form's newspaper frequency bucket (nf01..nf48), 0 when unranked. */
|
|
260
|
+
nf: number;
|
|
261
|
+
/** The reading's JMdict priority tags, space separated; empty for uncommon readings. */
|
|
262
|
+
priority: string;
|
|
263
|
+
/** Position of the reading among the form's readings, in JMdict order. */
|
|
264
|
+
order: number;
|
|
265
|
+
/** `来る`-type verb, whose kanji reads differently as it conjugates. */
|
|
266
|
+
conjugatesReading?: boolean;
|
|
267
|
+
/** The JLPT level whose word list has this pair: 5 for N5 down to 1 for N1. */
|
|
268
|
+
jlpt?: number;
|
|
269
|
+
/** How many times Tatoeba's example sentences use the pair, spelled this way. */
|
|
270
|
+
tatoeba?: number;
|
|
271
|
+
}
|
|
272
|
+
/** Everything `fuseDictionary` merges into a `Dictionary`. */
|
|
273
|
+
interface DictionarySources {
|
|
274
|
+
versions: Record<string, string>;
|
|
275
|
+
onyomi: Record<string, string[]>;
|
|
276
|
+
entries: DictionaryEntry[];
|
|
277
|
+
/** Place names, each with the one reading to show; common words take precedence over them. */
|
|
278
|
+
places: {
|
|
279
|
+
form: string;
|
|
280
|
+
furigana: string;
|
|
281
|
+
}[];
|
|
282
|
+
/** Word lists kept by hand, by source name, in inline notation; like place names, they fill runs no common word claims. */
|
|
283
|
+
manual: Partial<Record<ManualSource, string[]>>;
|
|
284
|
+
/** Curated default readings in inline notation, for words the data ranks wrong; pins override them. */
|
|
285
|
+
defaults: string[];
|
|
286
|
+
bare: string[];
|
|
287
|
+
}
|
|
288
|
+
/** A ruby annotation over characters `[start, end)` of a run. */
|
|
289
|
+
interface RubySpan {
|
|
290
|
+
start: number;
|
|
291
|
+
end: number;
|
|
292
|
+
ruby: string;
|
|
293
|
+
}
|
|
294
|
+
/** A maximal sequence of Han characters with its reading, the unit a shaper sees. */
|
|
295
|
+
interface HanRun {
|
|
296
|
+
text: string;
|
|
297
|
+
spans: RubySpan[];
|
|
298
|
+
}
|
|
299
|
+
export declare function isHan(char: string): boolean;
|
|
300
|
+
/** Spans of a JmdictFurigana alignment; a loop, not splits, as the planner parses the 400,000 readings of the dictionary as it starts. */
|
|
301
|
+
export declare function parseFurigana(furigana: string): RubySpan[];
|
|
302
|
+
/**
|
|
303
|
+
* Splits a form into its Han runs. Browsers itemize text by script before
|
|
304
|
+
* shaping, so a font only ever sees one run at a time: okurigana and other
|
|
305
|
+
* kana are never visible as context. Runs with an unannotated kanji or an
|
|
306
|
+
* annotation leaking outside the run are dropped.
|
|
307
|
+
*/
|
|
308
|
+
export declare function hanRuns(form: string, spans: readonly RubySpan[]): HanRun[];
|
|
309
|
+
/**
|
|
310
|
+
* Parses the inline notation for custom words: `日[に]本[ほん]` for one reading
|
|
311
|
+
* per kanji, `今日[きょう]` for a reading over several kanji, kana as written.
|
|
312
|
+
*/
|
|
313
|
+
export declare function parseNotation(notation: string): {
|
|
314
|
+
form: string;
|
|
315
|
+
spans: RubySpan[];
|
|
316
|
+
};
|
|
317
|
+
export declare function formatNotation(text: string, spans: readonly RubySpan[]): string;
|
|
318
|
+
//#endregion
|
|
319
|
+
//#region src/fuse.d.ts
|
|
320
|
+
/** Spans as a JmdictFurigana alignment: `0:に;1:ほん`, `0-1:きょう`. */
|
|
321
|
+
export declare function formatFurigana(spans: readonly RubySpan[]): string;
|
|
322
|
+
/**
|
|
323
|
+
* Merges every source into the readings of the Han runs a font sees, each
|
|
324
|
+
* reading with its score and sources. What no plan can use is left out: a
|
|
325
|
+
* word's runs with an unannotated kanji, lone kanji of the lists or of words
|
|
326
|
+
* no list tags but before okurigana, and the on'yomi of kanji no reading uses.
|
|
327
|
+
*/
|
|
328
|
+
export declare function fuseDictionary(sources: DictionarySources): Dictionary;
|
|
312
329
|
//#endregion
|
|
313
330
|
//#region src/glyphs.d.ts
|
|
314
331
|
export declare function glyphName(codepoint: number): string;
|
|
@@ -367,10 +384,10 @@ interface PlanResult {
|
|
|
367
384
|
report: PlanReport;
|
|
368
385
|
}
|
|
369
386
|
/**
|
|
370
|
-
* Indexes the dictionary once
|
|
387
|
+
* Indexes the compiled dictionary once, then plans fonts from it. Every
|
|
371
388
|
* decision about readings happens here: which words get ruby, which reading
|
|
372
389
|
* is the default, which longer words must be protected from a shorter match.
|
|
373
390
|
*/
|
|
374
391
|
export declare function createFontPlanner(dictionary: Dictionary): (options: PlanOptions, coverage: ReadonlySet<number>, previewText?: string) => PlanResult;
|
|
375
392
|
//#endregion
|
|
376
|
-
export type { Dictionary, DictionaryEntry, HanRun, Plan, PlanGlyph, PlanOptions, PlanOptionsInput, PlanReport, PlanResult, RubyMetrics, RubyScript, RubySpan };
|
|
393
|
+
export type { Dictionary, DictionaryEntry, DictionarySources, HanRun, ManualSource, Plan, PlanGlyph, PlanOptions, PlanOptionsInput, PlanReport, PlanResult, Reading, RubyMetrics, RubyScript, RubySpan, Source, WordSource };
|