A simple yet powerful library for controlling graphical displays. Multiple display controllers are supported using inheritance.
Dependents: mbed_rifletool Hexi_Bubble_Game Hexi_Catch-the-dot_Game Hexi_Acceleromagnetic_Synth
Font.h
00001 /* NeatGUI Library 00002 * Copyright (c) 2013 Neil Thiessen 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef FONT_H 00018 #define FONT_H 00019 00020 #include "mbed.h" 00021 #include "BitmapImage.h" 00022 00023 /** Font class. 00024 * Used to access font data in an external table. 00025 */ 00026 class Font 00027 { 00028 public: 00029 /** Create a white Font object 00030 * 00031 * @param table Pointer to the font table. 00032 */ 00033 Font(const char* table); 00034 00035 /** Create a Font object with the specified color 00036 * 00037 * @param table Pointer to the font table. 00038 * @param color Color for the font as a 32-bit ARGB value. 00039 */ 00040 Font(const char* table, unsigned int color); 00041 00042 /** Get the glyph Image for the specified character 00043 * 00044 * @returns The character glyph Image. 00045 */ 00046 BitmapImage glyph(char c); 00047 00048 /** Get the current Font color 00049 * 00050 * @returns The current Font color as a 32-bit ARGB value. 00051 */ 00052 unsigned int color(); 00053 00054 /** Set the Font color 00055 * 00056 * @param c The new Font color as a 32-bit ARGB value. 00057 */ 00058 void color(unsigned int c); 00059 00060 /** Get the height of the Font glyphs 00061 * 00062 * @returns The height of the Font glyphs. 00063 */ 00064 int height(); 00065 00066 /** Measures the width of a string in pixels if drawn with this font 00067 * 00068 * @param str Pointer to the string to measure. 00069 * 00070 * @returns The width of the string in pixels. 00071 */ 00072 int measureString(const char* str); 00073 00074 /** Measures the width of the next word in a string (separated by whitespace) in pixels if drawn with this font 00075 * 00076 * @param str Pointer to the string to measure. 00077 * 00078 * @returns The width of the next word in pixels. 00079 */ 00080 int measureWord(const char* str); 00081 00082 protected: 00083 const char* m_FontTable; 00084 unsigned int m_Color; 00085 }; 00086 00087 #endif
Generated on Tue Jul 12 2022 20:26:18 by 1.7.2