OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimFontFactoryRegistry.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 // Copyright (C) 2000 ImageLinks Inc.
3 //
4 // License: See top level LICENSE.txt file.
5 //
6 // Author: Garrett Potts
7 //
8 //********************************************************************
9 // $Id: ossimFontFactoryRegistry.cpp 15766 2009-10-20 12:37:09Z gpotts $
10 #include <algorithm>
13 
14 #if OSSIM_HAS_FREETYPE
16 #endif
17 
18 #include <ossim/font/ossimGdSansBold.inc>
19 
20 //ossimFontFactoryRegistry* ossimFontFactoryRegistry::theInstance = 0;
21 
23 :theDefaultFont(NULL)
24 {
25  // theInstance = this;
26 #if OSSIM_HAS_FREETYPE
28 #endif
29 }
30 
32 {
33  static ossimFontFactoryRegistry sharedInstance;
34  //theInstance = new ossimFontFactoryRegistry;
35 
36  return &sharedInstance;
37 }
38 
40 {
41  bool result = false;
42  if(factory&&!findFactory(factory))
43  {
44  theFactoryList.push_back(factory);
45  result = true;
46  }
47 
48  return result;
49 }
50 
52 {
53  std::vector<ossimFontFactoryBase*>::iterator iter = std::find(theFactoryList.begin(),
54  theFactoryList.end(),
55  factory);
56  if(iter != theFactoryList.end())
57  {
58  theFactoryList.erase(iter);
59  }
60 }
61 
63 {
64  return (std::find(theFactoryList.begin(),
65  theFactoryList.end(),
66  factory)!=theFactoryList.end());
67 }
68 
69 
71 {
72  ossimFont* result = (ossimFont*)NULL;
73  int i = 0;
74 
75  for(i= 0; ( (i < (int)theFactoryList.size()) &&(!result)); ++i)
76  {
77  result = theFactoryList[i]->createFont(information);
78  }
79 
80  return result;
81 }
82 
84 {
85  ossimFont* result = (ossimFont*)NULL;
86  int i = 0;
87 
88  for(i= 0; ( (i < (int)theFactoryList.size()) &&(!result)); ++i)
89  {
90  result = theFactoryList[i]->createFont(file);
91  }
92 
93  return result;
94 }
95 
96 void ossimFontFactoryRegistry::getFontInformation(std::vector<ossimFontInformation>& informationList)const
97 {
98  int i = 0;
99  for(i= 0; i < (int)theFactoryList.size(); ++i)
100  {
101  theFactoryList[i]->getFontInformation(informationList);
102  }
103 }
104 
105 void ossimFontFactoryRegistry::getFontInformationFamilyName(std::vector<ossimFontInformation>& informationList,
106  const ossimString& familyName)const
107 {
108  vector<ossimFontInformation> info;
109  getFontInformation(info);
110 
111  ossimString right = familyName;
112  right = right.upcase().trim();
113  int i = 0;
114  for(i = 0; i < (int)info.size(); ++i)
115  {
116  ossimString left = info[i].theFamilyName;
117  left = left.upcase().trim();
118 
119  if(left == right)
120  {
121  informationList.push_back(info[i]);
122  }
123  }
124 }
125 
126 void ossimFontFactoryRegistry::getFontInformationContainingFamilyName(std::vector<ossimFontInformation>& informationList,
127  const ossimString& familyName)const
128 {
129  vector<ossimFontInformation> info;
130  getFontInformation(info);
131 
132  ossimString right = familyName;
133  right = right.upcase().trim();
134  int i = 0;
135  for(i = 0; i < (int)info.size(); ++i)
136  {
137  ossimString left = info[i].theFamilyName;
138 
139  left = left.upcase().trim();
140  if(left.contains(right))
141  {
142  informationList.push_back(info[i]);
143  }
144  }
145 }
146 
148 {
149  if(!theDefaultFont)
150  {
151  std::vector<ossimFontInformation> infoList;
153  "Times");
154  if(infoList.size() < 1)
155  {
157  "Roman");
158  }
159  if(infoList.size() < 1)
160  {
162  "Sanz");
163  }
164  if(infoList.size() < 1)
165  {
166  getFontInformation(infoList);
167  }
168  if(infoList.size())
169  {
170  theDefaultFont = createFont(infoList[0]);
171  theDefaultFont->setPixelSize(12, 12);
172  }
173  else
174  {
175  theDefaultFont = new ossimGdBitmapFont("gd sans",
176  "bold",
177  ossimGdSansBold);
178  }
179  }
180  return theDefaultFont.get();
181 }
182 
184 {
185 }
186 
188 {
189 }
void operator=(const ossimFontFactoryRegistry &rhs)
static ossimString upcase(const ossimString &aString)
Definition: ossimString.cpp:34
std::vector< ossimFontFactoryBase * > theFactoryList
void getFontInformationContainingFamilyName(std::vector< ossimFontInformation > &informationList, const ossimString &familyName) const
bool contains(char aChar) const
Definition: ossimString.h:58
static ossimFreeTypeFontFactory * instance()
void push_back(char c)
Equivalent to insert(end(), c).
Definition: ossimString.h:905
void getFontInformation(std::vector< ossimFontInformation > &informationList) const
ossimString trim(const ossimString &valueToTrim=ossimString(" \\)) const
this will strip lead and trailing character passed in.
ossimFont * createFont(const ossimFontInformation &information) const
void unregisterFactory(ossimFontFactoryBase *factory)
void getFontInformationFamilyName(std::vector< ossimFontInformation > &informationList, const ossimString &familyName) const
static ossimFontFactoryRegistry * instance()
virtual void setPixelSize(int horizontalPixelSize, int verticalPixelSize)
Definition: ossimFont.h:205
bool findFactory(ossimFontFactoryBase *factory) const
bool registerFactory(ossimFontFactoryBase *factory)
ossimRefPtr< ossimFont > theDefaultFont