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

Font sizes #88

Closed
Galbi3000 opened this issue Jul 5, 2017 · 10 comments
Closed

Font sizes #88

Galbi3000 opened this issue Jul 5, 2017 · 10 comments

Comments

@Galbi3000
Copy link

Galbi3000 commented Jul 5, 2017

The difference in physical size of fonts using size 1 and size 2 is too great. There needs to be an intermediary size between them. The problem I encountered was that using display.setTextSize(1) makes the font too small to read easily on a 0.96" display and display.setTextSize(2) makes it too big to fit much information.

@PaintYourDragon
Copy link
Contributor

https://learn.adafruit.com/adafruit-gfx-graphics-library/using-fonts

Other-size fonts are available with a few extra steps. And they look much nicer than the default font!

@Galbi3000
Copy link
Author

Galbi3000 commented Jul 5, 2017

First of all, thanks for responding so quickly, but you are too quick to close the issue!
That page is not useful at all for the SSD1306. It refers to using the TFT hardware library's setFont function to change the font. As far as I can tell there is no setFont function in the SSD1306 hardware library as provided here. I see no reference to it in the .cpp or the .h files.

Here is how they tell you to do it:

#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_TFTLCD.h> // Hardware-specific library
#include <Fonts/FreeMonoBoldOblique12pt7b.h>
tft.setFont(&FreeMonoBoldOblique12pt7b);

As you see, the setFont is TFT specific.

@Galbi3000
Copy link
Author

Galbi3000 commented Jul 5, 2017

After looking through the source code for the GFX library I have found that the setFont function is indeed in that library but the "Using Fonts" web page provided says it's in the TFT hardware specific library which causes confusion. There really needs to be much better documentation on these libraries.

@gunhansancar
Copy link

I second that It is not that clear and spend an hour to see if I'm missing something.
For the future readers to change the font do the following:

1- Include the font header that you wish to use
#include <Fonts/FreeSans9pt7b.h>
2-Set the font

//Assuming you have declared your display object for instance:
//Adafruit_SSD1306 display(OLED_RESET);
display.setFont(&FreeSans9pt7b);

That's it.

@Rieny123
Copy link

Rieny123 commented Jan 22, 2018

EDIT: never mind I fixed it by changing the y value of set cursor to 15;

Hey,

I tried using the example code you gave for using that font, but when I do all it shows are flat stripes. Do you perhaps know what I'm doing wrong?

@CraigMarston
Copy link

Thank-you VERY much @gunhansancar !!

@Jahaziel-Ojeda
Copy link

Thanks to you I just spent 20 min. @gunhansancar

@adafruit adafruit deleted a comment from kevindawson Mar 26, 2020
@pyza666
Copy link

pyza666 commented Jan 18, 2022

This is an old post but i had the same problem with scaling the font size. I have changed all variables called TextSize in Adafruit_GFX.cpp and Adafruit_GFX.h from int (uint8_t, int16_t) to float. Now i can granularly change font size to values like 1.2, 1.5 etc..

@LuRoco
Copy link

LuRoco commented Jan 19, 2022

@pyza666

This is an old post but i had the same problem with scaling the font size. I have changed all variables called TextSize in Adafruit_GFX.cpp and Adafruit_GFX.h from int (uint8_t, int16_t) to float. Now i can granularly change font size to values like 1.2, 1.5 etc..

Hii, how did you replaced it ? like uint8_t to ufloat8_t ? and for int16_t the same?? I got an error when I tried to change all the int related to variable TextSize to float

@pyza666
Copy link

pyza666 commented Jan 19, 2022

@pyza666

This is an old post but i had the same problem with scaling the font size. I have changed all variables called TextSize in Adafruit_GFX.cpp and Adafruit_GFX.h from int (uint8_t, int16_t) to float. Now i can granularly change font size to values like 1.2, 1.5 etc..

Hii, how did you replaced it ? like uint8_t to ufloat8_t ? and for int16_t the same?? I got an error when I tried to change all the int related to variable TextSize to float
Check my files:
https://drive.google.com/drive/folders/1s5irKeFCHLMgdhiwgaWbUYswknHlWh12?usp=sharing

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

8 participants