13
std::string flFont::fontTest(const char* whichElement){
14
tinyxml2::XMLElement * currentFont = doc.FirstChildElement("JWM")->FirstChildElement(whichElement)->FirstChildElement("Font");
16
const char* fontTester = currentFont->GetText();
22
missingFont(whichElement);
26
void flFont::missingFont(const char* whichElement){
27
tinyxml2::XMLElement * currentFont = doc.FirstChildElement("JWM")->FirstChildElement(whichElement)->FirstChildElement("Font");
28
std::cout<<"The current Element doesn't have a font name or is missing a size.\n Recovering by rewriting default values\n";
29
currentFont->SetText("ubuntu-12:antialias=true");
30
getFontName(whichElement);//Is this a good Idea?? Is there a case that can make this loop endlessly?
13
32
std::string flFont::getFontName(const char* whichElement){
14
tinyxml2::XMLElement * currentFont = doc.FirstChildElement("JWM")->FirstChildElement(whichElement)->FirstChildElement("Font");
16
const char* fontTester = currentFont->GetText();
33
std::string font =fontTest(whichElement);
34
if (font.c_str() != NULL){
19
35
std::string fontName ="";
20
36
std::string::size_type size = font.find_first_of('-');
21
37
if((font.find_last_of('-')!=std::string::npos)){
23
39
//if (fontName !=NULL)
28
///Need to check for the crazy fonts -*-courier-*-*-*-*-17-*-*-*-*-*-* stuff
29
std::cout<<"The current Element doesn't have a font name or is missing a size.\n Recovering by rewriting default values\n";
30
currentFont->SetText("ubuntu-12:antialias=true");
31
getFontName(whichElement);//Is this a good Idea?? Is there a case that can make this loop endlessly?
44
std:: string error = "no font\n";
45
std::cout<<"This is an error, there is "<< error;
33
48
std::cout<<"ERROR in getFontName(const char*), this shouldn't happen\n";
37
52
void flFont::setFontName(const char* name, const char* whichElement){
38
53
if(name==NULL){return;}
39
54
tinyxml2::XMLElement * currentFont = doc.FirstChildElement("JWM")->FirstChildElement(whichElement)->FirstChildElement("Font");
41
const char* fontTester = currentFont->GetText();
55
std::string font =fontTest(whichElement);
56
if (font.c_str() != NULL){
44
57
std::string fontName ="";
45
58
std::string fontOptions ="";
46
59
std::string::size_type size = font.find_first_of('-');
63
75
unsigned int flFont::getFontSize(const char* whichElement){
64
tinyxml2::XMLElement * currentFont = doc.FirstChildElement("JWM")->FirstChildElement(whichElement)->FirstChildElement("Font");
66
const char* fontTester = currentFont->GetText();
76
std::string font =fontTest(whichElement);
77
if (font.c_str() != NULL){
69
78
unsigned int fontSizeInt;
70
79
std::string fontSize;
71
80
std::string::size_type position = font.find(':');
81
std::cout<<"The current Element doesn't have a font name or is missing a size.\n Recovering by rewriting default values NOW\n";
82
currentFont->SetText("ubuntu-12:antialias=true");
90
missingFont(whichElement);
83
91
getFontSize(whichElement);
85
93
std::cout<<"getFontSize had an Error.... abort... size 42\n";
147
//This needs to be hooked into the UI eventually, as well as all the multitudes of options... I think I will apply advanced options to ALL fonts.
148
// I might also make a checkbox that sets all fonts the same if the user wants.
139
149
bool flFont::getAntialias(const char* whichElement){
140
tinyxml2::XMLElement * currentFont = doc.FirstChildElement("JWM")->FirstChildElement(whichElement)->FirstChildElement("Font");
141
std::string font = currentFont->GetText();
143
std::string A; //String antialias
144
std::string::size_type antialias = font.find("antialias=");
145
std::string::size_type position = font.find(':');
146
if((font.find(':')!=std::string::npos)){
147
if((font.find("antialias=")!=std::string::npos)){
148
/*antialias +10 is 10 characters after the beginning of the string
150
std::string font =fontTest(whichElement);
151
if (font.c_str() != NULL){
152
std::string A; //String antialias
153
std::string::size_type antialias = font.find("antialias=");
154
std::string::size_type position = font.find(':');
155
if((font.find(':')!=std::string::npos)){
156
if((font.find("antialias=")!=std::string::npos)){
157
/*antialias +10 is 10 characters after the beginning of the string
149
158
* "antialias=" is 10 characters long
151
A = font.substr (antialias+10,std::string::npos);
152
if (A=="true"){alias =true;}else{alias = false;}
160
A = font.substr (antialias+10,std::string::npos);
161
if (A=="true"){return true;}else{return false;}
153
162
//std::cout<<"Antialias = "<< A <<"\n";
195
204
FcPattern* font = fontSet->fonts[i];
197
206
if (FcPatternGetString(font, FC_FAMILY, 0, &family) == FcResultMatch){
198
printf("Font: %s\n", family);
207
//printf("Font: %s\n", family);
199
208
const char * fontName = reinterpret_cast<const char*>(family);
200
209
o->add(fontName);