Example #1
0
void TexFont::RenderString( const char *string, int x, int y )
{
    glPushMatrix();
    glTranslatef(x, y, 0);

    glPushMatrix();
    glBindTexture( GL_TEXTURE_2D, texobj);

    for( int i = 0; string[i]; i++ ) {
        if(string[i] == '\n') {
            glPopMatrix();
            glTranslatef(0, tgi[(int)'A'].height, 0);
            glPushMatrix();
            continue;
        }
        /* degree symbol */
        if((unsigned char)string[i] == 0xc2 &&
           (unsigned char)string[i+1] == 0xb0) {
            RenderGlyph( DEGREE_GLYPH );
            i++;
            continue;
        }
        RenderGlyph( string[i] );
    }

    glPopMatrix();
    glPopMatrix();
}
Example #2
0
static void
RenderGlyph(uint8_t *buffer, size_t width, size_t height,
            FT_GlyphSlot glyph, int x, int y)
{

  if (IsMono()) {
    /* with anti-aliasing disabled, FreeType writes each pixel in one
       bit; hack: convert it to 1 byte per pixel and then render it */
    FT_Bitmap bitmap;
    ConvertMono(bitmap, glyph->bitmap);
    RenderGlyph(buffer, width, height, bitmap, x, y);
    delete[] bitmap.buffer;
  } else
    RenderGlyph(buffer, width, height, glyph->bitmap, x, y);
}
Example #3
0
// メッセージを表示
void RenderString(int x, int y, const char* message) {

    glPushMatrix();

    glLoadIdentity();

    // 既存の表示物と混合して表示
    glEnable(GL_BLEND);
    glBindTexture(GL_TEXTURE_2D, texName[0]);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    // 色指定
    glColor4f(1, 1, 1, 1);

    // messageにある文字列を表示
    const char* digit;
    for (digit = &message[0]; *digit; ++digit) {
        const glyph* glyphdat = &glyphlist[digit[0]];

        // スペースは表示しない
        if (digit[0] == ' ') {
            x += glyphdat->x_advance;
            continue;
        }

        // 登録のある文字は表示
        if (glyphdat->width != 0) {
            RenderGlyph(glyphdat, x, y);
            x += glyphdat->x_advance;
        }
    }
    glDisable(GL_BLEND);

    glPopMatrix();
}
Example #4
0
void SDraw::DrawTextOp(int x, int y, int angle, const wchar *text, Font font, Color ink, int n, const int *dx)
{
	sMakeTextGlyph g;
	g.font = font;
	g.color = White();
	g.angle = angle;
	g.draw = this;
	for(int i = 0; i < n; i++) {
		g.chr = text[i];
		LTIMING("Paint glyph");
		if(font.GetHeight() > 200) {
			Point at(font[g.chr], font.GetLineHeight());
			int n = at.x + at.y;
			Size bandsz(2 * n, 32);
			for(int yy = 0; yy < n; yy += bandsz.cy) {
				Image m = RenderGlyph(Point(0, -yy), angle, g.chr, font, White(), bandsz);
				SysDrawImageOp(x, y + yy, m, m.GetSize(), ink);
			}
		}
		else {
			Image m = MakeImage(g);
			Point h = m.GetHotSpot();
			SysDrawImageOp(x - h.x, y - h.y, m, m.GetSize(), ink);
		}
		x += dx ? *dx++ : font[g.chr];
	}
}
Example #5
0
CFX_GlyphBitmap* CPDF_Type3Cache::LoadGlyph(FX_DWORD charcode,
                                            const CFX_AffineMatrix* pMatrix,
                                            FX_FLOAT retinaScaleX,
                                            FX_FLOAT retinaScaleY) {
  _CPDF_UniqueKeyGen keygen;
  keygen.Generate(
      4, FXSYS_round(pMatrix->a * 10000), FXSYS_round(pMatrix->b * 10000),
      FXSYS_round(pMatrix->c * 10000), FXSYS_round(pMatrix->d * 10000));
  CFX_ByteStringC FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen);
  CPDF_Type3Glyphs* pSizeCache;
  auto it = m_SizeMap.find(FaceGlyphsKey);
  if (it == m_SizeMap.end()) {
    pSizeCache = new CPDF_Type3Glyphs;
    m_SizeMap[FaceGlyphsKey] = pSizeCache;
  } else {
    pSizeCache = it->second;
  }
  CFX_GlyphBitmap* pGlyphBitmap;
  if (pSizeCache->m_GlyphMap.Lookup((void*)(uintptr_t)charcode,
                                    (void*&)pGlyphBitmap)) {
    return pGlyphBitmap;
  }
  pGlyphBitmap =
      RenderGlyph(pSizeCache, charcode, pMatrix, retinaScaleX, retinaScaleY);
  pSizeCache->m_GlyphMap.SetAt((void*)(uintptr_t)charcode, pGlyphBitmap);
  return pGlyphBitmap;
}
Example #6
0
void TexFont::RenderString( const wxString &string, int x, int y )
{
    if(!texobj)
        return;
    
    glPushMatrix();
    glTranslatef(x, y, 0);

    glPushMatrix();
    glBindTexture( GL_TEXTURE_2D, texobj);

    for(unsigned int i=0; i<string.size(); i++) {
        wchar_t x = string[i]; 

        if(x == '\n') {
            glPopMatrix();
            glTranslatef(0, tgi[(int)'A'].height, 0);
            glPushMatrix();
            continue;
        }
        RenderGlyph( x );
    }

    glPopMatrix();
    glPopMatrix();
}
Example #7
0
void
ViewBuffer::PutGlyph(int32 x, int32 y, uint8 glyph, uint8 attr)
{
	if (x >= fColumns || y >= fRows)
		return;
	
	RenderGlyph(x, y, glyph, attr);
}
Example #8
0
TBFontGlyph *TBFontFace::GetGlyph(UCS4 cp, bool render_if_needed)
{
	TBFontGlyph *glyph = m_glyph_cache->GetGlyph(GetHashId(cp), cp);
	if (!glyph)
		glyph = CreateAndCacheGlyph(cp);
	if (glyph && !glyph->frag && render_if_needed)
		RenderGlyph(glyph);
	return glyph;
}
Example #9
0
void RenderText(bitmapfont_t * font, int x, int y, char const * text)
{
    if (font && text) {
        int i, n = strlen(text);
        int dx = x;
        for (i=0 ; i<n ; i++) {
            if (text[i] == '\n') {
                y += font->glyphs[0].h + font->newline;
                dx = x;
            } else {
                RenderGlyph(font,dx,y,text[i]);
                dx += font->glyphs[text[i]-font->begin].w + font->space;
            }
        }
    }
}
Example #10
0
CFX_GlyphBitmap* CPDF_Type3Cache::LoadGlyph(FX_DWORD charcode, const CFX_AffineMatrix* pMatrix, FX_FLOAT retinaScaleX, FX_FLOAT retinaScaleY)
{
    _CPDF_UniqueKeyGen keygen;
    keygen.Generate(4, FXSYS_round(pMatrix->a * 10000), FXSYS_round(pMatrix->b * 10000),
                    FXSYS_round(pMatrix->c * 10000), FXSYS_round(pMatrix->d * 10000));
    CFX_ByteStringC FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen);
    CPDF_Type3Glyphs* pSizeCache = NULL;
    if(!m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) {
        pSizeCache = FX_NEW CPDF_Type3Glyphs;
        m_SizeMap.SetAt(FaceGlyphsKey, pSizeCache);
    }
    CFX_GlyphBitmap* pGlyphBitmap;
    if(pSizeCache->m_GlyphMap.Lookup((FX_LPVOID)(FX_UINTPTR)charcode, (void*&)pGlyphBitmap)) {
        return pGlyphBitmap;
    }
    pGlyphBitmap = RenderGlyph(pSizeCache, charcode, pMatrix, retinaScaleX, retinaScaleY);
    pSizeCache->m_GlyphMap.SetAt((FX_LPVOID)(FX_UINTPTR)charcode, pGlyphBitmap);
    return pGlyphBitmap;
}
Example #11
0
void TextureFont::RenderString(const char *str, float x, float y)
{
	glEnable(GL_BLEND);

	float px = x;
	float py = y;

	int i = 0;
	while (str[i]) {
		if (str[i] == '\n') {
			px = x;
			py += GetHeight()*PARAGRAPH_SPACING;
			i++;
		}
		
		else {
			Uint32 chr;
			int n = conv_mb_to_wc(&chr, &str[i]);
			assert(n);
			i += n;

			glfglyph_t *glyph = &m_glyphs[chr];
			if (glyph->texture) RenderGlyph(chr, roundf(px), py);

			if (str[i]) {
				Uint32 chr2;
				n = conv_mb_to_wc(&chr2, &str[i]);
				assert(n);

				FT_UInt a = FT_Get_Char_Index(m_face, chr);
				FT_UInt b = FT_Get_Char_Index(m_face, chr2);

				FT_Vector kern;
				FT_Get_Kerning(m_face, a, b, FT_KERNING_UNFITTED, &kern);
				px += float(kern.x) / 64.0;
			}

			px += glyph->advx;
		}
	}

	glDisable(GL_BLEND);
}
Example #12
0
void
ViewBuffer::FillGlyph(int32 x, int32 y, int32 width, int32 height, uint8 glyph, uint8 attr)
{
	if (x >= fColumns || y >= fRows)
		return;
	
	int32 left = x + width;
	if (left > fColumns)
		left = fColumns;
	
	int32 bottom = y + height;
	if (bottom > fRows)
		bottom = fRows;
	
	for (; y < bottom; y++) {
		for (int32 x2 = x; x2 < left; x2++) {
			RenderGlyph(x2, y, glyph, attr);
		}
	}
}