el h / SimpleGUI

Fork of SimpleGUI by Duncan McIntyre

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Font.h Source File

Font.h

00001 #ifndef SIMPLEGUI_FONT_H
00002 #define SIMPLEGUI_FONT_H
00003 
00004 #include "mbed.h"
00005 
00006 /**
00007 * Interface defining a Font
00008 * This is used by both the UniGraphic and FastFont implementations.
00009 * 
00010 **/
00011 class Font
00012 {
00013 public:
00014 
00015     Font() : _zoomX(1), _zoomY(1) {};
00016     
00017     virtual uint8_t firstAscii() = 0;
00018     virtual uint8_t lastAscii() = 0;
00019     
00020     /**
00021     * The unzoomed width of the character
00022     **/
00023     virtual uint8_t  widthOf(char c) = 0;
00024     virtual uint8_t zoomedWidthOf(char c) =0;
00025     
00026     /**
00027     * The unzoomed height of a character
00028     **/
00029     virtual uint8_t  height() =0;
00030     virtual uint8_t zoomedHeight() =0;
00031     
00032     virtual bool isProportional() =0;
00033     
00034     bool contains(char c) {
00035         return c>= firstAscii() && c <= lastAscii();
00036     }
00037     
00038     void setZoom(uint8_t xmul, uint8_t ymul) {
00039         _zoomX=((xmul==0) ? 1:xmul);
00040         _zoomY=((ymul==0) ? 1:ymul);
00041     }
00042 
00043     uint8_t zoomX() {
00044         return _zoomX;
00045     }
00046 
00047     uint8_t zoomY() {
00048         return _zoomY;
00049     }
00050 
00051 protected:
00052 
00053     uint8_t _zoomX, _zoomY;
00054 };
00055 
00056 #endif