Commit 92373d9718b2e7ab3242d806bd930df718618064
1 parent
ec7b14ef
Exists in
master
and in
1 other branch
Working on new print component.
Showing
2 changed files
with
5 additions
and
74 deletions
Show diff stats
src/dialogs/print/begin.c
| ... | ... | @@ -68,77 +68,7 @@ |
| 68 | 68 | trace("Font size: %d",(int) valid); |
| 69 | 69 | cairo_set_font_size(cr,valid); |
| 70 | 70 | |
| 71 | + // Set view size | |
| 71 | 72 | |
| 72 | - /* | |
| 73 | - | |
| 74 | - gchar * font = get_string_from_config("print",FONT_CONFIG,DEFAULT_FONT); | |
| 75 | - | |
| 76 | - trace("%s: operation=%p context=%p font=\"%s\"",__FUNCTION__,prt,context,font); | |
| 77 | - | |
| 78 | - // Setup font | |
| 79 | - if(*font) | |
| 80 | - { | |
| 81 | - PangoFontDescription * descr = pango_font_description_from_string(font); | |
| 82 | - if(descr) | |
| 83 | - { | |
| 84 | - cairo_select_font_face(cr, pango_font_description_get_family(descr), | |
| 85 | - CAIRO_FONT_SLANT_NORMAL, | |
| 86 | - pango_font_description_get_weight(descr) == PANGO_WEIGHT_BOLD ? CAIRO_FONT_WEIGHT_BOLD : CAIRO_FONT_WEIGHT_NORMAL); | |
| 87 | - | |
| 88 | -#ifdef AUTO_FONT_SIZE | |
| 89 | - { | |
| 90 | - double width = gtk_print_context_get_width(context); | |
| 91 | -#if GTK_CHECK_VERSION(3,0,0) | |
| 92 | - double cols = (double) info->cols; | |
| 93 | -#else | |
| 94 | - double cols = (double) (info->cols+5); | |
| 95 | -#endif // GTK(3,0,0) | |
| 96 | - double current = width / cols; | |
| 97 | - double valid = current; | |
| 98 | - | |
| 99 | - do | |
| 100 | - { | |
| 101 | - valid = current; | |
| 102 | - current = valid +1.0; | |
| 103 | - cairo_set_font_size(cr,current); | |
| 104 | - cairo_font_extents(cr,&extents); | |
| 105 | - } | |
| 106 | - while( (cols * extents.max_x_advance) < width ); | |
| 107 | - | |
| 108 | - trace("Font size: %d",(int) valid); | |
| 109 | - cairo_set_font_size(cr,valid); | |
| 110 | - | |
| 111 | - } | |
| 112 | -#endif // AUTO_FONT_SIZE | |
| 113 | - | |
| 114 | - pango_font_description_free(descr); | |
| 115 | - } | |
| 116 | - } | |
| 117 | - g_free(font); | |
| 118 | - | |
| 119 | - info->font.scaled = cairo_get_scaled_font(cr); | |
| 120 | - cairo_scaled_font_reference(info->font.scaled); | |
| 121 | - cairo_scaled_font_extents(info->font.scaled,&extents); | |
| 122 | - | |
| 123 | - info->font.height = extents.height; | |
| 124 | - info->font.descent = extents.descent; | |
| 125 | - info->font.width = extents.max_x_advance; | |
| 126 | - | |
| 127 | - info->width = ((double) info->cols) * extents.max_x_advance; | |
| 128 | - info->height = ((double) info->rows) * (extents.height + extents.descent); | |
| 129 | - | |
| 130 | - // Center image | |
| 131 | - info->left = (gtk_print_context_get_width(context)-info->width)/2; | |
| 132 | - if(info->left < 2) | |
| 133 | - info->left = 2; | |
| 134 | - | |
| 135 | - // Setup page size | |
| 136 | - info->lpp = (gtk_print_context_get_height(context) / (extents.height + extents.descent)); | |
| 137 | - info->pages = (info->rows / info->lpp)+1; | |
| 138 | - | |
| 139 | - trace("%d lines per page, %d pages to print",info->lpp,info->pages); | |
| 140 | - | |
| 141 | - gtk_print_operation_set_n_pages(prt,info->pages); | |
| 142 | - */ | |
| 143 | 73 | } |
| 144 | 74 | ... | ... |
src/dialogs/print/private.h
| ... | ... | @@ -51,17 +51,18 @@ |
| 51 | 51 | struct |
| 52 | 52 | { |
| 53 | 53 | size_t width; ///< @brief Maximun text width (in characters) |
| 54 | - | |
| 54 | + size_t rows; ///< @brief Number of text rows. | |
| 55 | + size_t pages; ///< @brief Number of pages. | |
| 55 | 56 | } text; |
| 56 | 57 | |
| 57 | - struct { | |
| 58 | + struct | |
| 59 | + { | |
| 58 | 60 | gchar * name; |
| 59 | 61 | v3270FontInfo info; |
| 60 | 62 | } font; |
| 61 | 63 | |
| 62 | 64 | gboolean show_selection; |
| 63 | 65 | |
| 64 | - | |
| 65 | 66 | }; |
| 66 | 67 | |
| 67 | 68 | /*--[ Prototypes ]-----------------------------------------------------------------------------------*/ | ... | ... |