Exemplo n.º 1
0
static void rpi_draw_message(rpi_t *rpi, const char *msg)
{
   if (!rpi->mLastMsg || strcmp(rpi->mLastMsg, msg))
      rpi_render_message(rpi, msg);

   vgSeti(VG_SCISSORING, VG_FALSE);
   vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_STENCIL);

   VGfloat origins[] = {
      rpi->mScreenWidth * g_settings.video.msg_pos_x - 2.0f,
      rpi->mScreenHeight * g_settings.video.msg_pos_y - 2.0f,
   };

   vgSetfv(VG_GLYPH_ORIGIN, 2, origins);
   vgSetPaint(rpi->mPaintBg, VG_FILL_PATH);
   vgDrawGlyphs(rpi->mFont, rpi->mMsgLength, rpi->mGlyphIndices, NULL, NULL, VG_FILL_PATH, VG_TRUE);
   origins[0] += 2.0f;
   origins[1] += 2.0f;
   vgSetfv(VG_GLYPH_ORIGIN, 2, origins);
   vgSetPaint(rpi->mPaintFg, VG_FILL_PATH);
   vgDrawGlyphs(rpi->mFont, rpi->mMsgLength, rpi->mGlyphIndices, NULL, NULL, VG_FILL_PATH, VG_TRUE);

   vgSeti(VG_SCISSORING, VG_TRUE);
   vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_NORMAL);
}
Exemplo n.º 2
0
static void vg_draw_message(vg_t *vg, const char *msg)
{
   settings_t *settings = config_get_ptr();

   if (!vg->mLastMsg || strcmp(vg->mLastMsg, msg))
      vg_render_message(vg, msg);

   vgSeti(VG_SCISSORING, VG_FALSE);
   vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_STENCIL);

   VGfloat origins[] = {
      vg->mScreenWidth  * settings->video.msg_pos_x - 2.0f,
      vg->mScreenHeight * settings->video.msg_pos_y - 2.0f,
   };

   vgSetfv(VG_GLYPH_ORIGIN, 2, origins);
   vgSetPaint(vg->mPaintBg, VG_FILL_PATH);
   vgDrawGlyphs(vg->mFont, vg->mMsgLength, vg->mGlyphIndices, NULL, NULL, VG_FILL_PATH, VG_TRUE);
   origins[0] += 2.0f;
   origins[1] += 2.0f;
   vgSetfv(VG_GLYPH_ORIGIN, 2, origins);
   vgSetPaint(vg->mPaintFg, VG_FILL_PATH);
   vgDrawGlyphs(vg->mFont, vg->mMsgLength, vg->mGlyphIndices, NULL, NULL, VG_FILL_PATH, VG_TRUE);

   vgSeti(VG_SCISSORING, VG_TRUE);
   vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_NORMAL);
}
Exemplo n.º 3
0
static void draw_chars(VGFT_FONT_T *font, const char *text, int char_count, VGbitfield paint_modes, int peek) {
   // Put in first character
   glyph_indices[0] = FT_Get_Char_Index(font->ft_face, text[0]);
   int prev_glyph_index = glyph_indices[0];

   // Calculate glyph_indices and adjustments
   int i;
   FT_Vector kern;
   for (i = 1; i != char_count; ++i) {
      int glyph_index = FT_Get_Char_Index(font->ft_face, text[i]);
      if (!glyph_index) { return; }
      glyph_indices[i] = glyph_index;

      if (FT_Get_Kerning(font->ft_face, prev_glyph_index, glyph_index, FT_KERNING_DEFAULT, &kern)) assert(0);
      adjustments_x[i - 1] = float_from_26_6(kern.x);
      adjustments_y[i - 1] = float_from_26_6(kern.y);

      prev_glyph_index = glyph_index;
   }

   // Get the last adjustment?
   if (peek) {
      int peek_glyph_index = FT_Get_Char_Index(font->ft_face, text[i]);
      if (!peek_glyph_index) { return; }
      if (FT_Get_Kerning(font->ft_face, prev_glyph_index, peek_glyph_index, FT_KERNING_DEFAULT, &kern)) assert(0);
      adjustments_x[char_count - 1] = float_from_26_6(kern.x);
      adjustments_y[char_count - 1] = float_from_26_6(kern.y);
   } else {
      adjustments_x[char_count - 1] = 0.0f;
      adjustments_y[char_count - 1] = 0.0f;
   }

   vgDrawGlyphs(font->vg_font, char_count, glyph_indices, adjustments_x, adjustments_y, paint_modes, VG_FALSE);
}
Exemplo n.º 4
0
void OVGFont::DrawLine(VGFont &vgFont, VGint i32Size, VGuint *pStr, float fHeight, float fScale)
{
	static float fOrigin[] = {0.0f, 0.0f};

	/*
		Everytime vgDrawGlyph(s) is called the glyph(s) are drawn at the position
		defined by VG_GLYPH_ORIGIN. This value is updated after each call by the
		escapement vector defined by the glyph.

		As we don't want our text to follow any of the text previously drawn we're
		setting the glyph orign to 0,0.
	*/
	vgSetfv(VG_GLYPH_ORIGIN, 2, fOrigin);

	/*
		Using the matrix mode MATRIX_GLYPH_USER_TO_SURFACE translate and scale
		the font.
	*/
	vgLoadIdentity();
	vgTranslate(0.0f, fHeight);
	vgScale(fScale, fScale);

	/*
		Our string is only a few glyphs long so we're going to repeatedly
		draw it until the x value of the GLYPH_ORIGIN is greater than the
		scaled width.
	*/

	float fGlyphOrigin[2];
	fGlyphOrigin[0] = 0.0f;
	fGlyphOrigin[1] = 0.0f;

	float fScaledWidth = m_ui32ScreenWidth / fScale;

	while(fGlyphOrigin[0] < fScaledWidth)
	{
		/*
			Draw i32Size no of glyphs from pStr. The VG_FILL_PATH parameter
			defines how you would like the glyph (if a path) to be displayed.
			You can also have it stroked by using VG_STROKE_PATH. This parameter
			doesn't affect image based glyphs unless it's value is set to 0
			in which case no glyph (path or image based) will be drawn.

			The fourth and fifth parameters are the x and y adjustments
			for each glyph. These can be set to adjust the position of the glyphs
			drawn or can be set to NULL.

			The final parameter (set to VG_TRUE) disables or enables autohinting.
			If equal to true autohinting may be applied to alter the glyphs slightly
			to improve the render quality.
		*/
		vgDrawGlyphs(vgFont, i32Size, &pStr[0], NULL,NULL, VG_FILL_PATH, VG_TRUE);

		// Get the updated GLYPH_ORIGIN
		vgGetfv(VG_GLYPH_ORIGIN, 2, &fGlyphOrigin[0]);
	}
}
Exemplo n.º 5
0
static void draw_line(VGFT_FONT_T *font, VGfloat x, VGfloat y, const char *text, int glyphs_count, VGbitfield paint_modes)
{
   if (glyphs_count == 0) return;

   assert(glyphs_count <= GLYPHS_COUNT_MAX);

   VGfloat glor[] = { x, y };
   vgSetfv(VG_GLYPH_ORIGIN, 2, glor);

   int i;
   int prev_glyph_index = 0;
   for (i = 0; i != glyphs_count; ++i) {

      int glyph_index = FT_Get_Char_Index(font->ft_face, text[i]);
      if (!glyph_index) { return; }

      glyph_indices[i] = glyph_index;

      if (i != 0) {
         FT_Vector kern;
         if (FT_Get_Kerning(font->ft_face, prev_glyph_index, glyph_index, FT_KERNING_DEFAULT, &kern)) {
            assert(0);
         }

         adjustments_x[i - 1] = float_from_26_6(kern.x);
         adjustments_y[i - 1] = float_from_26_6(kern.y);
      }

      prev_glyph_index = glyph_index;
   }

   adjustments_x[glyphs_count - 1] = 0.0f;
   adjustments_y[glyphs_count - 1] = 0.0f;

   vgDrawGlyphs(font->vg_font, glyphs_count, glyph_indices, adjustments_x, adjustments_y, paint_modes, VG_FALSE);
}