Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FreeText Annotation Text Size #733

Open
RobTur opened this issue Sep 23, 2017 · 1 comment
Open

FreeText Annotation Text Size #733

RobTur opened this issue Sep 23, 2017 · 1 comment

Comments

@RobTur
Copy link

RobTur commented Sep 23, 2017

Is it possible to change the text size? I can't find the options available to this method
textAnnotation(x, y, width, height, text, options)

thank you

@ljluestc
Copy link

// Assuming you are using a graphics library like Fabric.js or a similar one

// Define the text annotation function
function textAnnotation(x, y, width, height, text, options) {
    // Set default options if none are provided
    options = options || {};

    // Default text size is 12px if not provided
    const textSize = options.fontSize || 12;
    const fontFamily = options.fontFamily || 'Arial';  // Default font family
    const fontColor = options.fontColor || 'black';   // Default color

    // Create a new text element with the given properties
    const textElement = new fabric.Text(text, {
        left: x,
        top: y,
        fontSize: textSize,
        fontFamily: fontFamily,
        fill: fontColor,
        width: width,
        height: height
    });

    // Assuming you have a canvas or context to render the text on
    canvas.add(textElement);
}

// Example usage:
textAnnotation(100, 100, 200, 50, "Hello World", { fontSize: 20, fontFamily: "Verdana", fontColor: "red" });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants