~ubuntu-branches/ubuntu/utopic/blender/utopic-proposed

« back to all changes in this revision

Viewing changes to source/blender/blenfont/intern/blf_font.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2014-02-19 11:24:23 UTC
  • mfrom: (14.2.23 sid)
  • Revision ID: package-import@ubuntu.com-20140219112423-rkmaz2m7ha06d4tk
Tags: 2.69-3ubuntu1
* Merge with Debian; remaining changes:
  - Configure without OpenImageIO on armhf, as it is not available on
    Ubuntu.

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
#include "BLI_string_utf8.h"
51
51
#include "BLI_threads.h"
52
52
#include "BLI_linklist.h"  /* linknode */
 
53
#include "BLI_strict_flags.h"
53
54
 
54
55
#include "BIF_gl.h"
55
56
#include "BLF_api.h"
59
60
#include "blf_internal_types.h"
60
61
#include "blf_internal.h"
61
62
 
62
 
#ifdef __GNUC__
63
 
#  pragma GCC diagnostic error "-Wsign-conversion"
64
 
#endif
65
 
 
66
63
/* freetype2 handle ONLY for this file!. */
67
64
static FT_Library ft_lib;
68
65
static SpinLock ft_lib_mutex;
163
160
                                   _kern_mode,                                           \
164
161
                                   &(_delta)) == 0)                                      \
165
162
                {                                                                        \
166
 
                        _pen_x += _delta.x >> 6;                                             \
 
163
                        _pen_x += (int)_delta.x >> 6;                                        \
167
164
                }                                                                        \
168
165
        }                                                                            \
169
166
} (void)0
194
191
                /* do not return this loop if clipped, we want every character tested */
195
192
                blf_glyph_render(font, g, (float)pen_x, (float)pen_y);
196
193
 
197
 
                pen_x += g->advance;
 
194
                pen_x += (int)g->advance;
198
195
                g_prev = g;
199
196
        }
200
197
}
221
218
                /* do not return this loop if clipped, we want every character tested */
222
219
                blf_glyph_render(font, g, (float)pen_x, (float)pen_y);
223
220
 
224
 
                pen_x += g->advance;
 
221
                pen_x += (int)g->advance;
225
222
                g_prev = g;
226
223
        }
227
224
}
273
270
        /* buffer specific vars */
274
271
        FontBufInfoBLF *buf_info = &font->buf_info;
275
272
        float b_col_float[4];
276
 
        const unsigned char b_col_char[4] = {buf_info->col[0] * 255,
277
 
                                             buf_info->col[1] * 255,
278
 
                                             buf_info->col[2] * 255,
279
 
                                             buf_info->col[3] * 255};
 
273
        const unsigned char b_col_char[4] = {
 
274
            (unsigned char)(buf_info->col[0] * 255),
 
275
            (unsigned char)(buf_info->col[1] * 255),
 
276
            (unsigned char)(buf_info->col[2] * 255),
 
277
            (unsigned char)(buf_info->col[3] * 255)};
280
278
 
281
279
        unsigned char *cbuf;
282
280
        int chx, chy;
378
376
                                                                cbuf[0] = b_col_char[0];
379
377
                                                                cbuf[1] = b_col_char[1];
380
378
                                                                cbuf[2] = b_col_char[2];
381
 
                                                                cbuf[3] = (alphatest = ((int)cbuf[3] + (int)b_col_char[3])) < 255 ? alphatest : 255;
 
379
                                                                
 
380
                                                                alphatest = (int)cbuf[3] + (int)b_col_char[3];
 
381
                                                                if (alphatest < 255) {
 
382
                                                                        cbuf[3] = (unsigned char)(alphatest);
 
383
                                                                }
 
384
                                                                else {
 
385
                                                                        cbuf[3] = 255;
 
386
                                                                }
382
387
                                                        }
383
388
                                                        else {
384
 
                                                                cbuf[0] = (b_col_char[0] * a) + (cbuf[0] * (1.0f - a));
385
 
                                                                cbuf[1] = (b_col_char[1] * a) + (cbuf[1] * (1.0f - a));
386
 
                                                                cbuf[2] = (b_col_char[2] * a) + (cbuf[2] * (1.0f - a));
387
 
                                                                cbuf[3] = (alphatest = ((int)cbuf[3] + (int)((b_col_float[3] * a) * 255.0f))) <
388
 
                                                                          255 ? alphatest : 255;
 
389
                                                                cbuf[0] = (unsigned char)((b_col_char[0] * a) + (cbuf[0] * (1.0f - a)));
 
390
                                                                cbuf[1] = (unsigned char)((b_col_char[1] * a) + (cbuf[1] * (1.0f - a)));
 
391
                                                                cbuf[2] = (unsigned char)((b_col_char[2] * a) + (cbuf[2] * (1.0f - a)));
 
392
                                                                
 
393
                                                                alphatest = ((int)cbuf[3] + (int)((b_col_float[3] * a) * 255.0f));
 
394
                                                                if (alphatest < 255) {
 
395
                                                                        cbuf[3] = (unsigned char)(alphatest);
 
396
                                                                }
 
397
                                                                else {
 
398
                                                                        cbuf[3] = 255;
 
399
                                                                }
389
400
                                                        }
390
401
                                                }
391
402
                                        }
398
409
                        }
399
410
                }
400
411
 
401
 
                pen_x += g->advance;
 
412
                pen_x += (int)g->advance;
402
413
                g_prev = g;
403
414
        }
404
415
}
433
444
                if (has_kerning)
434
445
                        BLF_KERNING_STEP(font, kern_mode, g_prev, g, delta, pen_x);
435
446
 
436
 
                gbox.xmin = pen_x;
437
 
                gbox.xmax = pen_x + g->advance;
438
 
                gbox.ymin = g->box.ymin + pen_y;
439
 
                gbox.ymax = g->box.ymax + pen_y;
 
447
                gbox.xmin = (float)pen_x;
 
448
                gbox.xmax = (float)pen_x + g->advance;
 
449
                gbox.ymin = g->box.ymin + (float)pen_y;
 
450
                gbox.ymax = g->box.ymax + (float)pen_y;
440
451
 
441
452
                if (gbox.xmin < box->xmin) box->xmin = gbox.xmin;
442
453
                if (gbox.ymin < box->ymin) box->ymin = gbox.ymin;
444
455
                if (gbox.xmax > box->xmax) box->xmax = gbox.xmax;
445
456
                if (gbox.ymax > box->ymax) box->ymax = gbox.ymax;
446
457
 
447
 
                pen_x += g->advance;
 
458
                pen_x += (int)g->advance;
448
459
                g_prev = g;
449
460
        }
450
461
 
524
535
        GlyphCacheBLF *gc;
525
536
 
526
537
        font->glyph_cache = NULL;
527
 
        while (font->cache.first) {
528
 
                gc = font->cache.first;
529
 
                BLI_remlink(&font->cache, gc);
 
538
        while ((gc = BLI_pophead(&font->cache))) {
530
539
                blf_glyph_cache_free(gc);
531
540
        }
532
541