Sharp LCD library forked to use a Lucida 8 pt font

Fork of SharpLCD by Rohit Grover

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers font.c Source File

font.c

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2006-2013 ARM Limited
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 #include <string.h>
00018 #include <stddef.h>
00019 
00020 #include "font.h"
00021 
00022 /* Externs private to the font subsystem. */
00023 /* extern const glyph_t glyphs_DejaVu_Serif_10[]; */
00024 /* extern const uint8_t bitmaps_DejaVu_Serif_10[]; */
00025 //extern const glyph_t glyphs_DejaVu_Serif_9[];
00026 //extern const uint8_t bitmaps_DejaVu_Serif_9[];
00027 //extern const glyph_t glyphs_DejaVu_Serif_8[];
00028 //extern const uint8_t bitmaps_DejaVu_Serif_8[];
00029 extern const uint8_t lucidaConsole_8ptBitmaps[];
00030 extern const glyph_t lucidaConsole_8ptDescriptors[];
00031 
00032 /* Accumulation of all avaialble fonts */
00033 const font_face_t fonts[] = {
00034     /* { */
00035     /*     "DejaVu Serif", */
00036     /*     10,   /\* pointSize *\/ */
00037     /*     glyphs_DejaVu_Serif_10, */
00038     /*     bitmaps_DejaVu_Serif_10 */
00039     /* }, */
00040     {
00041         "Lucida 8pt",
00042         8,   /* pointSize */
00043         lucidaConsole_8ptDescriptors,
00044         lucidaConsole_8ptBitmaps
00045     },
00046     //{
00047     //    "DejaVu Serif",
00048     //    9,   /* pointSize */
00049     //    glyphs_DejaVu_Serif_9,
00050     //    bitmaps_DejaVu_Serif_9
00051    // },
00052     //{
00053         //"DejaVu Serif",
00054         //8,   /* pointSize */
00055         //glyphs_DejaVu_Serif_8,
00056         //bitmaps_DejaVu_Serif_8
00057     //},
00058 
00059     /* sentinel value */
00060     {
00061         NULL,
00062         0,
00063         NULL,
00064         NULL
00065     }
00066 };
00067 
00068 
00069 const font_face_t *
00070 lookupFontFace(const char  *familyName,
00071                unsigned int pointSize)
00072 {
00073     unsigned fontIndex;
00074 
00075     for (fontIndex = 0; fonts[fontIndex].familyName != NULL; fontIndex++) {
00076         if ((strcmp(fonts[fontIndex].familyName, familyName) == 0) &&
00077             (fonts[fontIndex].pointSize == pointSize)) {
00078             /* found it! */
00079             return (&fonts[fontIndex]);
00080         }
00081     }
00082 
00083     return (NULL);
00084 }