X-Git-Url: https://git.rohieb.name/hackover2013-badge-firmware.git/blobdiff_plain/9e04bf6c52ed702ff98f18fc7d5508bc5f453767..b2d84a4b240edc1e4e15793180529eacce45cec8:/drivers/displays/tft/aafonts.c diff --git a/drivers/displays/tft/aafonts.c b/drivers/displays/tft/aafonts.c index c425bf9..0983c15 100644 --- a/drivers/displays/tft/aafonts.c +++ b/drivers/displays/tft/aafonts.c @@ -1,5 +1,5 @@ /**************************************************************************/ -/*! +/*! @file aafonts.c @author K. Townsend (microBuilder.eu) @@ -239,6 +239,30 @@ void aafontsDrawString(uint16_t x, uint16_t y, const uint16_t * colorTable, cons } } +/**************************************************************************/ +/*! + @brief Draws a string using the supplied anti-aliased font, centering + it on the specified X/Y co-ordinate + + @param[in] x + Center x co-ordinate + @param[in] y + Center y co-ordinate + @param[in] colorTable + The color lookup table to use for the antialiased pixels + @param[in] font + Pointer to the aafontsFont_t to use when drawing the string + @param[in] str + The string to render +*/ +/**************************************************************************/ +void aafontsCenterString(uint16_t x, uint16_t y, const uint16_t * colorTable, const aafontsFont_t *font, char *str) +{ + uint32_t stringWidth; + stringWidth = aafontsGetStringWidth(font, str); + aafontsDrawString(x - stringWidth/2, y, colorTable, font, str); +} + /**************************************************************************/ /*! @brief Returns the width in pixels of a string when it is rendered @@ -294,17 +318,11 @@ uint16_t aafontsGetStringWidth(const aafontsFont_t *font, char *str) /**************************************************************************/ /*! - @brief Creates a 4 or 16 shade color between the specified bg and - fore color for use with anti-aliased fonts. - - @note This method can be used to place anti-aliased in any color on - any known, solid-colored background. + @brief Calculates a 4 or 16 color lookup table between the specified + bg and fore colors for use with anti-aliased fonts. - You can get slightly higher-quality results by calculating - the color tables by hand, but this method is a convenient - method to create text in a variety of colors or on a variety - of backgrounds. Please note, though, that the visual quality - of the text heavily on the colors being used. + @note This method can be used to place anti-aliased text on any color + of background, as long as it's a single solid color. @param[in] bgColor The RGB565 color of the background