refactor(ComparisonView): unify pretext font string generation with a utility function
This commit is contained in:
@@ -22,6 +22,7 @@ import clsx from 'clsx';
|
||||
import { getContext } from 'svelte';
|
||||
import { Spring } from 'svelte/motion';
|
||||
import { fade } from 'svelte/transition';
|
||||
import { getPretextFontString } from '../../lib';
|
||||
import { comparisonStore } from '../../model';
|
||||
import Character from '../Character/Character.svelte';
|
||||
import Line from '../Line/Line.svelte';
|
||||
@@ -132,8 +133,8 @@ $effect(() => {
|
||||
|
||||
if (container && fontA && fontB) {
|
||||
// PRETEXT API strings: "weight sizepx family"
|
||||
const fontAStr = `${_weight} ${_size}px "${fontA.name}"`;
|
||||
const fontBStr = `${_weight} ${_size}px "${fontB.name}"`;
|
||||
const fontAStr = getPretextFontString(_weight, _size, fontA.name);
|
||||
const fontBStr = getPretextFontString(_weight, _size, fontB.name);
|
||||
|
||||
// Use offsetWidth to avoid transform scaling issues
|
||||
const width = container.offsetWidth;
|
||||
@@ -165,8 +166,8 @@ $effect(() => {
|
||||
containerWidth = width;
|
||||
layoutResult = comparisonEngine.layout(
|
||||
comparisonStore.text,
|
||||
`${typography.weight} ${typography.renderedSize}px "${fontA.name}"`,
|
||||
`${typography.weight} ${typography.renderedSize}px "${fontB.name}"`,
|
||||
getPretextFontString(typography.weight, typography.renderedSize, fontA.name),
|
||||
getPretextFontString(typography.weight, typography.renderedSize, fontB.name),
|
||||
width - padding,
|
||||
typography.renderedSize * typography.height,
|
||||
typography.spacing,
|
||||
|
||||
Reference in New Issue
Block a user