Ejemplo n.º 1
0
void redraw_screen(void)
{
	GP_Fill(win->context, black_pixel);

	GP_TextStyle style = GP_DEFAULT_TEXT_STYLE;

	switch (font_flag) {
	case 0:
		style.font = &GP_DefaultProportionalFont;
	break;
	case 1:
		style.font = &GP_DefaultConsoleFont;
	break;
	case 2:
		style.font = GP_FontTiny;
	break;
	case 3:
		style.font = GP_FontTinyMono;
	break;
	case 4:
		style.font = font;
	break;
	}

	print_font_properties(style.font);

	/* Text alignment (we are always drawing to the right
	 * and below the starting point).
	 */
	int align = GP_ALIGN_RIGHT|GP_VALIGN_BELOW;

	const size_t TEST_STRING_COUNT = sizeof(test_strings)/sizeof(const char *);
	size_t i;
	for (i = 0; i < TEST_STRING_COUNT; i++) {
		const char *test_string = test_strings[i];

		style.pixel_xmul = 1;
		style.pixel_ymul = 1;
		style.pixel_xspace = 0;
		style.pixel_yspace = 0;
		style.char_xspace = tracking;

		GP_FillRectXYWH(win->context,
			16, SPACING*i + 16,
			GP_TextWidth(&style, test_string),
			GP_FontHeight(style.font),
			dark_gray_pixel);

		GP_RectXYWH(win->context,
			15, SPACING*i + 15,
			GP_TextMaxWidth(&style, strlen(test_string)) + 1,
			GP_FontHeight(style.font) + 1,
			blue_pixel);

		GP_Text(win->context, &style, 16, SPACING*i + 16, align,
		        white_pixel, dark_gray_pixel, test_string);

		style.pixel_xmul = 2;
		style.pixel_ymul = 2;
		style.pixel_yspace = 1;

		GP_Text(win->context, &style, 34, SPACING * i + 44, align,
		        white_pixel, black_pixel, test_string);

		GP_RectXYWH(win->context, 33, SPACING * i + 43,
		            GP_TextWidth(&style, test_string) + 1,
			    GP_TextHeight(&style) + 1, dark_gray_pixel);

		style.pixel_xmul = 4;
		style.pixel_ymul = 2;

		style.pixel_xspace = 1;
		style.pixel_yspace = 1;

		if (font_flag == 2 || font_flag == 3) {
			style.pixel_xmul = 2;
			style.pixel_ymul = 5;

			style.pixel_xspace = 2;
			style.pixel_yspace = 2;
		}

		GP_Text(win->context, &style, 64, SPACING*i + 88, align,
		        dark_gray_pixel, black_pixel, test_string);
	}
}
Ejemplo n.º 2
0
void redraw_screen(void)
{
	gp_fill(win->pixmap, black_pixel);

	gp_text_style style = GP_DEFAULT_TEXT_STYLE;

	switch (font_flag) {
	case 0:
		style.font = gp_font_gfxprim;
	break;
	case 1:
		style.font = gp_font_gfxprim_mono;
	break;
	case 2:
		style.font = gp_font_tiny;
	break;
	case 3:
		style.font = gp_font_tiny_mono;
	break;
	case 4:
		style.font = gp_font_c64;
	break;
	case 5:
		style.font = font;
	break;
	}

	print_font_properties(style.font);

	/* Text alignment (we are always drawing to the right
	 * and below the starting point).
	 */
	int align = GP_ALIGN_RIGHT|GP_VALIGN_BELOW;

	const size_t TEST_STRING_COUNT = sizeof(test_strings)/sizeof(const char *);
	size_t i;
	for (i = 0; i < TEST_STRING_COUNT; i++) {
		const char *test_string = test_strings[i];

		style.pixel_xmul = 1;
		style.pixel_ymul = 1;
		style.pixel_xspace = 0;
		style.pixel_yspace = 0;
		style.char_xspace = tracking;

		gp_fill_rect_xywh(win->pixmap,
			16, SPACING*i + 16,
			gp_text_width(&style, test_string),
			gp_font_height(style.font),
			dark_gray_pixel);

		gp_rect_xywh(win->pixmap,
			15, SPACING*i + 15,
			gp_text_max_width(&style, strlen(test_string)) + 1,
			gp_font_height(style.font) + 1,
			blue_pixel);

		gp_text(win->pixmap, &style, 16, SPACING*i + 16, align,
		        white_pixel, dark_gray_pixel, test_string);

		style.pixel_xmul = 2;
		style.pixel_ymul = 2;
		style.pixel_yspace = 1;

		gp_text(win->pixmap, &style, 34, SPACING * i + 44, align,
		        white_pixel, black_pixel, test_string);

		gp_rect_xywh(win->pixmap, 33, SPACING * i + 43,
		             gp_text_width(&style, test_string) + 1,
			     gp_text_height(&style) + 1, dark_gray_pixel);

		style.pixel_xmul = 4;
		style.pixel_ymul = 2;

		style.pixel_xspace = 1;
		style.pixel_yspace = 1;

		if (font_flag == 2 || font_flag == 3) {
			style.pixel_xmul = 2;
			style.pixel_ymul = 5;

			style.pixel_xspace = 2;
			style.pixel_yspace = 2;
		}

		gp_text(win->pixmap, &style, 64, SPACING*i + 88, align,
		        dark_gray_pixel, black_pixel, test_string);
	}
}