@pao-at-office/reports-web 1.0.0 → 1.3.1

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.
@@ -0,0 +1,12 @@
1
+ /** PREPDJ の検査専用。読み込み・描画を呼ばず、入力を書き換えない。Node の配布にも同じファイルを使う。 */
2
+ export interface DesignDiagnostic {
3
+ severity: 'error' | 'warning';
4
+ code: string;
5
+ /** JSON の位置。表示用の部品名は混ぜない。 */
6
+ path: string;
7
+ message: string;
8
+ fix: string;
9
+ suggestion?: string;
10
+ }
11
+ /** error も通知だけ。既存の描画 API がこれを使ってファイルを断ることはない。 */
12
+ export declare function validateDesign(input: unknown): DesignDiagnostic[];
@@ -0,0 +1,164 @@
1
+ import { findKnownFamily } from './knownFamilyMetrics.js';
2
+ const record = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);
3
+ const finite = (v) => typeof v === 'number' && Number.isFinite(v);
4
+ const fields = (numbers, strings, booleans) => Object.fromEntries([
5
+ ...numbers.split(' ').filter(Boolean).map(k => [k, 'number']),
6
+ ...strings.split(' ').filter(Boolean).map(k => [k, 'string']),
7
+ ...booleans.split(' ').filter(Boolean).map(k => [k, 'boolean']),
8
+ ['ExtensionData', 'object'],
9
+ ]);
10
+ const rootFields = fields('Paper CustomWidthMm CustomHeightMm GridMm DesignScalePercent DefaultFontSizePt DefaultStrokeWidth BackgroundX BackgroundY BackgroundWidth BackgroundHeight', 'Version Title CoordinateUnit DefaultFontFamily DesignColor DefaultStrokeStyle DefaultDashPattern BackgroundImagePath BackgroundImageDataBase64 BackgroundImageSizeMode BackgroundImagePosition RepeatObjectColor', 'ShowGrid SnapToGrid IsInch ObjectsLocked DisplayRepeatObjects');
11
+ const objectFields = fields('Kind X Y Width Height Rotation FontSizePt StrokeWidth LineThickness HatchDensity TextOutlineWidth EndSpaceCount ElasticOverCharacters ElasticOverBytes CornerRadius RepeatIntervalX RepeatIntervalY RepeatCount RepeatCountX BarcodeKind BarcodeTextFontSizePt BarcodeBlackBarAdjustment BarcodeWhiteBarAdjustment PostalCustomerPoint QrVersion Pdf417Rows Pdf417Columns Pdf417ErrorLevel Pdf417AspectRatio ArtTextCharacterAngle ArtTextOverlapRate ArtTextDigitSeparatorBeforeRate ArtTextDigitSeparatorAfterRate ArtTextShearX ArtTextShearY ArtTextShadowX ArtTextShadowY ArtTextShadowOutlineWidth', 'Id Name Text FontFamily FontUnit TextColor FillColor StrokeColor StrokeStyle LineType StrokeDashPattern FillStyle HorizontalAlignment VerticalAlignment TextOutlineColor JustifyExcludedCharacters PdfFontFamily ImagePath ImageDataBase64 ImageSizeMode ImagePosition ImageReverse BarcodeTextFontFamily BarcodeWriteMode BarcodeStringEncoding BarcodeCodeSet QrErrorLevel DataMatrixCodeSize Pdf417SizeKind ArtTextDigitSeparatorCharacters ArtTextShadowTextColor ArtTextShadowOutlineColor', 'Visible Locked FontBold FontItalic FontUnderline FontStrikeout TextVertical FillEnabled Elastic FixedFontHeight Justify JustifyHalfWidth JustifyHalfWidthKana AutoJustifyEnds PdfAutoWrap PdfClipOverflow RoundTopLeft RoundTopRight RoundBottomRight RoundBottomLeft RepeatBothDirections BarcodeTextVisible BarcodeTextJustify BarcodeStartStopCode Pdf417AutoErrorLevel ArtTextReverse ArtTextVertical ArtTextBold ArtTextOverlapFront ArtTextDigitSeparatorOverlap ArtTextFlipVertical ArtTextFlipHorizontal ArtTextExpandForShear ArtTextExpandForShadow');
12
+ const paperSizes = [[100, 148], [148, 100], [148, 210], [210, 148], [182, 257], [257, 182], [210, 297], [297, 210], [257, 364], [364, 257], [297, 420], [420, 297]];
13
+ const enums = {
14
+ HorizontalAlignment: ['Left', 'Center', 'Right', 'Justify'], VerticalAlignment: ['Top', 'Middle', 'Bottom', 'Center'],
15
+ StrokeStyle: ['Solid', 'Dash', 'Dot', 'DashDot', 'DashDotDot', 'Double', 'Custom', 'DASH_DOT', 'DASH_DOT_DOT'],
16
+ LineType: ['Single', 'Double'], FillStyle: ['None', 'Solid', 'Hatch'], ImageSizeMode: ['Zoom', 'Stretch', 'Clip'],
17
+ ImagePosition: ['LeftTop', 'CenterTop', 'RightTop', 'LeftMiddle', 'Center', 'RightMiddle', 'LeftBottom', 'CenterBottom', 'RightBottom', 'LT', 'CT', 'RT', 'LM', 'C', 'CC', 'CM', 'RM', 'LB', 'CB', 'RB'],
18
+ ImageReverse: ['None', 'Horizontal', 'Vertical', 'Both', 'NoRev', 'LR', 'LeftRight', 'RevX', 'TB', 'TopBottom', 'RevY', 'TBLR', 'LRTB', 'TopBottomLeftRight', 'RevXY', 'RevYX'],
19
+ BarcodeWriteMode: ['Stretch', 'Direct'], BarcodeCodeSet: ['AUTO', 'A', 'B', 'C', 'CODE_A', 'CODE_B', 'CODE_C'],
20
+ QrErrorLevel: ['L', 'M', 'Q', 'H'], Pdf417SizeKind: ['Auto', 'Columns', 'Rows', 'RowsAndColumns', 'ColumnsAndRows'],
21
+ DataMatrixCodeSize: ['Auto', 'RectAuto', 'ShapeAuto', '10x10', '12x12', '14x14', '16x16', '18x18', '20x20', '22x22', '24x24', '26x26', '32x32', '36x36', '40x40', '44x44', '48x48', '52x52', '64x64', '72x72', '80x80', '88x88', '96x96', '104x104', '120x120', '132x132', '144x144', '8x18', '8x32', '12x26', '12x36', '16x36', '16x48'],
22
+ };
23
+ const hints = { FontSize: 'FontSizePt', Font: 'FontFamily', Bold: 'FontBold', Color: 'TextColor', Align: 'HorizontalAlignment', Type: 'Kind', Value: 'Text', BorderWidth: 'StrokeWidth', LineWidth: 'StrokeWidth', BackgroundColor: 'FillColor', Repeat: 'RepeatCount', IntervalY: 'RepeatIntervalY', Left: 'X', Top: 'Y' };
24
+ function distance(a, b) {
25
+ // 候補は距離 2 まで。長い未知のキーでサーバーの検査が膨らまないようにする。
26
+ if (Math.abs(a.length - b.length) > 2)
27
+ return 3;
28
+ let row = Array.from({ length: b.length + 1 }, (_, i) => i);
29
+ for (let i = 0; i < a.length; i++) {
30
+ const next = [i + 1];
31
+ for (let j = 0; j < b.length; j++)
32
+ next.push(Math.min(next[j] + 1, row[j + 1] + 1, row[j] + (a[i] === b[j] ? 0 : 1)));
33
+ row = next;
34
+ }
35
+ return row[b.length];
36
+ }
37
+ /** error も通知だけ。既存の描画 API がこれを使ってファイルを断ることはない。 */
38
+ export function validateDesign(input) {
39
+ const result = [];
40
+ const add = (severity, code, path, message, fix, suggestion) => result.push({ severity, code, path, message, fix, ...(suggestion ? { suggestion } : {}) });
41
+ const error = (code, path, message, fix) => add('error', code, path, message, fix);
42
+ const warn = (code, path, message, fix) => add('warning', code, path, message, fix);
43
+ const check = (value, schema, prefix, extra = []) => {
44
+ for (const [key, v] of Object.entries(value)) {
45
+ const path = prefix + key;
46
+ if (!Object.hasOwn(schema, key)) {
47
+ if (extra.includes(key))
48
+ continue;
49
+ const keys = Object.keys(schema);
50
+ const closest = keys.map(k => [k, distance(key.toLowerCase(), k.toLowerCase())]).sort((a, b) => a[1] - b[1])[0];
51
+ const suggestion = Object.hasOwn(hints, key) && Object.hasOwn(schema, hints[key]) ? hints[key] : closest && closest[1] <= Math.min(2, Math.floor(key.length / 3)) ? closest[0] : undefined;
52
+ add(suggestion ? 'error' : 'warning', 'UNKNOWN_FIELD', path, suggestion ? `その名前の項目はありません。${suggestion} のことですか。` : '知らない項目です。描画には使われません。', suggestion ? `項目名を ${suggestion} に直してください。` : '綴りを確認し、追加情報は ExtensionData に置いてください。', suggestion);
53
+ continue;
54
+ }
55
+ const type = schema[key];
56
+ if (!(type === 'number' ? finite(v) : type === 'object' ? record(v) || v === null : typeof v === type))
57
+ error('FIELD_TYPE', path, `${type === 'number' ? '有限の数値' : type === 'string' ? '文字列' : type === 'boolean' ? 'true / false' : 'JSON オブジェクト'}が必要です。`, `値を ${type === 'number' ? '引用符なしの JSON の数' : type === 'string' ? '引用符で囲んだ文字列' : type === 'boolean' ? '引用符なしの true または false' : 'JSON オブジェクト'}で書いてください。`);
58
+ }
59
+ };
60
+ if (!record(input)) {
61
+ error('DOCUMENT_TYPE', '$', 'デザインは JSON オブジェクトが必要です。', '外側を { ... } で書いてください。');
62
+ return result;
63
+ }
64
+ check(input, rootFields, '', ['Objects']);
65
+ for (const key of ['Version', 'Title'])
66
+ if (!Object.hasOwn(input, key))
67
+ error('FIELD_TYPE', key, '必須の文字列がありません。', key === 'Version' ? '"Version": "13.2.0" を書いてください。' : '帳票の名前を文字列で書いてください。');
68
+ if (typeof input.CoordinateUnit !== 'string' || !['mm', 'px'].includes(input.CoordinateUnit.toLowerCase()))
69
+ error('COORDINATE_UNIT', 'CoordinateUnit', '座標の単位が違います。', '"mm" または "px" を書いてください(96px=25.4mm)。');
70
+ const unit = typeof input.CoordinateUnit === 'string' && input.CoordinateUnit.toLowerCase() === 'px' ? 25.4 / 96 : 1;
71
+ const paper = input.Paper;
72
+ if (!finite(paper) || !Number.isInteger(paper) || paper < 0 || paper > 12)
73
+ error('PAPER_KIND', 'Paper', '知らない用紙番号です。', '0〜12 の整数を書いてください。任意の大きさは 12 です。');
74
+ let size = finite(paper) && Number.isInteger(paper) && paperSizes[paper] ? paperSizes[paper] : [210, 297];
75
+ if (paper === 12) {
76
+ for (const key of ['CustomWidthMm', 'CustomHeightMm'])
77
+ if (!finite(input[key]) || input[key] <= 0)
78
+ error('CUSTOM_PAPER_SIZE', key, '任意の用紙には正の寸法が必要です。', 'CustomWidthMm と CustomHeightMm を正の数で書いてください(px のときは 96px=25.4mm)。');
79
+ }
80
+ else if (finite(paper) && Number.isInteger(paper) && paper >= 0 && paper < 12) {
81
+ // 保存時に入る A4 の既定寸法と、選んだ用紙と同じ寸法は意図の相違と見なさない。
82
+ const differs = ['CustomWidthMm', 'CustomHeightMm'].some((key, i) => finite(input[key]) &&
83
+ Math.abs(input[key] * unit - size[i]) > 0.01 && Math.abs(input[key] * unit - [210, 297][i]) > 0.01);
84
+ if (differs)
85
+ warn('IGNORED_CUSTOM_SIZE', 'Paper', '規格用紙と異なる任意の寸法が指定されていますが、この用紙番号では使われません。', '指定した寸法を使う場合は Paper を 12 にしてください。');
86
+ }
87
+ // 読み込みは未知の用紙でも任意寸法を使う。検査の範囲計算もそれに合わせる。
88
+ if (!(finite(paper) && paperSizes[paper]))
89
+ size = [finite(input.CustomWidthMm) ? input.CustomWidthMm * unit : 210, finite(input.CustomHeightMm) ? input.CustomHeightMm * unit : 297];
90
+ if (!Array.isArray(input.Objects)) {
91
+ error('OBJECTS_TYPE', 'Objects', '部品の配列が必要です。', '"Objects": [ ... ] を書いてください。');
92
+ return result;
93
+ }
94
+ const names = new Set();
95
+ input.Objects.forEach((raw, i) => {
96
+ const p = `Objects[${i}]`;
97
+ if (!record(raw)) {
98
+ error('OBJECT_TYPE', p, '部品は JSON オブジェクトが必要です。', '{ "Name": "...", ... } の形で書いてください。');
99
+ return;
100
+ }
101
+ check(raw, objectFields, p + '.');
102
+ for (const key of ['X', 'Y', 'Width', 'Height'])
103
+ if (!Object.hasOwn(raw, key))
104
+ error('FIELD_TYPE', p + '.' + key, '位置・大きさの数値がありません。', `${key} を引用符なしの JSON の数で書いてください。`);
105
+ if (typeof raw.Name !== 'string' || !raw.Name.trim())
106
+ error('OBJECT_NAME', p + '.Name', '部品の名前がありません。', '空でない Name を文字列で書いてください。');
107
+ else if (names.has(raw.Name))
108
+ warn('DUPLICATE_NAME', p + '.Name', `名前「${raw.Name}」が重複しています。読み込みでは後の部品の名前に枝番が付きます。`, 'データを入れる先が区別できるよう、別の名前にしてください。');
109
+ else
110
+ names.add(raw.Name);
111
+ const kind = Object.hasOwn(raw, 'Kind') ? raw.Kind : 0;
112
+ if (!finite(kind) || !Number.isInteger(kind) || kind < 0 || kind > 5)
113
+ error('OBJECT_KIND', p + '.Kind', '知らない部品の種類です。', '0 文字・1 線・2 四角・3 円・4 画像・5 バーコードを指定してください。');
114
+ for (const [key, list] of Object.entries(enums))
115
+ if (Object.hasOwn(raw, key) && typeof raw[key] === 'string') {
116
+ let v = raw[key];
117
+ if (key === 'DataMatrixCodeSize')
118
+ v = v.replace(/^DxSz/i, '');
119
+ // 静的な縦寄せは他の列挙値と異なり Middle/Bottom の大小文字を区別する。
120
+ const valid = key === 'VerticalAlignment' ? ['Top', 'Middle', 'Bottom'].includes(v) || v.toLowerCase() === 'center' : list.some(s => s.toLowerCase() === v.trim().toLowerCase());
121
+ if (!valid)
122
+ error('ENUM_VALUE', p + '.' + key, '知らない値です。省略時の値に読み替えられます。', `${list.join(' / ')} のいずれかを書いてください。`);
123
+ }
124
+ if (Object.hasOwn(raw, 'BarcodeKind') && (!finite(raw.BarcodeKind) || !Number.isInteger(raw.BarcodeKind) || raw.BarcodeKind < 0 || raw.BarcodeKind > 23))
125
+ error('BARCODE_KIND', p + '.BarcodeKind', '知らないバーコード番号です。CODE128 として描かれます。', '0〜23 の整数で種類を指定してください。');
126
+ if ((kind === 0 || kind === 4) && !Object.hasOwn(raw, 'StrokeWidth'))
127
+ warn('DEFAULT_BORDER', p + '.StrokeWidth', 'StrokeWidth が無いので 0.3 の太さの枠が描かれます。', '枠が要らないときは "StrokeWidth": 0 を書いてください。');
128
+ if (kind === 0 && raw.Visible !== false && raw.Elastic !== true && raw.Justify !== true && raw.TextVertical !== true &&
129
+ finite(raw.Height) && raw.Height > 0 && typeof raw.Text === 'string' && raw.Text.trim() &&
130
+ (raw.PdfAutoWrap !== true || raw.PdfClipOverflow === true)) {
131
+ // PDF の alignedTextLines / legacyPdfTextBlock と同じ行高・採用行数。
132
+ // 字形の高さと行高は違う。1行が行高より低いだけでは警告しない。
133
+ // 入力前の空欄や、未測定の折返し・伸縮・縦書きはPNGで確認する。
134
+ const fontSize = finite(raw.FontSizePt) ? raw.FontSizePt : 10;
135
+ const metrics = findKnownFamily(typeof raw.FontFamily === 'string' ? raw.FontFamily : 'MS ゴシック');
136
+ if (metrics && fontSize > 0) {
137
+ const lineHeight = fontSize * metrics.lineEm, heightPt = raw.Height * unit * 72 / 25.4;
138
+ const lines = raw.Text.replace(/\r\n/g, '\n').replace(/\r/g, '').split('\n');
139
+ const count = Math.max(raw.PdfClipOverflow === true ? 0 : 1, Math.floor((heightPt - lineHeight / 4) / lineHeight + 1e-9) + 1);
140
+ if (lines.slice(count).some(line => line.trim()))
141
+ warn('TEXT_HEIGHT', p + '.Height', '欄の高さで、改行後の文字または文字全体が描かれません。', 'Height を大きくするか、文字を分けてください。最終データで PNG も確認してください。');
142
+ }
143
+ }
144
+ for (const key of ['RepeatCount', 'RepeatCountX'])
145
+ if (Object.hasOwn(raw, key) && (!finite(raw[key]) || !Number.isInteger(raw[key]) || raw[key] < 0 || raw[key] > 2147483647))
146
+ error('REPEAT_COUNT', p + '.' + key, '繰り返しの数が不正です。', '0〜2147483647 の整数を書いてください。0 は繰り返しなしです。');
147
+ const rows = finite(raw.RepeatCount) ? Math.max(1, raw.RepeatCount) : 1;
148
+ const cols = raw.RepeatBothDirections === true && finite(raw.RepeatCountX) ? Math.max(1, raw.RepeatCountX) : 1;
149
+ const ix = finite(raw.RepeatIntervalX) ? raw.RepeatIntervalX : 0, iy = finite(raw.RepeatIntervalY) ? raw.RepeatIntervalY : 0;
150
+ if (finite(raw.RepeatCountX) && raw.RepeatCountX > 1 && raw.RepeatBothDirections !== true)
151
+ warn('REPEAT_SETTINGS', p + '.RepeatBothDirections', '列数がありますが、縦横の繰り返しが有効になっていません。', '縦横に並べるなら RepeatBothDirections: true と列の間隔を指定してください。');
152
+ if (rows > 1 && (raw.RepeatBothDirections === true ? iy === 0 : ix === 0 && iy === 0) || cols > 1 && ix === 0)
153
+ warn('REPEAT_OVERLAP', p, '繰り返しの間隔が 0 のため、同じ場所に重なります。', 'RepeatIntervalX・RepeatIntervalY に必要な間隔を指定してください。');
154
+ if ([raw.X, raw.Y, raw.Width, raw.Height].every(finite)) {
155
+ const x = raw.X, y = raw.Y, w = raw.Width, h = raw.Height;
156
+ const dx = ix * (raw.RepeatBothDirections === true ? cols - 1 : rows - 1), dy = iy * (rows - 1);
157
+ const left = (Math.min(x, x + w) + Math.min(0, dx)) * unit, top = (Math.min(y, y + h) + Math.min(0, dy)) * unit;
158
+ const right = (Math.max(x, x + w) + Math.max(0, dx)) * unit, bottom = (Math.max(y, y + h) + Math.max(0, dy)) * unit;
159
+ if (left < -0.01 || top < -0.01 || right > size[0] + 0.01 || bottom > size[1] + 0.01)
160
+ warn('OUTSIDE_PAPER', p, `用紙(${size[0]}×${size[1]}mm)からはみ出します(右端 ${right.toFixed(1)}mm・下端 ${bottom.toFixed(1)}mm、繰り返しを含む)。`, '座標・大きさ・繰り返しの数や間隔を確認してください。回転・線の太さは範囲計算に含みません。');
161
+ }
162
+ });
163
+ return result;
164
+ }
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export { PrintData, type JsonObject, type Scalar } from "./PrintData.js";
2
- export { ReportsWebEngine, ReportsWebEngineError, type ReportsWebEngineOptions, type RenderPdfOptions, } from "./ReportsWebEngine.js";
2
+ export { ReportsWebEngine, ReportsWebEngineError, type ReportsWebEngineOptions, type RenderPdfOptions, type EngineWarning, type RenderPdfResult, type RenderPreviewOptions, type RenderPreviewResult, } from "./ReportsWebEngine.js";
3
+ export { validateDesign, type DesignDiagnostic } from './designLint.js';
package/dist/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export { PrintData } from "./PrintData.js";
2
2
  export { ReportsWebEngine, ReportsWebEngineError, } from "./ReportsWebEngine.js";
3
+ export { validateDesign } from './designLint.js';
@@ -0,0 +1,104 @@
1
+ export type KnownFamilyMetrics = {
2
+ english: string;
3
+ /** 上(usWinAscent)・下(usWinDescent)・行間(1 em あたり。行送り=上+下+行間)。 */
4
+ ascentEm: number;
5
+ descentEm: number;
6
+ leadingEm: number;
7
+ lineEm: number;
8
+ /** 字の高さの画素数(GDI の字の高さ)。1 em が emPixels 画素のとき。max(VDMX の行, round(上×画素数)+round(下×画素数))、VDMX が無ければ式。 */
9
+ fontHeightPixels(emPixels: number): number;
10
+ /** 指定した書体に字形がある字か(U+2E80 以上は和文の書体だけ true。欧文の書体は表の字だけ)。 */
11
+ hasGlyph(codePoint: number): boolean;
12
+ /** 固定ピッチ(post.isFixedPitch)。実物の太字の面がある。合成太字で足す送り(1/2048 em)。 */
13
+ fixed: boolean;
14
+ hasBoldFace: boolean;
15
+ syntheticBoldUnits: number;
16
+ /** 決まり BD1(2026-11-18):合成太字で+3% の前に送りへ足す量(F 行の 15 番目。Microsoft Sans Serif・BIZ UD明朝・BIZ UDP明朝は 41)。 */
17
+ syntheticBoldBefore: number;
18
+ /** 1 字の送り(hmtx、1/2048 em。表の A・B 行)。欧文だけの書体に無い字は -1、制御文字は 0。 */
19
+ advanceUnits(codePoint: number, bold: boolean, italic?: boolean): number;
20
+ /** 決まり R16:ヒンティング後の送り(画素。表の H 行)。表に無い字は -1。Maui KnownFamilyMetrics.HintedPixels と同じ。 */
21
+ hintedPixels(codePoint: number, emPixels: number, bold: boolean, italic?: boolean): number;
22
+ /** 決まり R15:字の組の詰め(1/2048 em。GPOS の kern の組、表の K 行)。組が無ければ 0。 */
23
+ kernUnits(first: number, second: number, bold?: boolean, italic?: boolean): number;
24
+ /**
25
+ * 決まり ST(2026-11-19 ADV):GDI+ が使う面。'J'=太字斜体の面、'I'=斜体の面、'B'=太字の面(太字斜体の面が無い書体の太字斜体も)、'R'=標準の面
26
+ * (面が無い太字・斜体は GDI+ が標準の面から作る:合成太字は BD1、合成斜体は傾けるだけで送りと詰めは標準の面)。表の Y・I・J・KB・KI・KJ 行。
27
+ */
28
+ styleFace(bold: boolean, italic: boolean): 'R' | 'B' | 'I' | 'J';
29
+ /** 縦書きの原点(1/2048 em あたりの値を em で。F 行の 14 番目。無い書体は min(上, 0.88))。Java KnownFamilyMetrics.verticalOriginEm と同じ。 */
30
+ verticalOriginEm: number;
31
+ /**
32
+ * 決まり R11:縦書きで立てて置く字の縦の送り(1/2048 em)。GSUB の vert で置き換えた字形の vmtx の送り(表の W 行)。
33
+ * W 行に無い字は横の送り。太字は横の送りの規則のまま(Maui KnownFamilyMetrics.VerticalAdvanceUnits と同じ)。
34
+ */
35
+ verticalAdvanceUnits(codePoint: number, bold: boolean): number;
36
+ /**
37
+ * 決まり R11:立てて置く字の小さな字のヒンティング後の縦の送り(画素)=ceil(n÷64−0.5)、n=round(縦の送り×P×64÷2048)(.5 は下へ)、P=ceil(画素数−0.5)。
38
+ * 横の H 行は使わない。太字は横のヒンティング後の送りのまま。Maui KnownFamilyMetrics.VerticalHintedPixels と同じ。
39
+ */
40
+ verticalHintedPixels(codePoint: number, emPixels: number, bold: boolean): number;
41
+ /**
42
+ * 決まり R12:横倒しの字の「字の高さ」の画素数(表の X 行=head の xMin・xMax・unitsPerEm。1 em が emPixels 画素、丸めない)。
43
+ * GDI+ は縦書きの横倒しの字を 90° 回した書体として作るので、小さな字と大きな字の境目(字の高さ 100 画素)を回した向きの高さ=書体全体の外接の幅で見る。
44
+ * glyphRules.sidewaysCellPixels の式。X 行が無ければ 0。Maui KnownFamilyMetrics.SidewaysCellPixels と同じ(2026-11-15 までの gasp の旗 gridFits はやめた)。
45
+ */
46
+ sidewaysCellPixels(emPixels: number): number;
47
+ /** 決まり R16F:書体の単位(head の unitsPerEm。表の X 行)。MS ゴシック・MS 明朝の仲間は 256、ほかは 2048。X 行が無ければ 2048(Maui KnownFamilyMetrics.UnitsPerEm と同じ)。 */
48
+ unitsPerEm: number;
49
+ /**
50
+ * 決まり YEN(2026-11-21、台帳 Y-01):書体が「\」(U+005C)を円記号の字形で描く(表の F 行の 13 番目。Maui KnownFamilyMetrics.YenBackslash・
51
+ * Java・Python と同じ表)。和文の 14 書体(MS ゴシック・明朝・P系・MS UI Gothic・メイリオ・Meiryo UI・游 4 書体・BIZ UD 4 書体)。
52
+ */
53
+ yenBackslash: boolean;
54
+ };
55
+ /**
56
+ * 決まり YEN:見た目だけ「\」を ¥ に置き換えた文字(textLayout.displayText)の配置の寸法の書体名に付ける印。
57
+ * この印の付いた書体名の寸法(findKnownFamily)は、表示の ¥(U+00A5)を入力の「\」(U+005C)の字として数える(送り・ヒンティング後の送り・字の組の詰め・
58
+ * 縦の送り・字形の有無)。MS Pゴシック・MS P明朝・MS UI Gothic は「\」の送りが ¥ と違う(1032 対 1208 ほか)ので、Reports.net と同じ「\」の送りで並べるため。
59
+ * 物体の入力に ¥ が無いとき(表示の ¥ が全部入力の「\」)だけ使う(textLayout.sourceFamily)。
60
+ */
61
+ export declare const YEN_METRICS_MARK = "\0yen";
62
+ /** 決まり YEN:配置で数える字(印の付いた書体名なら表示の ¥ を「\」に戻す)。 */
63
+ export declare function metricCodePoint(family: string | undefined, codePoint: number): number;
64
+ /** 書体名を表の鍵の形にする(Maui GdiFallbackMetrics.FamilyKey と同じ:NFKC、小文字、空白・「_」「-」を除く)。 */
65
+ export declare function knownFamilyKey(family: string | undefined): string;
66
+ /** 字の高さの画素数(VDMX が無い書体の式。Maui LayoutRules.FontHeightPixels と同じ)。 */
67
+ /**
68
+ * 決まり R12:横倒しの字の「字の高さ」の画素数。xMinEm・xMaxEm=書体全体の外接(head)の左・右(em)、emPixels=1 em の画素数(丸めない)。
69
+ * C(xMax×p)+C(−xMin×p)、C(v)=ceil(v を 1/16 画素に切り捨てた値)。右と左を別々に切り捨ててから切り上げる(1 つの数として丸めると境目がずれる)。
70
+ * Maui LayoutRules.SidewaysCellPixels と同じ(GDI+ 直:16 書体 × 1 em=6〜110 画素で確かめた)。glyphRules からも出す。
71
+ */
72
+ export declare function sidewaysCellPixels(xMinEm: number, xMaxEm: number, emPixels: number): number;
73
+ export declare function fontHeightPixelsFromMetrics(ascentEm: number, descentEm: number, emPixels: number): number;
74
+ /**
75
+ * 決まり FB1(2026-11-17):指定した書体に無い字(和文など)を GDI+ が描く代わりの書体と倍率 s。寸法の表の欧文の 7 書体だけ(ほかは undefined)。
76
+ * Segoe UI は Meiryo UI・s=(2210+514)÷(2171+430)(usWinAscent+usWinDescent の比)、Arial・Times New Roman・Courier New・Microsoft Sans Serif・
77
+ * Tahoma・Verdana は MS UI Gothic・s=1.1(GDI+ 直の GraphicsPath.AddString の外接と MeasureCharacterRanges で測った。試験ベクター FB1・FB1V・FB1I)。
78
+ * 代わりの字は代わりの書体を 1 em=s×p 画素で並べた R2・R16・R11 の送りで置き、行送り・基線は指定した書体のまま。Maui・Java・Python と同じ。
79
+ */
80
+ export type LinkedFallback = {
81
+ metrics: KnownFamilyMetrics;
82
+ scale: number;
83
+ };
84
+ export declare function linkedFallback(known: KnownFamilyMetrics | undefined): LinkedFallback | undefined;
85
+ /**
86
+ * 決まり FB1:折り返し(行・列の割り付け)に数える代わりの字の+3% の送り(指定した書体の 1/2048 em の整数)=floor((u+(3u+50)÷100 の整数部)×s)。
87
+ * 太字でも合成太字の量を足さない。立てて置く字は縦の送り。切り捨ては FB1V の短い枠(11mm に 12pt の「国」2 字=2×2319.9 単位が入る)で測った形
88
+ * (GDI+ が指定した書体の単位に直すときの切り捨てと見ている。推測)。字の位置は切り捨てない送り(glyphRules.placement)。
89
+ */
90
+ export declare function linkedNominalUnits(link: LinkedFallback, codePoint: number, upright?: boolean): number;
91
+ /** 名前が表にある書体の寸法。無ければ undefined。 */
92
+ export declare function findKnownFamily(family: string | undefined): KnownFamilyMetrics | undefined;
93
+ /** 決まり BD1:合成太字を足さない字(空白。字形の輪郭が無い)。Java Character.isWhitespace・isSpaceChar、Python str.isspace と同じ範囲の主な字。 */
94
+ export declare function isBoldBlank(codePoint: number): boolean;
95
+ /** 決まり BD1:太字を GDI+ が合成する(太字の面が無く、合成太字の量がある)書体か。 */
96
+ export declare function syntheticBold(known: KnownFamilyMetrics, bold: boolean): boolean;
97
+ /** 決まり BD1:この字に足す合成太字の前の量(空白は足さない)。 */
98
+ export declare function boldBefore(known: KnownFamilyMetrics, codePoint: number, bold: boolean): number;
99
+ /** 決まり BD1:この字に足す合成太字の後の量(MS の書体の 5。空白は U+0020 だけ足し、ほかの空白は足さない。GDI+ 直、em 4096 画素で測った)。 */
100
+ export declare function boldAfter(known: KnownFamilyMetrics, codePoint: number, bold: boolean): number;
101
+ /** 決まり BD1:+3% の送り(1/2048 em)。合成太字は、送りに前の量を足してから+3%、その後に後の量を足す(Java boldNominalUnits と同じ)。 */
102
+ export declare function boldNominalUnits(known: KnownFamilyMetrics, codePoint: number, units: number, bold: boolean): number;
103
+ /** 決まり BD1:合成太字の横書きのヒンティング後の送り=標準の送り+1 画素(合成の量を足さない字は足さない)。 */
104
+ export declare function boldHintedPixels(known: KnownFamilyMetrics, codePoint: number, emPixels: number, bold: boolean, italic?: boolean): number;
@@ -0,0 +1,29 @@
1
+ export type KnownFamilyEntry = {
2
+ keys: string[];
3
+ english: string;
4
+ ascent: number;
5
+ descent: number;
6
+ leading: number;
7
+ fixed: boolean;
8
+ hasBoldFace: boolean;
9
+ syntheticBold: number;
10
+ syntheticBoldBefore: number;
11
+ allGlyphs: boolean;
12
+ glyphRuns: string;
13
+ vdmx: string;
14
+ advance: string;
15
+ bold: string;
16
+ hinted: string;
17
+ kern: string;
18
+ vertical: string;
19
+ headBox: string;
20
+ verticalOrigin: number;
21
+ yenBackslash: boolean;
22
+ styleFlags: string;
23
+ italic: string;
24
+ boldItalic: string;
25
+ kernBold: string;
26
+ kernItalic: string;
27
+ kernBoldItalic: string;
28
+ };
29
+ export declare const knownFamilyEntries: KnownFamilyEntry[];