feat(shared): add getPretextFontString formatter
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Formats a font config into the string `@chenglou/pretext` and the Canvas 2D
|
||||
* `font` property both expect: `weight sizepx "family"`.
|
||||
*
|
||||
* ponytail: deliberate copy of widgets/ComparisonView/lib's version — ADR-0002
|
||||
* keeps the shelved morph tool untouched, so we don't move its util. Three lines
|
||||
* is cheaper to duplicate than to refactor frozen code.
|
||||
*
|
||||
* @param weight - Numeric font weight (e.g. 400).
|
||||
* @param sizePx - Font size in pixels.
|
||||
* @param fontName - The font family name.
|
||||
* @returns A formatted font string: `weight sizepx "fontName"`.
|
||||
*/
|
||||
export function getPretextFontString(weight: number, sizePx: number, fontName: string): string {
|
||||
return `${weight} ${sizePx}px "${fontName}"`;
|
||||
}
|
||||
Reference in New Issue
Block a user