Commit adcdb9bd52f7b2779f9a7ff11d4a61f00dee720a

Authored by Perry Werneck
1 parent 956331e8
Exists in master and in 1 other branch develop

Fixing win32 font scaling.

src/terminal/font/compute.c
@@ -66,6 +66,38 @@ @@ -66,6 +66,38 @@
66 terminal->font.face = cairo_toy_font_face_create(terminal->font.family, CAIRO_FONT_SLANT_NORMAL, terminal->font.weight); 66 terminal->font.face = cairo_toy_font_face_create(terminal->font.family, CAIRO_FONT_SLANT_NORMAL, terminal->font.weight);
67 cairo_set_font_face(cr,terminal->font.face); 67 cairo_set_font_face(cr,terminal->font.face);
68 68
  69 +#ifdef _WIN32
  70 + {
  71 + static const int font_size[] = { 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 18, 20, 22, 24, 26, 28, 32, 36, 40, 48, 56, 64, 72 };
  72 + size_t ix = 0;
  73 +
  74 + terminal->font.size = font_size[0];
  75 +
  76 + // debug("Window: width=%d height=%d",width,height);
  77 +
  78 + for(ix = 0; ix < G_N_ELEMENTS(font_size); ix++)
  79 + {
  80 + cairo_set_font_size(cr,font_size[ix]);
  81 + cairo_font_extents(cr,&extents);
  82 +
  83 + /*
  84 + debug("size=%d width=%d height=%d",
  85 + font_size[ix],
  86 + VIEW_WIDTH_FROM_FONT(extents.max_x_advance),
  87 + VIEW_HEIGTH_FROM_FONT( (extents.height+extents.descent) )
  88 + );
  89 + */
  90 +
  91 + if( (VIEW_WIDTH_FROM_FONT(extents.max_x_advance)) > width || VIEW_HEIGTH_FROM_FONT((extents.height+extents.descent)) > height) {
  92 + break;
  93 + }
  94 +
  95 + terminal->font.size = font_size[ix];
  96 + }
  97 +
  98 + debug("Selected size=%lf",terminal->font.size);
  99 + }
  100 +#else
69 { 101 {
70 double s = 0.1; 102 double s = 0.1;
71 103
@@ -82,6 +114,7 @@ @@ -82,6 +114,7 @@
82 debug("Selected size=%lf",terminal->font.size); 114 debug("Selected size=%lf",terminal->font.size);
83 115
84 } 116 }
  117 +#endif // _WIN32
85 118
86 // Save scaled font for use on next drawings 119 // Save scaled font for use on next drawings
87 cairo_set_font_size(cr,terminal->font.size); 120 cairo_set_font_size(cr,terminal->font.size);
src/testprogram/testprogram.c
@@ -68,7 +68,7 @@ @@ -68,7 +68,7 @@
68 gtk_notebook_append_page(GTK_NOTEBOOK(notebook),terminal,gtk_label_new("Terminal")); 68 gtk_notebook_append_page(GTK_NOTEBOOK(notebook),terminal,gtk_label_new("Terminal"));
69 69
70 #ifdef _WIN32 70 #ifdef _WIN32
71 - v3270_set_font_family(terminal,"Droid Sans Mono"); 71 + v3270_set_font_family(terminal,"Lucida Console");
72 #endif // _WIN32 72 #endif // _WIN32
73 73
74 } 74 }