From 9f4120faf425cff7c7bca03922bb5d3260f366c0 Mon Sep 17 00:00:00 2001 From: Zachariah Brown Date: Tue, 24 Feb 2015 10:41:32 -0500 Subject: [PATCH] Added support for the Font::Info struct --- include/SFML/Graphics/Font.h | 17 ++++++++++++- include/SFML/Graphics/FontInfo.h | 42 ++++++++++++++++++++++++++++++++ src/SFML/Graphics/CMakeLists.txt | 1 + src/SFML/Graphics/Font.cpp | 11 +++++++++ 4 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 include/SFML/Graphics/FontInfo.h diff --git a/include/SFML/Graphics/Font.h b/include/SFML/Graphics/Font.h index 2175294..ddcbc73 100644 --- a/include/SFML/Graphics/Font.h +++ b/include/SFML/Graphics/Font.h @@ -29,6 +29,7 @@ // Headers //////////////////////////////////////////////////////////// #include +#include #include #include #include @@ -132,5 +133,19 @@ CSFML_GRAPHICS_API float sfFont_getLineSpacing(sfFont* font, unsigned int charac //////////////////////////////////////////////////////////// CSFML_GRAPHICS_API const sfTexture* sfFont_getTexture(sfFont* font, unsigned int characterSize); +//////////////////////////////////////////////////////////// +/// \brief Get the font information +/// +/// The returned structure will remain valid only if the font +/// is still valid. If the font is invalid an invalid structure +/// is returned. +/// +/// \param font Source font +/// +/// \return A structure that holds the font information +/// +//////////////////////////////////////////////////////////// +CSFML_GRAPHICS_API sfFontInfo sfFont_getInfo(const sfFont* font); -#endif // SFML_IMAGE_H + +#endif // SFML_FONT_H diff --git a/include/SFML/Graphics/FontInfo.h b/include/SFML/Graphics/FontInfo.h new file mode 100644 index 0000000..a50f49f --- /dev/null +++ b/include/SFML/Graphics/FontInfo.h @@ -0,0 +1,42 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2007-2014 Laurent Gomila (laurent.gom@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_FONTINFO_H +#define SFML_FONTINFO_H + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + +//////////////////////////////////////////////////////////// +/// sfFontInfo holds various information about a font +//////////////////////////////////////////////////////////// +typedef struct +{ + const char* family; +} sfFontInfo; + + +#endif // SFML_FONTINFO_H diff --git a/src/SFML/Graphics/CMakeLists.txt b/src/SFML/Graphics/CMakeLists.txt index 2a43f14..a68ce3b 100644 --- a/src/SFML/Graphics/CMakeLists.txt +++ b/src/SFML/Graphics/CMakeLists.txt @@ -20,6 +20,7 @@ set(SRC ${SRCROOT}/Font.cpp ${SRCROOT}/FontStruct.h ${INCROOT}/Font.h + ${INCROOT}/FontInfo.h ${INCROOT}/Glyph.h ${SRCROOT}/Image.cpp ${SRCROOT}/ImageStruct.h diff --git a/src/SFML/Graphics/Font.cpp b/src/SFML/Graphics/Font.cpp index 320c269..5ccaf6f 100644 --- a/src/SFML/Graphics/Font.cpp +++ b/src/SFML/Graphics/Font.cpp @@ -155,3 +155,14 @@ const sfTexture* sfFont_getTexture(sfFont* font, unsigned int characterSize) return &font->Textures[characterSize]; } + +//////////////////////////////////////////////////////////// +sfFontInfo sfFont_getInfo(const sfFont* font) +{ + sfFontInfo info = {NULL}; + CSFML_CHECK_RETURN(font, info); + + info.family = font->This.getInfo().family.c_str(); + + return info; +}