Exemplo n.º 1
0
void MacFontManager::generateFontSubstitute(MacFont &macFont) {
	Common::String name;

	// First we try twice size
	name = getFontName(macFont.getId(), macFont.getSize() * 2, macFont.getSlant());
	if (_fontRegistry.contains(name) && !_fontRegistry[name]->isGenerated()) {
		generateFont(macFont, *_fontRegistry[name]);

		return;
	}

	// Now half size
	name = getFontName(macFont.getId(), macFont.getSize() / 2, macFont.getSlant());
	if (_fontRegistry.contains(name) && !_fontRegistry[name]->isGenerated()) {
		generateFont(macFont, *_fontRegistry[name]);

		return;
	}

	// No simple substitute was found. Looking for neighborhood fonts

	// First we gather all font sizes for this font
	Common::Array<int> sizes;
	for (Common::HashMap<Common::String, MacFont *>::iterator i = _fontRegistry.begin(); i != _fontRegistry.end(); ++i) {
		if (i->_value->getId() == macFont.getId() && i->_value->getSlant() == macFont.getSlant() && !i->_value->isGenerated())
			sizes.push_back(i->_value->getSize());
	}

	if (sizes.empty()) {
		warning("No viable substitute found for font %s", getFontName(macFont));
		return;
	}

	// Now looking next larger font, and store the largest one for next check
	int candidate = 1000;
	int maxSize = sizes[0];
	for (uint i = 0; i < sizes.size(); i++) {
		if (sizes[i] > macFont.getSize() && sizes[i] < candidate)
			candidate = sizes[i];

		if (sizes[i] > maxSize)
			maxSize = sizes[i];
	}

	if (candidate != 1000) {
		generateFont(macFont, *_fontRegistry[getFontName(macFont.getId(), candidate, macFont.getSlant())]);
		return;
	}

	// Now next smaller font, which is the biggest we have
	generateFont(macFont, *_fontRegistry[getFontName(macFont.getId(), maxSize, macFont.getSlant())]);
}
Exemplo n.º 2
0
void KIGPDialog::writeConfig()
{
 KConfigGroup group = m_config->group("Look");
 group.writeEntry("ImagesPerRow", getImagesPerRow());
 group.writeEntry("ImageName", printImageName());
 group.writeEntry("ImageSize", printImageSize());
 group.writeEntry("ImageProperty", printImageProperty());
 group.writeEntry("FontName", getFontName());
 group.writeEntry("FontSize", getFontSize());
 group.writeEntry("ForegroundColor", getForegroundColor().name() );
 group.writeEntry("BackgroundColor", getBackgroundColor().name());

 group =m_config->group("Directory");
 group.writeEntry("RecurseSubDirectories", recurseSubDirectories());
 group.writeEntry("RecursionLevel", recursionLevel());
 group.writeEntry("CopyOriginalFiles", copyOriginalFiles());
 group.writeEntry("UseCommentFile", useCommentFile());

 group = m_config->group("Thumbnails");
 group.writeEntry("ThumbnailSize", getThumbnailSize());
 group.writeEntry("ColorDepth", getColorDepth());
 group.writeEntry("ColorDepthSet", colorDepthSet());
 group.writeEntry("ImageFormat", getImageFormat());
 group.sync();
}
Exemplo n.º 3
0
void Tooltip::redoLayout() {
	checkEmpty();
	if (_empty)
		return;

	if (_font.empty())
		_font = getFontName();

	Graphics::Aurora::FontHandle font = FontMan.get(_font);

	_lineHeight  = font.getFont().getHeight();
	_lineSpacing = font.getFont().getLineSpacing();

	for (std::vector<Line>::iterator l = _lines.begin(); l != _lines.end(); ++l) {
		if (l->text)
			continue;

		l->text = new Graphics::Aurora::Text(font, l->line, l->r, l->g, l->b, l->a);
		l->text->setTag("Tooltip#Text");
	}

	float width, height;
	getSize(width, height);

	if ((_width != width) || (_height != height)) {
		_width  = width;
		_height = height;

		redoBubble();
	}

	updatePosition();
}
void*
Java_java_awt_Toolkit_fntInitFont( JNIEnv* envP, jclass clazz, jstring jSpec, jint style, jint size )
{
	GR_FONT_ID fontid;

#if 0
	const char *spec,*newspec;

	if ( jSpec == NULL ) {
		spec = NULL;
	} else {
		spec = (*envP)->GetStringUTFChars(envP , jSpec, NULL);
	}
	if ( spec == NULL ) {
		fontid = GrCreateFont(GR_FONT_SYSTEM_VAR, 0, NULL);
	} else {
		newspec = getFontName(spec,style);

		fontid = GrCreateFont((char *)newspec, size, NULL);
		if ( fontid == NULL ) {
			fontid = GrCreateFont((char *)spec, size, NULL);
		}
	}
#endif
	fontid = GrCreateFont(GR_FONT_SYSTEM_VAR, 0, NULL);
	
	return (void*)fontid;
}
Exemplo n.º 5
0
void Tooltip::addLine(const Common::UString &text, float r, float g, float b, float a) {
	hide();

	if (text.empty())
		return;

	std::vector<Common::UString> lines;
	Common::UString::split(text, '\n', lines);

	for (std::vector<Common::UString>::const_iterator l = lines.begin();
	     l != lines.end(); ++l) {

		_lines.push_back(Line());

		_lines.back().r    = r;
		_lines.back().g    = g;
		_lines.back().b    = b;
		_lines.back().a    = a;
		_lines.back().line = *l;
		_lines.back().text = new Graphics::Aurora::Text(FontMan.get(getFontName()), *l, r, g, b, a);
		_lines.back().text->setTag("Tooltip#Text");
	}

	redoLayout();
}
Exemplo n.º 6
0
void Tooltip::redoLayout() {
	checkEmpty();
	if (_empty)
		return;

	if (_font.empty())
		_font = getFontName();

	Graphics::Aurora::FontHandle font = FontMan.get(_font);

	_lineHeight  = font.getFont().getHeight();
	_lineSpacing = font.getFont().getLineSpacing();

	float width, height;
	getSize(width, height);

	if ((_width != width) || (_height != height)) {
		_width  = width;
		_height = height;

		redoBubble();
	}

	updatePosition();
}
Exemplo n.º 7
0
/*!
 * \brief TextAnnotation::duplicate
 * Creates a duplicate of this object.
 */
void TextAnnotation::duplicate()
{
  TextAnnotation *pTextAnnotation = new TextAnnotation("", false, mpGraphicsView);
  QPointF gridStep(mpGraphicsView->getCoOrdinateSystem()->getHorizontalGridStep(),
                   mpGraphicsView->getCoOrdinateSystem()->getVerticalGridStep());
  pTextAnnotation->setOrigin(mOrigin + gridStep);
  pTextAnnotation->setRotationAngle(mRotation);
  pTextAnnotation->initializeTransformation();
  pTextAnnotation->setLineColor(getLineColor());
  pTextAnnotation->setFillColor(getFillColor());
  pTextAnnotation->setLinePattern(getLinePattern());
  pTextAnnotation->setFillPattern(getFillPattern());
  pTextAnnotation->setLineThickness(getLineThickness());
  pTextAnnotation->setExtents(getExtents());
  pTextAnnotation->setTextString(getTextString());
  pTextAnnotation->setFontSize(getFontSize());
  pTextAnnotation->setFontName(getFontName());
  pTextAnnotation->setTextStyles(getTextStyles());
  pTextAnnotation->setTextHorizontalAlignment(getTextHorizontalAlignment());
  pTextAnnotation->drawCornerItems();
  pTextAnnotation->setCornerItemsPassive();
  pTextAnnotation->update();
  mpGraphicsView->addClassAnnotation();
  mpGraphicsView->setCanAddClassAnnotation(true);
}
Exemplo n.º 8
0
void XtgScanner::setFont()
{
	/** define/apply font */
	flushText();
	token = getToken();
	QString font = PrefsManager::instance()->appPrefs.itemToolPrefs.textFont;
	if (token != "$")
		font = getFontName(token);
	currentCharStyle.setFont(PrefsManager::instance()->appPrefs.fontPrefs.AvailFonts[font]);
	if(!doc->UsedFonts.contains(font))
		doc->AddFont(font);
}
Exemplo n.º 9
0
void Tooltip::redoLines() {
	bool needRedo = false;

	Common::UString fontName = getFontName();
	if (fontName != _font) {
		needRedo = true;

		for (std::vector<Line>::iterator l = _lines.begin(); l != _lines.end(); ++l) {
			delete l->text;
			l->text = 0;
		}

		_font = fontName;

		Graphics::Aurora::FontHandle font = FontMan.get(_font);

		_lineHeight  = font.getFont().getHeight();
		_lineSpacing = font.getFont().getLineSpacing();

		_width  = 0.0;
		_height = 0.0;
	}

	bool showBubble, showText, showPortrait;
	getFeedbackMode(showBubble, showText, showPortrait);

	if ((showBubble   != _showBubble  ) ||
		  (showText     != _showText    ) ||
			(showPortrait != _showPortrait)) {

		needRedo = true;

		_width  = 0.0;
		_height = 0.0;

		_showBubble   = showBubble;
		_showText     = showText;
		_showPortrait = showPortrait;
	}

	if (needRedo)
		redoLayout();
}
Exemplo n.º 10
0
void ComboLayer::comboComeIn()
{
	CCAssert(m_comboState != COMBO_COME_IN,"combo is showing");

	m_comboState = COMBO_COME_IN;
	m_comboNode->setVisible(true);
	float scale = UIManager::sharedManager()->getScaleFactor();
	m_comboNode->setScale(scale);
	if(m_comboLabel)
	{
		m_comboLabel->removeFromParentAndCleanup(true);
		m_comboLabel = NULL;
	}

	if(m_comboFrontLabel)
	{
		m_comboFrontLabel->removeFromParentAndCleanup(true);
		m_comboFrontLabel = NULL;
	}

	m_comboShow = m_comboNumber;
	char comboString[10];
	sprintf(comboString,"%d",m_comboShow);
	m_comboLabel = CCLabelAtlas::create(comboString,getFontName(m_comboShow),48,50,48);
	m_comboLabel->setAnchorPoint(ccp(0.5f,0));
/*
	m_comboFrontLabel = CCLabelAtlas::create(comboString,"UI/ui_combo_white.png",48,50,48);
	m_comboFrontLabel->setAnchorPoint(ccp(0.5f,0));
*/
	m_comboNode->addChild(m_comboLabel,1);
	//m_comboNode->addChild(m_comboFrontLabel,2);
	m_comboNode->setPosition(m_hidingPoint);
	CCMoveTo* m_move = CCMoveTo::create(0.15f,m_ExtraPoint);
	CCMoveTo* moveAction = CCMoveTo::create(0.05f,m_showingPoint);
	//CCCallFuncN *rc = CCCallFuncN::create(this,callfuncN_selector(ComboLayer::onComboMoveInOver));
	
	/*m_comboLabel->runAction(CCSequence::create(CCDelayTime::create(0.2f),CCScaleTo::create(0.01f,2.0f,2.0f),CCScaleTo::create(0.1f,1.0f,1.0f),NULL));
	m_comboFrontLabel->runAction(CCSequence::create(CCDelayTime::create(0.4f),CCFadeIn::create(0.1f),CCFadeOut::create(0.1f),NULL));*/

	m_comboNode->runAction(CCSequence::create(m_move,moveAction,
		CCCallFuncN::create(this,callfuncN_selector(ComboLayer::onComboMoveInOver)),
		NULL));
}
Exemplo n.º 11
0
void ComboLayer::updateComboNum()
{
	if(m_comboLabel)
	{
		m_comboLabel->stopAllActions();
		m_comboLabel->removeFromParentAndCleanup(true);
		m_comboLabel = NULL;
	}

	if(m_comboFrontLabel)
	{
		m_comboFrontLabel->stopAllActions();
		m_comboFrontLabel->removeFromParentAndCleanup(true);
		m_comboFrontLabel = NULL;
	}

	if(m_comboShow < m_comboNumber)
	{
		m_comboShow++;
		char comboString[10];
		sprintf(comboString,"%d",m_comboShow);
		m_comboLabel = CCLabelAtlas::create(comboString,getFontName(m_comboShow),48,50,48);
		m_comboLabel->setAnchorPoint(ccp(0.5f,0));
		m_comboLabel->setPosition(CCPointZero);
		m_comboNode->addChild(m_comboLabel,1);
		m_comboLabel->setScale(2.0f);

		m_comboFrontLabel = CCLabelAtlas::create(comboString,"UI/ui_combo_white.png",48,50,48);
		m_comboFrontLabel->setAnchorPoint(ccp(0.5f,0));
		m_comboFrontLabel->setOpacity(0);
		m_comboNode->addChild(m_comboFrontLabel,2);
		//CCScaleTo* action1 = CCScaleTo::create(0.05f,1.7f,1.7f);
		CCScaleTo* action = CCScaleTo::create(0.1f,1.0f,1.0f);
		m_comboLabel->runAction(action);
		m_comboFrontLabel->runAction(CCSequence::create(CCDelayTime::create(0.2f),CCFadeIn::create(0.1f),CCFadeOut::create(0.1f),NULL));
		//m_comboLabel->runAction(CCSequence::create(action,CCCallFuncN::create(this,callfuncN_selector(ComboLayer::onComboScaleOver)),NULL));
		//m_comboFrontLabel->runAction(CCSequence::create(action,CCCallFuncN::create(this,callfuncN_selector(ComboLayer::onComboScaleOver)),NULL));
	}
}
Exemplo n.º 12
0
void Tooltip::redoLines(bool force) {
	bool needRedo = force;

	bool showBubble, showText, showPortrait;
	getFeedbackMode(showBubble, showText, showPortrait);

	const Common::UString fontName = getFontName();

	if ((fontName     != _font        ) ||
	    (showBubble   != _showBubble  ) ||
		  (showText     != _showText    ) ||
			(showPortrait != _showPortrait)) {

		_font         = fontName;
		_showBubble   = showBubble;
		_showText     = showText;
		_showPortrait = showPortrait;

		needRedo = true;
	}

	if (!needRedo)
		return;

	Graphics::Aurora::FontHandle font = FontMan.get(_font);

	_lineHeight  = font.getFont().getHeight();
	_lineSpacing = font.getFont().getLineSpacing();

	_width  = 0.0f;
	_height = 0.0f;

	if (!createTexts(100.0f, 3))
		if (!createTexts(150.f, 3))
			createTexts(300.0f);

	redoLayout();
}
Exemplo n.º 13
0
void MacFontManager::generateFont(MacFont &toFont, MacFont &fromFont) {
	debugN("Found font substitute for font '%s' ", getFontName(toFont));
	debug("as '%s'", getFontName(fromFont));

	MacFONTFont *font = Graphics::MacFONTFont::scaleFont(fromFont.getFont(), toFont.getSize());

	if (!font) {
		warning("Failed to generate font '%s'", getFontName(toFont));
	}

	toFont.setGenerated(true);
	toFont.setFont(font);

	FontMan.assignFontToName(getFontName(toFont), font);
	_fontRegistry.setVal(getFontName(toFont), new MacFont(toFont));

	debug("Generated font '%s'", getFontName(toFont));
}
Exemplo n.º 14
0
const Font *MacFontManager::getFont(MacFont macFont) {
	const Font *font = 0;

	if (!_builtInFonts) {
		if (macFont.getName().empty())
			macFont.setName(getFontName(macFont.getId(), macFont.getSize(), macFont.getSlant()));

		if (!_fontRegistry.contains(macFont.getName()))
			generateFontSubstitute(macFont);

		font = FontMan.getFontByName(macFont.getName());

		if (!font) {
			warning("Cannot load font '%s'", macFont.getName().c_str());

			font = FontMan.getFontByName(MacFont(kMacFontChicago, 12).getName());
		}
	}

	if (_builtInFonts || !font)
		font = FontMan.getFontByUsage(macFont.getFallback());

	return font;
}
Exemplo n.º 15
0
const char *MacFontManager::getFontName(MacFont &font) {
	return getFontName(font.getId(), font.getSize(), font.getSlant());
}