Miroslaw K. / Graphics

Dependents:   RadarDemo 3DDemo RadarDemoT

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers GrFont.h Source File

GrFont.h

00001 /*
00002     GrFont.h - System font wrapper class
00003 
00004     Copyright(c) 2016 karpent at gmail.com, MIT License
00005 
00006     Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"),
00007     to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
00008     and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions :
00009 
00010     The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
00011 
00012     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00013     FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
00014     OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
00015     THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00016 */
00017 
00018 #pragma once
00019 
00020 #include "mbed.h"
00021 #include "stm32746g_discovery_lcd.h"
00022 
00023 /**
00024  * GrFontType defines available font types
00025  */
00026 typedef enum  {
00027     // Used for array indexes!  Don't change the numbers!
00028     Courier8 = 0,
00029     Courier12 = 1,
00030     Courier16 = 2,
00031     Courier20 = 3,
00032     Courier24 = 4,
00033     FontsNumber
00034 } GrFontType;
00035 
00036 
00037 /**
00038  *  @brief System font definition class
00039  *  to keep system fonts sFONT isolated.
00040  *  Class will be usefull to handle custom defined fonts.
00041  */
00042 class GrFont
00043 {
00044 
00045 public:
00046     /**
00047     * @brief Constructor sets system font of size 12 as a default font.
00048     */
00049     GrFont();
00050     
00051     /**
00052     * @brief Constructor sets font of type defined by GrFontType (enum EGrFont).
00053     */
00054     GrFont(GrFontType fontType);
00055 
00056     /**
00057     * @brief Get a reference to original system font.
00058     */
00059     sFONT * GetSystemFont();
00060 
00061     /**
00062     * @brief Change selected font.
00063     */
00064     void SetFontType(GrFontType fontType);
00065 
00066     /**
00067     * @brief Get selected font width in pixels.
00068     */
00069     uint16_t Width();
00070     
00071     /**
00072     * @brief Get selected font height in pixels.
00073     */
00074     uint16_t Height();
00075 
00076 private:
00077 
00078     static const sFONT * _fontType[FontsNumber];
00079   
00080     GrFontType _fontTypeSelected;
00081 };