2026-03-02 22:18:05 +03:00
|
|
|
<!--
|
|
|
|
|
Component: Line
|
2026-05-30 22:29:43 +03:00
|
|
|
Renders one laid-out line of comparison text as three regions:
|
|
|
|
|
a fontA bulk run (already past the slider), an N-char window of crossfade
|
|
|
|
|
slots straddling the slider, and a fontB bulk run (not yet past).
|
|
|
|
|
Bulk text is rendered as native shaped runs so the browser applies
|
|
|
|
|
kerning and ligatures; per-char DOM is reserved for the window only.
|
2026-03-02 22:18:05 +03:00
|
|
|
-->
|
|
|
|
|
<script lang="ts">
|
2026-05-30 22:29:43 +03:00
|
|
|
import type { LineRenderModel } from '$entities/Font';
|
2026-05-24 18:27:10 +03:00
|
|
|
import { typographySettingsStore } from '$features/AdjustTypography';
|
2026-05-30 22:29:43 +03:00
|
|
|
import { comparisonStore } from '../../model';
|
|
|
|
|
import Character from '../Character/Character.svelte';
|
2026-04-11 16:26:41 +03:00
|
|
|
|
2026-03-02 22:18:05 +03:00
|
|
|
interface Props {
|
|
|
|
|
/**
|
2026-05-30 22:29:43 +03:00
|
|
|
* Per-line render slice from computeLineRenderModel.
|
2026-03-02 22:18:05 +03:00
|
|
|
*/
|
2026-05-30 22:29:43 +03:00
|
|
|
model: LineRenderModel;
|
2026-03-02 22:18:05 +03:00
|
|
|
}
|
|
|
|
|
|
2026-05-30 22:29:43 +03:00
|
|
|
let { model }: Props = $props();
|
|
|
|
|
|
|
|
|
|
const typography = $derived(typographySettingsStore);
|
|
|
|
|
const fontA = $derived(comparisonStore.fontA);
|
|
|
|
|
const fontB = $derived(comparisonStore.fontB);
|
2026-03-02 22:18:05 +03:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<div
|
2026-05-30 22:29:43 +03:00
|
|
|
class="relative flex w-full justify-center items-center whitespace-pre"
|
2026-04-20 10:51:41 +03:00
|
|
|
style:height="{typography.height * typography.renderedSize}px"
|
|
|
|
|
style:line-height="{typography.height * typography.renderedSize}px"
|
2026-05-30 22:29:43 +03:00
|
|
|
style:font-size="{typography.renderedSize}px"
|
|
|
|
|
style:letter-spacing="{typography.spacing}em"
|
|
|
|
|
style:font-weight={typography.weight}
|
2026-03-02 22:18:05 +03:00
|
|
|
>
|
2026-05-30 22:29:43 +03:00
|
|
|
{#if model.leftText}
|
|
|
|
|
<span style:font-family={fontA?.name}>{model.leftText}</span>
|
|
|
|
|
{/if}
|
|
|
|
|
{#each model.windowChars as wc (wc.key)}
|
|
|
|
|
<Character char={wc.char} isPast={wc.isPast} />
|
2026-03-02 22:18:05 +03:00
|
|
|
{/each}
|
2026-05-30 22:29:43 +03:00
|
|
|
{#if model.rightText}
|
|
|
|
|
<span style:font-family={fontB?.name}>{model.rightText}</span>
|
|
|
|
|
{/if}
|
2026-03-02 22:18:05 +03:00
|
|
|
</div>
|