当前位置: 首页>>代码示例>>C++>>正文


C++ Font类代码示例

本文整理汇总了C++中Font的典型用法代码示例。如果您正苦于以下问题:C++ Font类的具体用法?C++ Font怎么用?C++ Font使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Font类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: init

    void init(unsigned w, unsigned h) {

        ResourceMap resource;
        resource.addPath("Fonts","");
        std::string fontPath = resource.getPath("Fonts")+"monaco11";
        font.load(fontPath.c_str());

        console.reserve(height/font.lineHeight());

        width=w;height=h;

        objs.clear();

        glMatrixMode (GL_PROJECTION);
        glLoadIdentity ();
        glFrustum (-1.0, 1.0, -1.0, 1.0, 1.5, 2000.0);
        
        glEnable(GL_DEPTH_TEST);
        glutIdleFunc (idle);
        glutDisplayFunc (draw);
        glutKeyboardFunc (keyboard);
               

        //adding here the mouse processing callbacks
        glutMotionFunc(processMouseActiveMotion);
        glutPassiveMotionFunc(processMousePassiveMotion);
        
        GLfloat mat_specular[] = { .5, .5, .5, 1.0 };
        GLfloat mat_shininess[] = { 5.0 };
        GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 };
        glClearColor (0.0, 0.0, 0.0, 0.0);
        glShadeModel (GL_SMOOTH);

        glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
        glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
        glLightfv(GL_LIGHT0, GL_POSITION, light_position);
        
        Color3 colors [] = {
            Color3(255,0,0),
            Color3(0,255,0),
            Color3(0,0,255),
            Color3(255,255,0),
            Color3(0,255,255),
            Color3(255,0,255),
            Color3(255,255,255),
        };
        
        int n = 1;
        

        for (unsigned i=0;i<n;i++) {
             size_t size;
//            size = objs.size();
//            objs.push_back(Object());
//            objs[size].p_ = DReal3(randnorm<dreal>(),randnorm<dreal>(),randnorm<dreal>());
//            initModel(objs[objs.size()-1], icosa_vertex, icosa_indices,icosa_vertex_size,icosa_indices_size, colors[(i+5)%7],(7./n));
            size = objs.size();
            objs.push_back(Object());
//            objs[size].p_ =0.8*DReal3(0.1+randnorm<dreal>(),0.1+randnorm<dreal>(),randnorm<dreal>());
            //objs[size].p_ =0.5*DReal3(randnorm<dreal>(),randnorm<dreal>(),randnorm<dreal>());
            objs[size].p_=Real3(0.5,0.,0.5)+0.1*Real3(randnorm<real>(),randnorm<real>(),randnorm<real>());
            initModel(objs[objs.size()-1], bunny_vertex, bunny_indices,bunny_vertex_size,bunny_indices_size, colors[(i)%7],5/*(1./n)*/);            
//            initModel(objs[objs.size()-1], bunnyh_vertex, bunnyh_indices,bunnyh_vertex_size,bunnyh_indices_size, colors[(i)%7],5/*(1./n)*/);
        }

        gettimeofday(&idleold, 0);        
        transformCoords();

        buildTree(objs,coltrees);
        colres.resize(coltrees.size());
        for (unsigned i=0;i<coltrees.size();i++) {
            coltrees[i]->collideWithSegment(seg[0], seg[1], colres[i]);
        }
    }
开发者ID:sutuglon,项目名称:Motor,代码行数:74,代码来源:testCollide.cpp

示例2: BidiStatus

float GraphicsContext::drawBidiText(const Font& font, const TextRun& run, const FloatPoint& point, Font::CustomFontNotReadyAction customFontNotReadyAction, BidiStatus* status, int length)
#endif
{
    if (paintingDisabled())
#if !PLATFORM(IOS)
        return;
#else
        return 0;
#endif

    BidiResolver<TextRunIterator, BidiCharacterRun> bidiResolver;
#if !PLATFORM(IOS)
    bidiResolver.setStatus(BidiStatus(run.direction(), run.directionalOverride()));
#else
    bidiResolver.setStatus(status ? *status : BidiStatus(run.direction(), run.directionalOverride()));
#endif
    bidiResolver.setPositionIgnoringNestedIsolates(TextRunIterator(&run, 0));

    // FIXME: This ownership should be reversed. We should pass BidiRunList
    // to BidiResolver in createBidiRunsForLine.
    BidiRunList<BidiCharacterRun>& bidiRuns = bidiResolver.runs();
#if !PLATFORM(IOS)
    bidiResolver.createBidiRunsForLine(TextRunIterator(&run, run.length()));
#else
    bidiResolver.createBidiRunsForLine(TextRunIterator(&run, length < 0 ? run.length() : length));
#endif
    if (!bidiRuns.runCount())
#if !PLATFORM(IOS)
        return;
#else
        return 0;
#endif

    FloatPoint currPoint = point;
    BidiCharacterRun* bidiRun = bidiRuns.firstRun();
    while (bidiRun) {
        TextRun subrun = run.subRun(bidiRun->start(), bidiRun->stop() - bidiRun->start());
        bool isRTL = bidiRun->level() % 2;
        subrun.setDirection(isRTL ? RTL : LTR);
        subrun.setDirectionalOverride(bidiRun->dirOverride(false));

#if !PLATFORM(IOS)
        font.drawText(this, subrun, currPoint, 0, -1, customFontNotReadyAction);

        bidiRun = bidiRun->next();
        // FIXME: Have Font::drawText return the width of what it drew so that we don't have to re-measure here.
        if (bidiRun)
            currPoint.move(font.width(subrun), 0);
#else
        float width = font.drawText(this, subrun, currPoint, 0, -1, customFontNotReadyAction);
        currPoint.move(width, 0);

        bidiRun = bidiRun->next();
#endif
    }

#if PLATFORM(IOS)
    if (status)
        *status = bidiResolver.status();
#endif
    bidiRuns.deleteRuns();

#if PLATFORM(IOS)
    return currPoint.x() - static_cast<float>(point.x());
#endif
}
开发者ID:Happy-Ferret,项目名称:webkit.js,代码行数:66,代码来源:GraphicsContext.cpp

示例3: menu

 void menu(RenderWindow &window)
 {
	 Texture menuText1, menuText2, menuText3, menuBackground;
	 menuBackground.loadFromFile("images/menu1.jpg");
	 menuText2.loadFromFile("images/cat.jpg");
	 Sprite menuLoad(menuText2);
	 Sprite menuBg(menuBackground);
	 bool isMenu = 1;
	 int menuNum = 0;
	 menuBg.setPosition(0,0);

	 Font font;
	 font.loadFromFile("Hamurz.ttf");
	 Text text("", font, 48);
	 Text text2("", font, 48);
	 Text text3("", font, 48);
	 text.setString("New Game");
	 text2.setString("Load");
	 text3.setString("Exit");
	 text.setPosition(500,410);
	 text2.setPosition(550,488);
	 text3.setPosition(550,564);


	 while(isMenu)
	 {
		text.setColor(Color(254,150,121));
		text2.setColor(Color(254,150,121));
		text3.setColor(Color(254,150,121));
		menuNum = 0;

		 window.clear(Color(129,181,221));
		 if(IntRect(500,410,200,60).contains(Mouse::getPosition(window)))
		 {
			 text.setColor(Color(98,198,223));
			 menuNum = 1;
		 }
		 if(IntRect(550,488,200,60).contains(Mouse::getPosition(window)))
		 {
			 text2.setColor(Color(98,198,223));
			 menuNum = 2;
		 }
		 if(IntRect(500,564,200,60).contains(Mouse::getPosition(window)))
		 {
			 text3.setColor(Color(98,198,223));
			 menuNum = 3;
		 }
			
			 
		if(Mouse::isButtonPressed(Mouse::Left))
		{
			if(menuNum == 2)
			{
				window.draw(menuLoad);
				window.display();
				while(!Keyboard::isKeyPressed(Keyboard::Escape))
				{;}
			}
			if(menuNum == 3)
			{
				window.close();
				isMenu = false;
			}
		}
		 window.draw(menuBg);
		 window.draw(text);
		 window.draw(text2);
		 window.draw(text3);
		 window.display();
	 }
 }
开发者ID:DariaDar,项目名称:Reposit,代码行数:71,代码来源:Menu.cpp

示例4: ASSERT

GlyphData SVGTextRunRenderingContext::glyphDataForCharacter(const Font& font, WidthIterator& iterator, UChar32 character, bool mirror, int currentCharacter, unsigned& advanceLength)
{
    const SimpleFontData* primaryFont = font.primaryFont();
    ASSERT(primaryFont);

    pair<GlyphData, GlyphPage*> pair = font.glyphDataAndPageForCharacter(character, mirror, AutoVariant);
    GlyphData glyphData = pair.first;

    // Check if we have the missing glyph data, in which case we can just return.
    GlyphData missingGlyphData = primaryFont->missingGlyphData();
    if (glyphData.glyph == missingGlyphData.glyph && glyphData.fontData == missingGlyphData.fontData) {
        ASSERT(glyphData.fontData);
        return glyphData;
    }

    // Save data fromt he font fallback list because we may modify it later. Do this before the
    // potential change to glyphData.fontData below.
    FontGlyphs* glyph = font.glyphs();
    ASSERT(glyph);
    FontGlyphs::GlyphPagesStateSaver glyphPagesSaver(*glyph);

    // Characters enclosed by an <altGlyph> element, may not be registered in the GlyphPage.
    const SimpleFontData* originalFontData = glyphData.fontData;
    if (glyphData.fontData && !glyphData.fontData->isSVGFont()) {
        auto& elementRenderer = renderer().isRenderElement() ? toRenderElement(renderer()) : *renderer().parent();
        if (Element* parentRendererElement = elementRenderer.element()) {
            if (parentRendererElement->hasTagName(SVGNames::altGlyphTag))
                glyphData.fontData = primaryFont;
        }
    }

    const SimpleFontData* fontData = glyphData.fontData;
    if (fontData) {
        if (!fontData->isSVGFont())
            return glyphData;

        SVGFontElement* fontElement = 0;
        SVGFontFaceElement* fontFaceElement = 0;

        const SVGFontData* svgFontData = svgFontAndFontFaceElementForFontData(fontData, fontFaceElement, fontElement);
        if (!fontElement || !fontFaceElement)
            return glyphData;

        // If we got here, we're dealing with a glyph defined in a SVG Font.
        // The returned glyph by glyphDataAndPageForCharacter() is a glyph stored in the SVG Font glyph table.
        // This doesn't necessarily mean the glyph is suitable for rendering/measuring in this context, its
        // arabic-form/orientation/... may not match, we have to apply SVG Glyph selection to discover that.
        if (svgFontData->applySVGGlyphSelection(iterator, glyphData, mirror, currentCharacter, advanceLength))
            return glyphData;
    }

    GlyphPage* page = pair.second;
    ASSERT(page);

    // No suitable glyph found that is compatible with the requirments (same language, arabic-form, orientation etc.)
    // Even though our GlyphPage contains an entry for eg. glyph "a", it's not compatible. So we have to temporarily
    // remove the glyph data information from the GlyphPage, and retry the lookup, which handles font fallbacks correctly.
    page->setGlyphDataForCharacter(character, 0, 0);

    // Assure that the font fallback glyph selection worked, aka. the fallbackGlyphData font data is not the same as before.
    GlyphData fallbackGlyphData = font.glyphDataForCharacter(character, mirror);
    ASSERT(fallbackGlyphData.fontData != fontData);

    // Restore original state of the SVG Font glyph table and the current font fallback list,
    // to assure the next lookup of the same glyph won't immediately return the fallback glyph.
    page->setGlyphDataForCharacter(character, glyphData.glyph, originalFontData);
    ASSERT(fallbackGlyphData.fontData);
    return fallbackGlyphData;
}
开发者ID:,项目名称:,代码行数:69,代码来源:

示例5: generateComponents

static int generateComponents(TextRunComponents* components, const Font &font, const TextRun &run)
{
    int letterSpacing = font.letterSpacing();
    int wordSpacing = font.wordSpacing();
    int padding = run.padding();
    int numSpaces = 0;
    if (padding) {
        for (int i = 0; i < run.length(); i++)
            if (Font::treatAsSpace(run[i]))
                ++numSpaces;
    }

    int offset = 0;
    if (letterSpacing) {
        // need to draw every letter on it's own
        int start = 0;
        if (Font::treatAsSpace(run[0])) {
            int add = 0;
            if (numSpaces) {
                add = padding/numSpaces;
                padding -= add;
                --numSpaces;
            }
            components->append(TextRunComponent(1, font, offset));
            offset += add + letterSpacing + components->last().m_width;
            start = 1;
        }
        for (int i = 1; i < run.length(); ++i) {
            uint ch = run[i];
            if (isHighSurrogate(ch) && isLowSurrogate(run[i-1]))
                ch = surrogateToUcs4(ch, run[i-1]);
            if (isLowSurrogate(ch) || category(ch) == Mark_NonSpacing)
                continue;
            if (Font::treatAsSpace(run[i])) {
                int add = 0;
                if (i - start > 0) {
                    components->append(TextRunComponent(run.characters() + start, i - start,
                                                        run, font, offset));
                    offset += components->last().m_width + letterSpacing;
                }
                if (numSpaces) {
                    add = padding/numSpaces;
                    padding -= add;
                    --numSpaces;
                }
                components->append(TextRunComponent(1, font, offset));
                offset += wordSpacing + add + components->last().m_width + letterSpacing;
                start = i + 1;
                continue;
            }
            if (i - start > 0) {
                components->append(TextRunComponent(run.characters() + start, i - start,
                                                    run,
                                                    font, offset));
                offset += components->last().m_width + letterSpacing;
            }
            start = i;
        }
        if (run.length() - start > 0) {
            components->append(TextRunComponent(run.characters() + start, run.length() - start,
                                                run,
                                                font, offset));
            offset += components->last().m_width;
        }
        offset += letterSpacing;
    } else {
        int start = 0;
        for (int i = 0; i < run.length(); ++i) {
            if (Font::treatAsSpace(run[i])) {
                if (i - start > 0) {
                    components->append(TextRunComponent(run.characters() + start, i - start,
                                                        run,
                                                        font, offset));
                    offset += components->last().m_width;
                }
                int add = 0;
                if (numSpaces) {
                    add = padding/numSpaces;
                    padding -= add;
                    --numSpaces;
                }
                components->append(TextRunComponent(1, font, offset));
                offset += add + components->last().m_width;
                if (i)
                    offset += wordSpacing;
                start = i + 1;
            }
        }
        if (run.length() - start > 0) {
            components->append(TextRunComponent(run.characters() + start, run.length() - start,
                                                run,
                                                font, offset));
            offset += components->last().m_width;
        }
    }
    return offset;
}
开发者ID:dslab-epfl,项目名称:warr,代码行数:97,代码来源:FontWinCE.cpp

示例6: thicknessForDecoration

static inline float thicknessForDecoration(TextDecoration, const Font& font)
{
    // FIXME: For SVG Fonts we need to use the attributes defined in the <font-face> if specified.
    // Compatible with Batik/Opera
    return font.size() / 20.0f;
}
开发者ID:,项目名称:,代码行数:6,代码来源:

示例7: glClear

bool Application::RenderScene()
{
	GT.NewFrame();
	glClear(GL_DEPTH_BUFFER_BIT);   // Очистка буфера глубины
	Cam.Look();
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//	РИСОВАНИЕ 
	glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);

	rm.SELECT_Mesh("someMesh")->Render();
	glTranslated(0,0,-2);
	//rm.SELECT_Mesh("someMesh")->Render();
	glTranslated(0,0,-2);
	//rm.SELECT_Mesh("someMesh")->Render();
	//rm.SELECT_Mesh(0)->Render();

	//PS.DRAW();


/////////////////////////////////////////////////////////////////////////////////////////////////////////////
//	Рисование осей координат :)
	//	Ось X
	glPushAttrib(GL_DEPTH_BUFFER_BIT|GL_ENABLE_BIT|GL_CURRENT_BIT);		// Сохранение настроек
	glDisable(GL_DEPTH_TEST);
	glPushMatrix();
	glScaled(0.2,0.2,0.2);
	glDisable(GL_TEXTURE_2D);
	glDisable(GL_LIGHTING);
	glLineWidth(4.0);
	glColor3d(0.0,1.0,0.0);
	glBegin(GL_LINES);
	{
		glVertex3d( 0.00, 0.00,  0.00);
		glVertex3d( 4.00, 0.00,  0.00);
		glVertex3d( 4.00, 0.00,  0.00);
		glVertex3d( 3.50, 0.00,  0.25);
		glVertex3d( 3.50, 0.00, -0.25);
		glVertex3d( 4.00, 0.00,  0.00);
		glVertex3d( 4.00, 0.00,  0.00);
		glVertex3d( 3.50, 0.25,  0.00);
		glVertex3d( 3.50,-0.25,  0.00);
		glVertex3d( 4.00, 0.00,  0.00);
	}
	glEnd();
	// Ось Y
	glColor3d(0.0,0.0,1.0);
	glBegin(GL_LINES);
	{
		glVertex3d( 0.00, 0.00, 0.00);
		glVertex3d( 0.00, 4.00, 0.00);
		glVertex3d( 0.00, 4.00, 0.00);
		glVertex3d( 0.00, 3.50, 0.25);
		glVertex3d( 0.00, 3.50,-0.25);
		glVertex3d( 0.00, 4.00, 0.00);
		glVertex3d( 0.00, 4.00, 0.00);
		glVertex3d( 0.25, 3.50, 0.00);
		glVertex3d(-0.25, 3.50, 0.00);
		glVertex3d( 0.00, 4.00, 0.00);
	}
	glEnd();
	glColor3d(1.0,0.0,0.0);
	glBegin(GL_LINES);
	{
		glVertex3d( 0.00, 0.00, 0.00);
		glVertex3d( 0.00, 0.00, 4.00);
		glVertex3d( 0.00, 0.00, 4.00);
		glVertex3d( 0.00, 0.25, 3.50);
		glVertex3d( 0.00,-0.25, 3.50);
		glVertex3d( 0.00, 0.00, 4.00);
		glVertex3d( 0.00, 0.00, 4.00);
		glVertex3d( 0.25, 0.00, 3.50);
		glVertex3d(-0.25, 0.00, 3.50);
		glVertex3d( 0.00, 0.00, 4.00);
	}
	glEnd();
	glPopMatrix();
	glPopAttrib();
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
//	ТЕКСТ
	// TODO: удалить енто после полной отладки текста

	if (TextBenchmark)
	{
		Font * Cour = rm.SELECT_Font("Courier");
		rm.SELECT_Font("Console")->SetStyle(Text::left,Text::top,1.0);
		rm.SELECT_Font("Console")->SetColor(0.0f,0.0f,0.0f,1.0f);
		for (int i = 0 ; i < 40 ; i++ )
		{
			for (int j = 0 ; j < 8 ; j++ )
			{
				Cour->Print((j)/8.0,i/40.0,"FPS:%4.1f",GT.GetFPS());
			}
		}
	} else
	{
		if (Globals.EFl.show_stat)
		{
			PFont uif = rm.SELECT_Font("Console");
			uif->SetStyle(Text::left,Text::top,1.0);
			uif->SetColor(0.0f,0.0f,0.0f,1.0f);
//.........这里部分代码省略.........
开发者ID:firej,项目名称:OGL2,代码行数:101,代码来源:RenderScene.cpp

示例8: latexWriteEndChanges

/// Writes ending block of LaTeX needed to close use of this font
// Returns number of chars written
// This one corresponds to latexWriteStartChanges(). (Asger)
int Font::latexWriteEndChanges(otexstream & os, BufferParams const & bparams,
				  OutputParams const & runparams,
				  Font const & base,
				  Font const & next,
				  bool const & closeLanguage) const
{
	int count = 0;
	bool env = false;

	// reduce the current font to changes against the base
	// font (of the layout). We use a temporary for this to
	// avoid changing this font instance, as that would break
	FontInfo f = bits_;
	f.reduce(base.bits_);

	if (f.family() != INHERIT_FAMILY) {
		os << '}';
		++count;
		env = true; // Size change need not bother about closing env.
	}
	if (f.series() != INHERIT_SERIES) {
		os << '}';
		++count;
		env = true; // Size change need not bother about closing env.
	}
	if (f.shape() != INHERIT_SHAPE) {
		os << '}';
		++count;
		env = true; // Size change need not bother about closing env.
	}
	if (f.color() != Color_inherit && f.color() != Color_ignore) {
		os << '}';
		++count;
		env = true; // Size change need not bother about closing env.
	}
	if (f.emph() == FONT_ON) {
		os << '}';
		++count;
		env = true; // Size change need not bother about closing env.
	}
	if (f.underbar() == FONT_ON) {
		os << '}';
		++count;
		runparams.inulemcmd = false;
		env = true; // Size change need not bother about closing env.
	}
	if (f.strikeout() == FONT_ON) {
		os << '}';
		++count;
		runparams.inulemcmd = false;
		env = true; // Size change need not bother about closing env.
	}
	if (f.uuline() == FONT_ON) {
		os << '}';
		++count;
		runparams.inulemcmd = false;
		env = true; // Size change need not bother about closing env.
	}
	if (f.uwave() == FONT_ON) {
		os << '}';
		++count;
		runparams.inulemcmd = false;
		env = true; // Size change need not bother about closing env.
	}
	if (f.noun() == FONT_ON) {
		os << '}';
		++count;
		env = true; // Size change need not bother about closing env.
	}
	if (f.size() != FONT_SIZE_INHERIT) {
		// We only have to close if only size changed
		if (!env) {
			os << '}';
			++count;
		}
		os << '}';
		++count;
	}

	// When the current language is Hebrew, Arabic, or Farsi
	// the numbers are written Left-to-Right. ArabTeX package
	// reorders the number automatically but the packages used
	// for Hebrew and Farsi (Arabi) do not.
	if (bits_.number() == FONT_ON && next.fontInfo().number() != FONT_ON
		&& (language()->lang() == "hebrew"
			|| language()->lang() == "farsi"
			|| language()->lang() == "arabic_arabi")) {
		os << "\\endL}";
		count += 6;
	}

	if (open_encoding_) {
		// We need to close the encoding even if it does not change
		// to do correct environment nesting
		Encoding const * const ascii = encodings.fromLyXName("ascii");
		pair<bool, int> const c = switchEncoding(os.os(), bparams,
				runparams, *ascii);
//.........这里部分代码省略.........
开发者ID:JoaquimBellmunt,项目名称:lyx,代码行数:101,代码来源:Font.cpp

示例9: adoptPtr

void FullscreenVideoController::draw()
{
    OwnPtr<HDC> bitmapDC = adoptPtr(CreateCompatibleDC(HWndDC(m_hudWindow)));
    HGDIOBJ oldBitmap = SelectObject(bitmapDC.get(), m_bitmap.get());

    GraphicsContext context(bitmapDC.get(), true);

    context.save();

    // Draw the background
    IntSize outerRadius(borderRadius, borderRadius);
    IntRect outerRect(0, 0, windowWidth, windowHeight);
    IntSize innerRadius(borderRadius - borderThickness, borderRadius - borderThickness);
    IntRect innerRect(borderThickness, borderThickness, windowWidth - borderThickness * 2, windowHeight - borderThickness * 2);

    context.fillRoundedRect(outerRect, outerRadius, outerRadius, outerRadius, outerRadius, Color(borderColor), ColorSpaceDeviceRGB);
    context.setCompositeOperation(CompositeCopy);
    context.fillRoundedRect(innerRect, innerRadius, innerRadius, innerRadius, innerRadius, Color(backgroundColor), ColorSpaceDeviceRGB);

    // Draw the widgets
    m_playPauseButton.draw(context);
    m_volumeUpButton.draw(context);
    m_volumeSliderButton.draw(context);
    m_volumeDownButton.draw(context);
    m_timeSliderButton.draw(context);
    m_exitFullscreenButton.draw(context);
    m_volumeSlider.draw(context);
    m_timeSlider.draw(context);

    // Draw the text strings
    FontDescription desc;

    NONCLIENTMETRICS metrics;
    metrics.cbSize = sizeof(metrics);
    SystemParametersInfo(SPI_GETNONCLIENTMETRICS, metrics.cbSize, &metrics, 0);
    FontFamily family;
    family.setFamily(metrics.lfSmCaptionFont.lfFaceName);
    desc.setFamily(family);

    desc.setComputedSize(textSize);
    Font font = Font(desc, 0, 0);
    font.update(0);

    String s;

    // The y positioning of these two text strings is tricky because they are so small. They
    // are currently positioned relative to the center of the slider and then down the font
    // height / 4 (which is actually half of font height /2), which positions the center of
    // the text at the center of the slider.
    // Left string
    s = timeToString(currentTime());
    int fontHeight = font.fontMetrics().height();
    TextRun leftText(s);
    context.setFillColor(Color(textColor), ColorSpaceDeviceRGB);
    context.drawText(font, leftText, IntPoint(windowWidth / 2 - timeSliderWidth / 2 - margin - font.width(leftText), windowHeight - margin - sliderHeight / 2 + fontHeight / 4));

    // Right string
    s = timeToString(currentTime() - duration());
    TextRun rightText(s);
    context.setFillColor(Color(textColor), ColorSpaceDeviceRGB);
    context.drawText(font, rightText, IntPoint(windowWidth / 2 + timeSliderWidth / 2 + margin, windowHeight - margin - sliderHeight / 2 + fontHeight / 4));

    // Copy to the window
    BLENDFUNCTION blendFunction = {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA};
    SIZE size = { windowWidth, windowHeight };
    POINT sourcePoint = {0, 0};
    POINT destPoint = { m_hudPosition.x(), m_hudPosition.y() };
    BOOL result = UpdateLayeredWindow(m_hudWindow, 0, &destPoint, &size, bitmapDC.get(), &sourcePoint, 0, &blendFunction, ULW_ALPHA);

    context.restore();

    ::SelectObject(bitmapDC.get(), oldBitmap);
}
开发者ID:,项目名称:,代码行数:73,代码来源:

示例10: switch

/// Writes the changes from this font to orgfont in .lyx format in file
void Font::lyxWriteChanges(Font const & orgfont,
			      ostream & os) const
{
	os << "\n";
	if (orgfont.fontInfo().family() != bits_.family())
		os << "\\family " << LyXFamilyNames[bits_.family()] << "\n";
	if (orgfont.fontInfo().series() != bits_.series())
		os << "\\series " << LyXSeriesNames[bits_.series()] << "\n";
	if (orgfont.fontInfo().shape() != bits_.shape())
		os << "\\shape " << LyXShapeNames[bits_.shape()] << "\n";
	if (orgfont.fontInfo().size() != bits_.size())
		os << "\\size " << LyXSizeNames[bits_.size()] << "\n";
	if (orgfont.fontInfo().emph() != bits_.emph())
		os << "\\emph " << LyXMiscNames[bits_.emph()] << "\n";
	if (orgfont.fontInfo().number() != bits_.number())
		os << "\\numeric " << LyXMiscNames[bits_.number()] << "\n";
	if (orgfont.fontInfo().underbar() != bits_.underbar()) {
		// This is only for backwards compatibility
		switch (bits_.underbar()) {
		case FONT_OFF:	os << "\\bar no\n"; break;
		case FONT_ON:        os << "\\bar under\n"; break;
		case FONT_TOGGLE:	lyxerr << "Font::lyxWriteFontChanges: "
					"FONT_TOGGLE should not appear here!"
				       << endl;
		break;
		case FONT_INHERIT:   os << "\\bar default\n"; break;
		case FONT_IGNORE:    lyxerr << "Font::lyxWriteFontChanges: "
					"IGNORE should not appear here!"
				       << endl;
		break;
		}
	}
	if (orgfont.fontInfo().strikeout() != bits_.strikeout()) {
		os << "\\strikeout " << LyXMiscNames[bits_.strikeout()] << "\n";
	}
	if (orgfont.fontInfo().uuline() != bits_.uuline()) {
		os << "\\uuline " << LyXMiscNames[bits_.uuline()] << "\n";
	}
	if (orgfont.fontInfo().uwave() != bits_.uwave()) {
		os << "\\uwave " << LyXMiscNames[bits_.uwave()] << "\n";
	}
	if (orgfont.fontInfo().noun() != bits_.noun()) {
		os << "\\noun " << LyXMiscNames[bits_.noun()] << "\n";
	}
	if (orgfont.fontInfo().color() != bits_.color())
		os << "\\color " << lcolor.getLyXName(bits_.color()) << '\n';
	// FIXME: uncomment this when we support background.
	//if (orgfont.fontInfo().background() != bits_.background())
	//	os << "\\color " << lcolor.getLyXName(bits_.background()) << '\n';
	if (orgfont.language() != language() &&
	    language() != latex_language) {
		if (language())
			os << "\\lang " << language()->lang() << "\n";
		else
			os << "\\lang unknown\n";
	}
}
开发者ID:JoaquimBellmunt,项目名称:lyx,代码行数:58,代码来源:Font.cpp

示例11: language

/// Writes the head of the LaTeX needed to impose this font
// Returns number of chars written.
int Font::latexWriteStartChanges(odocstream & os, BufferParams const & bparams,
				    OutputParams const & runparams,
				    Font const & base,
				    Font const & prev) const
{
	bool env = false;

	int count = 0;

	// polyglossia or babel?
	if (runparams.use_polyglossia
	    && language()->lang() != base.language()->lang()
	    && language() != prev.language()) {
		if (!language()->polyglossia().empty()) {
			string tmp = "\\text" + language()->polyglossia();
			if (!language()->polyglossiaOpts().empty())
				tmp += "[" + language()->polyglossiaOpts() + "]";
			tmp += "{";
			os << from_ascii(tmp);
			count += tmp.length();
		}
	} else if (language()->babel() != base.language()->babel() &&
	    language() != prev.language()) {
		if (language()->lang() == "farsi") {
			os << "\\textFR{";
			count += 8;
		} else if (!isRightToLeft() &&
			    base.language()->lang() == "farsi") {
			os << "\\textLR{";
			count += 8;
		} else if (language()->lang() == "arabic_arabi") {
			os << "\\textAR{";
			count += 8;
 		} else if (!isRightToLeft() &&
				base.language()->lang() == "arabic_arabi") {
			os << "\\textLR{";
			count += 8;
		// currently the remaining RTL languages are arabic_arabtex and hebrew
		} else if (isRightToLeft() != prev.isRightToLeft()) {
			if (isRightToLeft()) {
				os << "\\R{";
				count += 3;
			} else {
				os << "\\L{";
				count += 3;
			}
		} else if (!language()->babel().empty()) {
			string const tmp =
				subst(lyxrc.language_command_local,
				      "$$lang", language()->babel());
			os << from_ascii(tmp);
			count += tmp.length();
		} else {
			os << '{';
			count += 1;
		}
	}

	if (language()->encoding()->package() == Encoding::CJK) {
		pair<bool, int> const c = switchEncoding(os, bparams,
				runparams, *(language()->encoding()));
		if (c.first) {
			open_encoding_ = true;
			count += c.second;
			runparams.encoding = language()->encoding();
		}
	}

	// If the current language is Hebrew, Arabic, or Farsi
	// the numbers are written Left-to-Right. ArabTeX package
	// reorders the number automatically but the packages used
	// for Hebrew and Farsi (Arabi) do not.
	if (bits_.number() == FONT_ON && prev.fontInfo().number() != FONT_ON
		&& (language()->lang() == "hebrew"
			|| language()->lang() == "farsi" 
			|| language()->lang() == "arabic_arabi")) {
		os << "{\\beginL ";
		count += 9;
	}

	FontInfo f = bits_;
	f.reduce(base.bits_);

	if (f.family() != INHERIT_FAMILY) {
		os << '\\'
		   << LaTeXFamilyNames[f.family()]
		   << '{';
		count += strlen(LaTeXFamilyNames[f.family()]) + 2;
		env = true; //We have opened a new environment
	}
	if (f.series() != INHERIT_SERIES) {
		os << '\\'
		   << LaTeXSeriesNames[f.series()]
		   << '{';
		count += strlen(LaTeXSeriesNames[f.series()]) + 2;
		env = true; //We have opened a new environment
	}
	if (f.shape() != INHERIT_SHAPE) {
//.........这里部分代码省略.........
开发者ID:JoaquimBellmunt,项目名称:lyx,代码行数:101,代码来源:Font.cpp

示例12: main

int main()
{
    RenderWindow window(VideoMode(500, 500), "Tetris");
    srand(time(NULL));
    if(!cube.loadFromFile("cube.png"))
        return EXIT_FAILURE;
    if(!frame.loadFromFile("frame.png"))
        return EXIT_FAILURE;

    s_frame.setTexture(frame);
    init_cube();
    generate_cube(getrand());

    bool pause = false;
    bool over = false;
    while (window.isOpen())
    {
        int condition = check(over);
        if(!pause && !over){
            if(cube_clock.getElapsedTime().asSeconds() > 0.9f)
            {
                if(condition == 0){
                    drop();

                    cout<< "sstart: " << start.first << " " << start.second << endl;
                    for(int i=0; i<4; i++)
                        printf("cube:%d %d \n",current[i].first,current[i].second);
                    for(int i=3 ; i<=22; i++){
                        for(int j=0; j<10; j++){
                            // if(data[j][i] == -1)
                            //     printf("%d",random);
                            // else
                            printf("%d",data[j][i]);
                        }
                        printf("\n");
                    }
                    puts("===========");
                    cube_clock.restart();
                }
                else if(condition == 1){
                    end_line();
                }
            }
        }
        //Get Event。
        Event event;
        while (window.pollEvent(event))
        {
            if (event.type == Event::Closed)
                window.close();
                if(event.type == Event::KeyPressed)
                {
                    if(Keyboard::isKeyPressed(Keyboard::Left)){
                        operate_cube(LEFT);
                    }
                    else if(Keyboard::isKeyPressed(Keyboard::Right)){
                        operate_cube(RIGHT);
                    }
                    else if(Keyboard::isKeyPressed(Keyboard::Up)){
                        if(random != 3)
                            operate_cube(RR);
                    }
                    else if(Keyboard::isKeyPressed(Keyboard::Down)){
                        if(condition == 0)
                        drop();
                    }
                    else if(Keyboard::isKeyPressed(Keyboard::Space)){
                        movebase();
                        end_line();
                    }
                    else if(Keyboard::isKeyPressed(Keyboard::C)){
                        printf("%d\n",holden);
                        if(!holden){
                            makehold();
                            holden = true;
                        }
                    }
                    if(Keyboard::isKeyPressed(Keyboard::P))
                    pause = !pause;
                }
        }
        update_cube();
        Font font;
        if (!font.loadFromFile("brightfuture.ttf"))
            return EXIT_FAILURE;

        score[0] = Text("Line:",font, 40);
        score[0].setPosition(20,350);
        score[0].setColor(Color(255,88,0,255));
        stringstream ss;
        ss << line;
        string convert_str;
        ss >> convert_str;
        score[1] = Text(convert_str,font, 40);
        score[1].setPosition(40,385);
        score[1].setColor(Color(255,88,0,255));
        showNext();
        window.clear();
        window.draw(s_frame);
        for(int i=0; i<8; i++)
//.........这里部分代码省略.........
开发者ID:abcd40404,项目名称:tetris,代码行数:101,代码来源:main.cpp

示例13: Uninitialize

	void Graphics::Uninitialize()
	{
		if (s_moduleReferenceCounter != 1)
		{
			// The module is still in use, or can not be uninitialized
			if (s_moduleReferenceCounter > 1)
				s_moduleReferenceCounter--;

			return;
		}

		// Free of module
		s_moduleReferenceCounter = 0;

		// Free of atlas if it is ours
		std::shared_ptr<AbstractAtlas> defaultAtlas = Font::GetDefaultAtlas();
		if (defaultAtlas && defaultAtlas->GetStorage() == DataStorage_Hardware)
		{
			Font::SetDefaultAtlas(nullptr);

			// The default police can make live one hardware atlas after the free of a module (which could be problematic)
			// So, if the default police use a hardware atlas, we stole it.
			// I don't like this solution, but I don't have any better
			if (!defaultAtlas.unique())
			{
				// Still at least one police use the atlas
				Font* defaultFont = Font::GetDefault();
				defaultFont->SetAtlas(nullptr);

				if (!defaultAtlas.unique())
				{
					// Still not the only one to own it ? Then crap.
					NazaraWarning("Default font atlas uses hardware storage and is still used");
				}
			}
		}

		defaultAtlas.reset();

		// Textures
		TextureLibrary::Unregister("White2D");
		TextureLibrary::Unregister("WhiteCubemap");

		// Loaders
		Loaders::UnregisterMesh();
		Loaders::UnregisterTexture();

		// Renderables
		ParticleRenderer::Uninitialize();
		ParticleGenerator::Uninitialize();
		ParticleDeclaration::Uninitialize();
		ParticleController::Uninitialize();
		SkyboxBackground::Uninitialize();
		Sprite::Uninitialize();
		TileMap::Uninitialize();

		// Render techniques
		DeferredRenderTechnique::Uninitialize();
		DepthRenderTechnique::Uninitialize();
		ForwardRenderTechnique::Uninitialize();
		SkinningManager::Uninitialize();

		// Materials
		Material::Uninitialize();
		MaterialPipeline::Uninitialize();

		NazaraNotice("Uninitialized: Graphics module");

		// Free of dependances
		Renderer::Uninitialize();
	}
开发者ID:DigitalPulseSoftware,项目名称:NazaraEngine,代码行数:71,代码来源:Graphics.cpp

示例14: Vec3f

namespace Collide {

    std::vector<string> console;

    int width,height;
    Font font;

    std::vector<Object> objs;
    std::vector<AABBTreePoly*> coltrees;
    
    Vec3f seg[2] = { Vec3f(0,0,0) , Vec3f(1,1,1) };
    std::vector<ozcollide::AABBTreePoly::SegmentColResult> colres; 

    int rotateX=0;
    int rotateY=0;
    dreal rotModelX = 0;
    dreal level = 0.1;
    dreal offY= 0;
    dreal scale=1.;
    bool multiple = true;
    Int2 deltaMousePos;
    Int2 oldMousePos;
    bool showGeom = true;
    bool showWire = true;
    bool showNormals = false;


    struct timeval start, end, idleold, idlenew;
    float lapse;
    float average0,average1,average2;

    void initModel(Object& obj, float data[][3], unsigned indices[][3], unsigned vsize, unsigned fsize, 
                   const Color3& color,real scale) {
        obj.colors_.reserve(vsize);
        for (unsigned i=0;i<vsize;i++) {
            obj.colors_.push_back(color);
        }
        obj.tvx_.resize(vsize);
        obj.vx_.reserve(vsize);
        for (unsigned i=0;i<vsize;i++) {
            obj.vx_.push_back(scale*Real3(data[i][0],data[i][1],data[i][2]));
        }
        
        obj.faces_.reserve(fsize);
        for (unsigned i=0;i<fsize;++i) {
            obj.faces_.push_back(Int3(indices[i][0],indices[i][1],indices[i][2]));
        }
        obj.tnormals_.resize(vsize);
        obj.normals_.reserve(vsize);
        for (unsigned i = 0; i < vsize; i++) {
            obj.normals_[i]+=Real3(0.);
        }
        for (unsigned i = 0; i < fsize; i++) {
            unsigned ia=indices[i][0];
            unsigned ib=indices[i][1];
            unsigned ic=indices[i][2];
            
            Real3 a = obj.vx_[ia];
            Real3 b = obj.vx_[ib];
            Real3 c = obj.vx_[ic];
            Real3 n = normalize( crossProd( b-a, c-a) );
            
            obj.normals_[ia]+=n;
            obj.normals_[ib]+=n;
            obj.normals_[ic]+=n;
        }
        for (unsigned i = 0; i < vsize; i++) {
            obj.normals_[i]=normalize( obj.normals_[i] );
        }
    }


    void transformCoords() {

        //rotModelX += lapse*0.001;
        for (unsigned i=0;i<objs.size();++i) {
            objs[i].rot_ = Rotation(rotModelX, Real3(0,1,0));
        }

        for (unsigned i=0;i<objs.size();++i) {
            Matrix4 rmx = objs[i].rot_;
            SetTranslation(rmx,objs[i].p_+Real3(0,offY,0));
        
            for (unsigned j=0;j<objs[i].vx_.size();++j) {
                objs[i].tvx_[j] =Matrix4Affine (rmx, objs[i].vx_[j]);
                objs[i].tnormals_[j] = Matrix4Rotate(rmx,objs[i].normals_[j]);
            }
        }
    }

    void buildTree(const std::vector<Object>& objs, std::vector<AABBTreePoly*>& coltrees) {
        AABBTreePolyBuilder builder;
        for (unsigned i=0;i<objs.size();i++) {
            std::vector<Polygon> polys;
            polys.resize(objs[i].faces_.size());
            for (unsigned j=0;j<objs[i].faces_.size();j++) {
                polys[j].setIndicesMemory(3, const_cast<int*> (&objs[i].faces_[j][0]));
            }
            
            AABBTreePoly* coltree = builder.buildFromPolys( &polys[0],
//.........这里部分代码省略.........
开发者ID:sutuglon,项目名称:Motor,代码行数:101,代码来源:testCollide.cpp

示例15: tokenizer

TextParser::TextParser(const std::wstring &text, Font &font, int x, int y,
    int width, int height): tokenizer(text), font(font),
    spaceWidth(font.getWidth(L' ')), charHeight(font.getWidth(L'A')),
    offsetX(x), offsetY(y), pageWidth(width), pageHeight(height) {}
开发者ID:Oppen,项目名称:einstein,代码行数:4,代码来源:descr.cpp


注:本文中的Font类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。