📄 fontdatac.c
字号:
fname += '-'; \ fname += charsetPart; \ \} // End BuildName/*---------------------------------------------------------------------- * Method to return a font larger than the current font */FontDataC*FontDataC::Bigger(){ if ( !loaded && !bigger ) bigger = this;//// See if we already know this// if ( bigger ) return bigger; if ( debug1 ) cout <<"Looking for a bigger font for: " <<name NL;//// Try different patterns, getting less specific as failures mount// StringC bname; BuildName(foundry, family, weight, slant, setWidth, addStyle, "*", "*", resStr, spacing, "*", charset, bname); Boolean found = FindBigger(bname); if ( !found ) { // Try without res BuildName(foundry, family, weight, slant, setWidth, addStyle, "*", "*", "*", spacing, "*", charset, bname); found = FindBigger(bname); } if ( !found ) { // Try without width BuildName(foundry, family, weight, slant, "*", "*", "*", "*", resStr, spacing, "*", charset, bname); found = FindBigger(bname); if ( !found ) { // Try without res BuildName(foundry, family, weight, slant, "*", "*", "*", "*", "*", spacing, "*", charset, bname); found = FindBigger(bname); } } if ( !found ) { // Try without foundry BuildName("*", family, weight, slant, "*", "*", "*", "*", resStr, spacing, "*", charset, bname); found = FindBigger(bname); if ( !found ) { // Try without res BuildName("*", family, weight, slant, "*", "*", "*", "*", "*", spacing, "*", charset, bname); found = FindBigger(bname); } } if ( !found ) { // Try without family BuildName("*", "*", weight, slant, "*", "*", "*", "*", resStr, spacing, "*", charset, bname); found = FindBigger(bname); if ( !found ) { // Try without res BuildName("*", "*", weight, slant, "*", "*", "*", "*", "*", spacing, "*", charset, bname); found = FindBigger(bname); } } if ( !found ) { // Try without spacing BuildName("*", "*", weight, slant, "*", "*", "*", "*", resStr, "*", "*", charset, bname); found = FindBigger(bname); if ( !found ) { // Try without res BuildName("*", "*", weight, slant, "*", "*", "*", "*", "*", "*", "*", charset, bname); found = FindBigger(bname); } } if ( !found ) { // Try without weight BuildName(foundry, family, "*", slant, "*", "*", "*", "*", resStr, "*", "*", charset, bname); found = FindBigger(bname); if ( !found ) { // Try without res BuildName(foundry, family, "*", slant, "*", "*", "*", "*", "*", "*", "*", charset, bname); found = FindBigger(bname); } } if ( !found ) { // Try without slant BuildName(foundry, family, weight, "*", "*", "*", "*", "*", resStr, "*", "*", charset, bname); found = FindBigger(bname); if ( !found ) { // Try without res BuildName(foundry, family, weight, "*", "*", "*", "*", "*", "*", "*", "*", charset, bname); found = FindBigger(bname); } } if ( !found ) { // Try without foundry or weight BuildName("*", family, "*", slant, "*", "*", "*", "*", resStr, "*", "*", charset, bname); found = FindBigger(bname); if ( !found ) { // Try without res BuildName("*", family, "*", slant, "*", "*", "*", "*", "*", "*", "*", charset, bname); found = FindBigger(bname); } } if ( !found ) { // Try without foundry or slant BuildName("*", family, weight, "*", "*", "*", "*", "*", resStr, "*", "*", charset, bname); found = FindBigger(bname); if ( !found ) { // Try without res BuildName("*", family, weight, "*", "*", "*", "*", "*", "*", "*", "*", charset, bname); found = FindBigger(bname); } } if ( !found ) { // Try without foundry, family or weight BuildName("*", "*", "*", slant, "*", "*", "*", "*", resStr, "*", "*", charset, bname); found = FindBigger(bname); if ( !found ) { // Try without res BuildName("*", "*", "*", slant, "*", "*", "*", "*", "*", "*", "*", charset, bname); found = FindBigger(bname); } } if ( !found ) { // Try without foundry, family or slant BuildName("*", "*", weight, "*", "*", "*", "*", "*", resStr, "*", "*", charset, bname); found = FindBigger(bname); if ( !found ) { // Try without res BuildName("*", "*", weight, "*", "*", "*", "*", "*", "*", "*", "*", charset, bname); found = FindBigger(bname); } } if ( !found ) { // Try without weight or slant BuildName(foundry, family, "*", "*", "*", "*", "*", "*", resStr, "*", "*", charset, bname); found = FindBigger(bname); if ( !found ) { // Try without res BuildName(foundry, family, "*", "*", "*", "*", "*", "*", "*", "*", "*", charset, bname); found = FindBigger(bname); } } if ( !found ) { // Try without foundry, weight or slant BuildName("*", family, "*", "*", "*", "*", "*", "*", resStr, "*", "*", charset, bname); found = FindBigger(bname); if ( !found ) { // Try without res BuildName("*", family, "*", "*", "*", "*", "*", "*", "*", "*", "*", charset, bname); found = FindBigger(bname); } } if ( !found ) { // Try without foundry, family, weight or slant BuildName("*", "*", "*", "*", "*", "*", "*", "*", resStr, "*", "*", charset, bname); found = FindBigger(bname); if ( !found ) { // Try without res BuildName("*", "*", "*", "*", "*", "*", "*", "*", "*", "*", "*", charset, bname); found = FindBigger(bname); } }//// If nothing worked, return this font// if ( !found ) {#if 0 StringC errmsg("I could not find a bigger version of the font: "); errmsg += name; halApp->PopupMessage(errmsg);#else if ( debug1 ) cout <<"I could not find a bigger version of the font: " <<name <<endl;#endif if ( debug1 ) cout <<"Using: " <<name NL; bigger = this; return bigger; }//// Create a new font structure// if ( debug1 ) cout <<"Creating bigger font: " <<bname NL; bigger = new FontDataC(bname); if ( !bigger->loaded ) { delete bigger; bigger = this; } freeBigger = True; return bigger;} // End Bigger/*---------------------------------------------------------------------- * Method to look through a list of font names for a font bigger than * the current one. */BooleanFontDataC::FindBigger(StringC& fname){ if ( debug2 ) cout <<"Trying bigger: " <<fname NL; int actual; char **names = XListFonts(halApp->display, fname, 100, &actual); if ( !names ) return False;//// See if there's a bigger point size in the list// Boolean found = False; int i = 0; CharC name; StringC sizeStr; while ( !found && i<actual ) {//// Extract the point size information. It is found after the 8th dash.// name = names[i]; int pos = name.PosOf('-'); int dashCount = (pos>=0) ? 1 : 0; while ( pos >= 0 && dashCount < 8 ) { pos = name.PosOf('-', (u_int)pos+1); if ( pos >= 0 ) dashCount++; } if ( pos >= 0 && dashCount == 8 ) { sizeStr = name.NextWord((u_int)pos+1, '-'); int size = atoi(sizeStr); found = (size > this->points); } if ( found ) fname = name; else i++; } // End while a bigger font has not been found//// If no font was found, see if there's a bigger pixel size in the list// i = 0; while ( !found && i<actual ) {//// Extract the pixel size information. It is found after the 7th dash.// name = names[i]; int pos = name.PosOf('-'); int dashCount = (pos>=0) ? 1 : 0; while ( pos >= 0 && dashCount < 7 ) { pos = name.PosOf('-', (u_int)pos+1); if ( pos >= 0 ) dashCount++; } if ( pos >= 0 && dashCount == 7 ) { sizeStr = name.NextWord((u_int)pos+1, '-'); int size = atoi(sizeStr); found = (size > this->pixels); } if ( found ) fname = name; else i++; } // End while a bigger font has not been found XFreeFontNames(names); return found;} // End FindBigger/*---------------------------------------------------------------------- * Method to return a font smaller than the current font */FontDataC*FontDataC::Smaller(){ if ( !loaded && !smaller ) smaller = this;//// See if we already know this// if ( smaller ) return smaller; if ( debug1 ) cout <<"Looking for a smaller font for: " <<name NL;//// Try different patterns, getting less specific as failures mount// StringC bname; BuildName(foundry, family, weight, slant, setWidth, addStyle, "*", "*", resStr, spacing, "*", charset, bname); Boolean found = FindSmaller(bname); if ( !found ) { // Try without res BuildName(foundry, family, weight, slant, setWidth, addStyle, "*", "*", "*", spacing, "*", charset, bname); found = FindSmaller(bname); } if ( !found ) { // Try without width BuildName(foundry, family, weight, slant, "*", "*", "*", "*", resStr, spacing, "*", charset, bname); found = FindSmaller(bname); if ( !found ) { // Try without res BuildName(foundry, family, weight, slant, "*", "*", "*", "*", "*", spacing, "*", charset, bname); found = FindSmaller(bname); } } if ( !found ) { // Try without foundry BuildName("*", family, weight, slant, "*", "*", "*", "*", resStr, spacing, "*", charset, bname); found = FindSmaller(bname); if ( !found ) { // Try without res BuildName("*", family, weight, slant, "*", "*", "*", "*", "*", spacing, "*", charset, bname); found = FindSmaller(bname); } } if ( !found ) { // Try without family BuildName("*", "*", weight, slant, "*", "*", "*", "*", resStr, spacing, "*", charset, bname); found = FindSmaller(bname); if ( !found ) { // Try without res BuildName("*", "*", weight, slant, "*", "*", "*", "*", "*", spacing, "*", charset, bname); found = FindSmaller(bname); } } if ( !found ) { // Try without spacing BuildName("*", "*", weight, slant, "*", "*", "*", "*", resStr, "*", "*", charset, bname); found = FindSmaller(bname); if ( !found ) { // Try without res BuildName("*", "*", weight, slant, "*", "*", "*", "*", "*", "*", "*", charset, bname); found = FindSmaller(bname); } } if ( !found ) { // Try without weight BuildName(foundry, family, "*", slant, "*", "*", "*", "*", resStr, "*", "*", charset, bname); found = FindSmaller(bname); if ( !found ) { // Try without res BuildName(foundry, family, "*", slant, "*", "*", "*", "*", "*", "*", "*", charset, bname); found = FindSmaller(bname); } } if ( !found ) { // Try without slant BuildName(foundry, family, weight, "*", "*", "*", "*", "*", resStr, "*", "*", charset, bname); found = FindSmaller(bname); if ( !found ) { // Try without res BuildName(foundry, family, weight, "*", "*", "*", "*", "*", "*", "*", "*", charset, bname); found = FindSmaller(bname); } } if ( !found ) { // Try without foundry or weight BuildName("*", family, "*", slant, "*", "*", "*", "*", resStr, "*", "*", charset, bname); found = FindSmaller(bname); if ( !found ) { // Try without res BuildName("*", family, "*", slant, "*", "*", "*", "*", "*", "*", "*", charset, bname); found = FindSmaller(bname); } } if ( !found ) { // Try without foundry or slant BuildName("*", family, weight, "*", "*", "*", "*", "*", resStr, "*", "*", charset, bname); found = FindSmaller(bname); if ( !found ) { // Try without res BuildName("*", family, weight, "*", "*", "*", "*", "*", "*", "*", "*", charset, bname); found = FindSmaller(bname); } } if ( !found ) { // Try without foundry, family or weight BuildName("*", "*", "*", slant, "*", "*", "*", "*", resStr, "*", "*", charset, bname); found = FindSmaller(bname); if ( !found ) { // Try without res BuildName("*", "*", "*", slant, "*", "*", "*", "*", "*", "*", "*", charset, bname); found = FindSmaller(bname); } } if ( !found ) { // Try without foundry, family or slant BuildName("*", "*", weight, "*", "*", "*", "*", "*", resStr, "*", "*", charset, bname); found = FindSmaller(bname); if ( !found ) { // Try without res BuildName("*", "*", weight, "*", "*", "*", "*", "*", "*", "*", "*", charset, bname); found = FindSmaller(bname); } } if ( !found ) { // Try without weight or slant BuildName(foundry, family, "*", "*", "*", "*", "*", "*", resStr, "*", "*", charset, bname); found = FindSmaller(bname); if ( !found ) { // Try without res BuildName(foundry, family, "*", "*", "*", "*", "*", "*", "*", "*", "*", charset, bname); found = FindSmaller(bname); } } if ( !found ) { // Try without foundry, weight or slant BuildName("*", family, "*", "*", "*", "*", "*", "*", resStr, "*", "*", charset, bname); found = FindSmaller(bname); if ( !found ) { // Try without res BuildName("*", family, "*", "*", "*", "*", "*", "*", "*", "*", "*", charset, bname); found = FindSmaller(bname); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -