@odoo/o-spreadsheet
Version:
A spreadsheet component
53 lines (52 loc) • 3.32 kB
TypeScript
import { Canvas2DContext } from "../types/canvas";
import { Cell } from "../types/cells";
import { Locale } from "../types/locale";
import { Pixel, PixelPosition, Style } from "../types/misc";
export declare function computeTextLinesHeight(textLineHeight: number, numberOfLines?: number): number;
export declare function getCanvas(width?: number, height?: number): Canvas2DContext;
/**
* Get the default height of the cell given its style.
*/
export declare function getDefaultCellHeight(ctx: Canvas2DContext, cell: Cell | undefined, locale: Locale, colSize: number): number;
export declare function getCellContentHeight(ctx: Canvas2DContext, content: string, style: Style | undefined, colSize: number): number;
export declare function getDefaultContextFont(fontSize: number, bold?: boolean | undefined, italic?: boolean | undefined): string;
export declare function computeMultilineTextSize(context: Canvas2DContext, textLines: string[], style?: Style, fontUnit?: "px" | "pt"): {
width: number;
height: number;
};
export declare function computeTextWidth(context: Canvas2DContext, text: string, style?: Style, fontUnit?: "px" | "pt"): number;
export declare function computeTextDimension(context: Canvas2DContext, text: string, style: Style, fontUnit?: "px" | "pt"): {
width: number;
height: number;
};
export declare function fontSizeInPixels(fontSize: number): number;
export declare function computeTextFont(style: Style, fontUnit?: "px" | "pt"): string;
export declare function computeTextFontSizeInPixels(style?: Style): number;
/**
* Return the given text, split in multiple lines if needed. The text will be split in multiple
* line if it contains NEWLINE characters, or if it's longer than the given width.
*/
export declare function splitTextToWidth(ctx: Canvas2DContext, text: string, style: Style | undefined, width: number | undefined): string[];
/**
* Return the font size that makes the width of a text match the given line width.
* Minimum font size is 1.
*
* @param getTextWidth function that takes a fontSize as argument, and return the width of the text with this font size.
*/
export declare function getFontSizeMatchingWidth(lineWidth: number, maxFontSize: number, getTextWidth: (fontSize: number) => number, precision?: number): number;
/** Transform a string to lowercase and removes whitespace from both ends of the string*/
export declare function toTrimmedLowerCase(str: string | undefined): string;
export declare function getContextFontSize(font: string): Pixel;
export declare function clipTextWithEllipsis(ctx: Canvas2DContext, text: string, maxWidth: number): string;
export declare function drawDecoratedText(context: Canvas2DContext, text: string, position: PixelPosition, underline?: boolean | undefined, strikethrough?: boolean | undefined, strokeWidth?: number): void;
export declare function sliceTextToFitWidth(context: Canvas2DContext, width: number, text: string, style: Style, fontUnit?: "px" | "pt"): string;
/**
* Return the position to draw text on a rotated canvas to ensure that the rotated text alignment correspond
* with to original's text vertical and horizontal alignment.
*/
export declare function computeRotationPosition(rect: {
x: number;
y: number;
textWidth: number;
textHeight: number;
}, style: Style): PixelPosition;