Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: src/SGL.cpp
- Revision:
- 15:c49040bf0e1d
- Parent:
- 13:8dd215952d76
- Child:
- 17:1bcdc92af126
diff -r 961ce3497de1 -r c49040bf0e1d src/SGL.cpp
--- a/src/SGL.cpp Tue Dec 22 21:44:31 2015 +0000
+++ b/src/SGL.cpp Thu Dec 08 21:38:39 2016 +0000
@@ -269,7 +269,7 @@
}
//---------------------------------------------------------------------------------------
-template <class T>
+/*template <class T>
void SGL<T>::drawString(const char *string, T x, T y, uint16_t color, float zoom, uint8_t fontSpace)
{
if(!_currentFont && !*_currentFont)
@@ -286,6 +286,31 @@
x = 0;
}
}
+}*/
+
+//---------------------------------------------------------------------------------------
+template <class T>
+Rect<T> SGL<T>::drawString(const char *string, T x, T y, uint16_t color, float zoom, uint8_t fontSpace)
+{
+ if(!_currentFont && !*_currentFont)
+ return Rect<T>();
+
+ int boundingWidth = 0;
+
+ while(*string)
+ {
+ boundingWidth += _fontWidth;
+ drawChar(*string, x, y, color, zoom);
+ *string++;
+ x += fontSpace*zoom;
+ if(x >= _width-1)
+ {
+ y += _fontHeight*zoom;
+ x = 0;
+ }
+ }
+
+ return Rect<T>(x, y, boundingWidth, _fontHeight );
}
//---------------------------------------------------------------------------------------