X-Git-Url: https://git.kianting.info/?a=blobdiff_plain;f=src%2Fcanva.ts;h=712efeec8863e891e8432cc2dd6c4f4d0f0723a8;hb=c3dc58d74afa6b298d84bad90d63c027a32a954a;hp=e88d8fdf2f180a4265cabb4321dfb89aa4cf9fdc;hpb=796e0c20c767e214b104fa3d17e754ce58da6e73;p=clo diff --git a/src/canva.ts b/src/canva.ts index e88d8fd..712efee 100644 --- a/src/canva.ts +++ b/src/canva.ts @@ -23,16 +23,16 @@ export interface Clo{ /** * Font Style Interface - * family : eg. "FreeSans" - * size : in px, not in pt. - * textWeight : TextWeight.REGULAR ,etc - * textWeight : TextStyle.ITALIC ,etc + * - family : eg. "FreeSans" + * - size : in px, not in pt. + * - textWeight : TextWeight.REGULAR ,etc + * - fontStyle : FontStyle.ITALIC ,etc */ -export interface FontStyle{ +export interface TextStyle{ family : string, size : number, textWeight : TextWeight, - textStyle : TextStyle, + fontStyle : FontStyle, color? : string, }; @@ -41,7 +41,7 @@ export enum TextWeight { BOLD, }; -export enum TextStyle{ +export enum FontStyle{ NORMAL, ITALIC, OBLIQUE, @@ -57,10 +57,10 @@ export interface fontPathPSNamePair{ * @param style the font style * @returns pair of the font path and postscript name. */ -export function fontStyleTofont(style : FontStyle) : fontPathPSNamePair{ +export function fontStyleTofont(style : TextStyle) : fontPathPSNamePair{ try { let fcMatchCommand = `fc-match "${style.family}":${TextWeight[style.textWeight]}:`+ - `${TextStyle[style.textStyle]}` +` postscriptname file`; + `${FontStyle[style.fontStyle]}` +` postscriptname file`; let fcMatchOut = execSync(fcMatchCommand); let matched = fcMatchOut @@ -93,7 +93,7 @@ export function fontStyleTofont(style : FontStyle) : fontPathPSNamePair{ * @param y base y-point from top * @returns a new updated clo object */ -export async function putText(clo : Clo, str : string, sty : FontStyle, +export async function putText(clo : Clo, str : string, sty : TextStyle, pageNo : number, x : number, y : number): Promise{ let fontInfo = fontStyleTofont(sty);