Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenfont/intern/blf_font.c
| Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | |||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "DNA_vec_types.h" | #include "DNA_vec_types.h" | ||||
| #include "BLI_listbase.h" | #include "BLI_listbase.h" | ||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "BLI_rect.h" | #include "BLI_rect.h" | ||||
| #include "BLI_string.h" | #include "BLI_string.h" | ||||
campbellbarton: Don't re-order headers, it's unrelated to your patch and causes the patch to fail here.
```… | |||||
| #include "BLI_string_utf8.h" | #include "BLI_string_utf8.h" | ||||
| #include "BLI_threads.h" | #include "BLI_threads.h" | ||||
| #include "BLF_api.h" | #include "BLF_api.h" | ||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "GPU_immediate.h" | #include "GPU_immediate.h" | ||||
| #include "GPU_matrix.h" | #include "GPU_matrix.h" | ||||
| #include "GPU_batch.h" | #include "GPU_batch.h" | ||||
| #include "blf_internal_types.h" | #include "blf_internal_types.h" | ||||
| #include "blf_internal.h" | #include "blf_internal.h" | ||||
| #include "CLG_log.h" | |||||
| #include "BLI_strict_flags.h" | #include "BLI_strict_flags.h" | ||||
| #ifdef WIN32 | #ifdef WIN32 | ||||
| # define FT_New_Face FT_New_Face__win32_compat | # define FT_New_Face FT_New_Face__win32_compat | ||||
| #endif | #endif | ||||
| static CLG_LogRef LOG = {"blf.font"}; | |||||
| /* Batching buffer for drawing. */ | /* Batching buffer for drawing. */ | ||||
| BatchBLF g_batch; | BatchBLF g_batch; | ||||
| /* freetype2 handle ONLY for this file!. */ | /* freetype2 handle ONLY for this file!. */ | ||||
| static FT_Library ft_lib; | static FT_Library ft_lib; | ||||
| static SpinLock ft_lib_mutex; | static SpinLock ft_lib_mutex; | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| ▲ Show 20 Lines • Show All 160 Lines • ▼ Show 20 Lines | if (gc) { | ||||
| /* Optimization: do not call FT_Set_Char_Size if size did not change. */ | /* Optimization: do not call FT_Set_Char_Size if size did not change. */ | ||||
| if (font->size == size && font->dpi == dpi) | if (font->size == size && font->dpi == dpi) | ||||
| return; | return; | ||||
| } | } | ||||
| err = FT_Set_Char_Size(font->face, 0, (FT_F26Dot6)(size * 64), dpi, dpi); | err = FT_Set_Char_Size(font->face, 0, (FT_F26Dot6)(size * 64), dpi, dpi); | ||||
| if (err) { | if (err) { | ||||
| /* FIXME: here we can go through the fixed size and choice a close one */ | /* FIXME: here we can go through the fixed size and choice a close one */ | ||||
| printf("The current font don't support the size, %u and dpi, %u\n", size, dpi); | CLOG_ERROR(&LOG, "Font '%s' doesn't support the size, %u and dpi, %u", font->name, size, dpi); | ||||
| return; | return; | ||||
| } | } | ||||
| font->size = size; | font->size = size; | ||||
| font->dpi = dpi; | font->dpi = dpi; | ||||
| if (!gc) { | if (!gc) { | ||||
| gc = blf_glyph_cache_new(font); | gc = blf_glyph_cache_new(font); | ||||
| ▲ Show 20 Lines • Show All 890 Lines • ▼ Show 20 Lines | FontBLF *blf_font_new(const char *name, const char *filename) | ||||
| err = FT_New_Face(ft_lib, filename, 0, &font->face); | err = FT_New_Face(ft_lib, filename, 0, &font->face); | ||||
| if (err) { | if (err) { | ||||
| MEM_freeN(font); | MEM_freeN(font); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| err = FT_Select_Charmap(font->face, ft_encoding_unicode); | err = FT_Select_Charmap(font->face, ft_encoding_unicode); | ||||
| if (err) { | if (err) { | ||||
| printf("Can't set the unicode character map!\n"); | CLOG_ERROR(&LOG, "Can't set the unicode character map!"); | ||||
| FT_Done_Face(font->face); | FT_Done_Face(font->face); | ||||
| MEM_freeN(font); | MEM_freeN(font); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| mfile = blf_dir_metrics_search(filename); | mfile = blf_dir_metrics_search(filename); | ||||
| if (mfile) { | if (mfile) { | ||||
| err = FT_Attach_File(font->face, mfile); | err = FT_Attach_File(font->face, mfile); | ||||
| if (err) { | if (err) { | ||||
| fprintf(stderr, "FT_Attach_File failed to load '%s' with error %d\n", filename, (int)err); | CLOG_ERROR(&LOG, "failed to load '%s' with error %d", filename, (int)err); | ||||
| } | } | ||||
| MEM_freeN(mfile); | MEM_freeN(mfile); | ||||
| } | } | ||||
| font->name = BLI_strdup(name); | font->name = BLI_strdup(name); | ||||
| font->filename = BLI_strdup(filename); | font->filename = BLI_strdup(filename); | ||||
| blf_font_fill(font); | blf_font_fill(font); | ||||
| return font; | return font; | ||||
| Show All 18 Lines | FontBLF *blf_font_new_from_mem(const char *name, const unsigned char *mem, int mem_size) | ||||
| err = FT_New_Memory_Face(ft_lib, mem, mem_size, 0, &font->face); | err = FT_New_Memory_Face(ft_lib, mem, mem_size, 0, &font->face); | ||||
| if (err) { | if (err) { | ||||
| MEM_freeN(font); | MEM_freeN(font); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| err = FT_Select_Charmap(font->face, ft_encoding_unicode); | err = FT_Select_Charmap(font->face, ft_encoding_unicode); | ||||
| if (err) { | if (err) { | ||||
| printf("Can't set the unicode character map!\n"); | CLOG_ERROR(&LOG, "Can't set the unicode character map!"); | ||||
| FT_Done_Face(font->face); | FT_Done_Face(font->face); | ||||
| MEM_freeN(font); | MEM_freeN(font); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| font->name = BLI_strdup(name); | font->name = BLI_strdup(name); | ||||
| font->filename = NULL; | font->filename = NULL; | ||||
| blf_font_fill(font); | blf_font_fill(font); | ||||
| return font; | return font; | ||||
| } | } | ||||
Don't re-order headers, it's unrelated to your patch and causes the patch to fail here.
source/blender/gpu/GPU_vertex_buffer.h:117:35: error: conversion from 'long int' to 'uint' {aka 'unsigned int'} may change value [-Werror=conversion] return ((a->data - a->data_init) / a->stride); ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~ cc1: all warnings being treated as errors