GUIDOLib  1.7.7
Guido Engine Internal Documentation
StaticFont.h
1 #ifndef STATICFONT_H
2 #define STATICFONT_H
3 /*
4  GUIDO Library
5  Copyright (C) 2019 Grame
6 
7  This Source Code Form is subject to the terms of the Mozilla Public
8  License, v. 2.0. If a copy of the MPL was not distributed with this
9  file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 
11  Grame Research Laboratory, 11, cours de Verdun Gensoul 69002 Lyon - France
12  research@grame.fr
13 
14 */
15 
16 #include <string>
17 #include <map>
18 
19 #include "VGFont.h"
20 
21 #ifdef SMUFL
22 #define kMaxTblIndex 3647
23 #else
24 #define kMaxTblIndex 256
25 #endif
26 
27 class StaticFont : public VGFont
28 {
29  public:
34  StaticFont(const char * name, int size, int properties)
35  : fName(name), fSize(size), fProperties(properties) {}
36  virtual ~StaticFont() { }
37 
38  const char * GetName() const { return fName.c_str(); }
39  int GetSize() const { return fSize; }
40  int GetProperties() const { return fProperties; }
41 
42  virtual void GetExtent( const char * s, int inCharCount, float * outWidth, float * outHeight, VGDevice * context ) const;
43  virtual void GetExtent( int c, float * outWidth, float * outHeight, VGDevice * context ) const;
44 
45  protected:
46  int fExtends[kMaxTblIndex+1]; // the static extend values
47  float fRefSize=1; // the font size used to compute the extends map
48  int fHeight=1; // the static height value
49  int fTblOffset=0;
50 
51  virtual void initialize() = 0; // must initialize the fExtends maps, the height and the ref size
52 
53  inline float GetExtend (int c) const
54  { int i=c-fTblOffset; return ((i >= 0) && (i <= kMaxTblIndex)) ? fExtends[i] : 0.f; }
55 
56  std::string fName; // the font name
57  int fSize; // the font size
58  int fProperties; // the font properties
59 };
60 
61 #endif
StaticFont::fExtends
int fExtends[kMaxTblIndex+1]
Definition: StaticFont.h:46
StaticFont::GetExtend
float GetExtend(int c) const
Definition: StaticFont.h:53
StaticFont::fHeight
int fHeight
Definition: StaticFont.h:48
StaticFont::GetExtent
virtual void GetExtent(const char *s, int inCharCount, float *outWidth, float *outHeight, VGDevice *context) const
StaticFont::GetName
const char * GetName() const
Returns the current object's name (as a string)
Definition: StaticFont.h:38
StaticFont::fTblOffset
int fTblOffset
Definition: StaticFont.h:49
StaticFont::fSize
int fSize
Definition: StaticFont.h:57
StaticFont::fProperties
int fProperties
Definition: StaticFont.h:58
StaticFont::GetProperties
int GetProperties() const
Returns the current object's property value(s) (see enum above)
Definition: StaticFont.h:40
StaticFont
Definition: StaticFont.h:27
StaticFont::fName
std::string fName
Definition: StaticFont.h:56
StaticFont::StaticFont
StaticFont(const char *name, int size, int properties)
A font with pre-computed static metrics.
Definition: StaticFont.h:34
StaticFont::initialize
virtual void initialize()=0
VGDevice
Generic platform independant drawing device.
Definition: VGDevice.h:68
StaticFont::fRefSize
float fRefSize
Definition: StaticFont.h:47
StaticFont::GetSize
int GetSize() const
Returns the current object's size (as an int)
Definition: StaticFont.h:39
VGFont
Generic pure virtual & device-independant font class.
Definition: VGFont.h:36
StaticFont::~StaticFont
virtual ~StaticFont()
Definition: StaticFont.h:36

Guido Project Copyright © 2019 Grame-CNCM