[balsa/gtk4: 275/311] mime-widget-text: Cite bar dimension calculation
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/gtk4: 275/311] mime-widget-text: Cite bar dimension calculation
- Date: Fri, 17 Dec 2021 19:54:27 +0000 (UTC)
commit e537171ef2facb2cb43d37b0c4f457c58d10428d
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Fri Nov 20 17:18:33 2020 -0500
mime-widget-text: Cite bar dimension calculation
Getting the character width from a pango font description is mysterious.
src/balsa-mime-widget-text.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/src/balsa-mime-widget-text.c b/src/balsa-mime-widget-text.c
index 80d6798a5..7cce0e6c0 100644
--- a/src/balsa-mime-widget-text.c
+++ b/src/balsa-mime-widget-text.c
@@ -1021,7 +1021,7 @@ draw_cite_bar_real(gpointer data, gpointer user_data)
BalsaMimeWidgetText *mwt = user_data;
GtkTextView * view;
GtkTextBuffer * buffer;
- gint dimension;
+ int dimension;
GdkRectangle location;
int y_pos;
int height;
@@ -1527,13 +1527,14 @@ fill_text_buf_cited(BalsaMimeWidgetText *mwt,
}
/* width of monospace characters is 3/5 of the size */
- char_width = 0.6 * pango_font_description_get_size(desc);
- if (!pango_font_description_get_size_is_absolute(desc))
- char_width = char_width / PANGO_SCALE;
+ char_width = 0.6 * (double) pango_font_description_get_size(desc) / (double) PANGO_SCALE;
- /* convert char_width from points to pixels */
- /* Assume a logical DPI of 96, which is alleged to be common */
- mwt->cite_bar_dimension = (char_width / 72.0) * 96;
+ if (!pango_font_description_get_size_is_absolute(desc)) {
+ /* convert char_width from points to pixels */
+ /* Assume a logical DPI of 96, which is alleged to be common */
+ char_width = (char_width / 72.0) * 96.0;
+ }
+ mwt->cite_bar_dimension = (int) (char_width + 0.5); /* rounding */
buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(widget));
rgba = &balsa_app.url_color;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]