-
Notifications
You must be signed in to change notification settings - Fork 49
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
Scaling fonts #39
Comments
Currently there is no convenient way but you could use bitmap_t bitmap;
bitmap.buffer = (uint8_t *) malloc(6 * 9 * sizeof(color_t));
for (uint16_t i = 1; i < 20000; i++) {
int16_t x0 = rand() % DISPLAY_WIDTH;
int16_t y0 = rand() % DISPLAY_HEIGHT;
color_t color = rand() % 0xffff;
uint16_t code = rand() % 0xffff;
hagl_get_glyph(code, color, &bitmap, font6x9);
hagl_scale_blit(x0, y0, 24, 36, &bitmap);
} I have intentionally left scaled fonts out for now because I have not figured out a good API on how to do it. Lets assume we add a scaling factor. hagl_put_char(code, x0, y0, color, font8x8, scale); Still quite ok, but what about background color? hagl_put_char(code, x0, y0, color, background, font8x8, scale); What is we need be able to put chars rotated 90 degrees? hagl_put_char(code, x0, y0, color, background, font8x8, scale, rotate); etc. In the end there will be too many parameters and the code will look ugly. One option would be to add a style struct. font_style_t style;
style.font = font8x8;
style.scale = 2;
style.color = rand() % 0xffff;
hagl_put_char(code, x0, y0, style); This way it would be easy to maintain BC even when adding new stylable parameters. Question is should other functions such as Other possibility would be to use builder style functions. hagl_set_font(font8x8);
hagl_set_font_scale(2);
hagl_set_font_color(0xffff);
hagl_put_char(code, x0, y0); Or maybe use actual builders. font_style_t style;
hagl_set_font(font8x8, &style);
hagl_set_font_scale(2, &style);
hagl_set_font_color(0xffff, &style);
hagl_put_char(code, x0, y0, style); I think I personally like the first option ie. style structs most. |
hmmm, ok, thanks, I see what you mean. Not quite as simple as it first seems if you don't want to get into a mess in the future |
In the meanwhile if you just need bigger fonts check for example the X11 fonts. |
Thanks for the suggestion... The biggest problem I can see is that adding style (or anything) to the existing hagl_put_char, etc., functions is that it'd be a breaking change to the API? |
Is there a way to scale up existing fonts, i.e. use one of the supplied fonts at double/triple etc., the actual size? If not, would a PR that adds this be reasonable?
I'm thinking versions of hagl_put_text / hagl_put_char that take a scale factor as a parameter.
The text was updated successfully, but these errors were encountered: