Something went wrong. Try again.
Massive multiplayer game aiming to create a collaborative musical environment.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292/*********************************************************************** filename: CEGUIFontProperties.h created: 12/6/2006 author: Andrew Zabolotny
purpose: Interface to available font properties*************************************************************************//*************************************************************************** * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. ***************************************************************************/#include "CEGUIFont.h"#include "CEGUIFreeTypeFont.h"#include "CEGUIPixmapFont.h"#include "CEGUIImageset.h"#include "CEGUIXMLSerializer.h" #include "CEGUIPropertyHelper.h"#include "CEGUIExceptions.h"
// Start of CEGUI namespace sectionnamespace CEGUI{
// Start of WindowProperties namespace section/*!\brief Namespace containing all classes that make up the properties interface for the Font base class*/namespace FontProperties{
class NativeRes : public Property{public: NativeRes () : Property( "NativeRes", "Native screen resolution for this font. Value uses the 'w:# h:#' format.") {}
String get (const PropertyReceiver* receiver) const { const Font *f = static_cast<const Font*>(receiver); Size s (f->d_nativeHorzRes, f->d_nativeVertRes); return PropertyHelper::sizeToString (s); }
void set (PropertyReceiver* receiver, const String& value) { Font *f = static_cast<Font*>(receiver); f->setNativeResolution (PropertyHelper::stringToSize (value)); }};
class Name : public Property{public: Name () : Property( "Name", "This is font name. Value is a string.") {}
String get (const PropertyReceiver* receiver) const { return static_cast<const Font*>(receiver)->d_name; }
void set (PropertyReceiver* receiver, const String& value) { static_cast<Font*>(receiver)->d_name = value; }};
class FileName : public Property{public: FileName () : Property( "FileName", "This is the filename from which the font is loaded.") {}
String get (const PropertyReceiver* receiver) const { return static_cast<const Font*>(receiver)->d_fileName; }
void set (PropertyReceiver* receiver, const String& value) { static_cast<Font*>(receiver)->d_fileName = value; }};
class ResourceGroup : public Property{public: ResourceGroup () : Property( "ResourceGroup", "This is the resource group for font file name.") {}
String get (const PropertyReceiver* receiver) const { return static_cast<const Font*>(receiver)->d_resourceGroup; }
void set (PropertyReceiver* receiver, const String& value) { static_cast<Font*>(receiver)->d_resourceGroup = value; }};
class AutoScaled : public Property{public: AutoScaled () : Property( "AutoScaled", "This is a flag indicating whether to autoscale font depending on resolution. Value is either true or false.") {}
String get (const PropertyReceiver* receiver) const { return PropertyHelper::boolToString(static_cast<const Font*>(receiver)->d_autoScale); }
void set (PropertyReceiver* receiver, const String& value) { Font *f = static_cast<Font*>(receiver); bool v = PropertyHelper::stringToBool (value); if (f->d_autoScale != v) { f->d_autoScale = v; f->updateFont (); } }};
// FreeTypeFont propertyclass FreeTypePointSize : public Property{public: FreeTypePointSize () : Property( "PointSize", "This is the point size of the font.") {}
String get(const PropertyReceiver* receiver) const { return PropertyHelper::floatToString(static_cast<const FreeTypeFont*>(receiver)->d_ptSize); }
void set(PropertyReceiver* receiver, const String& value) { FreeTypeFont *f = static_cast<FreeTypeFont*>(receiver); float v = PropertyHelper::stringToFloat (value); if (v != f->d_ptSize) { f->d_ptSize = v; f->updateFont (); } }};
// FreeTypeFont propertyclass FreeTypeAntialiased : public Property{public: FreeTypeAntialiased () : Property( "Antialiased", "This is a flag indicating whenever to render antialiased font or not. Value is either true or false.") {}
String get (const PropertyReceiver* receiver) const { return PropertyHelper::boolToString(static_cast<const FreeTypeFont*>(receiver)->d_antiAliased); }
void set (PropertyReceiver* receiver, const String& value) { FreeTypeFont *f = static_cast<FreeTypeFont*>(receiver); bool v = PropertyHelper::stringToBool (value); if (f->d_antiAliased != v) { f->d_antiAliased = v; f->updateFont (); } }};
// PixmapFont propertyclass PixmapImageset : public Property{public: PixmapImageset () : Property( "Imageset", "This is the name of the imageset which contains the glyph images for this font.") {}
String get (const PropertyReceiver* receiver) const { const PixmapFont *f = static_cast<const PixmapFont*>(receiver); return f->d_glyphImages ? f->d_glyphImages->getName () : String (); }
void set (PropertyReceiver* receiver, const String& value) { PixmapFont *f = static_cast<PixmapFont*>(receiver); f->d_resourceGroup = "*"; f->d_fileName = value; f->reinit (); }};
// PixmapFont propertyclass PixmapMapping : public Property{public: PixmapMapping () : Property( "Mapping", "This is the glyph-to-image mapping font property. It cannot be read. Format is: codepoint,advance,imagename") {}
String get (const PropertyReceiver* receiver) const { return String (); }
void set (PropertyReceiver* receiver, const String& value) { char img [33]; utf32 codepoint; float adv; if (sscanf (value.c_str(), " %u , %g , %32s", &codepoint, &adv, img) != 3) throw InvalidRequestException ("Bad glyph Mapping specified: " + value); static_cast<PixmapFont*>(receiver)->defineMapping (img, codepoint, adv); }};
} // End of FontProperties namespace section
void Font::addFontProperties (){ static FontProperties::NativeRes NativeRes; static FontProperties::Name Name; static FontProperties::FileName FileName; static FontProperties::ResourceGroup ResourceGroup; static FontProperties::AutoScaled AutoScaled;
addProperty (&NativeRes); addProperty (&Name); addProperty (&FileName); addProperty (&ResourceGroup); addProperty (&AutoScaled);}
void FreeTypeFont::addFreeTypeFontProperties (){ static FontProperties::FreeTypePointSize FreeTypePointSize; static FontProperties::FreeTypeAntialiased FreeTypeAntialiased;
addProperty (&FreeTypePointSize); addProperty (&FreeTypeAntialiased);}
void PixmapFont::addPixmapFontProperties (){ static FontProperties::PixmapImageset PixmapImageset; static FontProperties::PixmapMapping PixmapMapping;
addProperty (&PixmapImageset); addProperty (&PixmapMapping);}
} // End of CEGUI namespace section