bool KstViewLabel::fillConfigWidget(QWidget *w, bool isNew) const { ViewLabelWidget *widget = dynamic_cast<ViewLabelWidget*>(w); if (!widget) { return false; } if (!isNew) { widget->_text->setText(text()); } widget->_precision->setValue(int(dataPrecision())); widget->_rotation->setValue(double(rotation())); widget->_fontSize->setValue(int(fontSize())); widget->_horizontal->setCurrentItem(horizJustifyWrap()); widget->_fontColor->setColor(foregroundColor()); widget->_font->setCurrentFont(fontName()); widget->_transparent->setChecked(transparent()); widget->_border->setValue(borderWidth()); widget->_boxColors->setForeground(borderColor()); widget->_boxColors->setBackground(backgroundColor()); widget->_margin->setValue(labelMargin()); widget->_text->setFocus(); return true; }
void CFont::Init() { vec4 white = { { 1.0, 1.0, 1.0, 1.0 } }; vec4 none = { { 1.0, 1.0, 1.0, 0.0 } }; buffer = text_buffer_new(); std::string fontName(FONT_NAME); fontPath = GetSystemFontFile(fontName); normal.family = (char*)fontPath.c_str(); normal.size = 13.0f; normal.bold = 0; normal.italic = 0; normal.spacing = 0.0; normal.gamma = 2.; normal.foreground_color = white; normal.background_color = none; normal.underline = 0; normal.underline_color = white; normal.overline = 0; normal.overline_color = white; normal.strikethrough = 0; normal.strikethrough_color = white; mat4_set_identity(&projection); mat4_set_identity(&model); mat4_set_identity(&view); }
QFont State::font(QFont base) { if (bold()) base.setBold(true); if (italic()) base.setItalic(true); if (underline()) base.setUnderline(true); if (strikeOut()) base.setStrikeOut(true); if (!fontName().isEmpty()) base.setFamily(fontName()); if (fontSize() > 0) base.setPointSize(fontSize()); return base; }
void FontResource::updateModelFromLogFont(const LOGFONT& logFont) { auto newFont = createFont (logFont); mFont->fontName (newFont->fontName()); mFont->size (newFont->size()); mFont->bold (newFont->bold()); mFont->italic (newFont->italic()); mFont->underline (newFont->underline()); }
uint8_t SFX::setFont(const char* name) { int i=0; for(; i<m_numFonts; ++i) { if (strEqual(name, fontName(i))) { break; } } return setFont(i); }
/*! * Returns a QFont object based on font data contained in the format. */ QFont Format::font() const { QFont font; font.setFamily(fontName()); if (fontSize() > 0) font.setPointSize(fontSize()); font.setBold(fontBold()); font.setItalic(fontItalic()); font.setUnderline(fontUnderline()!=FontUnderlineNone); font.setStrikeOut(fontStrikeOut()); return font; }
/** fill the custom widget with current properties */ bool KstViewLegend::fillConfigWidget(QWidget *w, bool isNew) const { ViewLegendWidget *widget = dynamic_cast<ViewLegendWidget*>(w); if (!widget) { return false; } KstBaseCurveList allCurves = kstObjectSubList<KstDataObject, KstBaseCurve>(KST::dataObjectList); if (isNew) { widget->_fontSize->setValue(0); widget->_fontColor->setColor(KstSettings::globalSettings()->foregroundColor); widget->_font->setCurrentFont(KstApp::inst()->defaultFont()); widget->_margin->setValue(5); widget->_boxColors->setColor(KstSettings::globalSettings()->foregroundColor); widget->_vertical->setChecked(true); widget->_transparent->setChecked(false); widget->_border->setValue(2); widget->_title->setText(""); widget->TrackContents->setChecked(true); for (KstBaseCurveList::ConstIterator it = allCurves.begin(); it != allCurves.end(); ++it) { (*it)->readLock(); widget->AvailableCurveList->insertItem((*it)->tagName()); (*it)->unlock(); } } else { // fill legend properties into widget widget->TrackContents->setChecked(trackContents()); widget->_title->setText(title()); widget->_fontSize->setValue(int(fontSize())); widget->_fontColor->setColor(foregroundColor()); widget->_font->setCurrentFont(fontName()); widget->_transparent->setChecked(transparent()); widget->_border->setValue(borderWidth()); widget->_boxColors->setColor(borderColor()); widget->_margin->setValue(_legendMargin); widget->_vertical->setChecked(vertical()); for (KstBaseCurveList::ConstIterator it = _curves.begin(); it != _curves.end(); ++it) { (*it)->readLock(); widget->DisplayedCurveList->insertItem((*it)->tagName()); (*it)->unlock(); } for (KstBaseCurveList::ConstIterator it = allCurves.begin(); it != allCurves.end(); ++it) { (*it)->readLock(); if (_curves.find(*it) == _curves.end()) { widget->AvailableCurveList->insertItem((*it)->tagName()); } (*it)->unlock(); } } return false; }
Common::String FontManager::getLocalizedFontNameByUsage(FontUsage usage) const { // We look for a name that matches the usage and that ends in .bdf. // It should also not contain "-ascii" or "-iso-" in its name. // We take the first name that matches. for (int i = 0; builtinFontNames[i].name; i++) { if (builtinFontNames[i].id == usage) { Common::String fontName(builtinFontNames[i].name); if (!fontName.contains("-ascii") && !fontName.contains("-iso-") && fontName.contains(".bdf")) return genLocalizedFontFilename(fontName); } } return Common::String(); }
bool KstViewLabel::fillConfigWidget(QWidget *w, bool isNew) const { ViewLabelWidget *widget = dynamic_cast<ViewLabelWidget*>(w); if (!widget) { return false; } if (isNew) { // probably a new label: set widget to defaults widget->_precision->setValue(8); widget->_rotation->setValue(0); widget->_fontSize->setValue(0); widget->_horizontal->setCurrentItem(0); widget->_fontColor->setColor(KstSettings::globalSettings()->foregroundColor); widget->_font->setCurrentFont(KstApp::inst()->defaultFont()); widget->_margin->setValue(5); widget->_boxColors->setColor(KstSettings::globalSettings()->backgroundColor); if (size().width() * size().height() < 25) { // assume a click, and default to just text widget->_transparent->setChecked(true); widget->_border->setValue(0); } else { // someone drew a box, so assume that is what they wanted widget->_transparent->setChecked(false); widget->_border->setValue(2); } } else { // No, this is broken. It kills latex. #if 0 // replace \n & \t with tabs and newlines for the text edit box QString tmpstr = text(); tmpstr.replace(QString("\\n"), "\n"); tmpstr.replace(QString("\\t"), "\t"); widget->_text->setText(tmpstr); #endif widget->_text->setText(text()); widget->_precision->setValue(int(dataPrecision())); widget->_rotation->setValue(double(rotation())); widget->_fontSize->setValue(int(fontSize())); widget->_horizontal->setCurrentIndex(horizJustifyWrap()); widget->_fontColor->setColor(foregroundColor()); widget->_font->setCurrentFont(fontName()); widget->_transparent->setChecked(transparent()); widget->_border->setValue(borderWidth()); widget->_boxColors->setColor(borderColor()); widget->_margin->setValue(_labelMargin); } widget->_text->setFocus(); return true; }
QString State::toCSS(const QString &gradientFolderPath, const QString &gradientFolderName, const QFont &baseFont) { QString css; if (bold()) css += " font-weight: bold;"; if (italic()) css += " font-style: italic;"; if (underline() && strikeOut()) css += " text-decoration: underline line-through;"; else if (underline()) css += " text-decoration: underline;"; else if (strikeOut()) css += " text-decoration: line-through;"; if (textColor().isValid()) css += " color: " + textColor().name() + ";"; if (!fontName().isEmpty()) { QString fontFamily = Tools::cssFontDefinition(fontName(), /*onlyFontFamily=*/true); css += " font-family: " + fontFamily + ";"; } if (fontSize() > 0) css += " font-size: " + QString::number(fontSize()) + "px;"; if (backgroundColor().isValid()) { // Get the colors of the gradient and the border: QColor topBgColor; QColor bottomBgColor; Note::getGradientColors(backgroundColor(), &topBgColor, &bottomBgColor); // Produce the CSS code: QString gradientFileName = Basket::saveGradientBackground(backgroundColor(), font(baseFont), gradientFolderPath); css += " background: " + bottomBgColor.name() + " url('" + gradientFolderName + gradientFileName + "') repeat-x;"; css += " border-top: solid " + topBgColor.name() + " 1px;"; css += " border-bottom: solid " + Tools::mixColor(topBgColor, bottomBgColor).name() + " 1px;"; } if (css.isEmpty()) return ""; else return " .tag_" + id() + " {" + css + " }\n"; }
// Creates a unique and unpredictable font name, in order to avoid collisions and to // not allow access from CSS. static String createUniqueFontName() { Vector<char> fontUuid(sizeof(GUID)); unsigned int* ptr = reinterpret_cast<unsigned int*>(fontUuid.data()); for (int i = 0; i < sizeof(GUID) / sizeof(int) ; ++i) *(ptr + i) = static_cast<unsigned int>(randomNumber() * (std::numeric_limits<unsigned>::max() + 1.0)); Vector<char> fontNameVector; base64Encode(fontUuid, fontNameVector); ASSERT(fontNameVector.size() < LF_FACESIZE); String fontName(fontNameVector.data(), fontNameVector.size()); return fontName.replace('/', '_'); }
gfxFontEntry* gfxGDIFontList::MakePlatformFont(const gfxProxyFontEntry *aProxyEntry, const PRUint8 *aFontData, PRUint32 aLength) { // MakePlatformFont is responsible for deleting the font data with NS_Free // so we set up a stack object to ensure it is freed even if we take an // early exit struct FontDataDeleter { FontDataDeleter(const PRUint8 *aFontData) : mFontData(aFontData) { } ~FontDataDeleter() { NS_Free((void*)mFontData); } const PRUint8 *mFontData; }; FontDataDeleter autoDelete(aFontData); // if calls aren't available, bail if (!TTLoadEmbeddedFontPtr || !TTDeleteEmbeddedFontPtr) return nsnull; PRBool isCFF = gfxFontUtils::IsCffFont(aFontData); nsresult rv; HANDLE fontRef = nsnull; PRBool isEmbedded = PR_FALSE; nsAutoString uniqueName; rv = gfxFontUtils::MakeUniqueUserFontName(uniqueName); if (NS_FAILED(rv)) return nsnull; // for TTF fonts, first try using the t2embed library if (!isCFF) { // TrueType-style glyphs, use EOT library AutoFallibleTArray<PRUint8,2048> eotHeader; PRUint8 *buffer; PRUint32 eotlen; isEmbedded = PR_TRUE; PRUint32 nameLen = PR_MIN(uniqueName.Length(), LF_FACESIZE - 1); nsPromiseFlatString fontName(Substring(uniqueName, 0, nameLen)); FontDataOverlay overlayNameData = {0, 0, 0}; rv = gfxFontUtils::MakeEOTHeader(aFontData, aLength, &eotHeader, &overlayNameData); if (NS_SUCCEEDED(rv)) { // load in embedded font data eotlen = eotHeader.Length(); buffer = reinterpret_cast<PRUint8*> (eotHeader.Elements()); PRInt32 ret; ULONG privStatus, pulStatus; EOTFontStreamReader eotReader(aFontData, aLength, buffer, eotlen, &overlayNameData); ret = TTLoadEmbeddedFontPtr(&fontRef, TTLOAD_PRIVATE, &privStatus, LICENSE_PREVIEWPRINT, &pulStatus, EOTFontStreamReader::ReadEOTStream, &eotReader, (PRUnichar*)(fontName.get()), 0, 0); if (ret != E_NONE) { fontRef = nsnull; char buf[256]; sprintf(buf, "font (%s) not loaded using TTLoadEmbeddedFont - error %8.8x", NS_ConvertUTF16toUTF8(aProxyEntry->FamilyName()).get(), ret); NS_WARNING(buf); } } } // load CFF fonts or fonts that failed with t2embed loader if (fontRef == nsnull) { // Postscript-style glyphs, swizzle name table, load directly FallibleTArray<PRUint8> newFontData; isEmbedded = PR_FALSE; rv = gfxFontUtils::RenameFont(uniqueName, aFontData, aLength, &newFontData); if (NS_FAILED(rv)) return nsnull; DWORD numFonts = 0; PRUint8 *fontData = reinterpret_cast<PRUint8*> (newFontData.Elements()); PRUint32 fontLength = newFontData.Length(); NS_ASSERTION(fontData, "null font data after renaming"); // http://msdn.microsoft.com/en-us/library/ms533942(VS.85).aspx // "A font that is added by AddFontMemResourceEx is always private // to the process that made the call and is not enumerable." fontRef = AddFontMemResourceEx(fontData, fontLength, 0 /* reserved */, &numFonts); if (!fontRef) return nsnull; // only load fonts with a single face contained in the data if (fontRef && numFonts != 1) { RemoveFontMemResourceEx(fontRef); return nsnull; } } // make a new font entry using the unique name WinUserFontData *winUserFontData = new WinUserFontData(fontRef, isEmbedded); PRUint16 w = (aProxyEntry->mWeight == 0 ? 400 : aProxyEntry->mWeight); GDIFontEntry *fe = GDIFontEntry::CreateFontEntry(uniqueName, gfxWindowsFontType(isCFF ? GFX_FONT_TYPE_PS_OPENTYPE : GFX_FONT_TYPE_TRUETYPE) /*type*/, PRUint32(aProxyEntry->mItalic ? FONT_STYLE_ITALIC : FONT_STYLE_NORMAL), w, winUserFontData); if (!fe) return fe; fe->mIsUserFont = PR_TRUE; // Uniscribe doesn't place CFF fonts loaded privately // via AddFontMemResourceEx on XP/Vista if (isCFF && gfxWindowsPlatform::WindowsOSVersion() < gfxWindowsPlatform::kWindows7) { fe->mForceGDI = PR_TRUE; } return fe; }
FTextureID FTextureManager::CheckForTexture (const char *name, int usetype, BITFIELD flags) { int i; int firstfound = -1; int firsttype = FTexture::TEX_Null; if (name == NULL || name[0] == '\0') { return FTextureID(-1); } // [RH] Doom counted anything beginning with '-' as "no texture". // Hopefully nobody made use of that and had textures like "-EMPTY", // because -NOFLAT- is a valid graphic for ZDoom. if (name[0] == '-' && name[1] == '\0') { return FTextureID(0); } i = HashFirst[MakeKey (name) % HASH_SIZE]; while (i != HASH_END) { const FTexture *tex = Textures[i].Texture; if (stricmp (tex->Name, name) == 0) { // The name matches, so check the texture type if (usetype == FTexture::TEX_Any) { // All NULL textures should actually return 0 if (tex->UseType == FTexture::TEX_FirstDefined && !(flags & TEXMAN_ReturnFirst)) return 0; return FTextureID(tex->UseType==FTexture::TEX_Null? 0 : i); } else if ((flags & TEXMAN_Overridable) && tex->UseType == FTexture::TEX_Override) { return FTextureID(i); } else if (tex->UseType == usetype) { return FTextureID(i); } else if (tex->UseType == FTexture::TEX_FirstDefined && usetype == FTexture::TEX_Wall) { if (!(flags & TEXMAN_ReturnFirst)) return FTextureID(0); else return FTextureID(i); } else if (tex->UseType == FTexture::TEX_Null && usetype == FTexture::TEX_Wall) { // We found a NULL texture on a wall -> return 0 return FTextureID(0); } else { if (firsttype == FTexture::TEX_Null || (firsttype == FTexture::TEX_MiscPatch && tex->UseType != firsttype && tex->UseType != FTexture::TEX_Null) ) { firstfound = i; firsttype = tex->UseType; } } } i = Textures[i].HashNext; } size_t namelen = strlen(name); if(name[0] == '#' && namelen == 7) { FTexture *solidTex = SolidTexture_TryCreate(name+1); solidTex->UseType = FTexture::TEX_Flat; return AddTexture(solidTex); } // Handle font look ups (FONTNAME:XX) if(namelen > 3 && name[namelen-3] == ':') { FString fontName(name, namelen-3); FFont *font = V_GetFont(fontName); if(font) { return font->GetCharID(ParseHex(name+namelen-2)); } } if ((flags & TEXMAN_TryAny) && usetype != FTexture::TEX_Any) { // Never return the index of NULL textures. if (firstfound != -1) { if (firsttype == FTexture::TEX_Null) return FTextureID(0); if (firsttype == FTexture::TEX_FirstDefined && !(flags & TEXMAN_ReturnFirst)) return FTextureID(0); } return FTextureID(firstfound); } return FTextureID(-1); }
int main (int argc, char* argv[]) { // This object makes sure that Juce is initialised and shut down correctly // for the scope of this function call. Make sure this declaration is the // first statement of this function. const ScopedJuceInitialiser_NonGUI juceSystemInitialiser; printf ("\n\n--------------------------------\n Font Serialiser by Niall Moody\n--------------------------------\n\n"); if (argc != 3) { printf (" Usage: FontSerialiser <filename> <fontname>\n\n"); printf (" FontSerialiser will turn a font into a compressed binary file.\n\n\n"); return 1; } // because we're not using the proper application startup procedure, we need to call // this explicitly here to initialise some of the time-related stuff.. initialiseJuce_GUI(); // get file and font name from command line arguments const File destFile (File::getCurrentWorkingDirectory().getChildFile (argv[1])); String fontName(argv[2]); // make sure the destination file can be written to OutputStream *destStream = destFile.createOutputStream(); if (destStream == 0) { String error; error << "\nError : Couldn't open " << destFile.getFullPathName() << " for writing.\n\n"; std::cout << error; destFile.deleteFile(); shutdownSequence(destStream); return 2; } // make sure the font is installed on the current system StringArray fontNames = Font::findAllTypefaceNames(); // for (int n = 0; n < fontNames.size(); n++) // { // std::cout << fontNames[n] << std::endl; // } if(!fontNames.contains(fontName)) { String error ("\nError: The font " + fontName + " does not exist in the system\n"); std::cout << error; destFile.deleteFile(); shutdownSequence(destStream); return 3; } // load the font as a system-Typeface Font font(fontName, 10, 0); if(!Typeface::createSystemTypefaceFor (font)) { String error ("\nError : Where's the font?\n\n"); std::cout << error; destFile.deleteFile(); shutdownSequence(destStream); return 4; } // copy the font-properties to a CustomTypeface CustomTypeface customTypeface; customTypeface.setCharacteristics(font.getTypefaceName(), font.getAscent(), font.isBold(), font.isItalic(), ' '); // Here's the important part: copy all glyphs to a new instance of CustomTypeface customTypeface.addGlyphsFromOtherTypeface( *font.getTypeface(), 0, 256); // finally write the typeface into the destination file customTypeface.writeToStream(*destStream); String op; op << "\nWrote font " << fontName << " to file " << destFile.getFullPathName() << " successfully.\n\n"; std::cout << op; std::cout << "\n(You might want to use Binary Builder to turn this file into a c++ file now)\n\n "; shutdownSequence(destStream); return 0; }
void SettingsManager::reloadFromPath(const std::string& path, bool merge) { if(path.empty()){ return; } if(!merge){ clusters_.clear(); connections_.clear(); recentConnections_.clear(); } QString inip = common::convertFromString<QString>(common::file_system::prepare_path(path)); QSettings settings(inip, QSettings::IniFormat); DCHECK(settings.status() == QSettings::NoError); curStyle_ = settings.value(STYLE, fasto::qt::gui::defStyle).toString(); curFontName_ = settings.value(FONT, fontName()).toString(); curLanguage_ = settings.value(LANGUAGE, fasto::qt::translations::defLanguage).toString(); int view = settings.value(VIEW, fastonosql::Tree).toInt(); views_ = static_cast<supportedViews>(view); QList<QVariant> clusters = settings.value(CLUSTERS, "").toList(); for(QList<QVariant>::const_iterator it = clusters.begin(); it != clusters.end(); ++it){ QVariant var = *it; QString string = var.toString(); std::string encoded = common::convertToString(string); std::string raw = common::utils::base64::decode64(encoded); IClusterSettingsBaseSPtr sett(IClusterSettingsBase::fromString(raw)); if(sett){ clusters_.push_back(sett); } } QList<QVariant> connections = settings.value(CONNECTIONS, "").toList(); for(QList<QVariant>::const_iterator it = connections.begin(); it != connections.end(); ++it){ QVariant var = *it; QString string = var.toString(); std::string encoded = common::convertToString(string); std::string raw = common::utils::base64::decode64(encoded); IConnectionSettingsBaseSPtr sett(IConnectionSettingsBase::fromString(raw)); if(sett){ connections_.push_back(sett); } } QStringList rconnections = settings.value(RCONNECTIONS, "").toStringList(); for(QStringList::const_iterator it = rconnections.begin(); it != rconnections.end(); ++it){ QString string = *it; std::string encoded = common::convertToString(string); std::string raw = common::utils::base64::decode64(encoded); QString qdata = common::convertFromString<QString>(raw); if(!qdata.isEmpty()){ recentConnections_.push_back(qdata); } } syncTabs_= settings.value(SYNCTABS, false).toBool(); loggingDir_ = settings.value(LOGGINGDIR, settingsDirPath()).toString(); autoCheckUpdate_ = settings.value(CHECKUPDATES, true).toBool(); autoCompletion_ = settings.value(AUTOCOMPLETION, true).toBool(); autoOpenConsole_ = settings.value(AUTOOPENCONSOLE, true).toBool(); fastViewKeys_ = settings.value(FASTVIEWKEYS, true).toBool(); }
PRBool gfxPlatform::ForEachPrefFont(eFontPrefLang aLangArray[], PRUint32 aLangArrayLen, PrefFontCallback aCallback, void *aClosure) { nsresult rv; nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID)); if (!prefs) return PR_FALSE; PRUint32 i; for (i = 0; i < aLangArrayLen; i++) { eFontPrefLang prefLang = aLangArray[i]; const char *langGroup = GetPrefLangName(prefLang); nsCAutoString prefName; nsXPIDLCString nameValue, nameListValue; nsCAutoString genericDotLang; prefName.AssignLiteral("font.default."); prefName.Append(langGroup); prefs->GetCharPref(prefName.get(), getter_Copies(genericDotLang)); genericDotLang.AppendLiteral("."); genericDotLang.Append(langGroup); // fetch font.name.xxx value prefName.AssignLiteral("font.name."); prefName.Append(genericDotLang); rv = prefs->GetCharPref(prefName.get(), getter_Copies(nameValue)); if (NS_SUCCEEDED(rv)) { if (!aCallback(prefLang, NS_ConvertUTF8toUTF16(nameValue), aClosure)) return PR_FALSE; } // fetch font.name-list.xxx value prefName.AssignLiteral("font.name-list."); prefName.Append(genericDotLang); rv = prefs->GetCharPref(prefName.get(), getter_Copies(nameListValue)); if (NS_SUCCEEDED(rv) && !nameListValue.Equals(nameValue)) { const char kComma = ','; const char *p, *p_end; nsCAutoString list(nameListValue); list.BeginReading(p); list.EndReading(p_end); while (p < p_end) { while (nsCRT::IsAsciiSpace(*p)) { if (++p == p_end) break; } if (p == p_end) break; const char *start = p; while (++p != p_end && *p != kComma) /* nothing */ ; nsCAutoString fontName(Substring(start, p)); fontName.CompressWhitespace(PR_FALSE, PR_TRUE); if (!aCallback(prefLang, NS_ConvertUTF8toUTF16(fontName), aClosure)) return PR_FALSE; p++; } } } return PR_TRUE; }
QStringList familyNameFromPath(const QString &filePath) { if(!QFile::exists(filePath)) { return QStringList(); } FT_Library library; FT_Face face; /* Initialize library */ if(FT_Init_FreeType(&library)) { return QStringList(); } /* Load face */ QByteArray pathBytes = filePath.toLocal8Bit(); if(FT_New_Face(library,pathBytes.data(),0,&face)) { FT_Done_FreeType(library); return QStringList(); } int numOfFaces = face->num_faces; int faceIndex = 0; QStringList faceNameList; do { // default QString fontName(face->family_name); int count = FT_Get_Sfnt_Name_Count(face); FT_SfntName fnm = { 0 }; for(int i = 0;i < count;i++) { FT_Get_Sfnt_Name(face,i,&fnm); /* Platform-specific ID code Meaning 0 Symbol 1 Unicode BMP-only (UCS-2) 2 Shift-JIS 3 PRC 4 BigFive 5 Johab 10 Unicode UCS-4 */ if((fnm.platform_id == TT_PLATFORM_MICROSOFT) && \ (fnm.name_id == TT_NAME_ID_FONT_FAMILY) && \ ((fnm.language_id == TT_MS_LANGID_CHINESE_GENERAL) || (fnm.language_id == TT_MS_LANGID_CHINESE_TAIWAN) || \ (fnm.language_id == TT_MS_LANGID_CHINESE_PRC) || (fnm.language_id == TT_MS_LANGID_CHINESE_HONG_KONG) || \ (fnm.language_id == TT_MS_LANGID_CHINESE_SINGAPORE) || (fnm.language_id == TT_MS_LANGID_CHINESE_MACAU))) { if(fnm.encoding_id == TT_MS_ID_UNICODE_CS) { QChar fmName[128]; for(int j = 0;j < (fnm.string_len / 2);j++) { int index = j * 2; fmName[j] = QChar((fnm.string[index] << 8) | (fnm.string[index + 1])); } fmName[fnm.string_len / 2] = QChar('\0'); fontName = QString(fmName); break; } else if(fnm.encoding_id == TT_MS_ID_GB2312) { QTextCodec *codec = QTextCodec::codecForLocale(); if(codec) { fontName = codec->toUnicode(QByteArray((const char *)fnm.string,fnm.string_len)); break; } } } } FT_Done_Face(face); faceNameList << fontName; faceIndex++; if(faceIndex < numOfFaces) { if(FT_New_Face(library,pathBytes.data(),faceIndex,&face)) { break; } } else { break; } } while(1); FT_Done_FreeType(library); return faceNameList; }
void ConfigDialog::_init() { // Video settings QStringList windowedModesList; int windowedModesCurrent = -1; for (unsigned int i = 0; i < numWindowedModes; ++i) { windowedModesList.append(WindowedModes[i].description); if (WindowedModes[i].width == config.video.windowedWidth && WindowedModes[i].height == config.video.windowedHeight) windowedModesCurrent = i; } ui->windowedResolutionComboBox->insertItems(0, windowedModesList); if (windowedModesCurrent > -1) ui->windowedResolutionComboBox->setCurrentIndex(windowedModesCurrent); else ui->windowedResolutionComboBox->setCurrentText( QString::number(config.video.windowedWidth) + " x " + QString::number(config.video.windowedHeight) ); // matches w x h where w is 300-7999 and h is 200-3999, spaces around x optional QRegExp windowedRegExp("([3-9][0-9]{2}|[1-7][0-9]{3}) ?x ?([2-9][0-9]{2}|[1-3][0-9]{3})"); QValidator *windowedValidator = new QRegExpValidator(windowedRegExp, this); ui->windowedResolutionComboBox->setValidator(windowedValidator); ui->cropImageComboBox->setCurrentIndex(config.video.cropMode); ui->cropImageWidthSpinBox->setValue(config.video.cropWidth); ui->cropImageHeightSpinBox->setValue(config.video.cropHeight); ui->cropImageCustomFrame->setVisible(config.video.cropMode == Config::cmCustom); QStringList fullscreenModesList, fullscreenRatesList; int fullscreenMode, fullscreenRate; fillFullscreenResolutionsList(fullscreenModesList, fullscreenMode, fullscreenRatesList, fullscreenRate); ui->fullScreenResolutionComboBox->insertItems(0, fullscreenModesList); ui->fullScreenResolutionComboBox->setCurrentIndex(fullscreenMode); ui->fullScreenRefreshRateComboBox->setCurrentIndex(fullscreenRate); ui->aliasingSlider->setValue(powof(config.video.multisampling)); ui->aliasingLabelVal->setText(QString::number(config.video.multisampling)); ui->anisotropicSlider->setValue(config.texture.maxAnisotropy); ui->vSyncCheckBox->setChecked(config.video.verticalSync != 0); switch (config.texture.bilinearMode) { case BILINEAR_3POINT: ui->blnr3PointRadioButton->setChecked(true); break; case BILINEAR_STANDARD: ui->blnrStandardRadioButton->setChecked(true); break; } switch (config.texture.screenShotFormat) { case 0: ui->pngRadioButton->setChecked(true); break; case 1: ui->jpegRadioButton->setChecked(true); break; } // Emulation settings ui->emulateLodCheckBox->setChecked(config.generalEmulation.enableLOD != 0); ui->emulateNoiseCheckBox->setChecked(config.generalEmulation.enableNoise != 0); ui->enableHWLightingCheckBox->setChecked(config.generalEmulation.enableHWLighting != 0); ui->enableShadersStorageCheckBox->setChecked(config.generalEmulation.enableShadersStorage != 0); ui->customSettingsCheckBox->setChecked(config.generalEmulation.enableCustomSettings != 0); switch (config.generalEmulation.correctTexrectCoords) { case Config::tcDisable: ui->fixTexrectDisableRadioButton->setChecked(true); break; case Config::tcSmart: ui->fixTexrectSmartRadioButton->setChecked(true); break; case Config::tcForce: ui->fixTexrectForceRadioButton->setChecked(true); break; } ui->nativeRes2D_checkBox->toggle(); ui->nativeRes2D_checkBox->setChecked(config.generalEmulation.enableNativeResTexrects != 0); ui->gammaCorrectionCheckBox->toggle(); ui->gammaCorrectionCheckBox->setChecked(config.gammaCorrection.force != 0); ui->gammaLevelSpinBox->setValue(config.gammaCorrection.level); ui->frameBufferSwapComboBox->setCurrentIndex(config.frameBufferEmulation.bufferSwapMode); ui->fbInfoEnableCheckBox->toggle(); ui->fbInfoEnableCheckBox->setChecked(config.frameBufferEmulation.fbInfoDisabled == 0); ui->frameBufferCheckBox->toggle(); const bool fbEmulationEnabled = config.frameBufferEmulation.enable != 0; ui->frameBufferCheckBox->setChecked(fbEmulationEnabled); ui->frameBufferInfoFrame->setVisible(!fbEmulationEnabled); ui->frameBufferInfoFrame2->setVisible(!fbEmulationEnabled); ui->copyColorBufferComboBox->setCurrentIndex(config.frameBufferEmulation.copyToRDRAM); ui->copyDepthBufferComboBox->setCurrentIndex(config.frameBufferEmulation.copyDepthToRDRAM); ui->RenderFBCheckBox->setChecked(config.frameBufferEmulation.copyFromRDRAM != 0); ui->n64DepthCompareCheckBox->toggle(); ui->n64DepthCompareCheckBox->setChecked(config.frameBufferEmulation.N64DepthCompare != 0); switch (config.frameBufferEmulation.aspect) { case Config::aStretch: ui->aspectStretchRadioButton->setChecked(true); break; case Config::a43: ui->aspect43RadioButton->setChecked(true); break; case Config::a169: ui->aspect169RadioButton->setChecked(true); break; case Config::aAdjust: ui->aspectAdjustRadioButton->setChecked(true); break; } ui->resolutionFactorSlider->valueChanged(2); ui->factor0xRadioButton->toggle(); ui->factor1xRadioButton->toggle(); ui->factorXxRadioButton->toggle(); switch (config.frameBufferEmulation.nativeResFactor) { case 0: ui->factor0xRadioButton->setChecked(true); break; case 1: ui->factor1xRadioButton->setChecked(true); break; default: ui->factorXxRadioButton->setChecked(true); ui->resolutionFactorSlider->setValue(config.frameBufferEmulation.nativeResFactor); break; } ui->copyAuxBuffersCheckBox->setChecked(config.frameBufferEmulation.copyAuxToRDRAM != 0); ui->readColorChunkCheckBox->setChecked(config.frameBufferEmulation.fbInfoReadColorChunk != 0); ui->readColorChunkCheckBox->setEnabled(fbEmulationEnabled && config.frameBufferEmulation.fbInfoDisabled == 0); ui->readDepthChunkCheckBox->setChecked(config.frameBufferEmulation.fbInfoReadDepthChunk != 0); ui->readDepthChunkCheckBox->setEnabled(fbEmulationEnabled && config.frameBufferEmulation.fbInfoDisabled == 0); // Texture filter settings ui->filterComboBox->setCurrentIndex(config.textureFilter.txFilterMode); ui->enhancementComboBox->setCurrentIndex(config.textureFilter.txEnhancementMode); ui->textureFilterCacheSpinBox->setValue(config.textureFilter.txCacheSize / gc_uMegabyte); ui->deposterizeCheckBox->setChecked(config.textureFilter.txDeposterize != 0); ui->ignoreBackgroundsCheckBox->setChecked(config.textureFilter.txFilterIgnoreBG != 0); ui->texturePackOnCheckBox->toggle(); ui->texturePackOnCheckBox->setChecked(config.textureFilter.txHiresEnable != 0); ui->alphaChannelCheckBox->setChecked(config.textureFilter.txHiresFullAlphaChannel != 0); ui->alternativeCRCCheckBox->setChecked(config.textureFilter.txHresAltCRC != 0); ui->textureDumpCheckBox->setChecked(config.textureFilter.txDump != 0); ui->force16bppCheckBox->setChecked(config.textureFilter.txForce16bpp != 0); ui->compressCacheCheckBox->setChecked(config.textureFilter.txCacheCompression != 0); ui->saveTextureCacheCheckBox->setChecked(config.textureFilter.txSaveCache != 0); ui->txPathLabel->setText(QString::fromWCharArray(config.textureFilter.txPath)); ui->txCachePathLabel->setText(QString::fromWCharArray(config.textureFilter.txCachePath)); ui->txDumpPathLabel->setText(QString::fromWCharArray(config.textureFilter.txDumpPath)); // OSD settings QString fontName(config.font.name.c_str()); ui->fontLineEdit->setText(fontName); m_font = QFont(fontName.left(fontName.indexOf(".ttf"))); m_font.setPixelSize(config.font.size); ui->fontLineEdit->setHidden(true); ui->fontSizeSpinBox->setValue(config.font.size); m_color = QColor(config.font.color[0], config.font.color[1], config.font.color[2]); QPalette palette; palette.setColor(QPalette::WindowText, m_color); palette.setColor(QPalette::Window, Qt::black); ui->fontPreviewLabel->setAutoFillBackground(true); ui->fontPreviewLabel->setPalette(palette); ui->PickFontColorButton->setStyleSheet(QString("color:") + m_color.name()); switch (config.onScreenDisplay.pos) { case Config::posTopLeft: ui->topLeftPushButton->setChecked(true); break; case Config::posTopCenter: ui->topPushButton->setChecked(true); break; case Config::posTopRight: ui->topRightPushButton->setChecked(true); break; case Config::posBottomLeft: ui->bottomLeftPushButton->setChecked(true); break; case Config::posBottomCenter: ui->bottomPushButton->setChecked(true); break; case Config::posBottomRight: ui->bottomRightPushButton->setChecked(true); break; } ui->fpsCheckBox->setChecked(config.onScreenDisplay.fps != 0); ui->visCheckBox->setChecked(config.onScreenDisplay.vis != 0); ui->percentCheckBox->setChecked(config.onScreenDisplay.percent != 0); ui->internalResolutionCheckBox->setChecked(config.onScreenDisplay.internalResolution != 0); ui->renderingResolutionCheckBox->setChecked(config.onScreenDisplay.renderingResolution != 0); // Buttons ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("OK")); ui->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("Cancel")); ui->buttonBox->button(QDialogButtonBox::RestoreDefaults)->setText(tr("Restore Defaults")); ui->dumpLowCheckBox->setChecked((config.debug.dumpMode & DEBUG_LOW) != 0); ui->dumpNormalCheckBox->setChecked((config.debug.dumpMode & DEBUG_NORMAL) != 0); ui->dumpDetailCheckBox->setChecked((config.debug.dumpMode & DEBUG_DETAIL) != 0); #ifndef DEBUG_DUMP for (int i = 0; i < ui->tabWidget->count(); ++i) { if (tr("Debug") == ui->tabWidget->tabText(i)) { ui->tabWidget->removeTab(i); break; } } #endif }
void wxSVGFileDCImpl::DoDrawRotatedText(const wxString& sText, wxCoord x, wxCoord y, double angle) { //known bug; if the font is drawn in a scaled DC, it will not behave exactly as wxMSW NewGraphicsIfNeeded(); wxString s; // Get extent of whole text. wxCoord w, h, heightLine; GetOwner()->GetMultiLineTextExtent(sText, &w, &h, &heightLine); // Compute the shift for the origin of the next line. const double rad = wxDegToRad(angle); const double dx = heightLine * sin(rad); const double dy = heightLine * cos(rad); // wxS("upper left") and wxS("upper right") CalcBoundingBox(x, y); CalcBoundingBox((wxCoord)(x + w*cos(rad)), (wxCoord)(y - h*sin(rad))); // wxS("bottom left") and wxS("bottom right") CalcBoundingBox((wxCoord)(x + h*sin(rad)), (wxCoord)(y + h*cos(rad))); CalcBoundingBox((wxCoord)(x + h*sin(rad) + w*cos(rad)), (wxCoord)(y + h*cos(rad) - w*sin(rad))); if (m_backgroundMode == wxBRUSHSTYLE_SOLID) { // draw background first // just like DoDrawRectangle except we pass the text color to it and set the border to a 1 pixel wide text background s += wxString::Format(wxS(" <rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" "), x, y, w, h); s += wxS("style=\"") + wxBrushString(m_textBackgroundColour); s += wxS("stroke-width:1; ") + wxPenString(m_textBackgroundColour); s += wxString::Format(wxS("\" transform=\"rotate(%s %d %d)\"/>"), NumStr(-angle), x, y); s += wxS("\n"); write(s); } // Draw all text line by line const wxArrayString lines = wxSplit(sText, '\n', '\0'); for (size_t lineNum = 0; lineNum < lines.size(); lineNum++) { // convert x,y to SVG text x,y (the coordinates of the text baseline) wxCoord ww, hh, desc; DoGetTextExtent(lines[lineNum], &ww, &hh, &desc); int xx = x + wxRound(lineNum * dx) + (hh - desc) * sin(rad); int yy = y + wxRound(lineNum * dy) + (hh - desc) * cos(rad); //now do the text itself s += wxString::Format(wxS(" <text x=\"%d\" y=\"%d\" textLength=\"%d\" "), xx, yy, ww); wxString fontName(m_font.GetFaceName()); if (fontName.Len() > 0) s += wxS("style=\"font-family:") + fontName + wxS("; "); else s += wxS("style=\" "); wxString fontweight; switch (m_font.GetWeight()) { case wxFONTWEIGHT_MAX: wxFAIL_MSG(wxS("invalid font weight value")); wxFALLTHROUGH; case wxFONTWEIGHT_NORMAL: fontweight = wxS("normal"); break; case wxFONTWEIGHT_LIGHT: fontweight = wxS("lighter"); break; case wxFONTWEIGHT_BOLD: fontweight = wxS("bold"); break; } wxASSERT_MSG(!fontweight.empty(), wxS("unknown font weight value")); s += wxS("font-weight:") + fontweight + wxS("; "); wxString fontstyle; switch (m_font.GetStyle()) { case wxFONTSTYLE_MAX: wxFAIL_MSG(wxS("invalid font style value")); wxFALLTHROUGH; case wxFONTSTYLE_NORMAL: fontstyle = wxS("normal"); break; case wxFONTSTYLE_ITALIC: fontstyle = wxS("italic"); break; case wxFONTSTYLE_SLANT: fontstyle = wxS("oblique"); break; } wxASSERT_MSG(!fontstyle.empty(), wxS("unknown font style value")); s += wxS("font-style:") + fontstyle + wxS("; "); wxString textDecoration; if (m_font.GetUnderlined()) textDecoration += wxS(" underline"); if (m_font.GetStrikethrough()) textDecoration += wxS(" line-through"); if (textDecoration.IsEmpty()) textDecoration = wxS(" none"); s += wxS("text-decoration:") + textDecoration + wxS("; "); s += wxString::Format(wxS("font-size:%dpt; "), m_font.GetPointSize()); //text will be solid, unless alpha value isn't opaque in the foreground colour s += wxBrushString(m_textForegroundColour) + wxPenString(m_textForegroundColour); s += wxString::Format(wxS("stroke-width:0;\" transform=\"rotate(%s %d %d)\""), NumStr(-angle), xx, yy); s += wxS(" xml:space=\"preserve\">"); s += wxMarkupParser::Quote(lines[lineNum]) + wxS("</text>\n"); write(s); } }
osg::Node* createHUD() { osg::Geode* geode = new osg::Geode(); osg::StateSet* ss = geode->getOrCreateStateSet(); ss->setMode( GL_LIGHTING, osg::StateAttribute::OFF ); std::string fontName( "fonts/arial.ttf" ); osg::Vec3 position( 150, 800, 0 ); osg::Vec3 delta( 0, -120, 0 ); { osgText::Text* text = new osgText::Text; text->setText( "HUD text\nfile modified " __TIMESTAMP__ "\nfile compiled " __DATE__ " " __TIME__ ); text->setFont( fontName ); text->setColor( osg::Vec4(1,1,0,1) ); text->setPosition( position ); position += delta; geode->addDrawable( text ); } // frame behind text #if 0 { osg::BoundingBox bb; for(unsigned int i=0;i<geode->getNumDrawables();++i) { bb.expandBy( geode->getDrawable(i)->getBound() ); } osg::Geometry* geom = new osg::Geometry; osg::Vec3Array* vertices = new osg::Vec3Array; float depth = bb.zMin() - 0.1; // in front or in back? vertices->push_back( osg::Vec3( bb.xMin(), bb.yMax(), depth ) ); vertices->push_back( osg::Vec3( bb.xMin(), bb.yMin(), depth ) ); vertices->push_back( osg::Vec3( bb.xMax(), bb.yMin(), depth ) ); vertices->push_back( osg::Vec3( bb.xMax(), bb.yMax(), depth ) ); geom->setVertexArray(vertices); osg::Vec3Array* normals = new osg::Vec3Array; normals->push_back( osg::Vec3(0,0,1) ); geom->setNormalArray(normals); geom->setNormalBinding(osg::Geometry::BIND_OVERALL); osg::Vec4Array* colors = new osg::Vec4Array; colors->push_back( osg::Vec4(0.2f,1,0.2f,0.2f) ); geom->setColorArray(colors); geom->setColorBinding(osg::Geometry::BIND_OVERALL); geom->addPrimitiveSet(new osg::DrawArrays(GL_QUADS,0,4)); osg::StateSet* ss = geom->getOrCreateStateSet(); ss->setMode( GL_BLEND, osg::StateAttribute::ON ); ss->setRenderingHint( osg::StateSet::TRANSPARENT_BIN ); // drawn last? geode->addDrawable( geom ); } #endif osg::CameraNode* camera = new osg::CameraNode; camera->setProjectionMatrix( osg::Matrix::ortho2D(0,1280,0,1024) ); camera->setReferenceFrame( osg::Transform::ABSOLUTE_RF ); camera->setViewMatrix( osg::Matrix::identity() ); camera->setClearMask( GL_DEPTH_BUFFER_BIT ); camera->setRenderOrder( osg::CameraNode::POST_RENDER ); camera->addChild( geode ); return camera; }
bool Ressources::loadConf(const std::string& rootIniFileName){ if(!fileFound(rootIniFileName)) return false; iniDoc rootDoc(rootIniFileName); // load other includes vector<string> ini; rootDoc.get("include", "ini", ini); for(auto s : ini){ if(!fileFound(s)){ omg_warn("requested include <"+s+"> (not found !)"); }else{ omg_info("requested include <"+s+">..."); iniLoader il; il.loadIniDoc(s, rootDoc); } } vector<string> rootSections = rootDoc.listSections(); // find languages for(const string& section : rootSections){ string tag = "lang:"; auto f = section.find(tag); if(f==string::npos) continue; string langId(section.begin()+f+tag.size(),section.end()); tools::trim(langId); omg_info("new lang found with ID <"+langId+">"); fetchLanguages(rootDoc, section, langId); } // find textures for(const string& section : rootSections){ string tag = "tex:"; auto f = section.find(tag); if(f==string::npos) continue; string texName(section.begin()+f+tag.size(),section.end()); tools::trim(texName); if(requiredTexturesNames.count(texName)){ omg_warn("new tex found with name <"+texName+"> but not used..."); }else{ omg_info("new tex found with name <"+texName+">"); } fetchTexInfo(rootDoc, section, texName); } // find fonts for(const string& section : rootSections){ string tag = "font:"; auto f = section.find(tag); if(f==string::npos) continue; string fontName(section.begin()+f+tag.size(),section.end()); tools::trim(fontName); fetchFont(rootDoc, section, fontName); } return true; }
QStringList FMPDFFontExtractor::list() { if(!document) return mfont.keys(); if(cachedList) return mfont.keys(); else cachedList = true; PoDoFo::TCIVecObjects objIt( document->GetObjects().begin() ); PoDoFo::PdfName pType("Type"); PoDoFo::PdfName pSubtype("Subtype"); PoDoFo::PdfName pFont("Font"); PoDoFo::PdfName pType1("Type1"); PoDoFo::PdfName pTrueType("TrueType"); PoDoFo::PdfName pFontDescriptor( "FontDescriptor" ); PoDoFo::PdfName pFontFile( "FontFile" ); PoDoFo::PdfName pFontFile3( "FontFile3" ); PoDoFo::PdfName pFontName( "FontName" ); while( objIt != document->GetObjects().end() ) { PoDoFo::PdfObject* obj(*objIt); if ( obj->IsDictionary() ) { if(obj->GetIndirectKey(pType)) { PoDoFo::PdfName type( obj->GetIndirectKey(pType)->GetName() ); if(type == pFont) { if(obj->GetIndirectKey( pSubtype )) { PoDoFo::PdfName subtype ( obj->GetIndirectKey( pSubtype )->GetName() ); if ((subtype == pType1) || (subtype == pTrueType)) { PoDoFo::PdfObject * fontDescriptor ( obj->GetIndirectKey ( pFontDescriptor ) ); if (fontDescriptor ) { bool hasFile(false); PoDoFo::PdfObject * fontFile ( fontDescriptor->GetIndirectKey ( pFontFile ) ); if ( !fontFile ) { fontFile = fontDescriptor->GetIndirectKey(pFontFile3) ; if ( !fontFile ) qWarning ( "Font not embedded not supported yet" ); else hasFile = true; } else hasFile = true; if(hasFile) { PoDoFo::PdfName fontName(fontDescriptor->GetIndirectKey(pFontName)->GetName()); if(1) { QString n(QString::fromStdString( fontName.GetName() )); mfont[n] = fontFile; // we know naming it pfb is wrong mType[n] = (subtype == pType1) ? "pfb" : "ttf"; } else qDebug()<<"Error: no /FontName key"; } } } } } } } objIt++; } return mfont.keys(); }
QSizeF HelperKaraokeLabel::RenderToImage(QImage** ppimage, const QString& lyric, QList<RubyChar>& ruby, const QColor& textCol, const QColor& strokeColor) { if (!ppimage) { return QSizeF(); } auto pimage = *ppimage; if (pimage) { delete pimage; pimage = NULL; *ppimage = NULL; } auto setting = Settings::getInstance(); _textColor = textCol; _strokeColor = strokeColor; // text setText(lyric); // set font QFont f; f.setFamily(setting->fontName()); f.setWeight(99); f.setPixelSize(setting->fontSize()); f.setLetterSpacing(QFont::SpacingType::AbsoluteSpacing, 1); setFont(f); // calc size QSizeF size = minimumSizeHint(); ////////////////////////////////////////////////////////////////////////// // ruby int rubyCount = ruby.size(); _maxSubW = 0.0; _maxSubH = setting->rubyFontSize(); QList<HelperKaraokeLabel*> subList; for (int i = 0; i < rubyCount; i++) { HelperKaraokeLabel* sub = new HelperKaraokeLabel(this); sub->_isRuby = true; sub->setRubyHidden(_isRubyHidden); subList.append(sub); sub->setText(ruby[i].ruby()); sub->_textColor = _textColor; sub->_strokeColor = _strokeColor; // set font QFont f; f.setFamily(setting->fontName()); f.setWeight(99); f.setPixelSize(setting->rubyFontSize()); f.setLetterSpacing(QFont::SpacingType::AbsoluteSpacing, 1); sub->setFont(f); QSizeF subsize = sub->minimumSizeHint(); if (_maxSubW < subsize.width()) { _maxSubW = subsize.width(); } // should be even!! /* if (_maxSubH < subsize.height()) { _maxSubH = subsize.height(); }*/ } // rearrange size _maxSubH += 1.0; // shadow // /--/ // _rubyOffset > 0 // /<--->/ // _maxSubW // |--|a|----|b|----|c|--| // AAAAAAAAAAAAAAAAA // // |a|b|c| // ---A--- // /--/ // _rubyOffset < 0 size.setHeight(size.height() + _maxSubH + setting->rubyVSpace()); if (rubyCount > 0) { qreal subTotalW = _maxSubW*rubyCount; qreal oWidth = size.width(); if (oWidth < subTotalW) { size.setWidth(_maxSubW*rubyCount); _rubyOffset = (oWidth - subTotalW) / 2.0; } else { auto oMaxSubW = _maxSubW; /* _maxSubW = ((qreal)(oWidth)) / rubyCount; _rubyOffset = oMaxSubW/2; */ _rubyOffset = (oWidth - rubyCount*oMaxSubW) / rubyCount / 2.0; _maxSubW = oMaxSubW + _rubyOffset * 2.0; } for (int i = 0; i < rubyCount; i++) { subList[i]->setFixedSize(QSize(_maxSubW, _maxSubH+setting->rubyVSpace())); subList[i]->_maxSubW = _maxSubW; subList[i]->_maxSubH = _maxSubH; auto geo = subList[i]->geometry(); geo.setX(geo.x() + i*_maxSubW + (_rubyOffset>0 ? _rubyOffset : 0)); subList[i]->setGeometry(geo); } /* auto geo = this->geometry(); geo.setY(maxSubH + subSpaceH); this->setGeometry(geo); */ } setFixedSize(size.toSize()); // render to image pimage = new QImage(size.toSize(), QImage::Format_ARGB32); QPainter painter(pimage); pimage->fill(qRgba(0, 0, 0, 0)); render(&painter, QPoint(), QRegion(), QWidget::DrawChildren); // assign return value *ppimage = pimage; return size; }
void ConfigDialog::_init() { // Video settings QStringList windowedModesList; int windowedModesCurrent = 0; for (int i = 0; i < numWindowedModes; ++i) { windowedModesList.append(WindowedModes[i].description); if (WindowedModes[i].width == config.video.windowedWidth && WindowedModes[i].height == config.video.windowedHeight) windowedModesCurrent = i; } ui->windowedResolutionComboBox->insertItems(0, windowedModesList); ui->windowedResolutionComboBox->setCurrentIndex(windowedModesCurrent); QStringList fullscreenModesList, fullscreenRatesList; int fullscreenMode, fullscreenRate; fillFullscreenResolutionsList(fullscreenModesList, fullscreenMode, fullscreenRatesList, fullscreenRate); ui->fullScreenResolutionComboBox->insertItems(0, fullscreenModesList); ui->fullScreenResolutionComboBox->setCurrentIndex(fullscreenMode); ui->fullScreenRefreshRateComboBox->insertItems(0, fullscreenRatesList); ui->fullScreenRefreshRateComboBox->setCurrentIndex(fullscreenRate); ui->aliasingSlider->setValue(config.video.multisampling); ui->anisotropicSlider->setValue(config.texture.maxAnisotropy); ui->cacheSizeSpinBox->setValue(config.texture.maxBytes / gc_uMegabyte); switch (config.texture.bilinearMode) { case BILINEAR_3POINT: ui->blnr3PointRadioButton->setChecked(true); break; case BILINEAR_STANDARD: ui->blnrStandardRadioButton->setChecked(true); break; } switch (config.texture.screenShotFormat) { case 0: ui->bmpRadioButton->setChecked(true); break; case 1: ui->jpegRadioButton->setChecked(true); break; } // Emulation settings ui->emulateLodCheckBox->setChecked(config.generalEmulation.enableLOD != 0); ui->emulateNoiseCheckBox->setChecked(config.generalEmulation.enableNoise != 0); ui->emulateFogCheckBox->setChecked(config.generalEmulation.enableFog != 0); ui->enableHWLightingCheckBox->setChecked(config.generalEmulation.enableHWLighting != 0); ui->enableShadersStorageCheckBox->setChecked(config.generalEmulation.enableShadersStorage != 0); ui->customSettingsCheckBox->setChecked(config.generalEmulation.enableCustomSettings != 0); ui->bufferSwapComboBox->setCurrentIndex(config.frameBufferEmulation.bufferSwapMode); ui->frameBufferGroupBox->setChecked(config.frameBufferEmulation.enable != 0); switch (config.frameBufferEmulation.copyToRDRAM) { case Config::ctDisable: ui->copyBufferDisableRadioButton->setChecked(true); break; case Config::ctSync: ui->copyBufferSyncRadioButton->setChecked(true); break; case Config::ctAsync: ui->copyBufferAsyncRadioButton->setChecked(true); break; } ui->RenderFBCheckBox->setChecked(config.frameBufferEmulation.copyFromRDRAM != 0); ui->CopyDepthCheckBox->setChecked(config.frameBufferEmulation.copyDepthToRDRAM != 0); ui->n64DepthCompareCheckBox->setChecked(config.frameBufferEmulation.N64DepthCompare != 0); switch (config.frameBufferEmulation.aspect) { case Config::aStretch: ui->aspectStretchRadioButton->setChecked(true); break; case Config::a43: ui->aspect43RadioButton->setChecked(true); break; case Config::a169: ui->aspect169RadioButton->setChecked(true); break; case Config::aAdjust: ui->aspectAdjustRadioButton->setChecked(true); break; } // Texture filter settings QStringList textureFiltersList; for (int i = 0; i < numFilters; ++i) textureFiltersList.append(cmbTexFilter_choices[i]); ui->filterComboBox->insertItems(0, textureFiltersList); ui->filterComboBox->setCurrentIndex(config.textureFilter.txFilterMode); QStringList textureEnhancementList; for (int i = 0; i < numEnhancements; ++i) textureEnhancementList.append(cmbTexEnhancement_choices[i]); ui->enhancementComboBox->insertItems(0, textureEnhancementList); ui->enhancementComboBox->setCurrentIndex(config.textureFilter.txEnhancementMode); ui->textureFilterCacheSpinBox->setValue(config.textureFilter.txCacheSize / gc_uMegabyte); ui->ignoreBackgroundsCheckBox->setChecked(config.textureFilter.txFilterIgnoreBG != 0); ui->texturePackGroupBox->setChecked(config.textureFilter.txHiresEnable != 0); ui->alphaChannelCheckBox->setChecked(config.textureFilter.txHiresFullAlphaChannel != 0); ui->alternativeCRCCheckBox->setChecked(config.textureFilter.txHresAltCRC != 0); ui->textureDumpCheckBox->setChecked(config.textureFilter.txDump != 0); ui->force16bppCheckBox->setChecked(config.textureFilter.txForce16bpp != 0); ui->compressCacheCheckBox->setChecked(config.textureFilter.txCacheCompression != 0); ui->saveTextureCacheCheckBox->setChecked(config.textureFilter.txSaveCache != 0); ui->txPathLabel->setText(QString::fromWCharArray(config.textureFilter.txPath)); QString fontName(config.font.name.c_str()); m_font = QFont(fontName.left(fontName.indexOf(".ttf")), config.font.size); QString strSize; strSize.setNum(m_font.pointSize()); ui->fontNameLabel->setText(m_font.family() + " - " + strSize); m_color = QColor(config.font.color[0], config.font.color[1], config.font.color[2]); ui->fontColorLabel->setFont(m_font); ui->fontColorLabel->setText(m_color.name()); QPalette palette; palette.setColor(QPalette::Window, Qt::black); palette.setColor(QPalette::WindowText, m_color); ui->fontColorLabel->setAutoFillBackground(true); ui->fontColorLabel->setPalette(palette); // Post filter settings ui->bloomGroupBox->setChecked(config.bloomFilter.enable != 0); switch (config.bloomFilter.blendMode) { case 0: ui->bloomStrongRadioButton->setChecked(true); break; case 1: ui->bloomMildRadioButton->setChecked(true); break; case 2: ui->bloomLightRadioButton->setChecked(true); break; } ui->bloomThresholdSlider->setValue(config.bloomFilter.thresholdLevel); ui->blurAmountSlider->setValue(config.bloomFilter.blurAmount); ui->blurStrengthSlider->setValue(config.bloomFilter.blurStrength); ui->forceGammaCorrectionCheckBox->setChecked(config.gammaCorrection.force != 0); ui->gammaLevelSpinBox->setValue(config.gammaCorrection.level); ui->gammaLevelSpinBox->setEnabled(ui->forceGammaCorrectionCheckBox->isChecked()); }
//-------------------------------------------------------------------------------------- // Load the font data from the given file describing properties of the font characters. // Param1: The filename, or path, of the file containing the font data. // Returns true if the data was loaded successfully, false otherwise. //-------------------------------------------------------------------------------------- bool Font::LoadFontData( const std::string& filename ) { std::ifstream in; // Open the file in.open(filename); if(in.fail()) { return false; } char temp = ' '; // Information listed at the top of the font file. At the moment only a few are being used. std::string fontName(""); int imageWidth = 0; int imageHeight = 0; int cellWidth = 0; int cellHeight = 0; int startChar = 0; int fontHeight = 0; int fontWidth = 0; while(temp != ',') { in.get(temp); } in >> imageWidth; // Invalid file, prevent division by zero later on if(imageWidth == 0) { in.close(); return false; } in.get(temp); while(temp != ',') { in.get(temp); } in >> imageHeight; in.get(temp); while(temp != ',') { in.get(temp); } in >> cellWidth; // Invalid file, prevent division by zero later on if(cellWidth == 0) { in.close(); return false; } in.get(temp); while(temp != ',') { in.get(temp); } in >> cellHeight; in.get(temp); while(temp != ',') { in.get(temp); } in >> startChar; in.get(temp); while(temp != ',') { in.get(temp); } in >> fontName; in.get(temp); while(temp != ',') { in.get(temp); } in >> fontHeight; in.get(temp); while(temp != ',') { in.get(temp); } in >> fontWidth; m_startCharacter = startChar; m_numberOfCharacters = imageWidth / cellWidth; m_textHeight = cellHeight; // Create character array m_pCharacters = new CharacterData[m_numberOfCharacters]; if(!m_pCharacters) { return false; } in.get(temp); // Read until the beginning of the start character, skip the ones before int garbage = 0; for(unsigned int i = 0; i < m_startCharacter + m_numberOfCharacters; ++i) { while(temp != ',') { in.get(temp); } if(i < m_startCharacter) { in >> garbage; }else {