Skip to content

Text object #9

Description

@pinventado

Design a Text object that allows you to set its size, color, and value. Its most important feature is to retrieve the text width and height so that developers can check whether they fit in a given region. For example, the feature allows you to check whether the text could fit inside a box of a given height and width.

A possible solution would be to create an image object, drawtext on it, then retrieve the objects resulting width and height as described here. The suggested code is shown below for reference:

CImg<unsigned char> imgtext;
unsigned char color = 1;
imgtext.draw_text(0,0,"Hello guys !",&color,0,1,23);  // Draw with font height 23.
// Now, imgtext.width() and imgtext.height() gives you the dimensions you want.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions