libpurple/protocols/myspace/markup.c

changeset 25158
7ef960d79a2e
parent 25147
a0b5713cb3ce
child 25169
a0b71a1e08e5
equal deleted inserted replaced
25157:c63edcfab96e 25158:7ef960d79a2e
79 /* Indexes of this array + 1 map HTML font size to scale of normal font size. * 79 /* Indexes of this array + 1 map HTML font size to scale of normal font size. *
80 * Based on _point_sizes from libpurple/gtkimhtml.c 80 * Based on _point_sizes from libpurple/gtkimhtml.c
81 * 1 2 3 4 5 6 7 */ 81 * 1 2 3 4 5 6 7 */
82 static gdouble _font_scale[] = { .85, .95, 1, 1.2, 1.44, 1.728, 2.0736 }; 82 static gdouble _font_scale[] = { .85, .95, 1, 1.2, 1.44, 1.728, 2.0736 };
83 83
84 #define MAX_FONT_SIZE 7 /* Purple maximum font size */ 84 /* Purple maximum font size. Equivalent to sizeof(_font_scale) / sizeof(_font_scale[0]) */
85 #define MAX_FONT_SIZE 7
86
85 #define POINTS_PER_INCH 72 /* How many pt's in an inch */ 87 #define POINTS_PER_INCH 72 /* How many pt's in an inch */
86 88
87 /* Text formatting bits for <f s=#> */ 89 /* Text formatting bits for <f s=#> */
88 #define MSIM_TEXT_BOLD 1 90 #define MSIM_TEXT_BOLD 1
89 #define MSIM_TEXT_ITALIC 2 91 #define MSIM_TEXT_ITALIC 2
114 * Based on libpurple/gtkimhtml.c */ 116 * Based on libpurple/gtkimhtml.c */
115 static guint 117 static guint
116 msim_point_to_purple_size(MsimSession *session, guint point) 118 msim_point_to_purple_size(MsimSession *session, guint point)
117 { 119 {
118 guint size, this_point, base; 120 guint size, this_point, base;
119 gdouble scale;
120 121
121 base = purple_account_get_int(session->account, "base_font_size", MSIM_BASE_FONT_POINT_SIZE); 122 base = purple_account_get_int(session->account, "base_font_size", MSIM_BASE_FONT_POINT_SIZE);
122 123
123 for (size = 0; 124 for (size = 0; size < MAX_FONT_SIZE; ++size) {
124 size < sizeof(_font_scale) / sizeof(_font_scale[0]); 125 this_point = (guint)msim_round(base * _font_scale[size]);
125 ++size) {
126 scale = _font_scale[CLAMP(size, 1, MAX_FONT_SIZE) - 1];
127 this_point = (guint)msim_round(scale * base);
128 126
129 if (this_point >= point) { 127 if (this_point >= point) {
130 purple_debug_info("msim", "msim_point_to_purple_size: %d pt -> size=%d\n", 128 purple_debug_info("msim", "msim_point_to_purple_size: %d pt -> size=%d\n",
131 point, size); 129 point, size);
132 return size; 130 return size;

mercurial