Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of SimpleGUI by
UGFontRenderer.cpp
00001 #include "UGFontRenderer.h" 00002 #include "Arial24x23.h" 00003 00004 UGFontRenderer::UGFontRenderer() : FontRenderer() 00005 { 00006 } 00007 00008 void UGFontRenderer::putc(const char c, GraphicsDisplay* display, Font* font) 00009 { 00010 00011 UGFont* _font = (UGFont*) font; 00012 if(!_font->contains(c)) { 00013 return; 00014 } 00015 00016 uint8_t cw = _font->zoomedWidthOf(c); 00017 uint8_t ch = _font->zoomedHeight(); 00018 00019 bool wrap = (_cx + cw) > _wx1 && !_clip; 00020 00021 if(c == '\n' || wrap) { 00022 _cx = _wx0; 00023 _cy += ch; 00024 } 00025 00026 if(cw == 0) { 00027 return; 00028 } 00029 00030 // We have to do clipping/wrapping for now because the display doesn't do it for us 00031 if((_cx + cw) > _wx1) { 00032 // We've done any wrapping already, so if we get here the window must be smaller than the character 00033 return; 00034 } 00035 00036 if((_cy + ch) > _wy1) { 00037 return; 00038 } 00039 00040 00041 uint8_t height = _font->height(); 00042 uint8_t width = _font->widthOf(c); 00043 uint8_t zx = _font->zoomX(); 00044 uint8_t zy = _font->zoomY(); 00045 uint8_t bpc = _font->bytesPerCol(); 00046 uint8_t row, col, v; 00047 uint8_t bits, mask; 00048 00049 // We don't do clipping logic for chars - that's the job of the display 00050 // Just set a window into which to render the char and let the display ignore it if it doesn't fit 00051 display->window(_cx, _cy, cw, ch); 00052 00053 uint8_t* glyphData = _font->getGlyphData(c); 00054 00055 // construct the char into the buffer 00056 for (row=0; row < height; row++) { // vert line 00057 for (v=0; v < zy; v++) { // repeat horiz line for vertical zooming 00058 for (col=0; col < width; col++) { // horz line 00059 00060 bits = glyphData[(bpc * col) + (row >> 3)]; 00061 00062 mask = 1 << (row & 0x07); 00063 00064 if (bits & mask) { 00065 display->window_pushpixel(_foreground, zx); 00066 } else { 00067 display->window_pushpixel(_background, zx); 00068 } 00069 } 00070 } //for each zoomed vert 00071 } 00072 _cx += cw; 00073 } 00074 00075 void UGFontRenderer::puts(const char* c, GraphicsDisplay* display, Font* _font) 00076 {}
Generated on Tue Jul 12 2022 22:27:14 by
