aboutsummaryrefslogtreecommitdiffstats
path: root/src/gdisp
diff options
context:
space:
mode:
authorJoel Bodenmann <joel@seriouslyembedded.com>2015-08-14 20:48:41 +0200
committerJoel Bodenmann <joel@seriouslyembedded.com>2015-08-14 20:48:41 +0200
commitf7075e25ed9bcd701395745161f9ee086c025e21 (patch)
treea0f3ec4c19e6fdc0a61f421e97ad5e63825f3c9b /src/gdisp
parent608290a261b5577825a31fb4f821e263bc43c094 (diff)
downloaduGFX-f7075e25ed9bcd701395745161f9ee086c025e21.tar.gz
uGFX-f7075e25ed9bcd701395745161f9ee086c025e21.tar.bz2
uGFX-f7075e25ed9bcd701395745161f9ee086c025e21.zip
More work on the TextEdit
Diffstat (limited to 'src/gdisp')
-rw-r--r--src/gdisp/gdisp.c20
-rw-r--r--src/gdisp/gdisp.h17
2 files changed, 33 insertions, 4 deletions
diff --git a/src/gdisp/gdisp.c b/src/gdisp/gdisp.c
index 43b470b2..6e431441 100644
--- a/src/gdisp/gdisp.c
+++ b/src/gdisp/gdisp.c
@@ -3324,12 +3324,26 @@ void gdispGDrawBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, co
return mf_character_width(font, c);
}
+ coord_t gdispGetStringWidthCount(const char* str, font_t font, uint16_t count) {
+ if (!str) {
+ return 0;
+ }
+
+ // No mutex required as we only read static data
+ #if GDISP_NEED_TEXT_KERNING
+ return mf_get_string_width(font, str, count, TRUE);
+ #else
+ return mf_get_string_width(font, str, count, FALSE);
+ #endif
+ }
+
coord_t gdispGetStringWidth(const char* str, font_t font) {
- if (!str)
+ if (!str) {
return 0;
+ }
- /* No mutex required as we only read static data */
- return mf_get_string_width(font, str, 0, 0);
+ // No mutex required as we only read static data
+ return gdispGetStringWidthCount(str, font, 0);
}
#endif
diff --git a/src/gdisp/gdisp.h b/src/gdisp/gdisp.h
index 298258cb..b096cb3d 100644
--- a/src/gdisp/gdisp.h
+++ b/src/gdisp/gdisp.h
@@ -978,7 +978,22 @@ void gdispGDrawBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, co
coord_t gdispGetCharWidth(char c, font_t font);
/**
- * @brief Get the pixel width of a string.
+ * @brief Get the pixel width of a string of a given length.
+ * @return The width of the string in pixels.
+ * @pre GDISP_NEED_TEXT must be TRUE in your gfxconf.h
+ *
+ * @note Passing 0 to count has the same effect as calling gdispGetStringWidt()
+ *
+ * @param[in] str The string to measure
+ * @param[in] font The font to use
+ * @param[in] count The number of characters to take into account
+ *
+ * @api
+ */
+ coord_t gdispGetStringWidthCount(const char* str, font_t font, uint16_t count);
+
+ /**
+ * @brief Get the pixel width of an entire string.
* @return The width of the string in pixels.
* @pre GDISP_NEED_TEXT must be TRUE in your gfxconf.h
*