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

Allow text size as float #352

Open
wmarkow opened this issue May 25, 2021 · 0 comments
Open

Allow text size as float #352

wmarkow opened this issue May 25, 2021 · 0 comments

Comments

@wmarkow
Copy link

wmarkow commented May 25, 2021

It would be a nice to have feature where the text size could be also entered as a float. Currently an integer numbers for text size are allowed.
By default:

  • text size 1 produces text with size 6x8 (width x height) pixels
  • text size 2 produces text with size 12x16 pixels

In my application I use both sizes but I would also like to have a size 9x12 pixels. This could be achieved with text size of 1.5 however at the moment this value is not allowed because text size is defined as uint8_t:

 Adafruit_GFX.h

  uint8_t textsize_x;   ///< Desired magnification in X-axis of text to print()
  uint8_t textsize_y;   ///< Desired magnification in Y-axis of text to print()

In 1.10.7-text-size branch of my fork I made a change where text size is now a float. It is implemented over original 1.10.7 release version. I did a minimal required effort to have what I want to have. Side effects for this are unknown; just the text size meet my requirement. Maybe somebody will find it as a useful feature and can use it in his own solution.

The result can be seen on the picture below. Under each Trip word is written what is the text size. The code used to generate the preview is:

    display.clearDisplay();

    display.setTextSize(1.0); // 6x8
    display.setCursor(0, 0);
    display.write("Trip");
    display.setCursor(5, 16);
    display.write("1.0");

    display.setTextSize(1.5); // 9x12
    display.setCursor(30, 0);
    display.write("Trip");
    display.setCursor(35, 16);
    display.write("1.5");

    display.setTextSize(2.0); // 12x16
    display.setCursor(75, 0);
    display.write("Trip");
    display.setCursor(80, 16);
    display.write("2.0");

    display.display();

The display has 128px width and 32px height. AVR board is Arduino Pro Mini 5V.

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