macFont.h
Engine/source/platformMac/macFont.h
Classes:
class
Detailed Description
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2013 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24#import "platform/platformFont.h" 25#import <CoreText/CoreText.h> 26//----------------------------------------------------------------------------- 27 28class OSXFont : public PlatformFont 29{ 30private: 31 32 // Font reference. 33 CTFontRef mFontRef; 34 35 // Distance from drawing point to typographic baseline. 36 // Think of the drawing point as the upper left corner of a text box. 37 // NOTE: 'baseline' is synonymous with 'ascent' in Torque. 38 U32 mBaseline; 39 40 // Distance between lines. 41 U32 mHeight; 42 43 // Glyph rendering color-space. 44 CGColorSpaceRef mColorSpace; 45 46public: 47 OSXFont(); 48 virtual ~OSXFont(); 49 50 /// Look up the requested font, cache style, layout, colorspace, and some metrics. 51 virtual bool create( const char* name, dsize_t size, U32 charset = TGE_ANSI_CHARSET); 52 53 /// Determine if the character requested is a drawable character, or if it should be ignored. 54 virtual bool isValidChar( const UTF16 character) const; 55 virtual bool isValidChar( const UTF8* str) const; 56 57 /// Get some vertical data on the font at large. Useful for drawing multiline text, and sizing text boxes. 58 virtual U32 getFontHeight() const { return mHeight; } 59 virtual U32 getFontBaseLine() const { return mBaseline; } 60 61 // Draw the character to a temporary bitmap, and fill the CharInfo with various text metrics. 62 virtual PlatformFont::CharInfo &getCharInfo(const UTF16 character) const; 63 virtual PlatformFont::CharInfo &getCharInfo(const UTF8 *str) const; 64}; 65