chore: follow the general comments style
This commit is contained in:
+30
-9
@@ -12,20 +12,37 @@ import {
|
||||
* each font's actual advance widths independently.
|
||||
*/
|
||||
export interface ComparisonLine {
|
||||
/** Full text of this line as returned by pretext. */
|
||||
/**
|
||||
* Full text of this line as returned by pretext.
|
||||
*/
|
||||
text: string;
|
||||
/** Rendered width of this line in pixels — maximum across font A and font B. */
|
||||
/**
|
||||
* Rendered width of this line in pixels — maximum across font A and font B.
|
||||
*/
|
||||
width: number;
|
||||
/**
|
||||
* Individual character metadata for both fonts in this line
|
||||
*/
|
||||
chars: Array<{
|
||||
/** The grapheme cluster string (may be >1 code unit for emoji, etc.). */
|
||||
/**
|
||||
* The grapheme cluster string (may be >1 code unit for emoji, etc.).
|
||||
*/
|
||||
char: string;
|
||||
/** X offset from the start of the line in font A, in pixels. */
|
||||
/**
|
||||
* X offset from the start of the line in font A, in pixels.
|
||||
*/
|
||||
xA: number;
|
||||
/** Advance width of this grapheme in font A, in pixels. */
|
||||
/**
|
||||
* Advance width of this grapheme in font A, in pixels.
|
||||
*/
|
||||
widthA: number;
|
||||
/** X offset from the start of the line in font B, in pixels. */
|
||||
/**
|
||||
* X offset from the start of the line in font B, in pixels.
|
||||
*/
|
||||
xB: number;
|
||||
/** Advance width of this grapheme in font B, in pixels. */
|
||||
/**
|
||||
* Advance width of this grapheme in font B, in pixels.
|
||||
*/
|
||||
widthB: number;
|
||||
}>;
|
||||
}
|
||||
@@ -34,9 +51,13 @@ export interface ComparisonLine {
|
||||
* Aggregated output of a dual-font layout pass.
|
||||
*/
|
||||
export interface ComparisonResult {
|
||||
/** Per-line grapheme data for both fonts. Empty when input text is empty. */
|
||||
/**
|
||||
* Per-line grapheme data for both fonts. Empty when input text is empty.
|
||||
*/
|
||||
lines: ComparisonLine[];
|
||||
/** Total height in pixels. Equals `lines.length * lineHeight` (pretext guarantee). */
|
||||
/**
|
||||
* Total height in pixels. Equals `lines.length * lineHeight` (pretext guarantee).
|
||||
*/
|
||||
totalHeight: number;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,8 +28,6 @@ describe('CharacterComparisonEngine', () => {
|
||||
engine = new CharacterComparisonEngine();
|
||||
});
|
||||
|
||||
// --- layout() ---
|
||||
|
||||
it('returns empty result for empty string', () => {
|
||||
const result = engine.layout('', '400 16px "FontA"', '400 16px "FontB"', 500, 20);
|
||||
expect(result.lines).toHaveLength(0);
|
||||
@@ -111,8 +109,6 @@ describe('CharacterComparisonEngine', () => {
|
||||
expect(r2).not.toBe(r1);
|
||||
});
|
||||
|
||||
// --- getCharState() ---
|
||||
|
||||
it('getCharState returns proximity 1 when slider is exactly over char center', () => {
|
||||
// 'A' only: FontA width=10. Container=500px. Line centered.
|
||||
// lineXOffset = (500 - maxWidth) / 2. maxWidth = max(10, 15) = 15 (FontB is wider).
|
||||
|
||||
Reference in New Issue
Block a user