[Bf-blender-cvs] [b2196ebe287] master: Win32: Relax Debug Assert in BLI_file_attributes
Commit: b2196ebe287ff54b0304f600031f49e683355409 Author: Harley Acheson Date: Sat Feb 4 13:44:10 2023 -0800 Branches: master https://developer.blender.org/rBb2196ebe287ff54b0304f600031f49e683355409 Win32: Relax Debug Assert in BLI_file_attributes If GetFileAttributesW returns an error, only debug assert if the reason is file not found. See D17204 for more details. Differential Revision: https://developer.blender.org/D17204 Reviewed by Ray Molenkamp === M source/blender/blenlib/intern/storage.c === diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index 8c212bf1758..64f4a0b1a26 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -211,9 +211,9 @@ eFileAttributes BLI_file_attributes(const char *path) } DWORD attr = GetFileAttributesW(wline); - BLI_assert_msg(attr != INVALID_FILE_ATTRIBUTES, - "BLI_file_attributes should only be called on existing files."); if (attr == INVALID_FILE_ATTRIBUTES) { +BLI_assert_msg(GetLastError() != ERROR_FILE_NOT_FOUND, + "BLI_file_attributes should only be called on existing files."); return ret; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [fc2a64e21a1] master: Win32: Better Error Handling in BLI_file_attributes
Commit: fc2a64e21a1f7253f2f523c93fc0ec62f639db95 Author: Harley Acheson Date: Thu Feb 2 08:01:43 2023 -0800 Branches: master https://developer.blender.org/rBfc2a64e21a1f7253f2f523c93fc0ec62f639db95 Win32: Better Error Handling in BLI_file_attributes After Win32 API call GetFileAttributesW, check for INVALID_FILE_ATTRIBUTES, which is returned on error, usually if file not found. See D17176 for more details. Differential Revision: https://developer.blender.org/D17176 Reviewed by Ray Molenkamp === M source/blender/blenlib/intern/storage.c === diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index c04fc41ab4d..8c212bf1758 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -209,7 +209,14 @@ eFileAttributes BLI_file_attributes(const char *path) if (conv_utf_8_to_16(path, wline, ARRAY_SIZE(wline)) != 0) { return ret; } + DWORD attr = GetFileAttributesW(wline); + BLI_assert_msg(attr != INVALID_FILE_ATTRIBUTES, + "BLI_file_attributes should only be called on existing files."); + if (attr == INVALID_FILE_ATTRIBUTES) { +return ret; + } + if (attr & FILE_ATTRIBUTE_READONLY) { ret |= FILE_ATTR_READONLY; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d82ffb9787c] master: Fix T103530: Allow Recursive File Lists
Commit: d82ffb9787c3181c6f4432f19309b59009aa34ec Author: Harley Acheson Date: Wed Feb 1 14:06:38 2023 -0800 Branches: master https://developer.blender.org/rBd82ffb9787c3181c6f4432f19309b59009aa34ec Fix T103530: Allow Recursive File Lists In File Browser, correct full path creation so that it works correctly in recursive listings. See D17175 for more details. Differential Revision: https://developer.blender.org/D17175 Reviewed by Julian Eisel === M source/blender/editors/space_file/filelist.cc === diff --git a/source/blender/editors/space_file/filelist.cc b/source/blender/editors/space_file/filelist.cc index 73de74ddaf6..000de4b860c 100644 --- a/source/blender/editors/space_file/filelist.cc +++ b/source/blender/editors/space_file/filelist.cc @@ -2983,7 +2983,7 @@ static int filelist_readjob_list_dir(FileListReadJob *job_params, entry->relpath = current_relpath_append(job_params, files[i].relname); entry->st = files[i].s; - BLI_path_join(full_path, FILE_MAX, root, entry->relpath); + BLI_path_join(full_path, FILE_MAX, root, files[i].relname); char *target = full_path; /* Set initial file type and attributes. */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [485ab420757] master: BLF: Improved CJK Font Preview Differentiation
Commit: 485ab420757bdad5ce4ec9b64ca31ab7fec78dd7 Author: Harley Acheson Date: Mon Jan 9 21:37:22 2023 -0800 Branches: master https://developer.blender.org/rB485ab420757bdad5ce4ec9b64ca31ab7fec78dd7 BLF: Improved CJK Font Preview Differentiation Use font's OS/2 table code page range bits to help differentiate between Korean, Japanese, Simplified & Traditional Chinese fonts. See D16484 for details. Differential Revision: https://developer.blender.org/D16484 Reviewed by Brecht Van Lommel === M source/blender/blenfont/intern/blf_thumbs.c M source/blender/imbuf/intern/thumbs_font.c === diff --git a/source/blender/blenfont/intern/blf_thumbs.c b/source/blender/blenfont/intern/blf_thumbs.c index 8a640ac86a7..0a0ae32af87 100644 --- a/source/blender/blenfont/intern/blf_thumbs.c +++ b/source/blender/blenfont/intern/blf_thumbs.c @@ -257,6 +257,22 @@ static const char32_t *blf_get_sample_text(FT_Face face) count_bits_i((uint)os2_table->ulUnicodeRange3) + count_bits_i((uint)os2_table->ulUnicodeRange4); + /* Use OS/2 Table code page range bits to differentiate between (combined) CJK fonts. + * See https://learn.microsoft.com/en-us/typography/opentype/spec/os2#cpr */ + FT_ULong codepages = os2_table->ulCodePageRange1; + if (codepages & (1 << 19) || codepages & (1 << 21)) { +return U"\ud55c\uad6d\uc5b4"; /* 한국어 Korean. */ + } + if (codepages & (1 << 20)) { +return U"\u7E41\u9AD4\u5B57"; /* 繁體字 Traditional Chinese. */ + } + if (codepages & (1 << 17) && !(codepages & (1 << 18))) { +return U"\u65E5\u672C\u8A9E"; /* 日本語 Japanese. */ + } + if (codepages & (1 << 18) && !(codepages & (1 << 17))) { +return U"\u7B80\u4F53\u5B57"; /* 简体字 Simplified Chinese. */ + } + for (uint i = 0; i < ARRAY_SIZE(unicode_samples); ++i) { const UnicodeSample *s = _samples[i]; if (os2_table && s->field && s->mask) { diff --git a/source/blender/imbuf/intern/thumbs_font.c b/source/blender/imbuf/intern/thumbs_font.c index c3ed81698d9..64f6741a34b 100644 --- a/source/blender/imbuf/intern/thumbs_font.c +++ b/source/blender/imbuf/intern/thumbs_font.c @@ -17,7 +17,7 @@ #include "../../blenfont/BLF_api.h" /* Only change if we need to update the previews in the on-disk cache. */ -#define FONT_THUMB_VERSION "1.0.0" +#define FONT_THUMB_VERSION "1.0.1" struct ImBuf *IMB_thumb_load_font(const char *filename, uint x, uint y) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d11f3267cd9] master: Fix T103210: Don't Always Clear Glyphs With Zoom
Commit: d11f3267cd9370d793264f5eba6eacefd4da2f56 Author: Harley Acheson Date: Sun Jan 8 13:57:09 2023 -0800 Branches: master https://developer.blender.org/rBd11f3267cd9370d793264f5eba6eacefd4da2f56 Fix T103210: Don't Always Clear Glyphs With Zoom Do not clear all the font's glyph caches with single-step zoom operators if the area does not change font size when doing so. See D16785 for more details. Differential Revision: https://developer.blender.org/D16785 Reviewed by Campbell Barton === M source/blender/editors/interface/view2d_ops.cc === diff --git a/source/blender/editors/interface/view2d_ops.cc b/source/blender/editors/interface/view2d_ops.cc index 30c5e79a794..b76f5f1e49f 100644 --- a/source/blender/editors/interface/view2d_ops.cc +++ b/source/blender/editors/interface/view2d_ops.cc @@ -791,9 +791,14 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op) * \{ */ /* Cleanup temp custom-data. */ -static void view_zoomstep_exit(wmOperator *op) +static void view_zoomstep_exit(bContext *C, wmOperator *op) { - UI_view2d_zoom_cache_reset(); + ScrArea *area = CTX_wm_area(C); + /* Some areas change font sizes when zooming, so clear glyph cache. */ + if (area && !ELEM(area->spacetype, SPACE_GRAPH, SPACE_ACTION)) { +UI_view2d_zoom_cache_reset(); + } + v2dViewZoomData *vzd = static_cast(op->customdata); vzd->v2d->flag &= ~V2D_IS_NAVIGATING; MEM_SAFE_FREE(op->customdata); @@ -816,7 +821,7 @@ static int view_zoomin_exec(bContext *C, wmOperator *op) /* apply movement, then we're done */ view_zoomstep_apply(C, op); - view_zoomstep_exit(op); + view_zoomstep_exit(C, op); return OPERATOR_FINISHED; } @@ -880,7 +885,7 @@ static int view_zoomout_exec(bContext *C, wmOperator *op) /* apply movement, then we're done */ view_zoomstep_apply(C, op); - view_zoomstep_exit(op); + view_zoomstep_exit(C, op); return OPERATOR_FINISHED; } @@ -1477,7 +1482,7 @@ static int view2d_ndof_invoke(bContext *C, wmOperator *op, const wmEvent *event) view_zoomstep_apply_ex( C, vzd, do_zoom_xy[0] ? zoom_factor : 0.0f, do_zoom_xy[1] ? zoom_factor : 0.0f); -view_zoomstep_exit(op); +view_zoomstep_exit(C, op); } return OPERATOR_FINISHED; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [7e5cb947483] blender-v3.4-release: Fix T103119: Allow Win32 Diacritical Composition
Commit: 7e5cb9474837ea25cbdb8ae36c67faacb74ed317 Author: Harley Acheson Date: Tue Dec 13 18:30:20 2022 -0800 Branches: blender-v3.4-release https://developer.blender.org/rB7e5cb9474837ea25cbdb8ae36c67faacb74ed317 Fix T103119: Allow Win32 Diacritical Composition Allow keyboard layouts which include "dead keys" to enter diacritics by calling MapVirtualKeyW even when not key_down. See D16770 for more details. Differential Revision: https://developer.blender.org/D16770 Reviewed by Campbell Barton === M intern/ghost/intern/GHOST_SystemWin32.cpp === diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index 4d016373fc6..dc350bb58a1 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -1195,16 +1195,16 @@ GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_WindowWin32 *window, RA const bool ctrl_pressed = has_state && state[VK_CONTROL] & 0x80; const bool alt_pressed = has_state && state[VK_MENU] & 0x80; -if (!key_down) { - /* Pass. */ -} +/* We can be here with !key_down if processing dead keys (diacritics). See T103119. */ + /* No text with control key pressed (Alt can be used to insert special characters though!). */ -else if (ctrl_pressed && !alt_pressed) { +if (ctrl_pressed && !alt_pressed) { /* Pass. */ } /* Don't call #ToUnicodeEx on dead keys as it clears the buffer and so won't allow diacritical - * composition. */ -else if (MapVirtualKeyW(vk, 2) != 0) { + * composition. XXX: we are not checking return of MapVirtualKeyW for high bit set, which is + * what is supposed to indicate dead keys. But this is working now so approach cautiously. */ +else if (MapVirtualKeyW(vk, MAPVK_VK_TO_CHAR) != 0) { wchar_t utf16[3] = {0}; int r; /* TODO: #ToUnicodeEx can respond with up to 4 utf16 chars (only 2 here). @@ -1219,6 +1219,10 @@ GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_WindowWin32 *window, RA utf8_char[0] = '\0'; } } + if (!key_down) { +/* Clear or wm_event_add_ghostevent will warn of unexpected data on key up. */ +utf8_char[0] = '\0'; + } } #ifdef WITH_INPUT_IME ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [93a629f1478] master: Fix T103119: Allow Win32 Diacritical Composition
Commit: 93a629f14781a920a785c08555e04fbea47b5ac0 Author: Harley Acheson Date: Tue Dec 13 18:30:20 2022 -0800 Branches: master https://developer.blender.org/rB93a629f14781a920a785c08555e04fbea47b5ac0 Fix T103119: Allow Win32 Diacritical Composition Allow keyboard layouts which include "dead keys" to enter diacritics by calling MapVirtualKeyW even when not key_down. See D16770 for more details. Differential Revision: https://developer.blender.org/D16770 Reviewed by Campbell Barton === M intern/ghost/intern/GHOST_SystemWin32.cpp === diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index 7aef23b39b6..75a4cc8389a 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -1210,16 +1210,16 @@ GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_WindowWin32 *window, RA const bool ctrl_pressed = has_state && state[VK_CONTROL] & 0x80; const bool alt_pressed = has_state && state[VK_MENU] & 0x80; -if (!key_down) { - /* Pass. */ -} +/* We can be here with !key_down if processing dead keys (diacritics). See T103119. */ + /* No text with control key pressed (Alt can be used to insert special characters though!). */ -else if (ctrl_pressed && !alt_pressed) { +if (ctrl_pressed && !alt_pressed) { /* Pass. */ } /* Don't call #ToUnicodeEx on dead keys as it clears the buffer and so won't allow diacritical - * composition. */ -else if (MapVirtualKeyW(vk, 2) != 0) { + * composition. XXX: we are not checking return of MapVirtualKeyW for high bit set, which is + * what is supposed to indicate dead keys. But this is working now so approach cautiously. */ +else if (MapVirtualKeyW(vk, MAPVK_VK_TO_CHAR) != 0) { wchar_t utf16[3] = {0}; int r; /* TODO: #ToUnicodeEx can respond with up to 4 utf16 chars (only 2 here). @@ -1234,6 +1234,10 @@ GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_WindowWin32 *window, RA utf8_char[0] = '\0'; } } + if (!key_down) { +/* Clear or wm_event_add_ghostevent will warn of unexpected data on key up. */ +utf8_char[0] = '\0'; + } } #ifdef WITH_INPUT_IME ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [658220e8150] master: Fix T101245: Allow Thumbnails of > 256:1 Images
Commit: 658220e815034a5026fe92164e2f1867ce5e78e7 Author: Harley Acheson Date: Tue Dec 6 08:14:02 2022 -0800 Branches: master https://developer.blender.org/rB658220e815034a5026fe92164e2f1867ce5e78e7 Fix T101245: Allow Thumbnails of > 256:1 Images Ensure that thumbnails of images with aspect greater than 256:1 have dimensions of at least one pixel. See D16707 for more details Differential Revision: https://developer.blender.org/D16707 Reviewed by Brecht Van Lommel === M source/blender/imbuf/intern/openexr/openexr_api.cpp M source/blender/imbuf/intern/webp.c === diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index d2bdb5041c5..c17931827f7 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -2215,8 +2215,8 @@ struct ImBuf *imb_load_filepath_thumbnail_openexr(const char *filepath, float scale_factor = MIN2(float(max_thumb_size) / float(source_w), float(max_thumb_size) / float(source_h)); -int dest_w = int(source_w * scale_factor); -int dest_h = int(source_h * scale_factor); +int dest_w = MAX2(int(source_w * scale_factor), 1); +int dest_h = MAX2(int(source_h * scale_factor), 1); struct ImBuf *ibuf = IMB_allocImBuf(dest_w, dest_h, 32, IB_rectfloat); diff --git a/source/blender/imbuf/intern/webp.c b/source/blender/imbuf/intern/webp.c index 3031b8c3e33..abf915b1b8e 100644 --- a/source/blender/imbuf/intern/webp.c +++ b/source/blender/imbuf/intern/webp.c @@ -112,8 +112,8 @@ struct ImBuf *imb_load_filepath_thumbnail_webp(const char *filepath, *r_height = (size_t)config.input.height; const float scale = (float)max_thumb_size / MAX2(config.input.width, config.input.height); - const int dest_w = (int)(config.input.width * scale); - const int dest_h = (int)(config.input.height * scale); + const int dest_w = MAX2((int)(config.input.width * scale), 1); + const int dest_h = MAX2((int)(config.input.height * scale), 1); colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE); struct ImBuf *ibuf = IMB_allocImBuf(dest_w, dest_h, 32, IB_rect); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [87582d95dfd] blender-v3.4-release: Fix T101245: Allow Thumbnails of > 256:1 Images
Commit: 87582d95dfdbc6df4baff881e0bbe62a1fb45c37 Author: Harley Acheson Date: Tue Dec 6 08:14:02 2022 -0800 Branches: blender-v3.4-release https://developer.blender.org/rB87582d95dfdbc6df4baff881e0bbe62a1fb45c37 Fix T101245: Allow Thumbnails of > 256:1 Images Ensure that thumbnails of images with aspect greater than 256:1 have dimensions of at least one pixel. See D16707 for more details Differential Revision: https://developer.blender.org/D16707 Reviewed by Brecht Van Lommel === M source/blender/imbuf/intern/openexr/openexr_api.cpp M source/blender/imbuf/intern/webp.c === diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index d2bdb5041c5..c17931827f7 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -2215,8 +2215,8 @@ struct ImBuf *imb_load_filepath_thumbnail_openexr(const char *filepath, float scale_factor = MIN2(float(max_thumb_size) / float(source_w), float(max_thumb_size) / float(source_h)); -int dest_w = int(source_w * scale_factor); -int dest_h = int(source_h * scale_factor); +int dest_w = MAX2(int(source_w * scale_factor), 1); +int dest_h = MAX2(int(source_h * scale_factor), 1); struct ImBuf *ibuf = IMB_allocImBuf(dest_w, dest_h, 32, IB_rectfloat); diff --git a/source/blender/imbuf/intern/webp.c b/source/blender/imbuf/intern/webp.c index 3031b8c3e33..abf915b1b8e 100644 --- a/source/blender/imbuf/intern/webp.c +++ b/source/blender/imbuf/intern/webp.c @@ -112,8 +112,8 @@ struct ImBuf *imb_load_filepath_thumbnail_webp(const char *filepath, *r_height = (size_t)config.input.height; const float scale = (float)max_thumb_size / MAX2(config.input.width, config.input.height); - const int dest_w = (int)(config.input.width * scale); - const int dest_h = (int)(config.input.height * scale); + const int dest_w = MAX2((int)(config.input.width * scale), 1); + const int dest_h = MAX2((int)(config.input.height * scale), 1); colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE); struct ImBuf *ibuf = IMB_allocImBuf(dest_w, dest_h, 32, IB_rect); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [4c1b250e172] master: Fix T102893: Assert Opening File Browser (Win32)
Commit: 4c1b250e172a99c44c7da20f20ea38970ec40340 Author: Harley Acheson Date: Thu Dec 1 12:25:49 2022 -0800 Branches: master https://developer.blender.org/rB4c1b250e172a99c44c7da20f20ea38970ec40340 Fix T102893: Assert Opening File Browser (Win32) Fix debug assert opening File Browser on Windows platform. See D16672 for more details. Differential Revision: https://developer.blender.org/D16672 Reviewed by Julian Eisel === M source/blender/editors/space_file/filelist.cc === diff --git a/source/blender/editors/space_file/filelist.cc b/source/blender/editors/space_file/filelist.cc index 3374da082d8..44bfa7fcbaf 100644 --- a/source/blender/editors/space_file/filelist.cc +++ b/source/blender/editors/space_file/filelist.cc @@ -2942,7 +2942,7 @@ static char *current_relpath_append(const FileListReadJob *job_params, const cha return BLI_strdup(filename); } - BLI_assert(relbase[strlen(relbase) - 1] == SEP); + BLI_assert(ELEM(relbase[strlen(relbase) - 1], SEP, ALTSEP)); BLI_assert(BLI_path_is_rel(relbase)); char relpath[FILE_MAX_LIBEXTRA]; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [99c970a94dc] master: UI: Allow Joining of Tiny Screen Areas
Commit: 99c970a94dcfeeab047ae57ba1e4a64032f120f9 Author: Harley Acheson Date: Wed Nov 16 09:51:40 2022 -0800 Branches: master https://developer.blender.org/rB99c970a94dcfeeab047ae57ba1e4a64032f120f9 UI: Allow Joining of Tiny Screen Areas Allow joining of areas that are below our minimum sizes. See D16522 for more details. Differential Revision: https://developer.blender.org/D16522 Reviewed by Campbell Barton === M source/blender/editors/screen/screen_edit.c === diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index b2ec251697e..14ed5987cc7 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -268,35 +268,35 @@ eScreenDir area_getorientation(ScrArea *sa_a, ScrArea *sa_b) return SCREEN_DIR_NONE; } - const vec2s *sa_bl = _a->v1->vec; - const vec2s *sa_tl = _a->v2->vec; - const vec2s *sa_tr = _a->v3->vec; - const vec2s *sa_br = _a->v4->vec; - - const vec2s *sb_bl = _b->v1->vec; - const vec2s *sb_tl = _b->v2->vec; - const vec2s *sb_tr = _b->v3->vec; - const vec2s *sb_br = _b->v4->vec; - - if (sa_bl->x == sb_br->x && sa_tl->x == sb_tr->x) { /* sa_a to right of sa_b = W */ -if ((MIN2(sa_tl->y, sb_tr->y) - MAX2(sa_bl->y, sb_br->y)) > AREAJOINTOLERANCEY) { - return 0; -} + short left_a = sa_a->v1->vec.x; + short right_a = sa_a->v3->vec.x; + short top_a = sa_a->v3->vec.y; + short bottom_a = sa_a->v1->vec.y; + + short left_b = sa_b->v1->vec.x; + short right_b = sa_b->v3->vec.x; + short top_b = sa_b->v3->vec.y; + short bottom_b = sa_b->v1->vec.y; + + /* How much these areas share a common edge. */ + short overlapx = MIN2(right_a, right_b) - MAX2(left_a, left_b); + short overlapy = MIN2(top_a, top_b) - MAX2(bottom_a, bottom_b); + + /* Minimum overlap required. */ + const short minx = MIN3(AREAJOINTOLERANCEX, right_a - left_a, right_b - left_b); + const short miny = MIN3(AREAJOINTOLERANCEY, top_a - bottom_a, top_b - bottom_b); + + if (top_a == bottom_b && overlapx >= minx) { +return 1; /* sa_a to bottom of sa_b = N */ } - else if (sa_tl->y == sb_bl->y && sa_tr->y == sb_br->y) { /* sa_a to bottom of sa_b = N */ -if ((MIN2(sa_tr->x, sb_br->x) - MAX2(sa_tl->x, sb_bl->x)) > AREAJOINTOLERANCEX) { - return 1; -} + if (bottom_a == top_b && overlapx >= minx) { +return 3; /* sa_a on top of sa_b = S */ } - else if (sa_tr->x == sb_tl->x && sa_br->x == sb_bl->x) { /* sa_a to left of sa_b = E */ -if ((MIN2(sa_tr->y, sb_tl->y) - MAX2(sa_br->y, sb_bl->y)) > AREAJOINTOLERANCEY) { - return 2; -} + if (left_a == right_b && overlapy >= miny) { +return 0; /* sa_a to right of sa_b = W */ } - else if (sa_bl->y == sb_tl->y && sa_br->y == sb_tr->y) { /* sa_a on top of sa_b = S */ -if ((MIN2(sa_br->x, sb_tr->x) - MAX2(sa_bl->x, sb_tl->x)) > AREAJOINTOLERANCEX) { - return 3; -} + if (right_a == left_b && overlapy >= miny) { +return 2; /* sa_a to left of sa_b = E */ } return -1; @@ -382,6 +382,9 @@ static bool screen_areas_can_align(bScreen *screen, ScrArea *sa1, ScrArea *sa2, const short xmin = MIN2(sa1->v1->vec.x, sa2->v1->vec.x); const short xmax = MAX2(sa1->v3->vec.x, sa2->v3->vec.x); LISTBASE_FOREACH (ScrArea *, area, >areabase) { + if (area == sa1 || area == sa2) { +continue; + } if (area->v3->vec.x - area->v1->vec.x < tolerance && (area->v1->vec.x == xmin || area->v3->vec.x == xmax)) { /* There is a narrow vertical area sharing an edge of the combined bounds. */ @@ -393,6 +396,9 @@ static bool screen_areas_can_align(bScreen *screen, ScrArea *sa1, ScrArea *sa2, const short ymin = MIN2(sa1->v1->vec.y, sa2->v1->vec.y); const short ymax = MAX2(sa1->v3->vec.y, sa2->v3->vec.y); LISTBASE_FOREACH (ScrArea *, area, >areabase) { + if (area == sa1 || area == sa2) { +continue; + } if (area->v3->vec.y - area->v1->vec.y < tolerance && (area->v1->vec.y == ymin || area->v3->vec.y == ymax)) { /* There is a narrow horizontal area sharing an edge of the combined bounds. */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [a81abbbb8f0] master: Fix T100772: Joins with Interfering Tiny Areas
Commit: a81a8f047f969cbe26ceeb6223d623f4e234 Author: Harley Acheson Date: Wed Nov 16 09:06:03 2022 -0800 Branches: master https://developer.blender.org/rBa81a8f047f969cbe26ceeb6223d623f4e234 Fix T100772: Joins with Interfering Tiny Areas Detect unlikely situation of an area (that is smaller than our allowed minimums) sharing an edge that will be moved during a join. See D16519 for more details. Differential Revision: https://developer.blender.org/D16519 Reviewed by Campbell Barton === M source/blender/editors/screen/screen_edit.c === diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index f06e2bd4f3c..b2ec251697e 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -360,11 +360,59 @@ static void screen_verts_valign(const wmWindow *win, } } +/* Test if two adjoining areas can be aligned by having their screen edges adjusted. */ +static bool screen_areas_can_align(bScreen *screen, ScrArea *sa1, ScrArea *sa2, eScreenDir dir) +{ + if (dir == SCREEN_DIR_NONE) { +return false; + } + + int offset1; + int offset2; + area_getoffsets(sa1, sa2, dir, , ); + + const int tolerance = SCREEN_DIR_IS_HORIZONTAL(dir) ? AREAJOINTOLERANCEY : AREAJOINTOLERANCEX; + if ((abs(offset1) >= tolerance) || (abs(offset2) >= tolerance)) { +/* Misalignment is too great. */ +return false; + } + + /* Areas that are _smaller_ than minimum sizes, sharing an edge to be moved. See T100772. */ + if (SCREEN_DIR_IS_VERTICAL(dir)) { +const short xmin = MIN2(sa1->v1->vec.x, sa2->v1->vec.x); +const short xmax = MAX2(sa1->v3->vec.x, sa2->v3->vec.x); +LISTBASE_FOREACH (ScrArea *, area, >areabase) { + if (area->v3->vec.x - area->v1->vec.x < tolerance && + (area->v1->vec.x == xmin || area->v3->vec.x == xmax)) { +/* There is a narrow vertical area sharing an edge of the combined bounds. */ +return false; + } +} + } + else { +const short ymin = MIN2(sa1->v1->vec.y, sa2->v1->vec.y); +const short ymax = MAX2(sa1->v3->vec.y, sa2->v3->vec.y); +LISTBASE_FOREACH (ScrArea *, area, >areabase) { + if (area->v3->vec.y - area->v1->vec.y < tolerance && + (area->v1->vec.y == ymin || area->v3->vec.y == ymax)) { +/* There is a narrow horizontal area sharing an edge of the combined bounds. */ +return false; + } +} + } + + return true; +} + /* Adjust all screen edges to allow joining two areas. 'dir' value is like area_getorientation(). */ -static void screen_areas_align( +static bool screen_areas_align( bContext *C, bScreen *screen, ScrArea *sa1, ScrArea *sa2, const eScreenDir dir) { + if (!screen_areas_can_align(screen, sa1, sa2, dir)) { +return false; + } + wmWindow *win = CTX_wm_window(C); if (SCREEN_DIR_IS_HORIZONTAL(dir)) { @@ -393,28 +441,20 @@ static void screen_areas_align( screen_verts_halign(win, screen, sa2->v1->vec.x, left); screen_verts_halign(win, screen, sa2->v3->vec.x, right); } + + return true; } /* Simple join of two areas without any splitting. Will return false if not possible. */ static bool screen_area_join_aligned(bContext *C, bScreen *screen, ScrArea *sa1, ScrArea *sa2) { const eScreenDir dir = area_getorientation(sa1, sa2); - if (dir == SCREEN_DIR_NONE) { -return false; - } - - int offset1; - int offset2; - area_getoffsets(sa1, sa2, dir, , ); - int tolerance = SCREEN_DIR_IS_HORIZONTAL(dir) ? AREAJOINTOLERANCEY : AREAJOINTOLERANCEX; - if ((abs(offset1) >= tolerance) || (abs(offset2) >= tolerance)) { + /* Ensure that the area edges are exactly aligned. */ + if (!screen_areas_align(C, screen, sa1, sa2, dir)) { return false; } - /* Align areas if they are not. */ - screen_areas_align(C, screen, sa1, sa2, dir); - if (dir == SCREEN_DIR_W) { /* sa1 to right of sa2 = West. */ sa1->v1 = sa2->v1; /* BL */ sa1->v2 = sa2->v2; /* TL */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [a43053a00a4] master: Improved Korean Font Sample
Commit: a43053a00a49bf02e4e7455f6170381cb13d98c6 Author: Harley Acheson Date: Wed Nov 9 08:51:00 2022 -0800 Branches: master https://developer.blender.org/rBa43053a00a49bf02e4e7455f6170381cb13d98c6 Improved Korean Font Sample Small change to the text sample used for Korean font previews See D16428 for details. Differential Revision: https://developer.blender.org/D16428 Reviewed by Brecht Van Lommel === M source/blender/blenfont/intern/blf_thumbs.c === diff --git a/source/blender/blenfont/intern/blf_thumbs.c b/source/blender/blenfont/intern/blf_thumbs.c index ac2f2f35ca3..8a640ac86a7 100644 --- a/source/blender/blenfont/intern/blf_thumbs.c +++ b/source/blender/blenfont/intern/blf_thumbs.c @@ -46,7 +46,7 @@ typedef struct UnicodeSample { * those need to be checked last. */ static const UnicodeSample unicode_samples[] = { /* Chinese, Japanese, Korean, ordered specific to general. */ -{U"\uc870\uc120\uae00", 2, TT_UCR_HANGUL}, /* 조선글 */ +{U"\ud55c\uad6d\uc5b4", 2, TT_UCR_HANGUL}, /* 한국어 */ {U"\u3042\u30a2\u4e9c", 2, TT_UCR_HIRAGANA}, /* あア亜 */ {U"\u30a2\u30a4\u4e9c", 2, TT_UCR_KATAKANA}, /* アイ亜 */ {U"\u1956\u195b\u1966", 3, TT_UCR_TAI_LE}, /* ᥖᥛᥦ */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [ce68367969c] master: Fix T102140: Replacement of Noto Sans CJK Font
Commit: ce68367969c729c33e6c105bd558452bacba3c11 Author: Harley Acheson Date: Wed Nov 9 08:17:52 2022 -0800 Branches: master https://developer.blender.org/rBce68367969c729c33e6c105bd558452bacba3c11 Fix T102140: Replacement of Noto Sans CJK Font Replace our Noto Sans CJK with a version that has Simplified Chinese set as the default script. See D16426 for details and examples Differential Revision: https://developer.blender.org/D16426 Reviewed by Brecht Van Lommel === M release/datafiles/fonts/Noto Sans CJK Regular.woff2 === diff --git a/release/datafiles/fonts/Noto Sans CJK Regular.woff2 b/release/datafiles/fonts/Noto Sans CJK Regular.woff2 index 5d3854b6bf7..4180a5914fa 100644 Binary files a/release/datafiles/fonts/Noto Sans CJK Regular.woff2 and b/release/datafiles/fonts/Noto Sans CJK Regular.woff2 differ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d01187c9634] blender-v3.4-release: Fix T102140: Replacement of Noto Sans CJK Font
Commit: d01187c9634631b53c932e2a2eed1f2e9e203989 Author: Harley Acheson Date: Wed Nov 9 08:17:52 2022 -0800 Branches: blender-v3.4-release https://developer.blender.org/rBd01187c9634631b53c932e2a2eed1f2e9e203989 Fix T102140: Replacement of Noto Sans CJK Font Replace our Noto Sans CJK with a version that has Simplified Chinese set as the default script. See D16426 for details and examples Differential Revision: https://developer.blender.org/D16426 Reviewed by Brecht Van Lommel === M release/datafiles/fonts/Noto Sans CJK Regular.woff2 === diff --git a/release/datafiles/fonts/Noto Sans CJK Regular.woff2 b/release/datafiles/fonts/Noto Sans CJK Regular.woff2 index 5d3854b6bf7..4180a5914fa 100644 Binary files a/release/datafiles/fonts/Noto Sans CJK Regular.woff2 and b/release/datafiles/fonts/Noto Sans CJK Regular.woff2 differ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [19202736d51] blender-v3.3-release: Fix T99872: Crash Loading Embedded Fonts - 3.3
Commit: 19202736d51679e3669e75e53780e6aeb4924303 Author: Harley Acheson Date: Wed Nov 9 09:27:59 2022 +0100 Branches: blender-v3.3-release https://developer.blender.org/rB19202736d51679e3669e75e53780e6aeb4924303 Fix T99872: Crash Loading Embedded Fonts - 3.3 Ensure kerning cache exists when loading embedded fonts --- When loading embedded fonts from memory the font->kerning_cache is not created and so we get a crash if the font does support kerning. This was not caught because the loading of packed fonts was not actually doing anything in VSE until {523bc981cfee}. We have since consolidated `blf_font_new` and `blf_font_new_from_mem` into a single function so that they cannot get out of sync like this any more. So this fix is specific to Blender 3.3. But we can add this as a candidate for corrective release 3.2.3 Reviewed By: brecht Maniphest Tasks: T99872 Differential Revision: https://developer.blender.org/D15704 === M source/blender/blenfont/intern/blf_font.c === diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 038e73cc928..07d19f307a2 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -1356,13 +1356,24 @@ FontBLF *blf_font_new_from_mem(const char *name, const unsigned char *mem, int m return NULL; } + font->name = BLI_strdup(name); + font->filepath = NULL; + blf_font_fill(font); + if (FT_HAS_MULTIPLE_MASTERS(font->face)) { FT_Get_MM_Var(font->face, &(font->variations)); } - font->name = BLI_strdup(name); - font->filepath = NULL; - blf_font_fill(font); + if (FT_HAS_KERNING(font->face)) { +/* Create kerning cache table and fill with value indicating "unset". */ +font->kerning_cache = MEM_mallocN(sizeof(KerningCacheBLF), __func__); +for (uint i = 0; i < KERNING_CACHE_TABLE_SIZE; i++) { + for (uint j = 0; j < KERNING_CACHE_TABLE_SIZE; j++) { +font->kerning_cache->ascii_table[i][j] = KERNING_ENTRY_UNSET; + } +} + } + return font; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [694481095ba] master: Fix for T101506: BLF Disable Kerning in Main Font
Commit: 694481095baca58d13474aed26ee7619615399b2 Author: Harley Acheson Date: Mon Oct 17 08:35:11 2022 -0700 Branches: master https://developer.blender.org/rB694481095baca58d13474aed26ee7619615399b2 Fix for T101506: BLF Disable Kerning in Main Font Disable kerning in our main font to exactly restore the spacing of text as seen in Blender 3.1 - 3.3 See D16186 for more details. Differential Revision: https://developer.blender.org/D16186 Reviewed by Brecht Van Lommel === M source/blender/blenfont/intern/blf.c === diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index a673f4a1bc7..d4f5be617fd 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -162,6 +162,14 @@ int BLF_load_unique(const char *name) } FontBLF *font = blf_font_new(name, filepath); + + /* XXX: Temporarily disable kerning in our main font. Kerning had been accidentally removed from + * our font in 3.1. In 3.4 we disable kerning here in the new version to keep spacing the same + * (T101506). Enable again later with change of font, placement, or rendering - Harley. */ + if (font && BLI_str_endswith(filepath, BLF_DEFAULT_PROPORTIONAL_FONT)) { +font->face_flags &= ~FT_FACE_FLAG_KERNING; + } + MEM_freeN(filepath); if (!font) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [104fd82f742] master: Fix for T101481: Improved VFont Loading
Commit: 104fd82f74281471d69e61d06de44fca8fdf269c Author: Harley Acheson Date: Thu Oct 6 18:02:40 2022 -0700 Branches: master https://developer.blender.org/rB104fd82f74281471d69e61d06de44fca8fdf269c Fix for T101481: Improved VFont Loading Remove redundancy in the testing and loading of VFont fonts. Includes improved setting of character map for using Wingding and Symbol fonts. See D16174 for more details. Differential Revision: https://developer.blender.org/D16174 Reviewed by Campbell Barton === M source/blender/blenkernel/intern/vfontdata_freetype.c === diff --git a/source/blender/blenkernel/intern/vfontdata_freetype.c b/source/blender/blenkernel/intern/vfontdata_freetype.c index 91ca3100f8c..37e85e70bdb 100644 --- a/source/blender/blenkernel/intern/vfontdata_freetype.c +++ b/source/blender/blenkernel/intern/vfontdata_freetype.c @@ -266,30 +266,22 @@ static VChar *objchr_to_ftvfontdata(VFont *vfont, FT_ULong charcode) return che; } -static VFontData *objfnt_to_ftvfontdata(PackedFile *pf) +static FT_Face vfont_face_load_from_packed_file(PackedFile *pf) { - /* Variables */ - FT_Face face; - VFontData *vfd; - - /* load the freetype font */ - err = FT_New_Memory_Face(library, pf->data, pf->size, 0, ); - - if (err) { + FT_Face face = NULL; + FT_New_Memory_Face(library, pf->data, pf->size, 0, ); + if (!face) { return NULL; } - /* allocate blender font */ - vfd = MEM_callocN(sizeof(*vfd), "FTVFontData"); - - /* Get the name. */ - if (face->family_name) { -BLI_snprintf(vfd->name, sizeof(vfd->name), "%s %s", face->family_name, face->style_name); -BLI_str_utf8_invalid_strip(vfd->name, strlen(vfd->name)); + /* Font must contain vectors, not bitmaps. */ + if (!(face->face_flags & FT_FACE_FLAG_SCALABLE)) { +FT_Done_Face(face); +return NULL; } /* Select a character map. */ - err = FT_Select_Charmap(face, FT_ENCODING_UNICODE); + FT_Error err = FT_Select_Charmap(face, FT_ENCODING_UNICODE); if (err) { err = FT_Select_Charmap(face, FT_ENCODING_APPLE_ROMAN); } @@ -298,10 +290,42 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf) } if (err) { FT_Done_Face(face); -MEM_freeN(vfd); return NULL; } + /* Test that we can load glyphs from this font. */ + FT_UInt glyph_index = 0; + FT_Get_First_Char(face, _index); + if (!glyph_index || + FT_Load_Glyph(face, glyph_index, FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP) != FT_Err_Ok) { +FT_Done_Face(face); +return NULL; + } + + return face; +} + +VFontData *BKE_vfontdata_from_freetypefont(PackedFile *pf) +{ + if (FT_Init_FreeType() != FT_Err_Ok) { +return NULL; + } + + FT_Face face = vfont_face_load_from_packed_file(pf); + if (!face) { +FT_Done_FreeType(library); +return NULL; + } + + /* allocate blender font */ + VFontData *vfd = MEM_callocN(sizeof(*vfd), "FTVFontData"); + + /* Get the name. */ + if (face->family_name) { +BLI_snprintf(vfd->name, sizeof(vfd->name), "%s %s", face->family_name, face->style_name); +BLI_str_utf8_invalid_strip(vfd->name, strlen(vfd->name)); + } + /* Blender default BFont is not "complete". */ const bool complete_font = (face->ascender != 0) && (face->descender != 0) && (face->ascender != face->descender); @@ -344,50 +368,6 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf) freetypechar_to_vchar(face, charcode, vfd); } - return vfd; -} - -static bool check_freetypefont(PackedFile *pf) -{ - FT_Face face = NULL; - FT_UInt glyph_index = 0; - bool success = false; - - err = FT_New_Memory_Face(library, pf->data, pf->size, 0, ); - if (err) { -return false; -// XXX error("This is not a valid font"); - } - - FT_Get_First_Char(face, _index); - if (glyph_index) { -err = FT_Load_Glyph(face, glyph_index, FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP); -if (!err) { - success = (face->glyph->format == ft_glyph_format_outline); -} - } - - FT_Done_Face(face); - - return success; -} - -VFontData *BKE_vfontdata_from_freetypefont(PackedFile *pf) -{ - VFontData *vfd = NULL; - - /* init Freetype */ - err = FT_Init_FreeType(); - if (err) { -/* XXX error("Failed to load the Freetype font library"); */ -return NULL; - } - - if (check_freetypefont(pf)) { -vfd = objfnt_to_ftvfontdata(pf); - } - - /* free Freetype */ FT_Done_FreeType(library); return vfd; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [be8ee05dcba] master: Fix for T53332: BFont 43 Inaccessible Glyphs
Commit: be8ee05dcba6987fd4098cc61d414b0b8cef4b3e Author: Harley Acheson Date: Thu Oct 6 10:35:36 2022 -0700 Branches: master https://developer.blender.org/rBbe8ee05dcba6987fd4098cc61d414b0b8cef4b3e Fix for T53332: BFont 43 Inaccessible Glyphs Preloading of BFont (default for 3D Text Objects) glyphs will not load any with a character code greater than 256, resulting in 43 characters that are inaccessible. This patch corrects that preloading code. See D16122 for more details Differential Revision: https://developer.blender.org/D16122 Reviewed by Campbell Barton === M source/blender/blenkernel/intern/vfontdata_freetype.c === diff --git a/source/blender/blenkernel/intern/vfontdata_freetype.c b/source/blender/blenkernel/intern/vfontdata_freetype.c index 30e5f29e6a8..91ca3100f8c 100644 --- a/source/blender/blenkernel/intern/vfontdata_freetype.c +++ b/source/blender/blenkernel/intern/vfontdata_freetype.c @@ -270,9 +270,6 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf) { /* Variables */ FT_Face face; - const FT_ULong charcode_reserve = 256; - FT_ULong charcode = 0, lcode; - FT_UInt glyph_index; VFontData *vfd; /* load the freetype font */ @@ -305,9 +302,6 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf) return NULL; } - /* Extract the first 256 character from TTF */ - lcode = charcode = FT_Get_First_Char(face, _index); - /* Blender default BFont is not "complete". */ const bool complete_font = (face->ascender != 0) && (face->descender != 0) && (face->ascender != face->descender); @@ -335,21 +329,19 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf) vfd->scale = 1.0f / 1000.0f; } - /* Load characters */ - vfd->characters = BLI_ghash_int_new_ex(__func__, charcode_reserve); + /* Load the first 256 glyphs. */ - while (charcode < charcode_reserve) { -/* Generate the font data */ -freetypechar_to_vchar(face, charcode, vfd); + const FT_ULong preload_count = 256; + vfd->characters = BLI_ghash_int_new_ex(__func__, preload_count); -/* Next glyph */ + FT_ULong charcode = 0; + FT_UInt glyph_index; + for (int i = 0; i < preload_count; i++) { charcode = FT_Get_Next_Char(face, charcode, _index); - -/* Check that we won't start infinite loop */ -if (charcode <= lcode) { +if (!charcode || !glyph_index) { break; } -lcode = charcode; +freetypechar_to_vchar(face, charcode, vfd); } return vfd; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [12fdf9069ab] master: BLF: Editing Text with Combining Characters
Commit: 12fdf9069abe3cd2250a9efec6e059eb85ec59d8 Author: Harley Acheson Date: Tue Sep 27 08:39:24 2022 -0700 Branches: master https://developer.blender.org/rB12fdf9069abe3cd2250a9efec6e059eb85ec59d8 BLF: Editing Text with Combining Characters Corrections for caret insertion & movement and deletion for text strings that include non-precomposed diacritical marks (Unicode combining characters). See D15659 for more details and examples. Differential Revision: https://developer.blender.org/D15659 Reviewed by Campbell Barton === M source/blender/blenfont/intern/blf_font.c M source/blender/blenkernel/intern/text.c M source/blender/blenlib/BLI_string_cursor_utf8.h M source/blender/blenlib/intern/string_cursor_utf8.c M source/blender/blenlib/tests/BLI_string_utf8_test.cc M source/blender/editors/curve/editfont.c === diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index cbf656289b5..2ee8cf088aa 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -33,6 +33,7 @@ #include "BLI_path_util.h" #include "BLI_rect.h" #include "BLI_string.h" +#include "BLI_string_cursor_utf8.h" #include "BLI_string_utf8.h" #include "BLI_threads.h" @@ -973,9 +974,16 @@ size_t blf_str_offset_from_cursor_position(struct FontBLF *font, .r_offset = (size_t)-1, }; blf_font_boundbox_foreach_glyph(font, str, str_len, blf_cursor_position_foreach_glyph, ); + if (data.r_offset == (size_t)-1) { +/* We are to the right of the string, so return position of null terminator. */ data.r_offset = BLI_strnlen(str, str_len); } + else if (BLI_str_utf8_char_width([data.r_offset]) < 1) { +/* This is a combining character (or invalid), so move to previous visible valid char. */ +BLI_str_cursor_step_prev_utf8(str, str_len, (int *)_offset); + } + return data.r_offset; } diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index c32ab64c478..1a0c0716fcd 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -896,8 +896,7 @@ void txt_move_left(Text *text, const bool sel) (*charp) -= tabsize; } else { - const char *prev = BLI_str_find_prev_char_utf8((*linep)->line + *charp, (*linep)->line); - *charp = prev - (*linep)->line; + BLI_str_cursor_step_prev_utf8((*linep)->line, (*linep)->len, charp); } } @@ -941,7 +940,7 @@ void txt_move_right(Text *text, const bool sel) (*charp) += tabsize; } else { - (*charp) += BLI_str_utf8_size((*linep)->line + *charp); + BLI_str_cursor_step_next_utf8((*linep)->line, (*linep)->len, charp); } } @@ -1757,8 +1756,6 @@ void txt_duplicate_line(Text *text) void txt_delete_char(Text *text) { - uint c = '\n'; - if (!text->curl) { return; } @@ -1778,10 +1775,9 @@ void txt_delete_char(Text *text) } } else { /* Just deleting a char */ -size_t c_len = text->curc; -c = BLI_str_utf8_as_unicode_step(text->curl->line, text->curl->len, _len); -c_len -= text->curc; -UNUSED_VARS(c); +int pos = text->curc; +BLI_str_cursor_step_next_utf8(text->curl->line, text->curl->len, ); +size_t c_len = pos - text->curc; memmove(text->curl->line + text->curc, text->curl->line + text->curc + c_len, @@ -1805,8 +1801,6 @@ void txt_delete_word(Text *text) void txt_backspace_char(Text *text) { - uint c = '\n'; - if (!text->curl) { return; } @@ -1828,13 +1822,9 @@ void txt_backspace_char(Text *text) txt_pop_sel(text); } else { /* Just backspacing a char */ -const char *prev = BLI_str_find_prev_char_utf8(text->curl->line + text->curc, - text->curl->line); -size_t c_len = prev - text->curl->line; -c = BLI_str_utf8_as_unicode_step(text->curl->line, text->curl->len, _len); -c_len -= prev - text->curl->line; - -UNUSED_VARS(c); +int pos = text->curc; +BLI_str_cursor_step_prev_utf8(text->curl->line, text->curl->len, ); +size_t c_len = text->curc - pos; /* source and destination overlap, don't use memcpy() */ memmove(text->curl->line + text->curc - c_len, diff --git a/source/blender/blenlib/BLI_string_cursor_utf8.h b/source/blender/blenlib/BLI_string_cursor_utf8.h index 70ba5da8e5a..9c0589b230a 100644 --- a/source/blender/blenlib/BLI_string_cursor_utf8.h +++ b/source/blender/blenlib/BLI_string_cursor_utf8.h @@ -25,6 +25,9 @@ typedef enum eStrCursorJumpDirection { bool BLI_str_curso
[Bf-blender-cvs] [b3714b1e85f] master: BLF: Refactor of blf_font_boundbox_foreach_glyph
Commit: b3714b1e85fd81d4f7db3c562483232fd6a89807 Author: Harley Acheson Date: Sun Sep 25 11:25:31 2022 -0700 Branches: master https://developer.blender.org/rBb3714b1e85fd81d4f7db3c562483232fd6a89807 BLF: Refactor of blf_font_boundbox_foreach_glyph Refactor of `BLF_boundbox_foreach_glyph` and simplification of its usage by only passing translated glyph bounds to callbacks. See D15765 for more details. Differential Revision: https://developer.blender.org/D15765 Reviewed by Campbell Barton === M source/blender/blenfont/BLF_api.h M source/blender/blenfont/intern/blf.c M source/blender/blenfont/intern/blf_font.c M source/blender/blenfont/intern/blf_internal.h M source/blender/editors/interface/interface_handlers.c M source/blender/editors/interface/interface_widgets.c === diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h index af2e4fd1784..01b6d1d8942 100644 --- a/source/blender/blenfont/BLF_api.h +++ b/source/blender/blenfont/BLF_api.h @@ -118,10 +118,7 @@ int BLF_draw_mono(int fontid, const char *str, size_t str_len, int cwidth) ATTR_ typedef bool (*BLF_GlyphBoundsFn)(const char *str, size_t str_step_ofs, - const struct rcti *glyph_step_bounds, - int glyph_advance_x, - const struct rcti *glyph_bounds, - const int glyph_bearing[2], + const struct rcti *bounds, void *user_data); /** @@ -132,18 +129,28 @@ typedef bool (*BLF_GlyphBoundsFn)(const char *str, * * \note The font position, clipping, matrix and rotation are not applied. */ -void BLF_boundbox_foreach_glyph_ex(int fontid, - const char *str, - size_t str_len, - BLF_GlyphBoundsFn user_fn, - void *user_data, - struct ResultBLF *r_info) ATTR_NONNULL(2); void BLF_boundbox_foreach_glyph(int fontid, const char *str, size_t str_len, BLF_GlyphBoundsFn user_fn, void *user_data) ATTR_NONNULL(2); +/** + * Get the byte offset within a string, selected by mouse at a horizontal location. + */ +size_t BLF_str_offset_from_cursor_position(int fontid, + const char *str, + size_t str_len, + int location_x); + +/** + * Return bounds of the glyph rect at the string offset. + */ +bool BLF_str_offset_to_glyph_bounds(int fontid, +const char *str, +size_t str_offset, +struct rcti *glyph_bounds); + /** * Get the string byte offset that fits within a given width. */ diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index df8a9734c9a..57c1e280e8d 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -563,32 +563,45 @@ int BLF_draw_mono(int fontid, const char *str, const size_t str_len, int cwidth) return columns; } -void BLF_boundbox_foreach_glyph_ex(int fontid, - const char *str, - size_t str_len, - BLF_GlyphBoundsFn user_fn, - void *user_data, - struct ResultBLF *r_info) +void BLF_boundbox_foreach_glyph( +int fontid, const char *str, size_t str_len, BLF_GlyphBoundsFn user_fn, void *user_data) { FontBLF *font = blf_get(fontid); - BLF_RESULT_CHECK_INIT(r_info); - if (font) { if (font->flags & BLF_WORD_WRAP) { /* TODO: word-wrap support. */ BLI_assert(0); } else { - blf_font_boundbox_foreach_glyph(font, str, str_len, user_fn, user_data, r_info); + blf_font_boundbox_foreach_glyph(font, str, str_len, user_fn, user_data); } } } -void BLF_boundbox_foreach_glyph( -int fontid, const char *str, const size_t str_len, BLF_GlyphBoundsFn user_fn, void *user_data) +size_t BLF_str_offset_from_cursor_position(int fontid, + const char *str, + size_t str_len, + int location_x) { - BLF_boundbox_foreach_glyph_ex(fontid, str, str_len, user_fn, user_data, NULL); + FontBLF *font = blf_get(fontid); + if (font) { +return blf_str_offset_from_cursor_position(fo
[Bf-blender-cvs] [4e7983e0732] master: UI: Improved Font Thumbnails
Commit: 4e7983e0732015d9fe52ecd12e203a230b30af16 Author: Harley Acheson Date: Sat Sep 24 10:55:46 2022 -0700 Branches: master https://developer.blender.org/rB4e7983e0732015d9fe52ecd12e203a230b30af16 UI: Improved Font Thumbnails Thumbnails of fonts that better show design, shapes, contents, intent, and intended language. Previews almost every known language - living and dead - and symbol, specialty fonts, etc. See D12032 for more details and samples. Differential Revision: https://developer.blender.org/D12032 Reviewed by Campbell Barton === M source/blender/blenfont/BLF_api.h M source/blender/blenfont/intern/blf_font.c M source/blender/blenfont/intern/blf_internal.h M source/blender/blenfont/intern/blf_thumbs.c M source/blender/blentranslation/intern/blt_lang.c M source/blender/editors/space_file/filelist.cc M source/blender/imbuf/IMB_thumbs.h M source/blender/imbuf/intern/thumbs_font.c M source/blender/windowmanager/intern/wm_init_exit.c === diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h index 992107a30e9..af2e4fd1784 100644 --- a/source/blender/blenfont/BLF_api.h +++ b/source/blender/blenfont/BLF_api.h @@ -290,16 +290,8 @@ void BLF_dir_free(char **dirs, int count) ATTR_NONNULL(); * * \note called from a thread, so it bypasses the normal BLF_* api (which isn't thread-safe). */ -void BLF_thumb_preview(const char *filepath, - const char **draw_str, - const char **i18n_draw_str, - unsigned char draw_str_lines, - const float font_color[4], - int font_size, - unsigned char *buf, - int w, - int h, - int channels) ATTR_NONNULL(); +bool BLF_thumb_preview(const char *filename, unsigned char *buf, int w, int h, int channels) +ATTR_NONNULL(); /* blf_default.c */ diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 3d7e83bc22f..9ea7e529df2 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -1145,38 +1145,6 @@ void blf_font_draw_buffer__wrap(FontBLF *font, /** \} */ -/* */ -/** \name Text Evaluation: Count Missing Characters - * \{ */ - -int blf_font_count_missing_chars(FontBLF *font, - const char *str, - const size_t str_len, - int *r_tot_chars) -{ - int missing = 0; - size_t i = 0; - - *r_tot_chars = 0; - while (i < str_len) { -uint c; - -if ((c = str[i]) < GLYPH_ASCII_TABLE_SIZE) { - i++; -} -else { - c = BLI_str_utf8_as_unicode_step(str, str_len, ); - if (blf_get_char_index(font, c) == 0) { -missing++; - } -} -(*r_tot_chars)++; - } - return missing; -} - -/** \} */ - /* */ /** \name Font Query: Attributes * \{ */ diff --git a/source/blender/blenfont/intern/blf_internal.h b/source/blender/blenfont/intern/blf_internal.h index e1001cfc1ba..28f433a3018 100644 --- a/source/blender/blenfont/intern/blf_internal.h +++ b/source/blender/blenfont/intern/blf_internal.h @@ -149,11 +149,6 @@ void blf_font_boundbox_foreach_glyph(struct FontBLF *font, void *user_data, struct ResultBLF *r_info); -int blf_font_count_missing_chars(struct FontBLF *font, - const char *str, - size_t str_len, - int *r_tot_chars); - void blf_font_free(struct FontBLF *font); struct GlyphCacheBLF *blf_glyph_cache_acquire(struct FontBLF *font); diff --git a/source/blender/blenfont/intern/blf_thumbs.c b/source/blender/blenfont/intern/blf_thumbs.c index cba4bb96f73..8ad880edf30 100644 --- a/source/blender/blenfont/intern/blf_thumbs.c +++ b/source/blender/blenfont/intern/blf_thumbs.c @@ -8,16 +8,20 @@ * Isolate since this needs to be called by #ImBuf code (bad level call). */ -#include #include -#include #include #include FT_FREETYPE_H +#include FT_ADVANCES_H/* For FT_Get_Advance */ +#include FT_TRUETYPE_IDS_H/* Codepoint coverage constants. */ +#include FT_TRUETYPE_TABLES_H /* For TT_OS2 */ #include "BLI_listbase.h" +#include "BLI_math_bits.h" #include "BLI_rect.h" +#include "BLI_string.h" +#include "BLI_string_utf8.h" #include "BLI_threads.h" #include "BLI_utildefines.h" @@ -25,89 +29,378 @@ #include "blf_internal_types.h"
[Bf-blender-cvs] [72933ebe96a] master: BLF: Correctly Set Default Font Size
Commit: 72933ebe96a02e96c9740e33d0a3e44d5b6365f1 Author: Harley Acheson Date: Sat Sep 24 08:23:36 2022 -0700 Branches: master https://developer.blender.org/rB72933ebe96a02e96c9740e33d0a3e44d5b6365f1 BLF: Correctly Set Default Font Size Commit cd1631b17dd0 fails to scale the global_font_size by UI scale in BLF_set_default. Generally used for simple text output like statistics. See D16053 for more details. Differential Revision: https://developer.blender.org/D16053 Own Code === M source/blender/blenfont/intern/blf_default.c === diff --git a/source/blender/blenfont/intern/blf_default.c b/source/blender/blenfont/intern/blf_default.c index a521d65fe30..738683284e3 100644 --- a/source/blender/blenfont/intern/blf_default.c +++ b/source/blender/blenfont/intern/blf_default.c @@ -45,7 +45,7 @@ int BLF_set_default(void) { ASSERT_DEFAULT_SET; - BLF_size(global_font_default, global_font_size); + BLF_size(global_font_default, global_font_size * U.dpi_fac); return global_font_default; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [cd1631b17dd] master: BLF: Refactor of DPI
Commit: cd1631b17dd0e25a8a398fb00a982ca5f0633558 Author: Harley Acheson Date: Fri Sep 23 17:36:49 2022 -0700 Branches: master https://developer.blender.org/rBcd1631b17dd0e25a8a398fb00a982ca5f0633558 BLF: Refactor of DPI Correction of U.dpi to hold actual monitor DPI. Simplify font sizing by omitting DPI as API argument, always using 72 internally. See D15961 for more details. Differential Revision: https://developer.blender.org/D15961 Reviewed by Campbell Barton === M source/blender/blenfont/BLF_api.h M source/blender/blenfont/intern/blf.c M source/blender/blenfont/intern/blf_default.c M source/blender/blenfont/intern/blf_font.c M source/blender/blenfont/intern/blf_glyph.c M source/blender/blenfont/intern/blf_internal.h M source/blender/blenfont/intern/blf_internal_types.h M source/blender/blenfont/intern/blf_thumbs.c M source/blender/blenkernel/intern/image.cc M source/blender/blenkernel/intern/image_gen.c M source/blender/draw/intern/draw_manager_text.c M source/blender/editors/interface/interface_icons_event.c M source/blender/editors/interface/interface_panel.cc M source/blender/editors/interface/interface_region_tooltip.cc M source/blender/editors/interface/interface_style.cc M source/blender/editors/mesh/editmesh_bevel.c M source/blender/editors/mesh/editmesh_knife.c M source/blender/editors/object/object_remesh.cc M source/blender/editors/screen/area.c M source/blender/editors/space_clip/clip_dopesheet_draw.c M source/blender/editors/space_clip/clip_draw.c M source/blender/editors/space_image/image_draw.c M source/blender/editors/space_info/textview.c M source/blender/editors/space_node/node_draw.cc M source/blender/editors/space_spreadsheet/space_spreadsheet.cc M source/blender/editors/space_text/text_draw.c M source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c M source/blender/editors/space_view3d/view3d_gizmo_ruler.c M source/blender/editors/util/ed_draw.c M source/blender/python/generic/blf_py_api.c M source/blender/sequencer/intern/effects.c M source/blender/windowmanager/intern/wm_operators.c M source/blender/windowmanager/intern/wm_playanim.c M source/blender/windowmanager/intern/wm_window.c === diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h index d3226a8f609..992107a30e9 100644 --- a/source/blender/blenfont/BLF_api.h +++ b/source/blender/blenfont/BLF_api.h @@ -69,7 +69,7 @@ void BLF_metrics_attach(int fontid, unsigned char *mem, int mem_size); void BLF_aspect(int fontid, float x, float y, float z); void BLF_position(int fontid, float x, float y, float z); -void BLF_size(int fontid, float size, int dpi); +void BLF_size(int fontid, float size); /* Goal: small but useful color API. */ @@ -303,7 +303,6 @@ void BLF_thumb_preview(const char *filepath, /* blf_default.c */ -void BLF_default_dpi(int dpi); void BLF_default_size(float size); void BLF_default_set(int fontid); /** diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index 9d9cc51ebcc..4e904768f79 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -63,8 +63,6 @@ int BLF_init(void) global_font[i] = NULL; } - BLF_default_dpi(72); - return blf_font_init(); } @@ -361,12 +359,12 @@ void BLF_position(int fontid, float x, float y, float z) } } -void BLF_size(int fontid, float size, int dpi) +void BLF_size(int fontid, float size) { FontBLF *font = blf_get(fontid); if (font) { -blf_font_size(font, size, dpi); +blf_font_size(font, size); } } @@ -912,7 +910,6 @@ void BLF_state_print(int fontid) printf("fontid %d %p\n", fontid, (void *)font); printf(" name:'%s'\n", font->name); printf(" size: %f\n", font->size); -printf(" dpi: %u\n", font->dpi); printf(" pos: %d %d %d\n", UNPACK3(font->pos)); printf(" aspect: (%d) %.6f %.6f %.6f\n", (font->flags & BLF_ROTATION) != 0, diff --git a/source/blender/blenfont/intern/blf_default.c b/source/blender/blenfont/intern/blf_default.c index a1f1b84636f..a521d65fe30 100644 --- a/source/blender/blenfont/intern/blf_default.c +++ b/source/blender/blenfont/intern/blf_default.c @@ -20,15 +20,9 @@ /* Default size and dpi, for BLF_draw_default. */ static int global_font_default = -1; -static int global_font_dpi = 72; /* Keep in sync with `UI_DEFAULT_TEXT_POINTS` */ static float global_font_size = 11.0f; -void BLF_default_dpi(int dpi) -{ - global_font_dpi = dpi; -} - void BLF_default_size(float size) { global_font_size = size; @@ -
[Bf-blender-cvs] [ff27b68f41c] master: Fix T101295: Allow Large Windows Thumbnails
Commit: ff27b68f41ce511e162d6e561103c522d9507a5f Author: Harley Acheson Date: Fri Sep 23 14:49:36 2022 -0700 Branches: master https://developer.blender.org/rBff27b68f41ce511e162d6e561103c522d9507a5f Fix T101295: Allow Large Windows Thumbnails Allow our Windows Thumbnail Handler to supply thumbnails up to the maximum 256x256 size. Differential Revision: https://developer.blender.org/D16051 Reviewed by Ray Molenkamp === M source/blender/blendthumb/src/blendthumb_win32.cc === diff --git a/source/blender/blendthumb/src/blendthumb_win32.cc b/source/blender/blendthumb/src/blendthumb_win32.cc index 287710934e2..2acc8f20a12 100644 --- a/source/blender/blendthumb/src/blendthumb_win32.cc +++ b/source/blender/blendthumb/src/blendthumb_win32.cc @@ -171,8 +171,8 @@ IFACEMETHODIMP CBlendThumb::GetThumbnail(UINT cx, HBITMAP *phbmp, WTS_ALPHATYPE } *pdwAlpha = WTSAT_ARGB; - /* Scale down the thumbnail if required. */ - if ((unsigned)thumb.width > cx || (unsigned)thumb.height > cx) { + /* Scale up the thumbnail if required. */ + if ((unsigned)thumb.width < cx && (unsigned)thumb.height < cx) { float scale = 1.0f / (std::max(thumb.width, thumb.height) / (float)cx); LONG NewWidth = (LONG)(thumb.width * scale); LONG NewHeight = (LONG)(thumb.height * scale); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d5554cdc7c9] master: Fix T100741: Update FFMPEG Dimensions
Commit: d5554cdc7c900880571c4265c9f3f7a7cfec6071 Author: Harley Acheson Date: Fri Sep 23 10:49:01 2022 -0700 Branches: master https://developer.blender.org/rBd5554cdc7c900880571c4265c9f3f7a7cfec6071 Fix T100741: Update FFMPEG Dimensions Update the animation's dimensions within ffmpeg_fetchibuf in case it has changed because of dynamic resolution (possible with WebM). Differential Revision: https://developer.blender.org/D15842 Reviewed by Richard Antalik === M source/blender/imbuf/intern/anim_movie.c === diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c index 4e6a52f8464..36ebe2b7cff 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.c @@ -1406,6 +1406,10 @@ static ImBuf *ffmpeg_fetchibuf(struct anim *anim, int position, IMB_Timecode_Typ ffmpeg_decode_video_frame_scan(anim, pts_to_search); + /* Update resolution as it can change per-frame with WebM. See T100741 & T100081. */ + anim->x = anim->pCodecCtx->width; + anim->y = anim->pCodecCtx->height; + IMB_freeImBuf(anim->cur_frame_final); /* Certain versions of FFmpeg have a bug in libswscale which ends up in crash ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [1a485489800] master: BLF: Incorrect Define Used
Commit: 1a4854898000661dd7cf57492a7a75cb60ea63ef Author: Harley Acheson Date: Wed Sep 14 09:56:50 2022 -0700 Branches: master https://developer.blender.org/rB1a4854898000661dd7cf57492a7a75cb60ea63ef BLF: Incorrect Define Used Replace incorrect usage of GLYPH_ASCII_TABLE_SIZE with correct KERNING_CACHE_TABLE_SIZE See D15815 for more details. Differential Revision: https://developer.blender.org/D15815 Own Code. === M source/blender/blenfont/intern/blf_font.c === diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index b96c01e704d..eaea88be9ae 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -377,7 +377,7 @@ BLI_INLINE ft_pix blf_kerning(FontBLF *font, const GlyphBLF *g_prev, const Glyph FT_Vector delta = {KERNING_ENTRY_UNSET}; /* Get unscaled kerning value from our cache if ASCII. */ -if ((g_prev->c < KERNING_CACHE_TABLE_SIZE) && (g->c < GLYPH_ASCII_TABLE_SIZE)) { +if ((g_prev->c < KERNING_CACHE_TABLE_SIZE) && (g->c < KERNING_CACHE_TABLE_SIZE)) { delta.x = font->kerning_cache->ascii_table[g->c][g_prev->c]; } @@ -388,7 +388,7 @@ BLI_INLINE ft_pix blf_kerning(FontBLF *font, const GlyphBLF *g_prev, const Glyph } /* If ASCII we save this value to our cache for quicker access next time. */ -if ((g_prev->c < KERNING_CACHE_TABLE_SIZE) && (g->c < GLYPH_ASCII_TABLE_SIZE)) { +if ((g_prev->c < KERNING_CACHE_TABLE_SIZE) && (g->c < KERNING_CACHE_TABLE_SIZE)) { font->kerning_cache->ascii_table[g->c][g_prev->c] = (int)delta.x; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [28c9b338708] master: IMBUF: Fix WebP Build Error and Warnings
Commit: 28c9b338708027f71fe56834e87048309313b4d3 Author: Harley Acheson Date: Mon Sep 12 17:27:02 2022 -0700 Branches: master https://developer.blender.org/rB28c9b338708027f71fe56834e87048309313b4d3 IMBUF: Fix WebP Build Error and Warnings Fix error and warnings introduced in commit 8851790dd733. Include unistd.h for close() on Non-Windows OSs. Calm warnings about unused argument. Return full size of image file to caller. Own Code. === M source/blender/imbuf/intern/webp.c === diff --git a/source/blender/imbuf/intern/webp.c b/source/blender/imbuf/intern/webp.c index 40be072177e..94c8e3fb61d 100644 --- a/source/blender/imbuf/intern/webp.c +++ b/source/blender/imbuf/intern/webp.c @@ -6,6 +6,8 @@ #ifdef _WIN32 # include +#else +# include #endif #include @@ -75,7 +77,7 @@ ImBuf *imb_loadwebp(const unsigned char *mem, } struct ImBuf *imb_load_filepath_thumbnail_webp(const char *filepath, - const int flags, + const int UNUSED(flags), const size_t max_thumb_size, char colorspace[], size_t *r_width, @@ -108,6 +110,10 @@ struct ImBuf *imb_load_filepath_thumbnail_webp(const char *filepath, return NULL; } + /* Return full size of the image. */ + *r_width = (size_t)config.input.width; + *r_height = (size_t)config.input.height; + const float scale = (float)max_thumb_size / MAX2(config.input.width, config.input.height); const int dest_w = (int)(config.input.width * scale); const int dest_h = (int)(config.input.height * scale); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [8851790dd73] master: IMBUF: Improved Thumbnailing of WebP Images
Commit: 8851790dd733e49b8be96c978e155a5411007410 Author: Harley Acheson Date: Mon Sep 12 15:41:56 2022 -0700 Branches: master https://developer.blender.org/rB8851790dd733e49b8be96c978e155a5411007410 IMBUF: Improved Thumbnailing of WebP Images Thumbnail WebP images quicker while using much less RAM. See D15908 for more details. Differential Revision: https://developer.blender.org/D15908 Reviewed by Brecht Van Lommel === M source/blender/imbuf/intern/IMB_filetype.h M source/blender/imbuf/intern/filetype.c M source/blender/imbuf/intern/webp.c === diff --git a/source/blender/imbuf/intern/IMB_filetype.h b/source/blender/imbuf/intern/IMB_filetype.h index 9a0a6998fab..bd17316d173 100644 --- a/source/blender/imbuf/intern/IMB_filetype.h +++ b/source/blender/imbuf/intern/IMB_filetype.h @@ -264,6 +264,12 @@ struct ImBuf *imb_loadwebp(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]); +struct ImBuf *imb_load_filepath_thumbnail_webp(const char *filepath, + const int flags, + const size_t max_thumb_size, + char colorspace[], + size_t *r_width, + size_t *r_height); bool imb_savewebp(struct ImBuf *ibuf, const char *name, int flags); /** \} */ diff --git a/source/blender/imbuf/intern/filetype.c b/source/blender/imbuf/intern/filetype.c index 92fa980cd7f..e1d2bea4ae9 100644 --- a/source/blender/imbuf/intern/filetype.c +++ b/source/blender/imbuf/intern/filetype.c @@ -217,7 +217,7 @@ const ImFileType IMB_FILE_TYPES[] = { .is_a = imb_is_a_webp, .load = imb_loadwebp, .load_filepath = NULL, -.load_filepath_thumbnail = NULL, +.load_filepath_thumbnail = imb_load_filepath_thumbnail_webp, .save = imb_savewebp, .load_tile = NULL, .flag = 0, diff --git a/source/blender/imbuf/intern/webp.c b/source/blender/imbuf/intern/webp.c index 19fe2373ea0..40be072177e 100644 --- a/source/blender/imbuf/intern/webp.c +++ b/source/blender/imbuf/intern/webp.c @@ -4,14 +4,21 @@ * \ingroup imbuf */ +#ifdef _WIN32 +# include +#endif + +#include #include #include #include #include #include "BLI_fileops.h" +#include "BLI_mmap.h" #include "BLI_utildefines.h" +#include "IMB_allocimbuf.h" #include "IMB_colormanagement.h" #include "IMB_colormanagement_intern.h" #include "IMB_filetype.h" @@ -67,6 +74,85 @@ ImBuf *imb_loadwebp(const unsigned char *mem, return ibuf; } +struct ImBuf *imb_load_filepath_thumbnail_webp(const char *filepath, + const int flags, + const size_t max_thumb_size, + char colorspace[], + size_t *r_width, + size_t *r_height) +{ + const int file = BLI_open(filepath, O_BINARY | O_RDONLY, 0); + if (file == -1) { +return NULL; + } + + const size_t data_size = BLI_file_descriptor_size(file); + + imb_mmap_lock(); + BLI_mmap_file *mmap_file = BLI_mmap_open(file); + imb_mmap_unlock(); + close(file); + if (mmap_file == NULL) { +return NULL; + } + + const unsigned char *data = BLI_mmap_get_pointer(mmap_file); + + WebPDecoderConfig config; + if (!data || !WebPInitDecoderConfig() || + WebPGetFeatures(data, data_size, ) != VP8_STATUS_OK) { +fprintf(stderr, "WebP: Invalid file\n"); +imb_mmap_lock(); +BLI_mmap_free(mmap_file); +imb_mmap_unlock(); +return NULL; + } + + const float scale = (float)max_thumb_size / MAX2(config.input.width, config.input.height); + const int dest_w = (int)(config.input.width * scale); + const int dest_h = (int)(config.input.height * scale); + + colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE); + struct ImBuf *ibuf = IMB_allocImBuf(dest_w, dest_h, 32, IB_rect); + if (ibuf == NULL) { +fprintf(stderr, "WebP: Failed to allocate image memory\n"); +imb_mmap_lock(); +BLI_mmap_free(mmap_file); +imb_mmap_unlock(); +return NULL; + } + + config.options.no_fancy_upsampling = 1; + config.options.use_scaling = 1; + config.options.scaled_width = dest_w; + config.options.scaled_height = dest_h; + config.options.bypass_filtering = 1; + config.options.use_threads = 0; + config.options.flip = 1; + config.output.is_external_memory = 1; + config.output.colorspace = MODE_RGBA; + config.output.u.RGBA.rgba = (uint8_t *)ibuf-&
[Bf-blender-cvs] [e53405bf15a] master: UI: Small Adjustments to Event Icons
Commit: e53405bf15aa6d386e83ce6daa5b6248690122c9 Author: Harley Acheson Date: Wed Sep 7 08:05:04 2022 -0700 Branches: master https://developer.blender.org/rBe53405bf15aa6d386e83ce6daa5b6248690122c9 UI: Small Adjustments to Event Icons Minor adjustments to event icons required after recent font changes. See D15582 for more details and examples. Differential Revision: https://developer.blender.org/D15582 Reviewed by Brecht Van Lommel === M source/blender/editors/interface/interface_icons_event.c === diff --git a/source/blender/editors/interface/interface_icons_event.c b/source/blender/editors/interface/interface_icons_event.c index 6ad5fe805ab..e892a989191 100644 --- a/source/blender/editors/interface/interface_icons_event.c +++ b/source/blender/editors/interface/interface_icons_event.c @@ -60,10 +60,8 @@ #include "interface_intern.h" -static void icon_draw_rect_input_text(const rctf *rect, - const float color[4], - const char *str, - float font_size) +static void icon_draw_rect_input_text( +const rctf *rect, const float color[4], const char *str, float font_size, float v_offset) { BLF_batch_draw_flush(); const int font_id = BLF_default(); @@ -71,21 +69,9 @@ static void icon_draw_rect_input_text(const rctf *rect, BLF_size(font_id, font_size * U.pixelsize, U.dpi); float width, height; BLF_width_and_height(font_id, str, BLF_DRAW_STR_DUMMY_MAX, , ); - const float x = rect->xmin + (((rect->xmax - rect->xmin) - width) / 2.0f); - const float y = rect->ymin + (((rect->ymax - rect->ymin) - height) / 2.0f); - BLF_position(font_id, x, y, 0.0f); - BLF_draw(font_id, str, BLF_DRAW_STR_DUMMY_MAX); - BLF_batch_draw_flush(); -} - -static void icon_draw_rect_input_symbol(const rctf *rect, const float color[4], const char *str) -{ - BLF_batch_draw_flush(); - const int font_id = blf_mono_font; - BLF_color4fv(font_id, color); - BLF_size(font_id, 19.0f * U.pixelsize, U.dpi); - const float x = rect->xmin + (2.0f * U.pixelsize); - const float y = rect->ymin + (1.0f * U.pixelsize); + const float x = trunc(rect->xmin + (((rect->xmax - rect->xmin) - width) / 2.0f)); + const float y = rect->ymin + (((rect->ymax - rect->ymin) - height) / 2.0f) + + (v_offset * U.dpi_fac); BLF_position(font_id, x, y, 0.0f); BLF_draw(font_id, str, BLF_DRAW_STR_DUMMY_MAX); BLF_batch_draw_flush(); @@ -99,20 +85,17 @@ void icon_draw_rect_input(float x, short event_type, short UNUSED(event_value)) { + rctf rect = { + .xmin = (int)x - U.pixelsize, + .xmax = (int)(x + w + U.pixelsize), + .ymin = (int)(y), + .ymax = (int)(y + h), + }; float color[4]; GPU_line_width(1.0f); UI_GetThemeColor4fv(TH_TEXT, color); UI_draw_roundbox_corner_set(UI_CNR_ALL); - UI_draw_roundbox_aa( - &(const rctf){ - .xmin = (int)x - U.pixelsize, - .xmax = (int)(x + w), - .ymin = (int)y, - .ymax = (int)(y + h), - }, - false, - 3.0f * U.pixelsize, - color); + UI_draw_roundbox_aa(, false, 3.0f * U.pixelsize, color); const enum { UNIX, @@ -129,94 +112,89 @@ void icon_draw_rect_input(float x, #endif ; - const rctf rect = { - .xmin = x, - .ymin = y, - .xmax = x + w, - .ymax = y + h, - }; - if ((event_type >= EVT_AKEY) && (event_type <= EVT_ZKEY)) { const char str[2] = {'A' + (event_type - EVT_AKEY), '\0'}; -icon_draw_rect_input_text(, color, str, 13.0f); +icon_draw_rect_input_text(, color, str, 13.0f, 0.0f); } - else if ((event_type >= EVT_F1KEY) && (event_type <= EVT_F12KEY)) { + else if ((event_type >= EVT_F1KEY) && (event_type <= EVT_F24KEY)) { char str[4]; SNPRINTF(str, "F%d", 1 + (event_type - EVT_F1KEY)); -icon_draw_rect_input_text(, color, str, event_type > EVT_F9KEY ? 8.0f : 10.0f); +icon_draw_rect_input_text(, color, str, event_type > EVT_F9KEY ? 8.5f : 11.5f, 0.0f); } else if (event_type == EVT_LEFTSHIFTKEY) { /* Right Shift has already been converted to left. */ -icon_draw_rect_input_symbol(, color, (const char[]){0xe2, 0x87, 0xa7, 0x0}); +icon_draw_rect_input_text(, color, (const char[]){0xe2, 0x87, 0xa7, 0x0}, 16.0f, 0.0f); } else if (event_type == EVT_LEFTCTRLKEY) { /* Right Shift has already been converted to left. */ if (platform == MACOS) { - icon_draw_rect_input_symbol(, color, (const char[]){0xe2, 0x8c, 0x83, 0x0}); + icon_draw_rect_input_text(, color, (const char[]){0xe2, 0x8c, 0x83, 0x0}, 21.0f, -8.0f); } else { - icon_draw_rect_input_text(, color
[Bf-blender-cvs] [da9e685e260] master: Fix T100823: Do Not Load Non-Scalable Fonts
Commit: da9e685e26021202f5cc82e757f4fdf643548805 Author: Harley Acheson Date: Tue Sep 6 09:48:41 2022 -0700 Branches: master https://developer.blender.org/rBda9e685e26021202f5cc82e757f4fdf643548805 Fix T100823: Do Not Load Non-Scalable Fonts Do not allow the loading of old-style non-scalable fonts. See D15884 for more details. Differential Revision: https://developer.blender.org/D15884 Reviewed by Brecht Van Lommel === M source/blender/blenfont/intern/blf_font.c === diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 3ddeaaaf1c7..b96c01e704d 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -1361,6 +1361,11 @@ bool blf_ensure_face(FontBLF *font) return false; } + if (font->face && !(font->face->face_flags & FT_FACE_FLAG_SCALABLE)) { +printf("Font is not scalable\n"); +return false; + } + err = FT_Select_Charmap(font->face, FT_ENCODING_UNICODE); if (err) { err = FT_Select_Charmap(font->face, FT_ENCODING_APPLE_ROMAN); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d26a0be968e] master: UI: Corrected Scaling of AREAMINX
Commit: d26a0be968e09a89bc0cd49dd08aba3e08a28aad Author: Harley Acheson Date: Mon Sep 5 10:37:15 2022 -0700 Branches: master https://developer.blender.org/rBd26a0be968e09a89bc0cd49dd08aba3e08a28aad UI: Corrected Scaling of AREAMINX Minimum horizontal area size should be scaled by UI resolution. See D15865 for more details. Differential Revision: https://developer.blender.org/D15865 Reviewed by Brecht Van Lommel === M source/blender/editors/screen/screen_geometry.c M source/blender/editors/screen/screen_ops.c M source/blender/editors/space_buttons/space_buttons.c M source/blender/makesdna/DNA_screen_types.h === diff --git a/source/blender/editors/screen/screen_geometry.c b/source/blender/editors/screen/screen_geometry.c index 3486ea8b466..3ad3fa7892c 100644 --- a/source/blender/editors/screen/screen_geometry.c +++ b/source/blender/editors/screen/screen_geometry.c @@ -284,7 +284,7 @@ short screen_geom_find_area_split_point(const ScrArea *area, { const int cur_area_width = screen_geom_area_width(area); const int cur_area_height = screen_geom_area_height(area); - const short area_min_x = AREAMINX; + const short area_min_x = AREAMINX * U.dpi_fac; const short area_min_y = ED_area_headersize(); /* area big enough? */ diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index c069b3c6292..5331747beae 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -1639,7 +1639,7 @@ static void area_move_set_limits(wmWindow *win, } } else { - int areamin = AREAMINX; + int areamin = AREAMINX * U.dpi_fac; if (area->v1->vec.x > window_rect.xmin) { areamin += U.pixelsize; @@ -2062,7 +2062,7 @@ static bool area_split_allowed(const ScrArea *area, const eScreenAxis dir_axis) return false; } - if ((dir_axis == SCREEN_AXIS_V && area->winx <= 2 * AREAMINX) || + if ((dir_axis == SCREEN_AXIS_V && area->winx <= 2 * AREAMINX * U.dpi_fac) || (dir_axis == SCREEN_AXIS_H && area->winy <= 2 * ED_area_headersize())) { /* Must be at least double minimum sizes to split into two. */ return false; diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 8026cc509b2..2bee60557b7 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -978,8 +978,7 @@ void ED_spacetype_buttons(void) /* regions: navigation bar */ art = MEM_callocN(sizeof(ARegionType), "spacetype nav buttons region"); art->regionid = RGN_TYPE_NAV_BAR; - art->prefsizex = AREAMINX - 3; /* XXX Works and looks best, - * should we update AREAMINX accordingly? */ + art->prefsizex = AREAMINX; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES | ED_KEYMAP_NAVBAR; art->init = buttons_navigation_bar_region_init; art->draw = buttons_navigation_bar_region_draw; diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h index 856d48e395b..9b999e4426f 100644 --- a/source/blender/makesdna/DNA_screen_types.h +++ b/source/blender/makesdna/DNA_screen_types.h @@ -539,7 +539,7 @@ enum { }; #define AREAGRID 4 -#define AREAMINX 32 +#define AREAMINX 29 #define HEADER_PADDING_Y 6 #define HEADERY (20 + HEADER_PADDING_Y) ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [a1e01f4c026] master: UI: 3D Text Caret
Commit: a1e01f4c026a389b94985b19678a0c69745ca248 Author: Harley Acheson Date: Fri Sep 2 13:18:09 2022 -0700 Branches: master https://developer.blender.org/rBa1e01f4c026a389b94985b19678a0c69745ca248 UI: 3D Text Caret Changes to the text caret (cursor) when editing Text objects in the 3D Viewport. See D15797 for more details and examples. Differential Revision: https://developer.blender.org/D15797 Reviewed by Brecht Van Lommel === M source/blender/blenkernel/intern/vfont.c M source/blender/draw/engines/overlay/overlay_edit_text.c M source/blender/draw/engines/overlay/overlay_private.h M source/blender/editors/include/UI_resources.h M source/blender/editors/interface/resources.c === diff --git a/source/blender/blenkernel/intern/vfont.c b/source/blender/blenkernel/intern/vfont.c index 9a6f861eae8..e016cf8db84 100644 --- a/source/blender/blenkernel/intern/vfont.c +++ b/source/blender/blenkernel/intern/vfont.c @@ -1422,7 +1422,8 @@ static bool vfont_to_curve(Object *ob, for (i = 0; i <= selend; i++, ct++) { if (i >= selstart) { selboxes[i - selstart].x = ct->xof * font_size; -selboxes[i - selstart].y = ct->yof * font_size; +selboxes[i - selstart].y = (ct->yof - 0.25f) * font_size; +selboxes[i - selstart].h = font_size; } } } @@ -1481,17 +1482,17 @@ static bool vfont_to_curve(Object *ob, f = ef->textcurs[0]; -f[0] = font_size * (-0.1f * co + ct->xof); -f[1] = font_size * (0.1f * si + ct->yof); +f[0] = font_size * (-0.02f * co + ct->xof); +f[1] = font_size * (0.1f * si - (0.25f * co) + ct->yof); -f[2] = font_size * (0.1f * co + ct->xof); -f[3] = font_size * (-0.1f * si + ct->yof); +f[2] = font_size * (0.02f * co + ct->xof); +f[3] = font_size * (-0.1f * si - (0.25f * co) + ct->yof); -f[4] = font_size * (0.1f * co + 0.8f * si + ct->xof); -f[5] = font_size * (-0.1f * si + 0.8f * co + ct->yof); +f[4] = font_size * (0.02f * co + 0.8f * si + ct->xof); +f[5] = font_size * (-0.1f * si + 0.75f * co + ct->yof); -f[6] = font_size * (-0.1f * co + 0.8f * si + ct->xof); -f[7] = font_size * (0.1f * si + 0.8f * co + ct->yof); +f[6] = font_size * (-0.02f * co + 0.8f * si + ct->xof); +f[7] = font_size * (0.1f * si + 0.75f * co + ct->yof); } if (mode == FO_SELCHANGE) { diff --git a/source/blender/draw/engines/overlay/overlay_edit_text.c b/source/blender/draw/engines/overlay/overlay_edit_text.c index dfef5b3c241..bd8720042f1 100644 --- a/source/blender/draw/engines/overlay/overlay_edit_text.c +++ b/source/blender/draw/engines/overlay/overlay_edit_text.c @@ -7,6 +7,8 @@ #include "DRW_render.h" +#include "UI_resources.h" + #include "BKE_vfont.h" #include "DNA_curve_types.h" @@ -38,17 +40,24 @@ void OVERLAY_edit_text_cache_init(OVERLAY_Data *vedata) DRW_shgroup_uniform_vec4_copy(grp, "color", G_draw.block.color_wire); } { +/* Cursor (text caret). */ state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA; -DRW_PASS_CREATE(psl->edit_text_overlay_ps, state | pd->clipping_state); - +DRW_PASS_CREATE(psl->edit_text_cursor_ps, state | pd->clipping_state); sh = OVERLAY_shader_uniform_color(); -pd->edit_text_overlay_grp = grp = DRW_shgroup_create(sh, psl->edit_text_overlay_ps); +pd->edit_text_cursor_grp = grp = DRW_shgroup_create(sh, psl->edit_text_cursor_ps); +DRW_shgroup_uniform_vec4(grp, "color", pd->edit_text.cursor_color, 1); -DRW_shgroup_uniform_vec4(grp, "color", pd->edit_text.overlay_color, 1); +/* Selection boxes. */ +state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA; +DRW_PASS_CREATE(psl->edit_text_selection_ps, state | pd->clipping_state); +sh = OVERLAY_shader_uniform_color(); +pd->edit_text_selection_grp = grp = DRW_shgroup_create(sh, psl->edit_text_selection_ps); +DRW_shgroup_uniform_vec4(grp, "color", pd->edit_text.selection_color, 1); -state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_MUL | DRW_STATE_DEPTH_GREATER_EQUAL | +/* Highlight text within selection boxes. */ +state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA | DRW_STATE_DEPTH_GREATER_EQUAL | pd->clipping_state; -DRW_PASS_INSTANCE_CREATE(psl->edit_text_darken_ps, psl->edit_text_overlay_ps, state); +DRW_PASS_INSTANCE_CREATE(psl->edit_text_highlight_ps, psl->edit_text_selection_ps, state); } { /* Create view which will render everything (hopefully) behind the text geometry. */ @@ -112,7 +121,7 @@ static void edit_text_cache_populate_select(OVERLAY_Data *vedata, Object *ob) v2_quad_corners_to_mat4(box, fina
[Bf-blender-cvs] [1a641b449a0] master: BLF: Replacement of Hebrew Font
Commit: 1a641b449a05e60c90bf3c2d221824f3b00aac39 Author: Harley Acheson Date: Fri Sep 2 10:52:20 2022 -0700 Branches: master https://developer.blender.org/rB1a641b449a05e60c90bf3c2d221824f3b00aac39 BLF: Replacement of Hebrew Font Replacement of our Hebrew font, which has bad variable weight default. See D15846 for more details. Differential Revision: https://developer.blender.org/D15846 Reviewed by Brecht Van Lommel === A release/datafiles/fonts/NotoSansHebrew-Regular.woff2 D release/datafiles/fonts/NotoSansHebrew-VariableFont_wdth,wght.woff2 M source/blender/blenfont/intern/blf_font.c === diff --git a/release/datafiles/fonts/NotoSansHebrew-Regular.woff2 b/release/datafiles/fonts/NotoSansHebrew-Regular.woff2 new file mode 100644 index 000..afbe2b7f62b Binary files /dev/null and b/release/datafiles/fonts/NotoSansHebrew-Regular.woff2 differ diff --git a/release/datafiles/fonts/NotoSansHebrew-VariableFont_wdth,wght.woff2 b/release/datafiles/fonts/NotoSansHebrew-VariableFont_wdth,wght.woff2 deleted file mode 100644 index 4f6033c916f..000 Binary files a/release/datafiles/fonts/NotoSansHebrew-VariableFont_wdth,wght.woff2 and /dev/null differ diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index fb157c71172..c5040abb641 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -1450,7 +1450,7 @@ static const struct FaceDetails static_face_details[] = { {"NotoSansGeorgian-VariableFont_wdth,wght.woff2", TT_UCR_GEORGIAN, 0, 0, 0}, {"NotoSansGujarati-Regular.woff2", TT_UCR_GUJARATI, 0, 0, 0}, {"NotoSansGurmukhi-VariableFont_wdth,wght.woff2", TT_UCR_GURMUKHI, 0, 0, 0}, -{"NotoSansHebrew-VariableFont_wdth,wght.woff2", TT_UCR_HEBREW, 0, 0, 0}, +{"NotoSansHebrew-Regular.woff2", TT_UCR_HEBREW, 0, 0, 0}, {"NotoSansJavanese-Regular.woff2", 0x8003L, 0x2000L, 0, 0}, {"NotoSansKannada-VariableFont_wdth,wght.woff2", TT_UCR_KANNADA, 0, 0, 0}, {"NotoSansMalayalam-VariableFont_wdth,wght.woff2", TT_UCR_MALAYALAM, 0, 0, 0}, ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d81e947c591] master: BLF: Fallback Stack Error Handling
Commit: d81e947c591ec6f3de2bc407b9f837b2efa36890 Author: Harley Acheson Date: Tue Aug 30 11:29:47 2022 -0700 Branches: master https://developer.blender.org/rBd81e947c591ec6f3de2bc407b9f837b2efa36890 BLF: Fallback Stack Error Handling Properly handle invalid fonts. See D15798 for more details Differential Revision: https://developer.blender.org/D15798 Reviewed by Brecht Van Lommel === M source/blender/blenfont/intern/blf_font.c M source/blender/blenfont/intern/blf_font_default.c === diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 886c34654c4..fb157c71172 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -110,6 +110,10 @@ static FT_Error blf_cache_face_requester(FTC_FaceID faceID, font->face->generic.data = font; font->face->generic.finalizer = blf_face_finalizer; } + else { +/* Clear this on error to avoid exception in FTC_Manager_LookupFace. */ +*face = NULL; + } return err; } diff --git a/source/blender/blenfont/intern/blf_font_default.c b/source/blender/blenfont/intern/blf_font_default.c index a88da6099e5..ffeee397c20 100644 --- a/source/blender/blenfont/intern/blf_font_default.c +++ b/source/blender/blenfont/intern/blf_font_default.c @@ -65,7 +65,9 @@ void BLF_load_font_stack() struct direntry *dir; uint num_files = BLI_filelist_dir_contents(path, ); for (int f = 0; f < num_files; f++) { - if (!FILENAME_IS_CURRPAR(dir[f].relname) && !BLI_is_dir(dir[f].path)) { + if (!BLI_is_dir(dir[f].path) && + BLI_path_extension_check_n( + dir[f].path, ".ttf", ".ttc", ".otf", ".otc", ".woff", ".woff2", NULL)) { if (!BLF_is_loaded(dir[f].path)) { int font_id = BLF_load(dir[f].path); if (font_id == -1) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [acf083a5bfc] master: BLF: Fix FT_Get_Advance Wrong Value Without Size
Commit: acf083a5bfc83a38050b1060d4832efc04124bcc Author: Harley Acheson Date: Fri Aug 19 17:16:22 2022 -0700 Branches: master https://developer.blender.org/rBacf083a5bfc83a38050b1060d4832efc04124bcc BLF: Fix FT_Get_Advance Wrong Value Without Size Fix possibility of getting invalid fixed-pitch advance size. See D15735 for more details. Differential Revision: https://developer.blender.org/D15735 Own Code. === M source/blender/blenfont/intern/blf_glyph.c === diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 6b36844cec8..18f372c666b 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -96,6 +96,8 @@ static GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font) memset(gc->glyph_ascii_table, 0, sizeof(gc->glyph_ascii_table)); memset(gc->bucket, 0, sizeof(gc->bucket)); + blf_ensure_size(font); + /* Determine ideal fixed-width size for monospaced output. */ FT_UInt gindex = blf_get_char_index(font, U'0'); if (gindex && font->face) { @@ -106,7 +108,6 @@ static GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font) } else { /* Font does not have a face or does not contain "0" so use CSS fallback of 1/2 of em. */ -blf_ensure_size(font); gc->fixed_width = (int)((font->ft_size->metrics.height / 2) >> 6); } if (gc->fixed_width < 1) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d772e11b5a1] master: BLF: Gamma Correction
Commit: d772e11b5a1e982ef31b8667a3aeaa93f99a19ce Author: Harley Acheson Date: Thu Aug 18 12:34:23 2022 -0700 Branches: master https://developer.blender.org/rBd772e11b5a1e982ef31b8667a3aeaa93f99a19ce BLF: Gamma Correction Gamma correction for glyph coverage values. See D13376 for details and examples. Differential Revision: https://developer.blender.org/D13376 Reviewed by Julian Eisel === M source/blender/blenfont/intern/blf_glyph.c === diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index fdf9883ee8f..f758c67be43 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -42,6 +42,11 @@ #include "BLI_strict_flags.h" #include "BLI_string_utf8.h" +/* Convert glyph converage amounts to lightness values. Uses a LUT that perceptually improves + * anti-aliasing and results in text that looks a bit fuller and slightly brighter. This should + * be reconsidered in some - or all - cases when we transform the entire UI. */ +#define BLF_GAMMA_CORRECT_GLYPHS + /* */ /** \name Internal Utilities * \{ */ @@ -183,6 +188,42 @@ static GlyphBLF *blf_glyph_cache_find_glyph(GlyphCacheBLF *gc, uint charcode) return NULL; } +#ifdef BLF_GAMMA_CORRECT_GLYPHS + +/* Gamma correction of glyph converage values with widely-recommended gamma of 1.43. + * "The reasons are historical. Because so many programmers have neglected gamma blending for so + * long, people who have created fonts have tried to work around the problem of fonts looking too + * thin by just making the fonts thicker! Obviously it doesn’t help the jaggedness, but it does + * make them look the proper weight, as originally intended. The obvious problem with this is + * that if we want to gamma blend correctly many older fonts will look wrong. So we compromise, + * and use a lower gamma value, so we get a bit better antialiasing, but the fonts don’t look too + * heavy." + * https://www.puredevsoftware.com/blog/2019/01/22/sub-pixel-gamma-correct-font-rendering/ + */ +static char blf_glyph_gamma(char c) +{ + /* The following is (char)(powf(c / 256.0f, 1.0f / 1.43f) * 256.0f). */ + static const char gamma[256] = { + 0, 5, 9, 11, 14, 16, 19, 21, 23, 25, 26, 28, 30, 32, 34, 35, 37, 38, + 40, 41, 43, 44, 46, 47, 49, 50, 52, 53, 54, 56, 57, 58, 60, 61, 62, 64, + 65, 66, 67, 69, 70, 71, 72, 73, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, + 86, 87, 88, 89, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, + 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, + 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 133, 134, 135, 136, 137, 138, 139, + 140, 141, 142, 143, 143, 144, 145, 146, 147, 148, 149, 150, 151, 151, 152, 153, 154, 155, + 156, 157, 157, 158, 159, 160, 161, 162, 163, 163, 164, 165, 166, 167, 168, 168, 169, 170, + 171, 172, 173, 173, 174, 175, 176, 177, 178, 178, 179, 180, 181, 182, 182, 183, 184, 185, + 186, 186, 187, 188, 189, 190, 190, 191, 192, 193, 194, 194, 195, 196, 197, 198, 198, 199, + 200, 201, 201, 202, 203, 204, 205, 205, 206, 207, 208, 208, 209, 210, 211, 211, 212, 213, + 214, 214, 215, 216, 217, 217, 218, 219, 220, 220, 221, 222, 223, 223, 224, 225, 226, 226, + 227, 228, 229, 229, 230, 231, 231, 232, 233, 234, 234, 235, 236, 237, 237, 238, 239, 239, + 240, 241, 242, 242, 243, 244, 244, 245, 246, 247, 247, 248, 249, 249, 250, 251, 251, 252, + 253, 254, 254, 255}; + return gamma[c]; +} + +#endif /* BLF_GAMMA_CORRECT_GLYPHS */ + /** * Add a rendered glyph to a cache. */ @@ -218,6 +259,14 @@ static GlyphBLF *blf_glyph_cache_add_glyph( glyph->bitmap.buffer[i] = glyph->bitmap.buffer[i] ? 255 : 0; } } +else { +#ifdef BLF_GAMMA_CORRECT_GLYPHS + /* Convert coverage amounts to perceptually-improved lightness values. */ + for (int i = 0; i < buffer_size; i++) { +glyph->bitmap.buffer[i] = blf_glyph_gamma(glyph->bitmap.buffer[i]); + } +#endif /* BLF_GAMMA_CORRECT_GLYPHS */ +} g->bitmap = MEM_mallocN((size_t)buffer_size, "glyph bitmap"); memcpy(g->bitmap, glyph->bitmap.buffer, (size_t)buffer_size); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d39abb74a0a] master: BLF: FreeType Optional Caching
Commit: d39abb74a0a99fde2c9d845821d52c198ae4da24 Author: Harley Acheson Date: Tue Aug 16 15:02:56 2022 -0700 Branches: master https://developer.blender.org/rBd39abb74a0a99fde2c9d845821d52c198ae4da24 BLF: FreeType Optional Caching Implementation of the FreeType 2 cache subsystem, which limits the number of concurrently-opened FT_Face and FT_Size objects, as well as caching information like character maps to speed up glyph id lookups. This time with the option of opening FontBLFs that are not cached. See D15686 for more details. Differential Revision: https://developer.blender.org/D15686 Reviewed by Brecht Van Lommel === M source/blender/blenfont/BLF_api.h M source/blender/blenfont/intern/blf.c M source/blender/blenfont/intern/blf_font.c M source/blender/blenfont/intern/blf_glyph.c M source/blender/blenfont/intern/blf_internal.h M source/blender/blenfont/intern/blf_thumbs.c === diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h index 75824ae056f..d3226a8f609 100644 --- a/source/blender/blenfont/BLF_api.h +++ b/source/blender/blenfont/BLF_api.h @@ -353,6 +353,8 @@ enum { BLF_LAST_RESORT = 1 << 15, /** Failure to load this font. Don't try again. */ BLF_BAD_FONT = 1 << 16, + /** This font is managed by the FreeType cache subsystem. */ + BLF_CACHED = 1 << 17, }; #define BLF_DRAW_STR_DUMMY_MAX 1024 diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index 36475321d4c..6fcb74e9cb0 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -22,6 +22,7 @@ #include "MEM_guardedalloc.h" #include "BLI_math.h" +#include "BLI_string.h" #include "BLI_threads.h" #include "BLF_api.h" @@ -885,12 +886,21 @@ void BLF_draw_buffer(int fontid, const char *str, const size_t str_len) char *BLF_display_name_from_file(const char *filepath) { - FontBLF *font = blf_font_new("font_name", filepath); - if (!font) { -return NULL; + /* While listing font directories this function can be called simultaneously from a greater + * number of threads than we want the FreeType cache to keep open at a time. Therefore open + * with own FT_Library object and use FreeType calls directly to avoid any contention. */ + char *name = NULL; + FT_Library ft_library; + if (FT_Init_FreeType(_library) == FT_Err_Ok) { +FT_Face face; +if (FT_New_Face(ft_library, filepath, 0, ) == FT_Err_Ok) { + if (face->family_name) { +name = BLI_sprintfN("%s %s", face->family_name, face->style_name); + } + FT_Done_Face(face); +} +FT_Done_FreeType(ft_library); } - char *name = blf_display_name(font); - blf_font_free(font); return name; } diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 226752bffd8..f820ec14507 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -17,6 +17,7 @@ #include #include FT_FREETYPE_H +#include FT_CACHE_H /* FreeType Cache. */ #include FT_GLYPH_H #include FT_MULTIPLE_MASTERS_H /* Variable font support. */ #include FT_TRUETYPE_IDS_H /* Codepoint coverage constants. */ @@ -55,6 +56,8 @@ BatchBLF g_batch; /* freetype2 handle ONLY for this file! */ static FT_Library ft_lib = NULL; +static FTC_Manager ftc_manager = NULL; +static FTC_CMapCache ftc_charmap_cache = NULL; /* Lock for FreeType library, used around face creation and deletion. */ static ThreadMutex ft_lib_mutex; @@ -67,19 +70,75 @@ static ft_pix blf_font_width_max_ft_pix(struct FontBLF *font); /* */ -/* Return glyph id from charcode. */ -uint blf_get_char_index(struct FontBLF *font, uint charcode) +/** \name FreeType Caching + * \{ */ + +/* Called when a face is removed by the cache. FreeType will call FT_Done_Face. */ +static void blf_face_finalizer(void *object) +{ + FT_Face face = object; + FontBLF *font = (FontBLF *)face->generic.data; + font->face = NULL; +} + +/* Called in response to FTC_Manager_LookupFace. Now add a face to our font. */ +FT_Error blf_cache_face_requester(FTC_FaceID faceID, + FT_Library lib, + FT_Pointer reqData, + FT_Face *face) +{ + FontBLF *font = (FontBLF *)faceID; + int err = FT_Err_Cannot_Open_Resource; + + BLI_mutex_lock(_lib_mutex); + if (font->filepath) { +err = FT_New_Face(lib, font->filepath, 0, face); + } + else if (font->mem) { +err = FT_New_Memory_Face(lib, font->mem, (FT_Long)font->mem_size, 0, face); + } + BLI_mutex_unlock(_lib_mutex); + + if
[Bf-blender-cvs] [09640ab2919] master: Fix T99872: Crash Loading Embedded Fonts - Master
Commit: 09640ab2919c17f24e14c8d71fafdb15c4748395 Author: Harley Acheson Date: Tue Aug 16 12:43:10 2022 -0700 Branches: master https://developer.blender.org/rB09640ab2919c17f24e14c8d71fafdb15c4748395 Fix T99872: Crash Loading Embedded Fonts - Master Commit rBc0845abd897f to 3.4 (master) uses font's filepath without checking if it exists, therefore crashing on embedded fonts since they do not have a filepath (loaded from memory). See D15703 for more details Differential Revision: https://developer.blender.org/D15703 Reviewed by Brecht Van Lommel === M source/blender/blenfont/intern/blf_font.c === diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index b3729b7a673..226752bffd8 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -1384,22 +1384,27 @@ static FontBLF *blf_font_new_ex(const char *name, BLI_mutex_init(>glyph_cache_mutex); - /* If we have static details about this font we don't need to load the Face. */ - const eFaceDetails *static_details = NULL; - char filename[256]; - for (int i = 0; i < (int)ARRAY_SIZE(static_face_details); i++) { -BLI_split_file_part(font->filepath, filename, sizeof(filename)); -if (STREQ(static_face_details[i].name, filename)) { - static_details = _face_details[i]; - font->UnicodeRanges[0] = static_details->coverage1; - font->UnicodeRanges[1] = static_details->coverage2; - font->UnicodeRanges[2] = static_details->coverage3; - font->UnicodeRanges[3] = static_details->coverage4; - break; + /* If we have static details about this font file, we don't have to load the Face yet. */ + bool face_needed = true; + + if (font->filepath) { +const eFaceDetails *static_details = NULL; +char filename[256]; +for (int i = 0; i < (int)ARRAY_SIZE(static_face_details); i++) { + BLI_split_file_part(font->filepath, filename, sizeof(filename)); + if (STREQ(static_face_details[i].name, filename)) { +static_details = _face_details[i]; +font->UnicodeRanges[0] = static_details->coverage1; +font->UnicodeRanges[1] = static_details->coverage2; +font->UnicodeRanges[2] = static_details->coverage3; +font->UnicodeRanges[3] = static_details->coverage4; +face_needed = false; +break; + } } } - if (!static_details) { + if (face_needed) { if (!blf_ensure_face(font)) { blf_font_free(font); return NULL; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [dcfe7f795ce] master: BLF: Adjustments to Static Font Details
Commit: dcfe7f795ce12c3291e0bedb70e8e9e460d127a3 Author: Harley Acheson Date: Fri Aug 12 11:57:53 2022 -0700 Branches: master https://developer.blender.org/rBdcfe7f795ce12c3291e0bedb70e8e9e460d127a3 BLF: Adjustments to Static Font Details Adjust static font details so that we can properly display Arabic contextual letter forms. And so that alphabetical ligatures are loaded from language-specific fonts. See D15678 for more details Differential Revision: https://developer.blender.org/D15678 Own Code. === M source/blender/blenfont/intern/blf_font.c === diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 6aac09190fc..b3729b7a673 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -1341,12 +1341,12 @@ static const eFaceDetails static_face_details[] = { {"lastresort.woff2", UINT32_MAX, UINT32_MAX, UINT32_MAX, UINT32_MAX}, {"Noto Sans CJK Regular.woff2", 0x3083L, 0x2BDF3C10L, 0x16L, 0}, {"NotoEmoji-VariableFont_wght.woff2", 0x8003L, 0x241E4ACL, 0x1400L, 0x400L}, -{"NotoSansArabic-VariableFont_wdth,wght.woff2", TT_UCR_ARABIC, 0, 0, 0}, -{"NotoSansArmenian-VariableFont_wdth,wght.woff2", - TT_UCR_ARMENIAN, - TT_UCR_ALPHABETIC_PRESENTATION_FORMS, - 0, +{"NotoSansArabic-VariableFont_wdth,wght.woff2", + TT_UCR_ARABIC, + (uint)TT_UCR_ARABIC_PRESENTATION_FORMS_A, + TT_UCR_ARABIC_PRESENTATION_FORMS_B, 0}, +{"NotoSansArmenian-VariableFont_wdth,wght.woff2", TT_UCR_ARMENIAN, 0, 0, 0}, {"NotoSansBengali-VariableFont_wdth,wght.woff2", TT_UCR_BENGALI, 0, 0, 0}, {"NotoSansDevanagari-Regular.woff2", TT_UCR_DEVANAGARI, 0, 0, 0}, {"NotoSansEthiopic-Regular.woff2", 0, 0, TT_UCR_ETHIOPIC, 0}, ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d2b1e4712dc] master: BLF: Mutex Lock Glyph Cache Per Font, Not Global
Commit: d2b1e4712dc16a18862d6c3bd46c68caea2511e7 Author: Harley Acheson Date: Thu Aug 11 12:52:07 2022 -0700 Branches: master https://developer.blender.org/rBd2b1e4712dc16a18862d6c3bd46c68caea2511e7 BLF: Mutex Lock Glyph Cache Per Font, Not Global Only lock access to our glyph caches per-font, rather than globally. Also upgrade from spinlocks to mutexes. See D15644 for more details. Differential Revision: https://developer.blender.org/D15644 Reviewed by Brecht Van Lommel === M source/blender/blenfont/intern/blf_font.c M source/blender/blenfont/intern/blf_glyph.c M source/blender/blenfont/intern/blf_internal_types.h === diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index b958f3c2336..6aac09190fc 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -56,8 +56,8 @@ BatchBLF g_batch; /* freetype2 handle ONLY for this file! */ static FT_Library ft_lib = NULL; -static SpinLock ft_lib_mutex; -static SpinLock blf_glyph_cache_mutex; +/* Lock for FreeType library, used around face creation and deletion. */ +static ThreadMutex ft_lib_mutex; /* May be set to #UI_widgetbase_draw_cache_flush. */ static void (*blf_draw_cache_flush)(void) = NULL; @@ -1162,19 +1162,17 @@ char *blf_display_name(FontBLF *font) int blf_font_init(void) { memset(_batch, 0, sizeof(g_batch)); - BLI_spin_init(_lib_mutex); - BLI_spin_init(_glyph_cache_mutex); + BLI_mutex_init(_lib_mutex); int err = FT_Init_FreeType(_lib); return err; } void blf_font_exit(void) { - BLI_spin_end(_lib_mutex); + BLI_mutex_end(_lib_mutex); if (ft_lib) { FT_Done_FreeType(ft_lib); } - BLI_spin_end(_glyph_cache_mutex); blf_batch_draw_exit(); } @@ -1233,8 +1231,6 @@ static void blf_font_fill(FontBLF *font) font->buf_info.col_init[3] = 0; font->ft_lib = ft_lib; - font->ft_lib_mutex = _lib_mutex; - font->glyph_cache_mutex = _glyph_cache_mutex; } /** @@ -1252,12 +1248,14 @@ bool blf_ensure_face(FontBLF *font) FT_Error err; + BLI_mutex_lock(_lib_mutex); if (font->filepath) { err = FT_New_Face(ft_lib, font->filepath, 0, >face); } if (font->mem) { err = FT_New_Memory_Face(ft_lib, font->mem, (FT_Long)font->mem_size, 0, >face); } + BLI_mutex_unlock(_lib_mutex); if (err) { if (ELEM(err, FT_Err_Unknown_File_Format, FT_Err_Unimplemented_Feature)) { @@ -1384,6 +1382,8 @@ static FontBLF *blf_font_new_ex(const char *name, } blf_font_fill(font); + BLI_mutex_init(>glyph_cache_mutex); + /* If we have static details about this font we don't need to load the Face. */ const eFaceDetails *static_details = NULL; char filename[256]; @@ -1450,7 +1450,9 @@ void blf_font_free(FontBLF *font) } if (font->face) { +BLI_mutex_lock(_lib_mutex); FT_Done_Face(font->face); +BLI_mutex_unlock(_lib_mutex); font->face = NULL; } if (font->filepath) { @@ -1459,6 +1461,9 @@ void blf_font_free(FontBLF *font) if (font->name) { MEM_freeN(font->name); } + + BLI_mutex_end(>glyph_cache_mutex); + MEM_freeN(font); } diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 9cdca81af28..f938174f92e 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -115,7 +115,7 @@ static GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font) GlyphCacheBLF *blf_glyph_cache_acquire(FontBLF *font) { - BLI_spin_lock(font->glyph_cache_mutex); + BLI_mutex_lock(>glyph_cache_mutex); GlyphCacheBLF *gc = blf_glyph_cache_find(font, font->size, font->dpi); @@ -128,7 +128,7 @@ GlyphCacheBLF *blf_glyph_cache_acquire(FontBLF *font) void blf_glyph_cache_release(FontBLF *font) { - BLI_spin_unlock(font->glyph_cache_mutex); + BLI_mutex_unlock(>glyph_cache_mutex); } static void blf_glyph_cache_free(GlyphCacheBLF *gc) @@ -152,13 +152,13 @@ void blf_glyph_cache_clear(FontBLF *font) { GlyphCacheBLF *gc; - BLI_spin_lock(font->glyph_cache_mutex); + BLI_mutex_lock(>glyph_cache_mutex); while ((gc = BLI_pophead(>cache))) { blf_glyph_cache_free(gc); } - BLI_spin_unlock(font->glyph_cache_mutex); + BLI_mutex_unlock(>glyph_cache_mutex); } /** diff --git a/source/blender/blenfont/intern/blf_internal_types.h b/source/blender/blenfont/intern/blf_internal_types.h index 3064630de1b..dfe24c1aa47 100644 --- a/source/blender/blenfont/intern/blf_internal_types.h +++ b/source/blender/blenfont/intern/blf_internal_types.h @@ -323,9 +323,6 @@ typedef struct FontBLF { /* freetype2 lib handle. */ FT_Library ft_lib; - /* Mutex lock for library */ - SpinLock *ft_lib_mutex; - /* freetype2 face. */
[Bf-blender-cvs] [51381c94d8e] master: BLF: Fallback Broken After Cache Removal
Commit: 51381c94d8e046c78ccba190bff137cc9f11dcef Author: Harley Acheson Date: Wed Aug 10 20:50:49 2022 -0700 Branches: master https://developer.blender.org/rB51381c94d8e046c78ccba190bff137cc9f11dcef BLF: Fallback Broken After Cache Removal Font fallback feature not working after reverting the implementation of the cache system. Missing an blf_ensure_face before FT_Get_Char_Index. Otherwise glyphs not found in fonts without faces. Own Code === M source/blender/blenfont/intern/blf_font.c === diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 5f904d86b03..b958f3c2336 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -70,7 +70,7 @@ static ft_pix blf_font_width_max_ft_pix(struct FontBLF *font); /* Return glyph id from charcode. */ uint blf_get_char_index(struct FontBLF *font, uint charcode) { - return FT_Get_Char_Index(font->face, charcode); + return blf_ensure_face(font) ? FT_Get_Char_Index(font->face, charcode) : 0; } /* */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d3c653c6d92] master: BLF: Revert FreeType Cache
Commit: d3c653c6d927728b565b86252d96c6be2805d06d Author: Harley Acheson Date: Mon Aug 8 20:31:55 2022 -0700 Branches: master https://developer.blender.org/rBd3c653c6d927728b565b86252d96c6be2805d06d BLF: Revert FreeType Cache Remove the FreeType cache implementation. Not multithreading correctly. Original commit: 9d77b5a0ed7b See D15647 for more details. Differential Revision: https://developer.blender.org/D15647 Own Code. === M source/blender/blenfont/intern/blf_font.c M source/blender/blenfont/intern/blf_glyph.c M source/blender/blenfont/intern/blf_internal.h M source/blender/blenfont/intern/blf_internal_types.h === diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 10e65cd6827..5f904d86b03 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -17,7 +17,6 @@ #include #include FT_FREETYPE_H -#include FT_CACHE_H /* FreeType Cache. */ #include FT_GLYPH_H #include FT_MULTIPLE_MASTERS_H /* Variable font support. */ #include FT_TRUETYPE_IDS_H /* Codepoint coverage constants. */ @@ -56,8 +55,6 @@ BatchBLF g_batch; /* freetype2 handle ONLY for this file! */ static FT_Library ft_lib = NULL; -static FTC_Manager ftc_manager = NULL; -static FTC_CMapCache ftc_charmap_cache = NULL; static SpinLock ft_lib_mutex; static SpinLock blf_glyph_cache_mutex; @@ -69,58 +66,11 @@ static ft_pix blf_font_height_max_ft_pix(struct FontBLF *font); static ft_pix blf_font_width_max_ft_pix(struct FontBLF *font); /* */ -/** \name FreeType Caching - * \{ */ - -/* Called when a face is removed. FreeType will call FT_Done_Face itself. */ -static void blf_face_finalizer(void *object) -{ - FT_Face face = object; - FontBLF *font = (FontBLF *)face->generic.data; - font->face = NULL; -} - -/* Called in response to FTC_Manager_LookupFace. Add a face to our font. */ -static FT_Error blf_cache_face_requester(FTC_FaceID faceID, - FT_Library lib, - FT_Pointer UNUSED(reqData), - FT_Face *face) -{ - FontBLF *font = (FontBLF *)faceID; - int err = FT_Err_Cannot_Open_Resource; - - BLI_spin_lock(font->ft_lib_mutex); - - if (font->filepath) { -err = FT_New_Face(lib, font->filepath, 0, face); - } - else if (font->mem) { -err = FT_New_Memory_Face(lib, font->mem, (FT_Long)font->mem_size, 0, face); - } - BLI_spin_unlock(font->ft_lib_mutex); - - if (err == FT_Err_Ok) { -font->face = *face; -font->face->generic.data = font; -font->face->generic.finalizer = blf_face_finalizer; - } - - return err; -} - -/* Called when FreeType is removing a font size. */ -static void blf_size_finalizer(void *object) -{ - FT_Size size = object; - FontBLF *font = (FontBLF *)size->generic.data; - font->ft_size = NULL; -} - -/* Use cache, not blf_get_char_index, to return glyph id from charcode. */ +/* Return glyph id from charcode. */ uint blf_get_char_index(struct FontBLF *font, uint charcode) { - return FTC_CMapCache_Lookup(ftc_charmap_cache, font, -1, charcode); + return FT_Get_Char_Index(font->face, charcode); } /* */ @@ -130,9 +80,6 @@ uint blf_get_char_index(struct FontBLF *font, uint charcode) /* Convert a FreeType 26.6 value representing an unscaled design size to fractional pixels. */ static ft_pix blf_unscaled_F26Dot6_to_pixels(FontBLF *font, FT_Pos value) { - /* Make sure we have a valid font->ft_size. */ - blf_ensure_size(font); - /* Scale value by font size using integer-optimized multiplication. */ FT_Long scaled = FT_MulFix(value, font->ft_size->metrics.x_scale); @@ -1168,7 +1115,6 @@ int blf_font_count_missing_chars(FontBLF *font, static ft_pix blf_font_height_max_ft_pix(FontBLF *font) { - blf_ensure_size(font); /* Metrics.height is rounded to pixel. Force minimum of one pixel. */ return MAX2((ft_pix)font->ft_size->metrics.height, ft_pix_from_int(1)); } @@ -1180,7 +1126,6 @@ int blf_font_height_max(FontBLF *font) static ft_pix blf_font_width_max_ft_pix(FontBLF *font) { - blf_ensure_size(font); /* Metrics.max_advance is rounded to pixel. Force minimum of one pixel. */ return MAX2((ft_pix)font->ft_size->metrics.max_advance, ft_pix_from_int(1)); } @@ -1192,13 +1137,11 @@ int blf_font_width_max(FontBLF *font) int blf_font_descender(FontBLF *font) { - blf_ensure_size(font); return ft_pix_to_int((ft_pix)font->ft_size->metrics.descender); } int blf_font_ascender(FontBLF *font) { - blf_ensure_size(font); return ft_pix_to_int((ft_pix)font-&g
[Bf-blender-cvs] [8b3e3c18100] master: Fix T100242: Handle Flushed FT Sizes
Commit: 8b3e3c18100aac6ac956e782dc108aae500eac93 Author: Harley Acheson Date: Mon Aug 8 17:23:25 2022 -0700 Branches: master https://developer.blender.org/rB8b3e3c18100aac6ac956e782dc108aae500eac93 Fix T100242: Handle Flushed FT Sizes Properly deal with FreeType cache flushing a font's ft_size. Set this to NULL in finalizer, and add a blf_ensure_size to make sure it exists only when needed. See D15639 for more details. Differential Revision: https://developer.blender.org/D15639 Reviewed by Brecht Van Lommel === M source/blender/blenfont/intern/blf_font.c M source/blender/blenfont/intern/blf_glyph.c M source/blender/blenfont/intern/blf_internal.h === diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 17145bdbe99..10e65cd6827 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -109,6 +109,14 @@ static FT_Error blf_cache_face_requester(FTC_FaceID faceID, return err; } +/* Called when FreeType is removing a font size. */ +static void blf_size_finalizer(void *object) +{ + FT_Size size = object; + FontBLF *font = (FontBLF *)size->generic.data; + font->ft_size = NULL; +} + /* Use cache, not blf_get_char_index, to return glyph id from charcode. */ uint blf_get_char_index(struct FontBLF *font, uint charcode) { @@ -122,6 +130,9 @@ uint blf_get_char_index(struct FontBLF *font, uint charcode) /* Convert a FreeType 26.6 value representing an unscaled design size to fractional pixels. */ static ft_pix blf_unscaled_F26Dot6_to_pixels(FontBLF *font, FT_Pos value) { + /* Make sure we have a valid font->ft_size. */ + blf_ensure_size(font); + /* Scale value by font size using integer-optimized multiplication. */ FT_Long scaled = FT_MulFix(value, font->ft_size->metrics.x_scale); @@ -1157,6 +1168,7 @@ int blf_font_count_missing_chars(FontBLF *font, static ft_pix blf_font_height_max_ft_pix(FontBLF *font) { + blf_ensure_size(font); /* Metrics.height is rounded to pixel. Force minimum of one pixel. */ return MAX2((ft_pix)font->ft_size->metrics.height, ft_pix_from_int(1)); } @@ -1168,6 +1180,7 @@ int blf_font_height_max(FontBLF *font) static ft_pix blf_font_width_max_ft_pix(FontBLF *font) { + blf_ensure_size(font); /* Metrics.max_advance is rounded to pixel. Force minimum of one pixel. */ return MAX2((ft_pix)font->ft_size->metrics.max_advance, ft_pix_from_int(1)); } @@ -1179,11 +1192,13 @@ int blf_font_width_max(FontBLF *font) int blf_font_descender(FontBLF *font) { + blf_ensure_size(font); return ft_pix_to_int((ft_pix)font->ft_size->metrics.descender); } int blf_font_ascender(FontBLF *font) { + blf_ensure_size(font); return ft_pix_to_int((ft_pix)font->ft_size->metrics.ascender); } @@ -1519,35 +1534,44 @@ void blf_font_free(FontBLF *font) /** \name Font Configure * \{ */ -bool blf_font_size(FontBLF *font, float size, unsigned int dpi) +bool blf_ensure_size(FontBLF *font) { - if (!blf_ensure_face(font)) { -return false; + if (font->ft_size) { +return true; } - /* FreeType uses fixed-point integers in 64ths. */ - FT_UInt ft_size = round_fl_to_uint(size * 64.0f); - /* Adjust our new size to be on even 64ths. */ - size = (float)ft_size / 64.0f; - FTC_ScalerRec scaler = {0}; scaler.face_id = font; scaler.width = 0; - scaler.height = ft_size; + scaler.height = round_fl_to_uint(font->size * 64.0f); scaler.pixel = 0; - scaler.x_res = dpi; - scaler.y_res = dpi; + scaler.x_res = font->dpi; + scaler.y_res = font->dpi; - if (FTC_Manager_LookupSize(ftc_manager, , >ft_size) != FT_Err_Ok) { -printf("The current font don't support the size, %f and dpi, %u\n", size, dpi); + if (FTC_Manager_LookupSize(ftc_manager, , >ft_size) == FT_Err_Ok) { +font->ft_size->generic.data = (void *)font; +font->ft_size->generic.finalizer = blf_size_finalizer; +return true; + } + + BLI_assert_unreachable(); + return false; +} + +bool blf_font_size(FontBLF *font, float size, unsigned int dpi) +{ + if (!blf_ensure_face(font)) { return false; } - font->size = size; + /* FreeType uses fixed-point integers in 64ths. */ + FT_UInt ft_size = round_fl_to_uint(size * 64.0f); + /* Adjust our new size to be on even 64ths. */ + font->size = (float)ft_size / 64.0f; font->dpi = dpi; - font->ft_size->generic.data = (void *)font; + font->ft_size = NULL; - return true; + return blf_ensure_size(font); } /** \} */ diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 780b75c6296..3b73224152f 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -103,6 +1
[Bf-blender-cvs] [a9b4b044e3a] master: BLF: Remove Unwanted Font File
Commit: a9b4b044e3a327f879cc2a2719c7a23749760e4d Author: Harley Acheson Date: Sat Aug 6 12:53:23 2022 -0700 Branches: master https://developer.blender.org/rBa9b4b044e3a327f879cc2a2719c7a23749760e4d BLF: Remove Unwanted Font File Remove "Material Icons" font file, mistakenly added. See D15627 for details Differential Revision: https://developer.blender.org/D15627 Reviewed by Brecht Van Lommel === D release/datafiles/fonts/MaterialIcons-Variable.woff2 === diff --git a/release/datafiles/fonts/MaterialIcons-Variable.woff2 b/release/datafiles/fonts/MaterialIcons-Variable.woff2 deleted file mode 100644 index 048802a6454..000 Binary files a/release/datafiles/fonts/MaterialIcons-Variable.woff2 and /dev/null differ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [8b467313965] master: Fix Build Warnings in blf_font.c
Commit: 8b467313965ac5ea86d71e6ac90c0e9f54f2c830 Author: Harley Acheson Date: Thu Aug 4 14:40:11 2022 -0700 Branches: master https://developer.blender.org/rB8b467313965ac5ea86d71e6ac90c0e9f54f2c830 Fix Build Warnings in blf_font.c Function made static, unused argument, type conversion Introduced in 9d77b5a0ed7b Own Code. === M source/blender/blenfont/intern/blf_font.c === diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 372dc19d64a..07b66d0728e 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -81,10 +81,10 @@ static void blf_face_finalizer(void *object) } /* Called in response to FTC_Manager_LookupFace. Add a face to our font. */ -FT_Error blf_cache_face_requester(FTC_FaceID faceID, - FT_Library lib, - FT_Pointer reqData, - FT_Face *face) +static FT_Error blf_cache_face_requester(FTC_FaceID faceID, + FT_Library lib, + FT_Pointer UNUSED(reqData), + FT_Face *face) { FontBLF *font = (FontBLF *)faceID; int err = FT_Err_Cannot_Open_Resource; @@ -1526,7 +1526,7 @@ bool blf_font_size(FontBLF *font, float size, unsigned int dpi) } /* FreeType uses fixed-point integers in 64ths. */ - FT_F26Dot6 ft_size = lroundf(size * 64.0f); + FT_UInt ft_size = lroundf(size * 64.0f); /* Adjust our new size to be on even 64ths. */ size = (float)ft_size / 64.0f; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [9d77b5a0ed7] master: BLF: Implement FreeType Caching
Commit: 9d77b5a0ed7bed48dcb7483e79945067666eac0b Author: Harley Acheson Date: Thu Aug 4 13:05:19 2022 -0700 Branches: master https://developer.blender.org/rB9d77b5a0ed7bed48dcb7483e79945067666eac0b BLF: Implement FreeType Caching Implementation of the FreeType 2 cache subsystem, which limits the number of concurrently-opened FT_Face and FT_Size objects, as well as caching information like character maps to speed up glyph id lookups. See D13137 for much more detail. Differential Revision: https://developer.blender.org/D13137 Reviewed by Brecht Van Lommel === M source/blender/blenfont/intern/blf.c M source/blender/blenfont/intern/blf_font.c M source/blender/blenfont/intern/blf_glyph.c M source/blender/blenfont/intern/blf_internal.h M source/blender/blenfont/intern/blf_internal_types.h === diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index a1fcc17ca3f..36475321d4c 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -122,7 +122,7 @@ bool BLF_has_glyph(int fontid, unsigned int unicode) { FontBLF *font = blf_get(fontid); if (font) { -return FT_Get_Char_Index(font->face, unicode) != FT_Err_Ok; +return blf_get_char_index(font, unicode) != FT_Err_Ok; } return false; } diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 339df9eb269..372dc19d64a 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -17,6 +17,7 @@ #include #include FT_FREETYPE_H +#include FT_CACHE_H /* FreeType Cache. */ #include FT_GLYPH_H #include FT_MULTIPLE_MASTERS_H /* Variable font support. */ #include FT_TRUETYPE_IDS_H /* Codepoint coverage constants. */ @@ -54,7 +55,10 @@ BatchBLF g_batch; /* freetype2 handle ONLY for this file! */ -static FT_Library ft_lib; +static FT_Library ft_lib = NULL; +static FTC_Manager ftc_manager = NULL; +static FTC_CMapCache ftc_charmap_cache = NULL; + static SpinLock ft_lib_mutex; static SpinLock blf_glyph_cache_mutex; @@ -64,6 +68,53 @@ static void (*blf_draw_cache_flush)(void) = NULL; static ft_pix blf_font_height_max_ft_pix(struct FontBLF *font); static ft_pix blf_font_width_max_ft_pix(struct FontBLF *font); +/* */ +/** \name FreeType Caching + * \{ */ + +/* Called when a face is removed. FreeType will call FT_Done_Face itself. */ +static void blf_face_finalizer(void *object) +{ + FT_Face face = object; + FontBLF *font = (FontBLF *)face->generic.data; + font->face = NULL; +} + +/* Called in response to FTC_Manager_LookupFace. Add a face to our font. */ +FT_Error blf_cache_face_requester(FTC_FaceID faceID, + FT_Library lib, + FT_Pointer reqData, + FT_Face *face) +{ + FontBLF *font = (FontBLF *)faceID; + int err = FT_Err_Cannot_Open_Resource; + + BLI_spin_lock(font->ft_lib_mutex); + + if (font->filepath) { +err = FT_New_Face(lib, font->filepath, 0, face); + } + else if (font->mem) { +err = FT_New_Memory_Face(lib, font->mem, (FT_Long)font->mem_size, 0, face); + } + + BLI_spin_unlock(font->ft_lib_mutex); + + if (err == FT_Err_Ok) { +font->face = *face; +font->face->generic.data = font; +font->face->generic.finalizer = blf_face_finalizer; + } + + return err; +} + +/* Use cache, not blf_get_char_index, to return glyph id from charcode. */ +uint blf_get_char_index(struct FontBLF *font, uint charcode) +{ + return FTC_CMapCache_Lookup(ftc_charmap_cache, font, -1, charcode); +} + /* */ /** \name FreeType Utilities (Internal) * \{ */ @@ -72,12 +123,12 @@ static ft_pix blf_font_width_max_ft_pix(struct FontBLF *font); static ft_pix blf_unscaled_F26Dot6_to_pixels(FontBLF *font, FT_Pos value) { /* Scale value by font size using integer-optimized multiplication. */ - FT_Long scaled = FT_MulFix(value, font->face->size->metrics.x_scale); + FT_Long scaled = FT_MulFix(value, font->ft_size->metrics.x_scale); /* Copied from FreeType's FT_Get_Kerning (with FT_KERNING_DEFAULT), scaling down */ /* kerning distances at small ppem values so that they don't become too big. */ - if (font->face->size->metrics.x_ppem < 25) { -scaled = FT_MulDiv(scaled, font->face->size->metrics.x_ppem, 25); + if (font->ft_size->metrics.x_ppem < 25) { +scaled = FT_MulDiv(scaled, font->ft_size->metrics.x_ppem, 25); } return (ft_pix)scaled; @@ -296,7 +347,7 @@ BLI_INLINE ft_pix blf_kerning(FontBLF *font, const GlyphBLF *g_prev, const Glyph /* Small
[Bf-blender-cvs] [af6f0f17574] master: Fix failing blenlib test from previous commit
Commit: af6f0f17574d52316da7a3ab1dfa14ff4b003743 Author: Harley Acheson Date: Sat Jul 30 09:27:32 2022 -0700 Branches: master https://developer.blender.org/rBaf6f0f17574d52316da7a3ab1dfa14ff4b003743 Fix failing blenlib test from previous commit Commit 310be2e37cfb did not update UI_MENU_ARROW_SEP used in tests. === M source/blender/blenlib/tests/BLI_string_search_test.cc === diff --git a/source/blender/blenlib/tests/BLI_string_search_test.cc b/source/blender/blenlib/tests/BLI_string_search_test.cc index aa6adae8d76..ab1d073ed33 100644 --- a/source/blender/blenlib/tests/BLI_string_search_test.cc +++ b/source/blender/blenlib/tests/BLI_string_search_test.cc @@ -9,7 +9,7 @@ namespace blender::string_search::tests { /* Right arrow, keep in sync with #UI_MENU_ARROW_SEP in `UI_interface.h`. */ -#define UI_MENU_ARROW_SEP "\xe2\x96\xb6" +#define UI_MENU_ARROW_SEP "\xe2\x96\xb8" TEST(string_search, damerau_levenshtein_distance) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [310be2e37cf] master: UI: UI_MENU_ARROW_SEP Unicode Character
Commit: 310be2e37cfb756da67806c0a0babb9ff472b803 Author: Harley Acheson Date: Sat Jul 30 07:54:12 2022 -0700 Branches: master https://developer.blender.org/rB310be2e37cfb756da67806c0a0babb9ff472b803 UI: UI_MENU_ARROW_SEP Unicode Character Use a smaller arrow text character as menu item separator. See D15578 for examples and details. Differential Revision: https://developer.blender.org/D15578 Reviewed by Julian Eisel === M source/blender/blenlib/intern/string_search.cc M source/blender/editors/include/UI_interface.h === diff --git a/source/blender/blenlib/intern/string_search.cc b/source/blender/blenlib/intern/string_search.cc index 14d85b99739..31ea24eb494 100644 --- a/source/blender/blenlib/intern/string_search.cc +++ b/source/blender/blenlib/intern/string_search.cc @@ -11,8 +11,8 @@ #include "BLI_timeit.hh" /* Right arrow, keep in sync with #UI_MENU_ARROW_SEP in `UI_interface.h`. */ -#define UI_MENU_ARROW_SEP "\xe2\x96\xb6" -#define UI_MENU_ARROW_SEP_UNICODE 0x25b6 +#define UI_MENU_ARROW_SEP "\xe2\x96\xb8" +#define UI_MENU_ARROW_SEP_UNICODE 0x25b8 namespace blender::string_search { diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index afef516b245..163ea7e9493 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -85,7 +85,7 @@ typedef struct uiViewItemHandle uiViewItemHandle; /* Separator for text in search menus (right pointing arrow). * keep in sync with `string_search.cc`. */ -#define UI_MENU_ARROW_SEP "\xe2\x96\xb6" +#define UI_MENU_ARROW_SEP "\xe2\x96\xb8" /* names */ #define UI_MAX_DRAW_STR 400 ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [e9bd6abde37] master: BLF: New Font Stack for Better Language Coverage
Commit: e9bd6abde37c276f1b8a9a22f5312d794b0f159b Author: Harley Acheson Date: Thu Jul 28 20:09:20 2022 -0700 Branches: master https://developer.blender.org/rBe9bd6abde37c276f1b8a9a22f5312d794b0f159b BLF: New Font Stack for Better Language Coverage Replace our existing two fonts with a stack of new fonts to increase and improve language coverage and to add many new symbols and icons. Covers glyphs of top 44 languages - 1.5 billion more potential users. See D10887 for lots of details. Differential Revision: https://developer.blender.org/D10887 Reviewed by Brecht Van Lommel === A release/datafiles/fonts/DejaVuSans.woff2 A release/datafiles/fonts/DejaVuSansMono.woff2 A release/datafiles/fonts/MaterialIcons-Variable.woff2 A release/datafiles/fonts/Noto Sans CJK Regular.woff2 A release/datafiles/fonts/NotoEmoji-VariableFont_wght.woff2 A release/datafiles/fonts/NotoSansArabic-VariableFont_wdth,wght.woff2 A release/datafiles/fonts/NotoSansArmenian-VariableFont_wdth,wght.woff2 A release/datafiles/fonts/NotoSansBengali-VariableFont_wdth,wght.woff2 A release/datafiles/fonts/NotoSansDevanagari-Regular.woff2 A release/datafiles/fonts/NotoSansEthiopic-Regular.woff2 A release/datafiles/fonts/NotoSansGeorgian-VariableFont_wdth,wght.woff2 A release/datafiles/fonts/NotoSansGujarati-Regular.woff2 A release/datafiles/fonts/NotoSansGurmukhi-VariableFont_wdth,wght.woff2 A release/datafiles/fonts/NotoSansHebrew-VariableFont_wdth,wght.woff2 A release/datafiles/fonts/NotoSansJavanese-Regular.woff2 A release/datafiles/fonts/NotoSansKannada-VariableFont_wdth,wght.woff2 A release/datafiles/fonts/NotoSansMalayalam-VariableFont_wdth,wght.woff2 A release/datafiles/fonts/NotoSansMath-Regular.woff2 A release/datafiles/fonts/NotoSansMyanmar-Regular.woff2 A release/datafiles/fonts/NotoSansSymbols-VariableFont_wght.woff2 A release/datafiles/fonts/NotoSansSymbols2-Regular.woff2 A release/datafiles/fonts/NotoSansTamil-VariableFont_wdth,wght.woff2 A release/datafiles/fonts/NotoSansTelugu-VariableFont_wdth,wght.woff2 A release/datafiles/fonts/NotoSansThai-VariableFont_wdth,wght.woff2 D release/datafiles/fonts/bmonofont-i18n.ttf D release/datafiles/fonts/droidsans.ttf A release/datafiles/fonts/lastresort.woff2 M source/blender/blenfont/BLF_api.h M source/blender/blenfont/intern/blf_glyph.c === diff --git a/release/datafiles/fonts/DejaVuSans.woff2 b/release/datafiles/fonts/DejaVuSans.woff2 new file mode 100644 index 000..a391596a421 Binary files /dev/null and b/release/datafiles/fonts/DejaVuSans.woff2 differ diff --git a/release/datafiles/fonts/DejaVuSansMono.woff2 b/release/datafiles/fonts/DejaVuSansMono.woff2 new file mode 100644 index 000..cf200e12fff Binary files /dev/null and b/release/datafiles/fonts/DejaVuSansMono.woff2 differ diff --git a/release/datafiles/fonts/MaterialIcons-Variable.woff2 b/release/datafiles/fonts/MaterialIcons-Variable.woff2 new file mode 100644 index 000..048802a6454 Binary files /dev/null and b/release/datafiles/fonts/MaterialIcons-Variable.woff2 differ diff --git a/release/datafiles/fonts/Noto Sans CJK Regular.woff2 b/release/datafiles/fonts/Noto Sans CJK Regular.woff2 new file mode 100644 index 000..5d3854b6bf7 Binary files /dev/null and b/release/datafiles/fonts/Noto Sans CJK Regular.woff2 differ diff --git a/release/datafiles/fonts/NotoEmoji-VariableFont_wght.woff2 b/release/datafiles/fonts/NotoEmoji-VariableFont_wght.woff2 new file mode 100644 index 000..4d019787bca Binary files /dev/null and b/release/datafiles/fonts/NotoEmoji-VariableFont_wght.woff2 differ diff --git a/release/datafiles/fonts/NotoSansArabic-VariableFont_wdth,wght.woff2 b/release/datafiles/fonts/NotoSansArabic-VariableFont_wdth,wght.woff2 new file mode 100644 index 000..8ee78b73e72 Binary files /dev/null and b/release/datafiles/fonts/NotoSansArabic-VariableFont_wdth,wght.woff2 differ diff --git a/release/datafiles/fonts/NotoSansArmenian-VariableFont_wdth,wght.woff2 b/release/datafiles/fonts/NotoSansArmenian-VariableFont_wdth,wght.woff2 new file mode 100644 index 000..c6c1ed5c2cf Binary files /dev/null and b/release/datafiles/fonts/NotoSansArmenian-VariableFont_wdth,wght.woff2 differ diff --git a/release/datafiles/fonts/NotoSansBengali-VariableFont_wdth,wght.woff2 b/release/datafiles/fonts/NotoSansBengali-VariableFont_wdth,wght.woff2 new file mode 100644 index 000..cdac12cc8e8 Binary files /dev/null and b/release/datafiles/fonts/NotoSansBengali-VariableFont_wdth,wght.woff2 differ diff --git a/release/datafiles/fonts/NotoSansDevanagari-Regular.woff2 b/release/datafiles/fonts/NotoSansDevanagari-Regular.woff2 new file mode 100644 index 000..2cb157b2c51
[Bf-blender-cvs] [c0845abd897] master: BLF: Fonts with FT_Face Optional
Commit: c0845abd897ffd547cd0ac226da99318d5c2fb30 Author: Harley Acheson Date: Thu Jul 28 17:50:34 2022 -0700 Branches: master https://developer.blender.org/rBc0845abd897ffd547cd0ac226da99318d5c2fb30 BLF: Fonts with FT_Face Optional Allow FontBLFs to exist with NULL FT_Face, added only when actually needed. Speeds up startup and unused fonts are not loaded. See D15258 for more details. Differential Revision: https://developer.blender.org/D15258 Reviewed by Brecht Van Lommel === M source/blender/blenfont/BLF_api.h M source/blender/blenfont/intern/blf_font.c M source/blender/blenfont/intern/blf_font_default.c M source/blender/blenfont/intern/blf_glyph.c M source/blender/blenfont/intern/blf_internal.h M source/blender/blenfont/intern/blf_internal_types.h === diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h index 83ca9158efc..8cb368e2075 100644 --- a/source/blender/blenfont/BLF_api.h +++ b/source/blender/blenfont/BLF_api.h @@ -351,6 +351,8 @@ enum { BLF_DEFAULT = 1 << 14, /** Must only be used as last font in the stack. */ BLF_LAST_RESORT = 1 << 15, + /** Failure to load this font. Don't try again. */ + BLF_BAD_FONT = 1 << 16, }; #define BLF_DRAW_STR_DUMMY_MAX 1024 diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 0efd3537a32..fed01d90314 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -18,8 +18,9 @@ #include FT_FREETYPE_H #include FT_GLYPH_H -#include FT_TRUETYPE_TABLES_H /* For TT_OS2 */ #include FT_MULTIPLE_MASTERS_H /* Variable font support. */ +#include FT_TRUETYPE_IDS_H /* Codepoint coverage constants. */ +#include FT_TRUETYPE_TABLES_H /* For TT_OS2 */ #include "MEM_guardedalloc.h" @@ -28,6 +29,7 @@ #include "BLI_listbase.h" #include "BLI_math.h" #include "BLI_math_color_blend.h" +#include "BLI_path_util.h" #include "BLI_rect.h" #include "BLI_string.h" #include "BLI_string_utf8.h" @@ -1157,7 +1159,7 @@ int blf_font_ascender(FontBLF *font) char *blf_display_name(FontBLF *font) { - if (!font->face->family_name) { + if (!blf_ensure_face(font) || !font->face->family_name) { return NULL; } return BLI_sprintfN("%s %s", font->face->family_name, font->face->style_name); @@ -1244,14 +1246,28 @@ static void blf_font_fill(FontBLF *font) font->glyph_cache_mutex = _glyph_cache_mutex; } -FontBLF *blf_font_new(const char *name, const char *filepath) +/** + * Create an FT_Face for this font if not already existing. + */ +bool blf_ensure_face(FontBLF *font) { - FontBLF *font; + if (font->face) { +return true; + } + + if (font->flags & BLF_BAD_FONT) { +return false; + } + FT_Error err; - char *mfile; - font = (FontBLF *)MEM_callocN(sizeof(FontBLF), "blf_font_new"); - err = FT_New_Face(ft_lib, filepath, 0, >face); + if (font->filepath) { +err = FT_New_Face(ft_lib, font->filepath, 0, >face); + } + if (font->mem) { +err = FT_New_Memory_Face(ft_lib, font->mem, (FT_Long)font->mem_size, 0, >face); + } + if (err) { if (ELEM(err, FT_Err_Unknown_File_Format, FT_Err_Unimplemented_Feature)) { printf("Format of this font file is not supported\n"); @@ -1259,8 +1275,8 @@ FontBLF *blf_font_new(const char *name, const char *filepath) else { printf("Error encountered while opening font file\n"); } -MEM_freeN(font); -return NULL; +font->flags |= BLF_BAD_FONT; +return false; } err = FT_Select_Charmap(font->face, FT_ENCODING_UNICODE); @@ -1272,28 +1288,28 @@ FontBLF *blf_font_new(const char *name, const char *filepath) } if (err) { printf("Can't set a character map!\n"); -FT_Done_Face(font->face); -MEM_freeN(font); -return NULL; +font->flags |= BLF_BAD_FONT; +return false; } - mfile = blf_dir_metrics_search(filepath); - if (mfile) { -err = FT_Attach_File(font->face, mfile); -if (err) { - fprintf(stderr, "FT_Attach_File failed to load '%s' with error %d\n", filepath, (int)err); + if (font->filepath) { +char *mfile = blf_dir_metrics_search(font->filepath); +if (mfile) { + err = FT_Attach_File(font->face, mfile); + if (err) { +fprintf(stderr, +"FT_Attach_File failed to load '%s' with error %d\n", +font->filepath, +(int)err); + } + MEM_freeN(mfile); } -MEM_freeN(mfile); } if (FT_HAS_MULTIPLE_MASTERS(font->face)) { FT_Get_MM_Var(font->face, &(font->
[Bf-blender-cvs] [848dd4a40af] master: BLF: Don't Print Empty Strings
Commit: 848dd4a40afed8874abfb499100f09ff291ce14e Author: Harley Acheson Date: Thu Jul 28 17:28:05 2022 -0700 Branches: master https://developer.blender.org/rB848dd4a40afed8874abfb499100f09ff291ce14e BLF: Don't Print Empty Strings Optimize font drawing by skipping empty strings. See D15472 for more details. Differential Revision: https://developer.blender.org/D15472 Reviewed by Campbell Barton === M source/blender/blenfont/intern/blf_font.c === diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 038e73cc928..0efd3537a32 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -836,7 +836,7 @@ static void blf_font_boundbox_foreach_glyph_ex(FontBLF *font, size_t i = 0, i_curr; rcti gbox_px; - if (str_len == 0) { + if (str_len == 0 || str[0] == 0) { /* early output. */ return; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [9428efc36dc] gpencil-new-data-proposal: BLF: Add Support for Variable Fonts
Commit: 9428efc36dc806b8efb2128cd472f5a470e51b52 Author: Harley Acheson Date: Thu Jul 7 12:59:16 2022 -0700 Branches: gpencil-new-data-proposal https://developer.blender.org/rB9428efc36dc806b8efb2128cd472f5a470e51b52 BLF: Add Support for Variable Fonts Add support for Variable/Multiple Master font features. These are fonts that contain a range of design variations along multiple axes. This contains no client-facing options. See D12977 for details and examples Differential Revision: https://developer.blender.org/D12977 Reviewed by Brecht Van Lommel === M source/blender/blenfont/intern/blf_font.c M source/blender/blenfont/intern/blf_glyph.c M source/blender/blenfont/intern/blf_internal_types.h === diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 3e2927d581e..038e73cc928 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -18,7 +18,8 @@ #include FT_FREETYPE_H #include FT_GLYPH_H -#include FT_TRUETYPE_TABLES_H /* For TT_OS2 */ +#include FT_TRUETYPE_TABLES_H /* For TT_OS2 */ +#include FT_MULTIPLE_MASTERS_H /* Variable font support. */ #include "MEM_guardedalloc.h" @@ -1285,6 +1286,10 @@ FontBLF *blf_font_new(const char *name, const char *filepath) MEM_freeN(mfile); } + if (FT_HAS_MULTIPLE_MASTERS(font->face)) { +FT_Get_MM_Var(font->face, &(font->variations)); + } + font->name = BLI_strdup(name); font->filepath = BLI_strdup(filepath); blf_font_fill(font); @@ -1351,6 +1356,10 @@ FontBLF *blf_font_new_from_mem(const char *name, const unsigned char *mem, int m return NULL; } + if (FT_HAS_MULTIPLE_MASTERS(font->face)) { +FT_Get_MM_Var(font->face, &(font->variations)); + } + font->name = BLI_strdup(name); font->filepath = NULL; blf_font_fill(font); @@ -1365,6 +1374,10 @@ void blf_font_free(FontBLF *font) MEM_freeN(font->kerning_cache); } + if (font->variations) { +FT_Done_MM_Var(ft_lib, font->variations); + } + FT_Done_Face(font->face); if (font->filepath) { MEM_freeN(font->filepath); diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 2eb43e3df43..4db083366c3 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -18,7 +18,8 @@ #include FT_GLYPH_H #include FT_OUTLINE_H #include FT_BITMAP_H -#include FT_ADVANCES_H /* For FT_Get_Advance. */ +#include FT_ADVANCES_H /* For FT_Get_Advance. */ +#include FT_MULTIPLE_MASTERS_H /* Variable font support. */ #include "MEM_guardedalloc.h" @@ -64,7 +65,9 @@ static GlyphCacheBLF *blf_glyph_cache_find(FontBLF *font, float size, unsigned i GlyphCacheBLF *gc = (GlyphCacheBLF *)font->cache.first; while (gc) { if (gc->size == size && gc->dpi == dpi && (gc->bold == ((font->flags & BLF_BOLD) != 0)) && -(gc->italic == ((font->flags & BLF_ITALIC) != 0))) { +(gc->italic == ((font->flags & BLF_ITALIC) != 0)) && +(gc->char_weight == font->char_weight) && (gc->char_slant == font->char_slant) && +(gc->char_width == font->char_width) && (gc->char_spacing == font->char_spacing)) { return gc; } gc = gc->next; @@ -82,6 +85,10 @@ static GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font) gc->dpi = font->dpi; gc->bold = ((font->flags & BLF_BOLD) != 0); gc->italic = ((font->flags & BLF_ITALIC) != 0); + gc->char_weight = font->char_weight; + gc->char_slant = font->char_slant; + gc->char_width = font->char_width; + gc->char_spacing = font->char_spacing; memset(gc->glyph_ascii_table, 0, sizeof(gc->glyph_ascii_table)); memset(gc->bucket, 0, sizeof(gc->bucket)); @@ -673,6 +680,96 @@ static bool blf_glyph_render_bitmap(FontBLF *font, FT_GlyphSlot glyph) /** \} */ +/* */ +/** \name Variations (Multiple Masters) support + * \{ */ + +/** + * Return a design axis that matches an identifying tag. + * + * \param variations: Variation descriptors from `FT_Get_MM_Var`. + * \param tag: Axis tag (4-character string as uint), like 'wght' + * \param axis_index: returns index of axis in variations array. + */ +static FT_Var_Axis *blf_var_axis_by_tag(FT_MM_Var *variations, uint tag, int *axis_index) +{ + *axis_index = -1; + if (!variations) { +return NULL; + } + for (int i = 0; i < (int)variations->num_axis; i++) { +if (variations->axis[i].tag == tag) { + *axis_index = i; + return &(
[Bf-blender-cvs] [76925661f76] gpencil-new-data-proposal: Cleanup: Calm GCC Conversion Warning
Commit: 76925661f7640fc9067f07b425a58be1838fd5da Author: Harley Acheson Date: Thu Jul 7 14:29:37 2022 -0700 Branches: gpencil-new-data-proposal https://developer.blender.org/rB76925661f7640fc9067f07b425a58be1838fd5da Cleanup: Calm GCC Conversion Warning Commit b9c0eed206b0 introduced a GCC conversion warning because of an assignment of a long int value to an int. Own Code === M source/blender/blenfont/intern/blf_glyph.c === diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 4db083366c3..103919e86f2 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -843,7 +843,7 @@ static bool blf_glyph_transform_width(FT_GlyphSlot glyph, float factor) static bool blf_glyph_transform_spacing(FT_GlyphSlot glyph, float factor) { if (glyph->advance.x > 0) { -const int size = glyph->face->size->metrics.height; +const long int size = glyph->face->size->metrics.height; glyph->advance.x += (FT_Pos)(factor * (float)size / 6.0f); return true; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [56bf92f0f6d] master: Cleanup: Calm GCC Conversion Warning
Commit: 56bf92f0f6df8684c5ffb63ffa7218322eedf574 Author: Harley Acheson Date: Thu Jul 7 14:29:37 2022 -0700 Branches: master https://developer.blender.org/rB56bf92f0f6df8684c5ffb63ffa7218322eedf574 Cleanup: Calm GCC Conversion Warning Commit b9c0eed206b0 introduced a GCC conversion warning because of an assignment of a long int value to an int. Own Code === M source/blender/blenfont/intern/blf_glyph.c === diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 4db083366c3..103919e86f2 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -843,7 +843,7 @@ static bool blf_glyph_transform_width(FT_GlyphSlot glyph, float factor) static bool blf_glyph_transform_spacing(FT_GlyphSlot glyph, float factor) { if (glyph->advance.x > 0) { -const int size = glyph->face->size->metrics.height; +const long int size = glyph->face->size->metrics.height; glyph->advance.x += (FT_Pos)(factor * (float)size / 6.0f); return true; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b9c0eed206b] master: BLF: Add Support for Variable Fonts
Commit: b9c0eed206b0d7d1b6af6809c6d2cb6c2187bcc8 Author: Harley Acheson Date: Thu Jul 7 12:59:16 2022 -0700 Branches: master https://developer.blender.org/rBb9c0eed206b0d7d1b6af6809c6d2cb6c2187bcc8 BLF: Add Support for Variable Fonts Add support for Variable/Multiple Master font features. These are fonts that contain a range of design variations along multiple axes. This contains no client-facing options. See D12977 for details and examples Differential Revision: https://developer.blender.org/D12977 Reviewed by Brecht Van Lommel === M source/blender/blenfont/intern/blf_font.c M source/blender/blenfont/intern/blf_glyph.c M source/blender/blenfont/intern/blf_internal_types.h === diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 3e2927d581e..038e73cc928 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -18,7 +18,8 @@ #include FT_FREETYPE_H #include FT_GLYPH_H -#include FT_TRUETYPE_TABLES_H /* For TT_OS2 */ +#include FT_TRUETYPE_TABLES_H /* For TT_OS2 */ +#include FT_MULTIPLE_MASTERS_H /* Variable font support. */ #include "MEM_guardedalloc.h" @@ -1285,6 +1286,10 @@ FontBLF *blf_font_new(const char *name, const char *filepath) MEM_freeN(mfile); } + if (FT_HAS_MULTIPLE_MASTERS(font->face)) { +FT_Get_MM_Var(font->face, &(font->variations)); + } + font->name = BLI_strdup(name); font->filepath = BLI_strdup(filepath); blf_font_fill(font); @@ -1351,6 +1356,10 @@ FontBLF *blf_font_new_from_mem(const char *name, const unsigned char *mem, int m return NULL; } + if (FT_HAS_MULTIPLE_MASTERS(font->face)) { +FT_Get_MM_Var(font->face, &(font->variations)); + } + font->name = BLI_strdup(name); font->filepath = NULL; blf_font_fill(font); @@ -1365,6 +1374,10 @@ void blf_font_free(FontBLF *font) MEM_freeN(font->kerning_cache); } + if (font->variations) { +FT_Done_MM_Var(ft_lib, font->variations); + } + FT_Done_Face(font->face); if (font->filepath) { MEM_freeN(font->filepath); diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 2eb43e3df43..4db083366c3 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -18,7 +18,8 @@ #include FT_GLYPH_H #include FT_OUTLINE_H #include FT_BITMAP_H -#include FT_ADVANCES_H /* For FT_Get_Advance. */ +#include FT_ADVANCES_H /* For FT_Get_Advance. */ +#include FT_MULTIPLE_MASTERS_H /* Variable font support. */ #include "MEM_guardedalloc.h" @@ -64,7 +65,9 @@ static GlyphCacheBLF *blf_glyph_cache_find(FontBLF *font, float size, unsigned i GlyphCacheBLF *gc = (GlyphCacheBLF *)font->cache.first; while (gc) { if (gc->size == size && gc->dpi == dpi && (gc->bold == ((font->flags & BLF_BOLD) != 0)) && -(gc->italic == ((font->flags & BLF_ITALIC) != 0))) { +(gc->italic == ((font->flags & BLF_ITALIC) != 0)) && +(gc->char_weight == font->char_weight) && (gc->char_slant == font->char_slant) && +(gc->char_width == font->char_width) && (gc->char_spacing == font->char_spacing)) { return gc; } gc = gc->next; @@ -82,6 +85,10 @@ static GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font) gc->dpi = font->dpi; gc->bold = ((font->flags & BLF_BOLD) != 0); gc->italic = ((font->flags & BLF_ITALIC) != 0); + gc->char_weight = font->char_weight; + gc->char_slant = font->char_slant; + gc->char_width = font->char_width; + gc->char_spacing = font->char_spacing; memset(gc->glyph_ascii_table, 0, sizeof(gc->glyph_ascii_table)); memset(gc->bucket, 0, sizeof(gc->bucket)); @@ -673,6 +680,96 @@ static bool blf_glyph_render_bitmap(FontBLF *font, FT_GlyphSlot glyph) /** \} */ +/* */ +/** \name Variations (Multiple Masters) support + * \{ */ + +/** + * Return a design axis that matches an identifying tag. + * + * \param variations: Variation descriptors from `FT_Get_MM_Var`. + * \param tag: Axis tag (4-character string as uint), like 'wght' + * \param axis_index: returns index of axis in variations array. + */ +static FT_Var_Axis *blf_var_axis_by_tag(FT_MM_Var *variations, uint tag, int *axis_index) +{ + *axis_index = -1; + if (!variations) { +return NULL; + } + for (int i = 0; i < (int)variations->num_axis; i++) { +if (variations->axis[i].tag == tag) { + *axis_index = i; + return &(variations->axis)[i]; + break
[Bf-blender-cvs] [0f23776ea2a] cycles_oneapi: UI: Scrollbar Behavior Changes
Commit: 0f23776ea2a9abcae5b78d5f7af4b07462810580 Author: Harley Acheson Date: Mon Jun 27 06:45:49 2022 -0700 Branches: cycles_oneapi https://developer.blender.org/rB0f23776ea2a9abcae5b78d5f7af4b07462810580 UI: Scrollbar Behavior Changes Changes to scrollbars so that they are always visible, but thin and dim, and widen and become more visible as your mouse approaches. See D6505 for details and examples. Differential Revision: https://developer.blender.org/D6505 Reviewed by Campbell Barton === M source/blender/editors/include/UI_view2d.h M source/blender/editors/interface/interface_region_hud.cc M source/blender/editors/interface/view2d.cc M source/blender/editors/screen/area.c M source/blender/editors/screen/screen_ops.c === diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h index 23dbd3ed36f..5c4eb254462 100644 --- a/source/blender/editors/include/UI_view2d.h +++ b/source/blender/editors/include/UI_view2d.h @@ -49,8 +49,21 @@ enum eView2D_CommonViewTypes { /* -- Defines for Scrollers - */ /** Scroll bar area. */ -#define V2D_SCROLL_HEIGHT (0.45f * U.widget_unit) -#define V2D_SCROLL_WIDTH (0.45f * U.widget_unit) + +/* Maximum has to include outline which varies with line width. */ +#define V2D_SCROLL_HEIGHT ((0.45f * U.widget_unit) + (2.0f * U.pixelsize)) +#define V2D_SCROLL_WIDTH ((0.45f * U.widget_unit) + (2.0f * U.pixelsize)) + +/* Alpha of scrollbar when at minimum size. */ +#define V2D_SCROLL_MIN_ALPHA (0.4f) + +/* Minimum size needs to include outline which varies with line width. */ +#define V2D_SCROLL_MIN_WIDTH ((5.0f * U.dpi_fac) + (2.0f * U.pixelsize)) + +/* When to start showing the full-width scroller. */ +#define V2D_SCROLL_HIDE_WIDTH (AREAMINX * U.dpi_fac) +#define V2D_SCROLL_HIDE_HEIGHT (HEADERY * U.dpi_fac) + /** Scroll bars with 'handles' used for scale (zoom). */ #define V2D_SCROLL_HANDLE_HEIGHT (0.6f * U.widget_unit) #define V2D_SCROLL_HANDLE_WIDTH (0.6f * U.widget_unit) @@ -236,9 +249,13 @@ void UI_view2d_draw_scale_x__frames_or_seconds(const struct ARegion *region, void UI_view2d_scrollers_calc(struct View2D *v2d, const struct rcti *mask_custom, struct View2DScrollers *r_scrollers); + /** * Draw scroll-bars in the given 2D-region. */ +void UI_view2d_scrollers_draw_ex(struct View2D *v2d, + const struct rcti *mask_custom, + bool use_full_hide); void UI_view2d_scrollers_draw(struct View2D *v2d, const struct rcti *mask_custom); /* List view tools. */ @@ -329,8 +346,10 @@ struct View2D *UI_view2d_fromcontext_rwin(const struct bContext *C); /** * Get scrollbar sizes of the current 2D view. * The size will be zero if the view has its scrollbars disabled. + * + * \param mapped: whether to use view2d_scroll_mapped which changes flags */ -void UI_view2d_scroller_size_get(const struct View2D *v2d, float *r_x, float *r_y); +void UI_view2d_scroller_size_get(const struct View2D *v2d, bool mapped, float *r_x, float *r_y); /** * Calculate the scale per-axis of the drawing-area * diff --git a/source/blender/editors/interface/interface_region_hud.cc b/source/blender/editors/interface/interface_region_hud.cc index d6166694a4a..aca36686dea 100644 --- a/source/blender/editors/interface/interface_region_hud.cc +++ b/source/blender/editors/interface/interface_region_hud.cc @@ -143,6 +143,11 @@ static void hud_panels_register(ARegionType *art, int space_type, int region_typ static void hud_region_init(wmWindowManager *wm, ARegion *region) { ED_region_panels_init(wm, region); + + /* Reset zoom from panels init because we don't want zoom allowed for redo panel. */ + region->v2d.maxzoom = 1.0f; + region->v2d.minzoom = 1.0f; + UI_region_handlers_add(>handlers); region->flag |= RGN_FLAG_TEMP_REGIONDATA; } @@ -251,7 +256,7 @@ static ARegion *hud_region_add(ScrArea *area) if (region_win) { float x, y; -UI_view2d_scroller_size_get(_win->v2d, , ); +UI_view2d_scroller_size_get(_win->v2d, true, , ); region->runtime.offset_x = x; region->runtime.offset_y = y; } diff --git a/source/blender/editors/interface/view2d.cc b/source/blender/editors/interface/view2d.cc index 6ece7eb4ffa..ee4bfd351ae 100644 --- a/source/blender/editors/interface/view2d.cc +++ b/source/blender/editors/interface/view2d.cc @@ -149,7 +149,9 @@ static void view2d_masks(View2D *v2d, const rcti *mask_scroll) } } - scroll = view2d_scroll_mapped(v2d->scroll); + /* Do not use mapped scroll here because we want to update scroller rects + * even if they are not displayed. For init purposes. See T75003.*/ + scroll = v2d->scroll; /* Scrollers are based off region-size: * -
[Bf-blender-cvs] [4fa7ff83c04] cycles_oneapi: BLF: Add Support for Variable Fonts
Commit: 4fa7ff83c041a78c280a0f2d49721ad371ce6551 Author: Harley Acheson Date: Mon Jun 27 06:05:46 2022 -0700 Branches: cycles_oneapi https://developer.blender.org/rB4fa7ff83c041a78c280a0f2d49721ad371ce6551 BLF: Add Support for Variable Fonts Add support for Variable/Multiple Master font features. These are fonts that contain a range of design variations along multiple axes. This contains no client-facing options. See D12977 for details and examples Differential Revision: https://developer.blender.org/D12977 Reviewed by Brecht Van Lommel === M source/blender/blenfont/intern/blf_font.c M source/blender/blenfont/intern/blf_glyph.c M source/blender/blenfont/intern/blf_internal_types.h === diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 3e2927d581e..038e73cc928 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -18,7 +18,8 @@ #include FT_FREETYPE_H #include FT_GLYPH_H -#include FT_TRUETYPE_TABLES_H /* For TT_OS2 */ +#include FT_TRUETYPE_TABLES_H /* For TT_OS2 */ +#include FT_MULTIPLE_MASTERS_H /* Variable font support. */ #include "MEM_guardedalloc.h" @@ -1285,6 +1286,10 @@ FontBLF *blf_font_new(const char *name, const char *filepath) MEM_freeN(mfile); } + if (FT_HAS_MULTIPLE_MASTERS(font->face)) { +FT_Get_MM_Var(font->face, &(font->variations)); + } + font->name = BLI_strdup(name); font->filepath = BLI_strdup(filepath); blf_font_fill(font); @@ -1351,6 +1356,10 @@ FontBLF *blf_font_new_from_mem(const char *name, const unsigned char *mem, int m return NULL; } + if (FT_HAS_MULTIPLE_MASTERS(font->face)) { +FT_Get_MM_Var(font->face, &(font->variations)); + } + font->name = BLI_strdup(name); font->filepath = NULL; blf_font_fill(font); @@ -1365,6 +1374,10 @@ void blf_font_free(FontBLF *font) MEM_freeN(font->kerning_cache); } + if (font->variations) { +FT_Done_MM_Var(ft_lib, font->variations); + } + FT_Done_Face(font->face); if (font->filepath) { MEM_freeN(font->filepath); diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index ed30cca4da2..f1a9816c417 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -19,6 +19,7 @@ #include FT_OUTLINE_H #include FT_BITMAP_H #include FT_ADVANCES_H /* For FT_Get_Advance. */ +#include FT_MULTIPLE_MASTERS_H /* Variable font support. */ #include "MEM_guardedalloc.h" @@ -64,7 +65,9 @@ static GlyphCacheBLF *blf_glyph_cache_find(FontBLF *font, float size, unsigned i GlyphCacheBLF *gc = (GlyphCacheBLF *)font->cache.first; while (gc) { if (gc->size == size && gc->dpi == dpi && (gc->bold == ((font->flags & BLF_BOLD) != 0)) && -(gc->italic == ((font->flags & BLF_ITALIC) != 0))) { +(gc->italic == ((font->flags & BLF_ITALIC) != 0)) && +(gc->char_weight == font->char_weight) && (gc->char_slant == font->char_slant) && +(gc->char_width == font->char_width) && (gc->char_spacing == font->char_spacing)) { return gc; } gc = gc->next; @@ -82,6 +85,10 @@ static GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font) gc->dpi = font->dpi; gc->bold = ((font->flags & BLF_BOLD) != 0); gc->italic = ((font->flags & BLF_ITALIC) != 0); + gc->char_weight = font->char_weight; + gc->char_slant = font->char_slant; + gc->char_width = font->char_width; + gc->char_spacing = font->char_spacing; memset(gc->glyph_ascii_table, 0, sizeof(gc->glyph_ascii_table)); memset(gc->bucket, 0, sizeof(gc->bucket)); @@ -673,6 +680,96 @@ static bool blf_glyph_render_bitmap(FontBLF *font, FT_GlyphSlot glyph) /** \} */ +/* */ +/** \name Variations (Multiple Masters) support + * \{ */ + +/** + * Return a design axis that matches an identifying tag. + * + * \param variations: Variation descriptors from `FT_Get_MM_Var`. + * \param tag: Axis tag (4-character string as uint), like 'wght' + * \param axis_index: returns index of axis in variations array. + */ +static FT_Var_Axis *blf_var_axis_by_tag(FT_MM_Var *variations, uint tag, int *axis_index) +{ + *axis_index = -1; + if (!variations) { +return NULL; + } + for (int i = 0; i < (int)variations->num_axis; i++) { +if (variations->axis[i].tag == tag) { + *axis_index = i; + return &(variations->axis)[i]; + break; +} + } + return NULL; +} + +/** + * Convert a float factor to
[Bf-blender-cvs] [ab7d9301866] cycles_oneapi: Revert 6de0f299505a: BLF: Support for Variable Fonts
Commit: ab7d93018669b222e022a0cd76d995f9bae27b5d Author: Harley Acheson Date: Mon Jun 27 06:32:30 2022 -0700 Branches: cycles_oneapi https://developer.blender.org/rBab7d93018669b222e022a0cd76d995f9bae27b5d Revert 6de0f299505a: BLF: Support for Variable Fonts Reverting for now, breaks on GCC === M source/blender/blenfont/intern/blf_font.c M source/blender/blenfont/intern/blf_glyph.c M source/blender/blenfont/intern/blf_internal_types.h === diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 038e73cc928..3e2927d581e 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -18,8 +18,7 @@ #include FT_FREETYPE_H #include FT_GLYPH_H -#include FT_TRUETYPE_TABLES_H /* For TT_OS2 */ -#include FT_MULTIPLE_MASTERS_H /* Variable font support. */ +#include FT_TRUETYPE_TABLES_H /* For TT_OS2 */ #include "MEM_guardedalloc.h" @@ -1286,10 +1285,6 @@ FontBLF *blf_font_new(const char *name, const char *filepath) MEM_freeN(mfile); } - if (FT_HAS_MULTIPLE_MASTERS(font->face)) { -FT_Get_MM_Var(font->face, &(font->variations)); - } - font->name = BLI_strdup(name); font->filepath = BLI_strdup(filepath); blf_font_fill(font); @@ -1356,10 +1351,6 @@ FontBLF *blf_font_new_from_mem(const char *name, const unsigned char *mem, int m return NULL; } - if (FT_HAS_MULTIPLE_MASTERS(font->face)) { -FT_Get_MM_Var(font->face, &(font->variations)); - } - font->name = BLI_strdup(name); font->filepath = NULL; blf_font_fill(font); @@ -1374,10 +1365,6 @@ void blf_font_free(FontBLF *font) MEM_freeN(font->kerning_cache); } - if (font->variations) { -FT_Done_MM_Var(ft_lib, font->variations); - } - FT_Done_Face(font->face); if (font->filepath) { MEM_freeN(font->filepath); diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index f1a9816c417..bda6c51bf14 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -19,7 +19,6 @@ #include FT_OUTLINE_H #include FT_BITMAP_H #include FT_ADVANCES_H /* For FT_Get_Advance. */ -#include FT_MULTIPLE_MASTERS_H /* Variable font support. */ #include "MEM_guardedalloc.h" @@ -65,9 +64,7 @@ static GlyphCacheBLF *blf_glyph_cache_find(FontBLF *font, float size, unsigned i GlyphCacheBLF *gc = (GlyphCacheBLF *)font->cache.first; while (gc) { if (gc->size == size && gc->dpi == dpi && (gc->bold == ((font->flags & BLF_BOLD) != 0)) && -(gc->italic == ((font->flags & BLF_ITALIC) != 0)) && -(gc->char_weight == font->char_weight) && (gc->char_slant == font->char_slant) && -(gc->char_width == font->char_width) && (gc->char_spacing == font->char_spacing)) { +(gc->italic == ((font->flags & BLF_ITALIC) != 0))) { return gc; } gc = gc->next; @@ -85,10 +82,6 @@ static GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font) gc->dpi = font->dpi; gc->bold = ((font->flags & BLF_BOLD) != 0); gc->italic = ((font->flags & BLF_ITALIC) != 0); - gc->char_weight = font->char_weight; - gc->char_slant = font->char_slant; - gc->char_width = font->char_width; - gc->char_spacing = font->char_spacing; memset(gc->glyph_ascii_table, 0, sizeof(gc->glyph_ascii_table)); memset(gc->bucket, 0, sizeof(gc->bucket)); @@ -680,96 +673,6 @@ static bool blf_glyph_render_bitmap(FontBLF *font, FT_GlyphSlot glyph) /** \} */ -/* */ -/** \name Variations (Multiple Masters) support - * \{ */ - -/** - * Return a design axis that matches an identifying tag. - * - * \param variations: Variation descriptors from `FT_Get_MM_Var`. - * \param tag: Axis tag (4-character string as uint), like 'wght' - * \param axis_index: returns index of axis in variations array. - */ -static FT_Var_Axis *blf_var_axis_by_tag(FT_MM_Var *variations, uint tag, int *axis_index) -{ - *axis_index = -1; - if (!variations) { -return NULL; - } - for (int i = 0; i < (int)variations->num_axis; i++) { -if (variations->axis[i].tag == tag) { - *axis_index = i; - return &(variations->axis)[i]; - break; -} - } - return NULL; -} - -/** - * Convert a float factor to a fixed-point design coordinate. - * - * \param axis: Pointer to a design space axis structure. - * \param factor: -1 to 1 with 0 meaning "default" - */ -static FT_Fixed blf_factor_to_coordinate(FT_Var_Axis *axis, float factor) -{ - FT_Fix
[Bf-blender-cvs] [62439723192] master: UI: Scrollbar Behavior Changes
Commit: 6243972319289d86c70ce9946d10909e7eddfdaf Author: Harley Acheson Date: Mon Jun 27 06:45:49 2022 -0700 Branches: master https://developer.blender.org/rB6243972319289d86c70ce9946d10909e7eddfdaf UI: Scrollbar Behavior Changes Changes to scrollbars so that they are always visible, but thin and dim, and widen and become more visible as your mouse approaches. See D6505 for details and examples. Differential Revision: https://developer.blender.org/D6505 Reviewed by Campbell Barton === M source/blender/editors/include/UI_view2d.h M source/blender/editors/interface/interface_region_hud.cc M source/blender/editors/interface/view2d.cc M source/blender/editors/screen/area.c M source/blender/editors/screen/screen_ops.c === diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h index 23dbd3ed36f..5c4eb254462 100644 --- a/source/blender/editors/include/UI_view2d.h +++ b/source/blender/editors/include/UI_view2d.h @@ -49,8 +49,21 @@ enum eView2D_CommonViewTypes { /* -- Defines for Scrollers - */ /** Scroll bar area. */ -#define V2D_SCROLL_HEIGHT (0.45f * U.widget_unit) -#define V2D_SCROLL_WIDTH (0.45f * U.widget_unit) + +/* Maximum has to include outline which varies with line width. */ +#define V2D_SCROLL_HEIGHT ((0.45f * U.widget_unit) + (2.0f * U.pixelsize)) +#define V2D_SCROLL_WIDTH ((0.45f * U.widget_unit) + (2.0f * U.pixelsize)) + +/* Alpha of scrollbar when at minimum size. */ +#define V2D_SCROLL_MIN_ALPHA (0.4f) + +/* Minimum size needs to include outline which varies with line width. */ +#define V2D_SCROLL_MIN_WIDTH ((5.0f * U.dpi_fac) + (2.0f * U.pixelsize)) + +/* When to start showing the full-width scroller. */ +#define V2D_SCROLL_HIDE_WIDTH (AREAMINX * U.dpi_fac) +#define V2D_SCROLL_HIDE_HEIGHT (HEADERY * U.dpi_fac) + /** Scroll bars with 'handles' used for scale (zoom). */ #define V2D_SCROLL_HANDLE_HEIGHT (0.6f * U.widget_unit) #define V2D_SCROLL_HANDLE_WIDTH (0.6f * U.widget_unit) @@ -236,9 +249,13 @@ void UI_view2d_draw_scale_x__frames_or_seconds(const struct ARegion *region, void UI_view2d_scrollers_calc(struct View2D *v2d, const struct rcti *mask_custom, struct View2DScrollers *r_scrollers); + /** * Draw scroll-bars in the given 2D-region. */ +void UI_view2d_scrollers_draw_ex(struct View2D *v2d, + const struct rcti *mask_custom, + bool use_full_hide); void UI_view2d_scrollers_draw(struct View2D *v2d, const struct rcti *mask_custom); /* List view tools. */ @@ -329,8 +346,10 @@ struct View2D *UI_view2d_fromcontext_rwin(const struct bContext *C); /** * Get scrollbar sizes of the current 2D view. * The size will be zero if the view has its scrollbars disabled. + * + * \param mapped: whether to use view2d_scroll_mapped which changes flags */ -void UI_view2d_scroller_size_get(const struct View2D *v2d, float *r_x, float *r_y); +void UI_view2d_scroller_size_get(const struct View2D *v2d, bool mapped, float *r_x, float *r_y); /** * Calculate the scale per-axis of the drawing-area * diff --git a/source/blender/editors/interface/interface_region_hud.cc b/source/blender/editors/interface/interface_region_hud.cc index d6166694a4a..aca36686dea 100644 --- a/source/blender/editors/interface/interface_region_hud.cc +++ b/source/blender/editors/interface/interface_region_hud.cc @@ -143,6 +143,11 @@ static void hud_panels_register(ARegionType *art, int space_type, int region_typ static void hud_region_init(wmWindowManager *wm, ARegion *region) { ED_region_panels_init(wm, region); + + /* Reset zoom from panels init because we don't want zoom allowed for redo panel. */ + region->v2d.maxzoom = 1.0f; + region->v2d.minzoom = 1.0f; + UI_region_handlers_add(>handlers); region->flag |= RGN_FLAG_TEMP_REGIONDATA; } @@ -251,7 +256,7 @@ static ARegion *hud_region_add(ScrArea *area) if (region_win) { float x, y; -UI_view2d_scroller_size_get(_win->v2d, , ); +UI_view2d_scroller_size_get(_win->v2d, true, , ); region->runtime.offset_x = x; region->runtime.offset_y = y; } diff --git a/source/blender/editors/interface/view2d.cc b/source/blender/editors/interface/view2d.cc index 6ece7eb4ffa..ee4bfd351ae 100644 --- a/source/blender/editors/interface/view2d.cc +++ b/source/blender/editors/interface/view2d.cc @@ -149,7 +149,9 @@ static void view2d_masks(View2D *v2d, const rcti *mask_scroll) } } - scroll = view2d_scroll_mapped(v2d->scroll); + /* Do not use mapped scroll here because we want to update scroller rects + * even if they are not displayed. For init purposes. See T75003.*/ + scroll = v2d->scroll; /* Scrollers are based off region-size: * - they c
[Bf-blender-cvs] [228d79b7897] master: Revert 6de0f299505a: BLF: Support for Variable Fonts
Commit: 228d79b78977282fcfcfe95a24a97cd023f3dc3f Author: Harley Acheson Date: Mon Jun 27 06:32:30 2022 -0700 Branches: master https://developer.blender.org/rB228d79b78977282fcfcfe95a24a97cd023f3dc3f Revert 6de0f299505a: BLF: Support for Variable Fonts Reverting for now, breaks on GCC === M source/blender/blenfont/intern/blf_font.c M source/blender/blenfont/intern/blf_glyph.c M source/blender/blenfont/intern/blf_internal_types.h === diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 038e73cc928..3e2927d581e 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -18,8 +18,7 @@ #include FT_FREETYPE_H #include FT_GLYPH_H -#include FT_TRUETYPE_TABLES_H /* For TT_OS2 */ -#include FT_MULTIPLE_MASTERS_H /* Variable font support. */ +#include FT_TRUETYPE_TABLES_H /* For TT_OS2 */ #include "MEM_guardedalloc.h" @@ -1286,10 +1285,6 @@ FontBLF *blf_font_new(const char *name, const char *filepath) MEM_freeN(mfile); } - if (FT_HAS_MULTIPLE_MASTERS(font->face)) { -FT_Get_MM_Var(font->face, &(font->variations)); - } - font->name = BLI_strdup(name); font->filepath = BLI_strdup(filepath); blf_font_fill(font); @@ -1356,10 +1351,6 @@ FontBLF *blf_font_new_from_mem(const char *name, const unsigned char *mem, int m return NULL; } - if (FT_HAS_MULTIPLE_MASTERS(font->face)) { -FT_Get_MM_Var(font->face, &(font->variations)); - } - font->name = BLI_strdup(name); font->filepath = NULL; blf_font_fill(font); @@ -1374,10 +1365,6 @@ void blf_font_free(FontBLF *font) MEM_freeN(font->kerning_cache); } - if (font->variations) { -FT_Done_MM_Var(ft_lib, font->variations); - } - FT_Done_Face(font->face); if (font->filepath) { MEM_freeN(font->filepath); diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index f1a9816c417..bda6c51bf14 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -19,7 +19,6 @@ #include FT_OUTLINE_H #include FT_BITMAP_H #include FT_ADVANCES_H /* For FT_Get_Advance. */ -#include FT_MULTIPLE_MASTERS_H /* Variable font support. */ #include "MEM_guardedalloc.h" @@ -65,9 +64,7 @@ static GlyphCacheBLF *blf_glyph_cache_find(FontBLF *font, float size, unsigned i GlyphCacheBLF *gc = (GlyphCacheBLF *)font->cache.first; while (gc) { if (gc->size == size && gc->dpi == dpi && (gc->bold == ((font->flags & BLF_BOLD) != 0)) && -(gc->italic == ((font->flags & BLF_ITALIC) != 0)) && -(gc->char_weight == font->char_weight) && (gc->char_slant == font->char_slant) && -(gc->char_width == font->char_width) && (gc->char_spacing == font->char_spacing)) { +(gc->italic == ((font->flags & BLF_ITALIC) != 0))) { return gc; } gc = gc->next; @@ -85,10 +82,6 @@ static GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font) gc->dpi = font->dpi; gc->bold = ((font->flags & BLF_BOLD) != 0); gc->italic = ((font->flags & BLF_ITALIC) != 0); - gc->char_weight = font->char_weight; - gc->char_slant = font->char_slant; - gc->char_width = font->char_width; - gc->char_spacing = font->char_spacing; memset(gc->glyph_ascii_table, 0, sizeof(gc->glyph_ascii_table)); memset(gc->bucket, 0, sizeof(gc->bucket)); @@ -680,96 +673,6 @@ static bool blf_glyph_render_bitmap(FontBLF *font, FT_GlyphSlot glyph) /** \} */ -/* */ -/** \name Variations (Multiple Masters) support - * \{ */ - -/** - * Return a design axis that matches an identifying tag. - * - * \param variations: Variation descriptors from `FT_Get_MM_Var`. - * \param tag: Axis tag (4-character string as uint), like 'wght' - * \param axis_index: returns index of axis in variations array. - */ -static FT_Var_Axis *blf_var_axis_by_tag(FT_MM_Var *variations, uint tag, int *axis_index) -{ - *axis_index = -1; - if (!variations) { -return NULL; - } - for (int i = 0; i < (int)variations->num_axis; i++) { -if (variations->axis[i].tag == tag) { - *axis_index = i; - return &(variations->axis)[i]; - break; -} - } - return NULL; -} - -/** - * Convert a float factor to a fixed-point design coordinate. - * - * \param axis: Pointer to a design space axis structure. - * \param factor: -1 to 1 with 0 meaning "default" - */ -static FT_Fixed blf_factor_to_coordinate(FT_Var_Axis *axis, float factor) -{ - FT_Fixed valu
[Bf-blender-cvs] [6de0f299505] master: BLF: Add Support for Variable Fonts
Commit: 6de0f299505a24969022cc2a63dd11db7b13b1be Author: Harley Acheson Date: Mon Jun 27 06:05:46 2022 -0700 Branches: master https://developer.blender.org/rB6de0f299505a24969022cc2a63dd11db7b13b1be BLF: Add Support for Variable Fonts Add support for Variable/Multiple Master font features. These are fonts that contain a range of design variations along multiple axes. This contains no client-facing options. See D12977 for details and examples Differential Revision: https://developer.blender.org/D12977 Reviewed by Brecht Van Lommel === M source/blender/blenfont/intern/blf_font.c M source/blender/blenfont/intern/blf_glyph.c M source/blender/blenfont/intern/blf_internal_types.h === diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 3e2927d581e..038e73cc928 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -18,7 +18,8 @@ #include FT_FREETYPE_H #include FT_GLYPH_H -#include FT_TRUETYPE_TABLES_H /* For TT_OS2 */ +#include FT_TRUETYPE_TABLES_H /* For TT_OS2 */ +#include FT_MULTIPLE_MASTERS_H /* Variable font support. */ #include "MEM_guardedalloc.h" @@ -1285,6 +1286,10 @@ FontBLF *blf_font_new(const char *name, const char *filepath) MEM_freeN(mfile); } + if (FT_HAS_MULTIPLE_MASTERS(font->face)) { +FT_Get_MM_Var(font->face, &(font->variations)); + } + font->name = BLI_strdup(name); font->filepath = BLI_strdup(filepath); blf_font_fill(font); @@ -1351,6 +1356,10 @@ FontBLF *blf_font_new_from_mem(const char *name, const unsigned char *mem, int m return NULL; } + if (FT_HAS_MULTIPLE_MASTERS(font->face)) { +FT_Get_MM_Var(font->face, &(font->variations)); + } + font->name = BLI_strdup(name); font->filepath = NULL; blf_font_fill(font); @@ -1365,6 +1374,10 @@ void blf_font_free(FontBLF *font) MEM_freeN(font->kerning_cache); } + if (font->variations) { +FT_Done_MM_Var(ft_lib, font->variations); + } + FT_Done_Face(font->face); if (font->filepath) { MEM_freeN(font->filepath); diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index ed30cca4da2..f1a9816c417 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -19,6 +19,7 @@ #include FT_OUTLINE_H #include FT_BITMAP_H #include FT_ADVANCES_H /* For FT_Get_Advance. */ +#include FT_MULTIPLE_MASTERS_H /* Variable font support. */ #include "MEM_guardedalloc.h" @@ -64,7 +65,9 @@ static GlyphCacheBLF *blf_glyph_cache_find(FontBLF *font, float size, unsigned i GlyphCacheBLF *gc = (GlyphCacheBLF *)font->cache.first; while (gc) { if (gc->size == size && gc->dpi == dpi && (gc->bold == ((font->flags & BLF_BOLD) != 0)) && -(gc->italic == ((font->flags & BLF_ITALIC) != 0))) { +(gc->italic == ((font->flags & BLF_ITALIC) != 0)) && +(gc->char_weight == font->char_weight) && (gc->char_slant == font->char_slant) && +(gc->char_width == font->char_width) && (gc->char_spacing == font->char_spacing)) { return gc; } gc = gc->next; @@ -82,6 +85,10 @@ static GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font) gc->dpi = font->dpi; gc->bold = ((font->flags & BLF_BOLD) != 0); gc->italic = ((font->flags & BLF_ITALIC) != 0); + gc->char_weight = font->char_weight; + gc->char_slant = font->char_slant; + gc->char_width = font->char_width; + gc->char_spacing = font->char_spacing; memset(gc->glyph_ascii_table, 0, sizeof(gc->glyph_ascii_table)); memset(gc->bucket, 0, sizeof(gc->bucket)); @@ -673,6 +680,96 @@ static bool blf_glyph_render_bitmap(FontBLF *font, FT_GlyphSlot glyph) /** \} */ +/* */ +/** \name Variations (Multiple Masters) support + * \{ */ + +/** + * Return a design axis that matches an identifying tag. + * + * \param variations: Variation descriptors from `FT_Get_MM_Var`. + * \param tag: Axis tag (4-character string as uint), like 'wght' + * \param axis_index: returns index of axis in variations array. + */ +static FT_Var_Axis *blf_var_axis_by_tag(FT_MM_Var *variations, uint tag, int *axis_index) +{ + *axis_index = -1; + if (!variations) { +return NULL; + } + for (int i = 0; i < (int)variations->num_axis; i++) { +if (variations->axis[i].tag == tag) { + *axis_index = i; + return &(variations->axis)[i]; + break; +} + } + return NULL; +} + +/** + * Convert a float factor to a f
[Bf-blender-cvs] [3d3c0dfe30f] master: Cleanup: Compiler Warning of Sign Conversion
Commit: 3d3c0dfe30ff186817b9a54985bfa0b5e437fff2 Author: Harley Acheson Date: Fri Jun 17 12:45:32 2022 -0700 Branches: master https://developer.blender.org/rB3d3c0dfe30ff186817b9a54985bfa0b5e437fff2 Cleanup: Compiler Warning of Sign Conversion rB524a9e3db810 introduced sign-conversion warning on Linux. Own Code === M source/blender/blenfont/intern/blf_glyph.c === diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 32d4be3be0c..6c8909685dc 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -549,7 +549,7 @@ static bool blf_font_has_coverage_bit(FontBLF *font, int coverage_bit) if (coverage_bit < 0) { return false; } - return (font->UnicodeRanges[coverage_bit >> 5] & (1 << (coverage_bit % 32))); + return (font->UnicodeRanges[(uint)coverage_bit >> 5] & (1 << ((uint)coverage_bit % 32))); } /** ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [524a9e3db81] master: BLF: Fallback Font Stack
Commit: 524a9e3db8102c89abf3b80cddaea60c314d67ae Author: Harley Acheson Date: Fri Jun 17 10:30:34 2022 -0700 Branches: master https://developer.blender.org/rB524a9e3db8102c89abf3b80cddaea60c314d67ae BLF: Fallback Font Stack Allow use of multiple fonts acting together like a fallback stack, where if a glyph is not found in one it can be retrieved from another. See D12622 for much more detail Differential Revision: https://developer.blender.org/D12622 Reviewed by Brecht Van Lommel === M source/blender/blenfont/BLF_api.h M source/blender/blenfont/intern/blf.c M source/blender/blenfont/intern/blf_font.c M source/blender/blenfont/intern/blf_font_default.c M source/blender/blenfont/intern/blf_glyph.c M source/blender/blenfont/intern/blf_internal.h M source/blender/blenfont/intern/blf_internal_types.h M source/blender/blenlib/intern/string_utf8.c M source/blender/editors/interface/interface_style.cc M source/blender/windowmanager/intern/wm_playanim.c === diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h index e5e2b1711b1..78c8612f7f5 100644 --- a/source/blender/blenfont/BLF_api.h +++ b/source/blender/blenfont/BLF_api.h @@ -14,6 +14,15 @@ extern "C" { #endif +/* Name of subfolder inside BLENDER_DATAFILES that contains font files. */ +#define BLF_DATAFILES_FONTS_DIR "fonts" + +/* File name of the default variable-width font. */ +#define BLF_DEFAULT_PROPORTIONAL_FONT "droidsans.ttf" + +/* File name of the default fixed-pitch font. */ +#define BLF_DEFAULT_MONOSPACED_FONT "bmonofont-i18n.ttf" + /* enable this only if needed (unused circa 2016) */ #define BLF_BLUR_ENABLE 0 @@ -37,12 +46,14 @@ void BLF_cache_flush_set_fn(void (*cache_flush_fn)(void)); */ int BLF_load(const char *name) ATTR_NONNULL(); int BLF_load_mem(const char *name, const unsigned char *mem, int mem_size) ATTR_NONNULL(); +bool BLF_is_loaded(const char *name) ATTR_NONNULL(); int BLF_load_unique(const char *name) ATTR_NONNULL(); int BLF_load_mem_unique(const char *name, const unsigned char *mem, int mem_size) ATTR_NONNULL(); void BLF_unload(const char *name) ATTR_NONNULL(); void BLF_unload_id(int fontid); +void BLF_unload_all(void); char *BLF_display_name_from_file(const char *filepath); @@ -312,6 +323,7 @@ int BLF_set_default(void); int BLF_load_default(bool unique); int BLF_load_mono_default(bool unique); +void BLF_load_font_stack(void); #ifdef DEBUG void BLF_state_print(int fontid); @@ -331,6 +343,9 @@ void BLF_state_print(int fontid); #define BLF_HINTING_FULL (1 << 10) #define BLF_BOLD (1 << 11) #define BLF_ITALIC (1 << 12) +#define BLF_MONOSPACED (1 << 13) /* Intended USE is monospaced, regardless of font type. */ +#define BLF_DEFAULT (1 << 14) /* A font within the default stack of fonts. */ +#define BLF_LAST_RESORT (1 << 15) /* Must only be used as last font in the stack. */ #define BLF_DRAW_STR_DUMMY_MAX 1024 diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index a944ab332bd..a1fcc17ca3f 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -34,13 +34,6 @@ #include "blf_internal.h" #include "blf_internal_types.h" -/* Max number of font in memory. - * Take care that now every font have a glyph cache per size/dpi, - * so we don't need load the same font with different size, just - * load one and call BLF_size. - */ -#define BLF_MAX_FONT 16 - #define BLF_RESULT_CHECK_INIT(r_info) \ if (r_info) { \ memset(r_info, 0, sizeof(*(r_info))); \ @@ -48,7 +41,7 @@ ((void)0) /* Font array. */ -static FontBLF *global_font[BLF_MAX_FONT] = {NULL}; +FontBLF *global_font[BLF_MAX_FONT] = {NULL}; /* XXX: should these be made into global_font_'s too? */ @@ -134,6 +127,11 @@ bool BLF_has_glyph(int fontid, unsigned int unicode) return false; } +bool BLF_is_loaded(const char *name) +{ + return blf_search(name) >= 0; +} + int BLF_load(const char *name) { /* check if we already load this font. */ @@ -255,6 +253,20 @@ void BLF_unload_id(int fontid) } } +void BLF_unload_all(void) +{ + for (int i = 0; i < BLF_MAX_FONT; i++) { +FontBLF *font = global_font[i]; +if (font) { + blf_font_free(font); + global_font[i] = NULL; +} + } + blf_mono_font = -1; + blf_mono_font_render = -1; + BLF_default_set(-1); +} + void BLF_enable(int fontid, int option) { FontBLF *font = blf_get(fontid); diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index a170f27d247..26a72fcb95a 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -18,6 +18,7 @@ #include FT_FREETYPE_
[Bf-blender-cvs] [3e7d977886f] master: IME Cleanup: Removal of BLT_lang_is_ime_supported
Commit: 3e7d977886f467a8d14d0edc49f65000336caa64 Author: Harley Acheson Date: Tue Jun 7 10:02:04 2022 -0700 Branches: master https://developer.blender.org/rB3e7d977886f467a8d14d0edc49f65000336caa64 IME Cleanup: Removal of BLT_lang_is_ime_supported Removal of BLT_lang_is_ime_supported which is always returns true and is no longer needed. See D11800 for more details. Differential Revision: https://developer.blender.org/D11800 Reviewed by Campbell Barton === M source/blender/blentranslation/BLT_translation.h M source/blender/blentranslation/intern/blt_lang.c M source/blender/editors/interface/interface_handlers.c === diff --git a/source/blender/blentranslation/BLT_translation.h b/source/blender/blentranslation/BLT_translation.h index ebb0f604df7..129eba3de2f 100644 --- a/source/blender/blentranslation/BLT_translation.h +++ b/source/blender/blentranslation/BLT_translation.h @@ -28,13 +28,6 @@ const char *BLT_translate_do_iface(const char *msgctxt, const char *msgid); const char *BLT_translate_do_tooltip(const char *msgctxt, const char *msgid); const char *BLT_translate_do_new_dataname(const char *msgctxt, const char *msgid); -/** - * Note that "lang" here is the _output_ display language. We used to restrict - * IME for keyboard _input_ language because our multilingual font was only used - * when some output languages were selected. That font is used all the time now. - */ -bool BLT_lang_is_ime_supported(void); - /* The "translation-marker" macro. */ #define N_(msgid) msgid #define CTX_N_(context, msgid) msgid diff --git a/source/blender/blentranslation/intern/blt_lang.c b/source/blender/blentranslation/intern/blt_lang.c index b015057ad2d..cb04b3ac0dc 100644 --- a/source/blender/blentranslation/intern/blt_lang.c +++ b/source/blender/blentranslation/intern/blt_lang.c @@ -345,12 +345,3 @@ void BLT_lang_locale_explode(const char *locale, MEM_freeN(_t); } } - -bool BLT_lang_is_ime_supported(void) -{ -#ifdef WITH_INPUT_IME - return true; -#else - return false; -#endif -} diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 10840c61b02..b06361c7e28 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -3507,7 +3507,7 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data) WM_cursor_modal_set(win, WM_CURSOR_TEXT_EDIT); #ifdef WITH_INPUT_IME - if (is_num_but == false && BLT_lang_is_ime_supported()) { + if (!is_num_but) { ui_textedit_ime_begin(win, but); } #endif @@ -3911,7 +3911,7 @@ static void ui_do_but_textedit( if ((event->ascii || event->utf8_buf[0]) && (retval == WM_UI_HANDLER_CONTINUE) #ifdef WITH_INPUT_IME -&& !is_ime_composing && (!WM_event_is_ime_switch(event) || !BLT_lang_is_ime_supported()) +&& !is_ime_composing && !WM_event_is_ime_switch(event) #endif ) { char ascii = event->ascii; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [f600a2aa6df] master: IMBUF: Thumbnails of all EXR files using less RAM
Commit: f600a2aa6df1dd85f9d00be57031c9e1dcbfbd08 Author: Harley Acheson Date: Thu May 19 14:55:04 2022 -0700 Branches: master https://developer.blender.org/rBf600a2aa6df1dd85f9d00be57031c9e1dcbfbd08 IMBUF: Thumbnails of all EXR files using less RAM Specialized thumbnailing function to create previews of all EXR image files, regardless of type, size, or dimensions. Uses less RAM by only loading a single row of pixels at a time. See D14663 for more details and examples. Differential Revision: https://developer.blender.org/D14663 Reviewed by Brecht Van Lommel === M source/blender/imbuf/intern/filetype.c M source/blender/imbuf/intern/openexr/openexr_api.cpp M source/blender/imbuf/intern/openexr/openexr_api.h === diff --git a/source/blender/imbuf/intern/filetype.c b/source/blender/imbuf/intern/filetype.c index 74042ef75be..92fa980cd7f 100644 --- a/source/blender/imbuf/intern/filetype.c +++ b/source/blender/imbuf/intern/filetype.c @@ -157,7 +157,7 @@ const ImFileType IMB_FILE_TYPES[] = { .is_a = imb_is_a_openexr, .load = imb_load_openexr, .load_filepath = NULL, -.load_filepath_thumbnail = NULL, +.load_filepath_thumbnail = imb_load_filepath_thumbnail_openexr, .save = imb_save_openexr, .load_tile = NULL, .flag = IM_FTYPE_FLOAT, diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 66ee3cf2c26..104be9008a4 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -43,6 +44,8 @@ #include #include #include +#include +#include #include #include #include @@ -63,6 +66,9 @@ #if defined(WIN32) # include "utfconv.h" +# include +#else +# include #endif #include "MEM_guardedalloc.h" @@ -77,7 +83,9 @@ _CRTIMP void __cdecl _invalid_parameter_noinfo(void) #endif } #include "BLI_blenlib.h" +#include "BLI_fileops.h" #include "BLI_math_color.h" +#include "BLI_mmap.h" #include "BLI_string_utils.h" #include "BLI_threads.h" @@ -151,6 +159,66 @@ class IMemStream : public Imf::IStream { unsigned char *_exrbuf; }; +/* Memory-Mapped Input Stream */ + +class IMMapStream : public Imf::IStream { + public: + IMMapStream(const char *filepath) : IStream(filepath) + { +int file = BLI_open(filepath, O_BINARY | O_RDONLY, 0); +if (file < 0) { + throw IEX_NAMESPACE::InputExc("file not found"); +} +_exrpos = 0; +_exrsize = BLI_file_descriptor_size(file); +imb_mmap_lock(); +_mmap_file = BLI_mmap_open(file); +imb_mmap_unlock(); +if (_mmap_file == NULL) { + throw IEX_NAMESPACE::InputExc("BLI_mmap_open failed"); +} +close(file); +_exrbuf = (unsigned char *)BLI_mmap_get_pointer(_mmap_file); + } + + ~IMMapStream() + { +imb_mmap_lock(); +BLI_mmap_free(_mmap_file); +imb_mmap_unlock(); + } + + /* This is implementing regular `read`, not `readMemoryMapped`, because DWAA and DWAB + * decompressors load on unaligned offsets. Therefore we can't avoid the memory copy. */ + + bool read(char c[], int n) override + { +if (_exrpos + n > _exrsize) { + throw Iex::InputExc("Unexpected end of file."); +} +memcpy(c, _exrbuf + _exrpos, n); +_exrpos += n; + +return _exrpos < _exrsize; + } + + exr_file_offset_t tellg() override + { +return _exrpos; + } + + void seekg(exr_file_offset_t pos) override + { +_exrpos = pos; + } + + private: + BLI_mmap_file *_mmap_file; + exr_file_offset_t _exrpos; + exr_file_offset_t _exrsize; + unsigned char *_exrbuf; +}; + /* File Input Stream */ class IFileStream : public Imf::IStream { @@ -2099,19 +2167,122 @@ struct ImBuf *imb_load_openexr(const unsigned char *mem, } } -void imb_initopenexr(void) +struct ImBuf *imb_load_filepath_thumbnail_openexr(const char *filepath, + const int flags, + const size_t max_thumb_size, + char colorspace[], + size_t *r_width, + size_t *r_height) { - int num_threads = BLI_system_thread_count(); + IStream *stream = nullptr; + Imf::RgbaInputFile *file = nullptr; + + /* OpenExr uses exceptions for error-handling. */ + try { + +/* The memory-mapped stream is faster, but don't use for huge files as it requires contiguous + * address space and we are processing multiple files at once (typically one per process
[Bf-blender-cvs] [fcbd81fb0f8] master: Win32: WM_SETTINGCHANGE lParam Check for NULL
Commit: fcbd81fb0f82080186220b554d12331b675f1e5e Author: Harley Acheson Date: Thu May 5 17:48:55 2022 -0700 Branches: master https://developer.blender.org/rBfcbd81fb0f82080186220b554d12331b675f1e5e Win32: WM_SETTINGCHANGE lParam Check for NULL Check that lParam is non-NULL in WM_SETTINGCHANGE message handler. See D14867 for details. Differential Revision: https://developer.blender.org/D14867 Reviewed by Jesse Yurkovich === M intern/ghost/intern/GHOST_SystemWin32.cpp === diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index ff02bc5781e..ca4bfa634c1 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -1987,7 +1987,8 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, } break; case WM_SETTINGCHANGE: - if (wcscmp(LPCWSTR(lParam), L"ImmersiveColorSet") == 0) { + /* Microsoft: "Note that some applications send this message with lParam set to NULL" */ + if ((lParam != NULL) && (wcscmp(LPCWSTR(lParam), L"ImmersiveColorSet") == 0)) { window->ThemeRefresh(); } break; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [ddbac88c08e] master: Win32: Dark Mode Title Bar Color
Commit: ddbac88c08ef2f97e4d7b99690cef28322cfb0ed Author: Harley Acheson Date: Wed May 4 20:18:15 2022 -0700 Branches: master https://developer.blender.org/rBddbac88c08ef2f97e4d7b99690cef28322cfb0ed Win32: Dark Mode Title Bar Color Blender will respect Windows "Dark Mode" setting for title bar color. See D14847 for details. Differential Revision: https://developer.blender.org/D14847 Reviewed by Ray Molenkamp === M build_files/cmake/platform/platform_win32.cmake M intern/ghost/intern/GHOST_SystemWin32.cpp M intern/ghost/intern/GHOST_WindowWin32.cpp M intern/ghost/intern/GHOST_WindowWin32.h === diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake index c5d2049b292..40c25abd585 100644 --- a/build_files/cmake/platform/platform_win32.cmake +++ b/build_files/cmake/platform/platform_win32.cmake @@ -104,7 +104,7 @@ string(APPEND CMAKE_MODULE_LINKER_FLAGS " /SAFESEH:NO /ignore:4099") list(APPEND PLATFORM_LINKLIBS ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32 Comctl32 version advapi32 shfolder shell32 ole32 oleaut32 uuid psapi Dbghelp Shlwapi - pathcch Shcore + pathcch Shcore Dwmapi ) if(WITH_INPUT_IME) diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index 83869188b65..ff02bc5781e 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -14,6 +14,7 @@ #endif #include +#include #include #include #include @@ -1985,6 +1986,11 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, ::SetFocus(hwnd); } break; +case WM_SETTINGCHANGE: + if (wcscmp(LPCWSTR(lParam), L"ImmersiveColorSet") == 0) { +window->ThemeRefresh(); + } + break; // Window events, ignored diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp index 2ce224b666b..f74a4b17a51 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.cpp +++ b/intern/ghost/intern/GHOST_WindowWin32.cpp @@ -16,9 +16,7 @@ #include "GHOST_ContextWGL.h" -#ifdef WIN32_COMPOSITING -# include -#endif +#include #include #include @@ -172,6 +170,8 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system, break; } + ThemeRefresh(); + ::ShowWindow(m_hWnd, nCmdShow); #ifdef WIN32_COMPOSITING @@ -1016,6 +1016,25 @@ GHOST_TabletData GHOST_WindowWin32::getTabletData() } } +void GHOST_WindowWin32::ThemeRefresh() +{ + DWORD lightMode; + DWORD pcbData = sizeof(lightMode); + if (RegGetValueW(HKEY_CURRENT_USER, + L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize\\", + L"AppsUseLightTheme", + RRF_RT_REG_DWORD, + NULL, + , + ) == ERROR_SUCCESS) { +BOOL DarkMode = !lightMode; + +/* 20 == DWMWA_USE_IMMERSIVE_DARK_MODE in Windows 11 SDK. This value was undocumented for + * Windows 10 versions 2004 and later, supported for Windows 11 Build 22000 and later. */ +DwmSetWindowAttribute(this->m_hWnd, 20, , sizeof(DarkMode)); + } +} + uint16_t GHOST_WindowWin32::getDPIHint() { if (m_user32) { diff --git a/intern/ghost/intern/GHOST_WindowWin32.h b/intern/ghost/intern/GHOST_WindowWin32.h index d5f47871aff..bc678adff3c 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.h +++ b/intern/ghost/intern/GHOST_WindowWin32.h @@ -294,6 +294,9 @@ class GHOST_WindowWin32 : public GHOST_Window { /** True if the window currently resizing. */ bool m_inLiveResize; + /** Called when OS colors change and when the window is created. */ + void ThemeRefresh(); + #ifdef WITH_INPUT_IME GHOST_ImeWin32 *getImeInput() { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [8960c6e0601] master: IMBUF: Faster JPEG Thumbnails
Commit: 8960c6e06017a3c3fc90c5745433009c00e64c1b Author: Harley Acheson Date: Wed May 4 16:55:59 2022 -0700 Branches: master https://developer.blender.org/rB8960c6e06017a3c3fc90c5745433009c00e64c1b IMBUF: Faster JPEG Thumbnails Make preview thumbnails of JPEG files in less time and with less RAM. See D14727 for more details. Differential Revision: https://developer.blender.org/D14727 Reviewed by Brecht Van Lommel === M source/blender/imbuf/IMB_imbuf.h M source/blender/imbuf/intern/IMB_filetype.h M source/blender/imbuf/intern/filetype.c M source/blender/imbuf/intern/jpeg.c M source/blender/imbuf/intern/readimage.c M source/blender/imbuf/intern/thumbs.c === diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index 0390df06052..8796c99629e 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -107,6 +107,14 @@ struct ImBuf *IMB_testiffname(const char *filepath, int flags); */ struct ImBuf *IMB_loadiffname(const char *filepath, int flags, char colorspace[IM_MAX_SPACE]); +/** + * + * \attention Defined in readimage.c + */ +struct ImBuf *IMB_thumb_load_image(const char *filepath, + const size_t max_thumb_size, + char colorspace[IM_MAX_SPACE]); + /** * * \attention Defined in allocimbuf.c diff --git a/source/blender/imbuf/intern/IMB_filetype.h b/source/blender/imbuf/intern/IMB_filetype.h index 31f8b3a9505..bcca6f9fd85 100644 --- a/source/blender/imbuf/intern/IMB_filetype.h +++ b/source/blender/imbuf/intern/IMB_filetype.h @@ -36,6 +36,15 @@ typedef struct ImFileType { char colorspace[IM_MAX_SPACE]); /** Load an image from a file. */ struct ImBuf *(*load_filepath)(const char *filepath, int flags, char colorspace[IM_MAX_SPACE]); + /** Load/Create a thumbnail image from a filepath. `max_thumb_size` is maximum size of either + * dimension, so can return less on either or both. Should, if possible and performant, return + * dimensions of the full-size image in width_r & height_r. */ + struct ImBuf *(*load_filepath_thumbnail)(const char *filepath, + const int flags, + const size_t max_thumb_size, + size_t *width_r, + size_t *height_r, + char colorspace[IM_MAX_SPACE]); /** Save to a file (or memory if #IB_mem is set in `flags` and the format supports it). */ bool (*save)(struct ImBuf *ibuf, const char *filepath, int flags); void (*load_tile)(struct ImBuf *ibuf, @@ -143,6 +152,12 @@ struct ImBuf *imb_load_jpeg(const unsigned char *buffer, size_t size, int flags, char colorspace[IM_MAX_SPACE]); +struct ImBuf *imb_thumbnail_jpeg(const char *filepath, + const int flags, + const size_t max_thumb_size, + size_t *width_r, + size_t *height_r, + char colorspace[IM_MAX_SPACE]); /** \} */ diff --git a/source/blender/imbuf/intern/filetype.c b/source/blender/imbuf/intern/filetype.c index 548bc9e120c..74042ef75be 100644 --- a/source/blender/imbuf/intern/filetype.c +++ b/source/blender/imbuf/intern/filetype.c @@ -33,6 +33,7 @@ const ImFileType IMB_FILE_TYPES[] = { .is_a = imb_is_a_jpeg, .load = imb_load_jpeg, .load_filepath = NULL, +.load_filepath_thumbnail = imb_thumbnail_jpeg, .save = imb_savejpeg, .load_tile = NULL, .flag = 0, @@ -45,6 +46,7 @@ const ImFileType IMB_FILE_TYPES[] = { .is_a = imb_is_a_png, .load = imb_loadpng, .load_filepath = NULL, +.load_filepath_thumbnail = NULL, .save = imb_savepng, .load_tile = NULL, .flag = 0, @@ -57,6 +59,7 @@ const ImFileType IMB_FILE_TYPES[] = { .is_a = imb_is_a_bmp, .load = imb_bmp_decode, .load_filepath = NULL, +.load_filepath_thumbnail = NULL, .save = imb_savebmp, .load_tile = NULL, .flag = 0, @@ -69,6 +72,7 @@ const ImFileType IMB_FILE_TYPES[] = { .is_a = imb_is_a_targa, .load = imb_loadtarga, .load_filepath = NULL, +.load_filepath_thumbnail = NULL, .save = imb_savetarga, .load_tile = NULL, .flag = 0, @@ -81,6 +85,7 @@ const ImFileType IMB_FILE_TYPES[] = { .is_a = imb_is_a_iris, .load = imb_loadiris, .load_filepath = NULL, +.load_filepath_thumbnail = NULL, .save = imb_save
[Bf-blender-cvs] [c6ce2be4962] master: Fix T97627: Revert Window Redraw When Saving
Commit: c6ce2be4962de62415fadd8f4f38e5a9e12b5f64 Author: Harley Acheson Date: Wed Apr 27 15:07:34 2022 -0700 Branches: master https://developer.blender.org/rBc6ce2be4962de62415fadd8f4f38e5a9e12b5f64 Fix T97627: Revert Window Redraw When Saving Removal of the `WM_redraw_windows` call in `wm_file_write` introduced in rB7a9cfd08a8d7415ff004809cf62570be9152273e as that can cause crashing while saving from a script. See D14780 for more details. Differential Revision: https://developer.blender.org/D14780 Reviewed by Campbell Barton === M source/blender/windowmanager/intern/wm_files.c === diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index caa3a493349..bee7e71df54 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -1760,11 +1760,9 @@ static bool wm_file_write(bContext *C, /* Enforce full override check/generation on file save. */ BKE_lib_override_library_main_operations_create(bmain, true); - if (!G.background && BLI_thread_is_main()) { -/* Redraw to remove menus that might be open. - * But only in the main thread otherwise this can crash, see T92704. */ -WM_redraw_windows(C); - } + /* NOTE: Ideally we would call `WM_redraw_windows` here to remove any open menus. But we + * can crash if saving from a script, see T92704 & T97627. Just checking `!G.background + * && BLI_thread_is_main()` is not sufficient to fix this. */ /* don't forget not to return without! */ WM_cursor_wait(true); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [8826db8f030] master: Fix T97310: BLF Line Height While Text Wrapping
Commit: 8826db8f0300cdc60b985ce9b05f2338c20ac411 Author: Harley Acheson Date: Wed Apr 13 17:45:32 2022 -0700 Branches: master https://developer.blender.org/rB8826db8f0300cdc60b985ce9b05f2338c20ac411 Fix T97310: BLF Line Height While Text Wrapping Fix word-wrapped tooltip text not showing by aligning to pixel grid. See D14639 for more details. Differential Revision: https://developer.blender.org/D14639 Reviewed by Campbell Barton === M source/blender/blenfont/intern/blf_font.c M source/blender/blenfont/intern/blf_internal_types.h === diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 51b65dab8fc..f93cb8b2d64 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -921,6 +921,9 @@ static void blf_font_wrap_apply(FontBLF *font, int lines = 0; ft_pix pen_x_next = 0; + /* Space between lines needs to be aligned to the pixel grid (T97310). */ + ft_pix line_height = FT_PIX_FLOOR(blf_font_height_max_ft_pix(font)); + GlyphCacheBLF *gc = blf_glyph_cache_acquire(font); struct WordWrapVars { @@ -978,7 +981,7 @@ static void blf_font_wrap_apply(FontBLF *font, wrap.start = wrap.last[0]; i = wrap.last[1]; pen_x = 0; - pen_y -= blf_font_height_max_ft_pix(font); + pen_y -= line_height; g_prev = NULL; lines += 1; continue; diff --git a/source/blender/blenfont/intern/blf_internal_types.h b/source/blender/blenfont/intern/blf_internal_types.h index 79388752969..62bce36dda0 100644 --- a/source/blender/blenfont/intern/blf_internal_types.h +++ b/source/blender/blenfont/intern/blf_internal_types.h @@ -76,7 +76,6 @@ BLI_INLINE ft_pix ft_pix_round_advance(ft_pix v, ft_pix step) return FT_PIX_DEFAULT_ROUNDING(v) + FT_PIX_DEFAULT_ROUNDING(step); } -#undef FT_PIX_FLOOR #undef FT_PIX_ROUND #undef FT_PIX_CEIL #undef FT_PIX_DEFAULT_ROUNDING ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [84fde382e43] master: Fix T85689: Assume Win32 Volumes are Valid
Commit: 84fde382e43cff6407bfa3587fec9bd570cf9123 Author: Harley Acheson Date: Wed Mar 30 11:10:15 2022 -0700 Branches: master https://developer.blender.org/rB84fde382e43cff6407bfa3587fec9bd570cf9123 Fix T85689: Assume Win32 Volumes are Valid Skip validation when inserting items into the Win32 "Volumes" list. This fixes some long hangs when launching Blender with disconnected network shares. See D14506 for more details. Differential Revision: https://developer.blender.org/D14506 Reviewed by Brecht Van Lommel === M source/blender/editors/include/ED_fileselect.h M source/blender/editors/space_file/fsmenu.c === diff --git a/source/blender/editors/include/ED_fileselect.h b/source/blender/editors/include/ED_fileselect.h index 6a207a6e453..c367072e6e7 100644 --- a/source/blender/editors/include/ED_fileselect.h +++ b/source/blender/editors/include/ED_fileselect.h @@ -216,6 +216,8 @@ typedef enum FSMenuInsert { FS_INSERT_FIRST = (1 << 2), /** just append to preserve delivered order */ FS_INSERT_LAST = (1 << 3), + /** Do not validate the link when inserted. */ + FS_INSERT_NO_VALIDATE = (1 << 4), } FSMenuInsert; struct FSMenu; diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index ae0e5b23d55..65354591034 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -463,7 +463,12 @@ void fsmenu_insert_entry(struct FSMenu *fsmenu, ED_fsmenu_entry_set_icon(fsm_iter, icon); - fsmenu_entry_refresh_valid(fsm_iter); + if (flag & FS_INSERT_NO_VALIDATE) { +fsm_iter->valid = true; + } + else { +fsmenu_entry_refresh_valid(fsm_iter); + } if (fsm_prev) { if (flag & FS_INSERT_FIRST) { @@ -689,7 +694,12 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) break; } -fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, tmps, name, icon, FS_INSERT_SORTED); +fsmenu_insert_entry(fsmenu, +FS_CATEGORY_SYSTEM, +tmps, +name, +icon, +FS_INSERT_SORTED | FS_INSERT_NO_VALIDATE); } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b030ec8760a] master: BLF Cleanup: Use FreeType Enum FT_Err_Ok
Commit: b030ec8760a0f3ca9b0eb36c265cb35025fdc7ca Author: Harley Acheson Date: Thu Mar 24 16:20:10 2022 -0700 Branches: master https://developer.blender.org/rBb030ec8760a0f3ca9b0eb36c265cb35025fdc7ca BLF Cleanup: Use FreeType Enum FT_Err_Ok Replace comparisons of FT_Error against 0 with FT_Err_Ok instead. See D14052 for more details. Differential Revision: https://developer.blender.org/D14052 Reviewed by Campbell Barton === M source/blender/blenfont/intern/blf.c M source/blender/blenfont/intern/blf_font.c M source/blender/blenfont/intern/blf_glyph.c === diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index 17d6e431632..2b5a2cdf606 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -129,7 +129,7 @@ bool BLF_has_glyph(int fontid, unsigned int unicode) { FontBLF *font = blf_get(fontid); if (font) { -return FT_Get_Char_Index(font->face, unicode) != 0; +return FT_Get_Char_Index(font->face, unicode) != FT_Err_Ok; } return false; } diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index f833eb96f38..60ff5f6470f 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -1340,7 +1340,7 @@ bool blf_font_size(FontBLF *font, float size, unsigned int dpi) size = (float)ft_size / 64.0f; if (font->size != size || font->dpi != dpi) { -if (FT_Set_Char_Size(font->face, 0, ft_size, dpi, dpi) == 0) { +if (FT_Set_Char_Size(font->face, 0, ft_size, dpi, dpi) == FT_Err_Ok) { font->size = size; font->dpi = dpi; } diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 4810e46b1d2..28531c5afc1 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -258,7 +258,7 @@ static FT_GlyphSlot blf_glyph_load(FontBLF *font, FT_UInt glyph_index) } } - if (FT_Load_Glyph(font->face, glyph_index, load_flags) == 0) { + if (FT_Load_Glyph(font->face, glyph_index, load_flags) == FT_Err_Ok) { return font->face->glyph; } return NULL; @@ -280,7 +280,7 @@ static bool blf_glyph_render_bitmap(FontBLF *font, FT_GlyphSlot glyph) /* Render the glyph curves to a bitmap. */ FT_Error err = FT_Render_Glyph(glyph, render_mode); - if (err != 0) { + if (err != FT_Err_Ok) { return false; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [873801d25e2] master: Make Format Changes
Commit: 873801d25e24141a1d513b4b75b123fb7e08b614 Author: Harley Acheson Date: Sat Mar 19 10:24:56 2022 -0700 Branches: master https://developer.blender.org/rB873801d25e24141a1d513b4b75b123fb7e08b614 Make Format Changes Only formatting changes found by running "make format", no functional changes Committed without review, but with verbal approval by Hans Goudey === M source/blender/blenloader/intern/versioning_290.c M source/blender/editors/io/io_obj.c M source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc === diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c index 079d69be4d9..2f6f0d5c9fa 100644 --- a/source/blender/blenloader/intern/versioning_290.c +++ b/source/blender/blenloader/intern/versioning_290.c @@ -1711,7 +1711,6 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) } } } - } if (!MAIN_VERSION_ATLEAST(bmain, 293, 10)) { diff --git a/source/blender/editors/io/io_obj.c b/source/blender/editors/io/io_obj.c index f253f63946b..8e380e3f2bc 100644 --- a/source/blender/editors/io/io_obj.c +++ b/source/blender/editors/io/io_obj.c @@ -293,11 +293,8 @@ void WM_OT_obj_export(struct wmOperatorType *ot) 0.01, 1000.0f); /* File Writer options. */ - RNA_def_boolean(ot->srna, - "apply_modifiers", - true, - "Apply Modifiers", - "Apply modifiers to exported meshes"); + RNA_def_boolean( + ot->srna, "apply_modifiers", true, "Apply Modifiers", "Apply modifiers to exported meshes"); RNA_def_enum(ot->srna, "export_eval_mode", io_obj_export_evaluation_mode, diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc index 5955fe1f3b1..894580f2932 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc @@ -12,7 +12,6 @@ #include "node_geometry_util.hh" - namespace blender::nodes::node_geo_curve_to_points_cc { NODE_STORAGE_FUNCS(NodeGeometryCurveToPoints) @@ -64,8 +63,8 @@ static void node_update(bNodeTree *ntree, bNode *node) } static void curve_create_default_rotation_attribute(Span tangents, - Span normals, - MutableSpan rotations) +Span normals, +MutableSpan rotations) { threading::parallel_for(IndexRange(rotations.size()), 512, [&](IndexRange range) { for (const int i : range) { @@ -75,7 +74,6 @@ static void curve_create_default_rotation_attribute(Span tangents, }); } - static Array calculate_spline_point_offsets(GeoNodeExecParams , const GeometryNodeCurveResampleMode mode, const CurveEval , ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [f381c73a21d] master: Fix T95257: Filter files on "name" and "relpath"
Commit: f381c73a21d3095e64657fab4fe02aa4ac320a14 Author: Harley Acheson Date: Sat Mar 19 09:23:05 2022 -0700 Branches: master https://developer.blender.org/rBf381c73a21d3095e64657fab4fe02aa4ac320a14 Fix T95257: Filter files on "name" and "relpath" When filtering File Browser items by name, use entry's "name" field as well as the "relpath" field since they can vary. See D13940 for details. Differential Revision: https://developer.blender.org/D13940 Reviewed by Bastien Montagne === M source/blender/editors/space_file/filelist.c === diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 363e19a8905..180e30a11d4 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -851,6 +851,20 @@ static bool is_filtered_file_relpath(const FileListInternEntry *file, const File return fnmatch(filter->filter_search, file->relpath, FNM_CASEFOLD) == 0; } +/** + * Apply the filter string as matching pattern on file name. + * \return true when the file should be in the result set, false if it should be filtered out. + */ +static bool is_filtered_file_name(const FileListInternEntry *file, const FileListFilter *filter) +{ + if (filter->filter_search[0] == '\0') { +return true; + } + + /* If there's a filter string, apply it as filter even if FLF_DO_FILTER is not set. */ + return fnmatch(filter->filter_search, file->name, FNM_CASEFOLD) == 0; +} + /** \return true when the file should be in the result set, false if it should be filtered out. */ static bool is_filtered_file_type(const FileListInternEntry *file, const FileListFilter *filter) { @@ -890,7 +904,8 @@ static bool is_filtered_file(FileListInternEntry *file, const char *UNUSED(root), FileListFilter *filter) { - return is_filtered_file_type(file, filter) && is_filtered_file_relpath(file, filter); + return is_filtered_file_type(file, filter) && + (is_filtered_file_relpath(file, filter) || is_filtered_file_name(file, filter)); } static bool is_filtered_id_file_type(const FileListInternEntry *file, ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [82c852f3873] master: Fix D14173: Chinese IME Full Width Numbers
Commit: 82c852f38732a005a1da72f4fb7fb402ecd71ec0 Author: Harley Acheson Date: Sat Mar 19 09:05:10 2022 -0700 Branches: master https://developer.blender.org/rB82c852f38732a005a1da72f4fb7fb402ecd71ec0 Fix D14173: Chinese IME Full Width Numbers Windows IME: Fix duplicated initial character when entering numbers while in Chinese full width character mode. See D14354 for more details. Differential Revision: https://developer.blender.org/D14354 Reviewed by Brecht Van Lommel === M intern/ghost/intern/GHOST_ImeWin32.cpp === diff --git a/intern/ghost/intern/GHOST_ImeWin32.cpp b/intern/ghost/intern/GHOST_ImeWin32.cpp index 702c10d377b..c3fcd7214ca 100644 --- a/intern/ghost/intern/GHOST_ImeWin32.cpp +++ b/intern/ghost/intern/GHOST_ImeWin32.cpp @@ -88,9 +88,14 @@ bool GHOST_ImeWin32::IsImeKeyEvent(char ascii, GHOST_TKey key) if (IsLanguage(IMELANG_JAPANESE) && (ascii >= ' ' && ascii <= '~')) { return true; } -else if (IsLanguage(IMELANG_CHINESE) && ascii && strchr("!\"$'(),.:;<>?[\\]^_`/", ascii) && - !(key == GHOST_kKeyNumpadPeriod)) { - return true; +if (IsLanguage(IMELANG_CHINESE)) { + if (ascii && strchr("!\"$'(),.:;<>?[\\]^_`/", ascii) && !(key == GHOST_kKeyNumpadPeriod)) { +return true; + } + if (conversion_modes_ & IME_CMODE_FULLSHAPE && (ascii >= '0' && ascii <= '9')) { +/* When in Full Width mode the number keys are also converted. */ +return true; + } } } return false; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b959f603da4] master: Fix T96267: Sidebar Tab Font Size Correction
Commit: b959f603da4532cd18618a31f091c40bff88e442 Author: Harley Acheson Date: Sun Mar 13 17:08:15 2022 -0700 Branches: master https://developer.blender.org/rBb959f603da4532cd18618a31f091c40bff88e442 Fix T96267: Sidebar Tab Font Size Correction Correction to the calculation of font size used for the tabs on the Sidebar so that they are always the same size as other content on the panel. See D14322 for more details. Differential Revision: https://developer.blender.org/D14322 Reviewed by Brecht Van Lommel === M source/blender/editors/interface/interface_panel.c === diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index c7f2eb230cb..87bfb7ca0f7 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -1357,9 +1357,8 @@ void UI_panel_category_draw_all(ARegion *region, const char *category_id_active) BLF_enable(fontid, BLF_ROTATION); BLF_rotation(fontid, M_PI_2); - // UI_fontstyle_set(>widget); - ui_fontscale(_points, aspect / (U.pixelsize * 1.1f)); - BLF_size(fontid, fstyle_points, U.dpi); + ui_fontscale(_points, aspect); + BLF_size(fontid, fstyle_points * U.pixelsize, U.dpi); /* Check the region type supports categories to avoid an assert * for showing 3D view panels in the properties space. */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [bd9f94e9172] master: Fix T94692: Show Cached OneDrive Thumbnails
Commit: bd9f94e91720e6d2ce5308344e83c5a787351669 Author: Harley Acheson Date: Fri Mar 11 10:04:24 2022 -0800 Branches: master https://developer.blender.org/rBbd9f94e91720e6d2ce5308344e83c5a787351669 Fix T94692: Show Cached OneDrive Thumbnails When OneDrive files are offline, show preexisting thumbnails. See D13930 for details. Differential Revision: https://developer.blender.org/D13930 Reviewed by Julian Eisel === M source/blender/editors/space_file/filelist.c === diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index d47e67b9d27..363e19a8905 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -339,7 +339,7 @@ typedef struct FileListEntryPreview { char path[FILE_MAX]; uint flags; int index; - + int attributes; /* from FileDirEntry. */ int icon_id; } FileListEntryPreview; @@ -1623,8 +1623,10 @@ static void filelist_cache_preview_runf(TaskPool *__restrict pool, void *taskdat IMB_thumb_path_lock(preview->path); /* Always generate biggest preview size for now, it's simpler and avoids having to re-generate - * in case user switch to a bigger preview size. */ - ImBuf *imbuf = IMB_thumb_manage(preview->path, THB_LARGE, source); + * in case user switch to a bigger preview size. Do not create preview when file is offline. */ + ImBuf *imbuf = (preview->attributes & FILE_ATTR_OFFLINE) ? + IMB_thumb_read(preview->path, THB_LARGE) : + IMB_thumb_manage(preview->path, THB_LARGE, source); IMB_thumb_path_unlock(preview->path); if (imbuf) { preview->icon_id = BKE_icon_imbuf_create(imbuf); @@ -1704,11 +1706,6 @@ static void filelist_cache_previews_push(FileList *filelist, FileDirEntry *entry BLI_assert(cache->flags & FLC_PREVIEWS_ACTIVE); - if (!entry->preview_icon_id && (entry->attributes & FILE_ATTR_OFFLINE)) { -entry->flags |= FILE_ENTRY_INVALID_PREVIEW; -return; - } - if (entry->preview_icon_id) { return; } @@ -1735,6 +1732,7 @@ static void filelist_cache_previews_push(FileList *filelist, FileDirEntry *entry FileListEntryPreview *preview = MEM_mallocN(sizeof(*preview), __func__); preview->index = index; preview->flags = entry->typeflag; + preview->attributes = entry->attributes; preview->icon_id = 0; if (preview_in_memory) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [ae3c8bc9f09] master: Fix T85689: Replace SHGetFileInfoW for Drive Name
Commit: ae3c8bc9f098b1be19da19f9d555bc7b22c2d03c Author: Harley Acheson Date: Fri Mar 11 09:25:45 2022 -0800 Branches: master https://developer.blender.org/rBae3c8bc9f098b1be19da19f9d555bc7b22c2d03c Fix T85689: Replace SHGetFileInfoW for Drive Name Win32: Replace SHGetFileInfoW as means to get friendly display names for volumes because it causes long pauses for disconnected remote drives. See D14305 for more details. Differential Revision: https://developer.blender.org/D14305 Reviewed by Brecht Van Lommel === M source/blender/editors/space_file/fsmenu.c === diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index 988ba7728f1..847bf89bba8 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -29,6 +29,7 @@ * because 'near' is disabled through BLI_windstuff. */ # include "BLI_winstuff.h" # include +# include #endif #include "UI_interface_icons.h" @@ -642,14 +643,29 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) tmps[3] = '\0'; name = NULL; -/* Flee from horrible win querying hover floppy drives! */ +/* Skip over floppy disks A & B. */ if (i > 1) { - /* Try to get a friendly drive description. */ - SHFILEINFOW shFile = {0}; + /* Friendly volume descriptions without using SHGetFileInfoW (T85689). */ BLI_strncpy_wchar_from_utf8(wline, tmps, 4); - if (SHGetFileInfoW(wline, 0, , sizeof(SHFILEINFOW), SHGFI_DISPLAYNAME)) { -BLI_strncpy_wchar_as_utf8(line, shFile.szDisplayName, FILE_MAXDIR); -name = line; + IShellFolder *desktop; + if (SHGetDesktopFolder() == S_OK) { +PIDLIST_RELATIVE volume; +if (desktop->lpVtbl->ParseDisplayName( +desktop, NULL, NULL, wline, NULL, , NULL) == S_OK) { + STRRET volume_name; + volume_name.uType = STRRET_WSTR; + if (desktop->lpVtbl->GetDisplayNameOf( + desktop, volume, SHGDN_FORADDRESSBAR, _name) == S_OK) { +wchar_t *volume_name_wchar; +if (StrRetToStrW(_name, volume, _name_wchar) == S_OK) { + BLI_strncpy_wchar_as_utf8(line, volume_name_wchar, FILE_MAXDIR); + name = line; + CoTaskMemFree(volume_name_wchar); +} + } + CoTaskMemFree(volume); +} +desktop->lpVtbl->Release(desktop); } } if (name == NULL) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [353376c7833] master: Fix T92331: Duplicated Window Should Not Be Modal
Commit: 353376c783390a158c0a3cedf9887a4df06c7cf1 Author: Harley Acheson Date: Tue Mar 8 13:54:19 2022 -0800 Branches: master https://developer.blender.org/rB353376c783390a158c0a3cedf9887a4df06c7cf1 Fix T92331: Duplicated Window Should Not Be Modal Operator area_dupli_invoke should not create modal windows. See D14253 for details. Differential Revision: https://developer.blender.org/D14253 Reviewed by Brecht Van Lommel === M source/blender/editors/screen/screen_ops.c === diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index ee3bc3cba76..9343f4a3b34 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -1421,7 +1421,7 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event) area->winy, SPACE_EMPTY, false, -true, +false, false, WIN_ALIGN_ABSOLUTE); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [29696fb7252] master: UI: ActionZone Swap Areas Between Windows
Commit: 29696fb7252b88ecda0a5e724bb333b545e77c1e Author: Harley Acheson Date: Tue Feb 22 08:57:22 2022 -0800 Branches: master https://developer.blender.org/rB29696fb7252b88ecda0a5e724bb333b545e77c1e UI: ActionZone Swap Areas Between Windows Allow SCREEN_OT_area_swap to operate between different Blender windows, and other minor feedback improvements. See D14135 for more details and demonstrations. Differential Revision: https://developer.blender.org/D14135 Reviewed by Campbell Barton === M source/blender/editors/include/ED_screen.h M source/blender/editors/screen/area.c M source/blender/editors/screen/screen_ops.c === diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index 5b439cb0978..c89df9c3789 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -250,6 +250,12 @@ void ED_area_offscreen_free(struct wmWindowManager *wm, struct wmWindow *win, struct ScrArea *area); +/** + * Search all screens, even non-active or overlapping (multiple windows), return the most-likely + * area of interest. xy is relative to active window, like all similar functions. + */ +ScrArea *ED_area_find_under_cursor(const struct bContext *C, int spacetype, const int xy[2]); + ScrArea *ED_screen_areas_iter_first(const struct wmWindow *win, const bScreen *screen); ScrArea *ED_screen_areas_iter_next(const bScreen *screen, const ScrArea *area); /** diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 95534d2a036..a64948b5864 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -3438,6 +3438,38 @@ bool ED_area_is_global(const ScrArea *area) return area->global != NULL; } +ScrArea *ED_area_find_under_cursor(const bContext *C, int spacetype, const int xy[2]) +{ + bScreen *screen = CTX_wm_screen(C); + wmWindow *win = CTX_wm_window(C); + wmWindowManager *wm = CTX_wm_manager(C); + + ScrArea *area = NULL; + + if (win->parent) { +/* If active window is a child, check itself first. */ +area = BKE_screen_find_area_xy(screen, spacetype, xy); + } + + if (!area) { +/* Check all windows except the active one. */ +int scr_pos[2]; +wmWindow *r_win = WM_window_find_under_cursor(wm, win, win, xy, scr_pos); +if (r_win) { + win = r_win; + screen = WM_window_get_active_screen(win); + area = BKE_screen_find_area_xy(screen, spacetype, scr_pos); +} + } + + if (!area && !win->parent) { +/* If active window is a parent window, check itself last. */ +area = BKE_screen_find_area_xy(screen, spacetype, xy); + } + + return area; +} + ScrArea *ED_screen_areas_iter_first(const wmWindow *win, const bScreen *screen) { ScrArea *global_area = win->global_areas.areabase.first; diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 75c704b5f7b..b912b02852f 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -1008,9 +1008,6 @@ static void actionzone_exit(wmOperator *op) static void actionzone_apply(bContext *C, wmOperator *op, int type) { wmWindow *win = CTX_wm_window(C); - sActionzoneData *sad = op->customdata; - - sad->modifier = RNA_int_get(op->ptr, "modifier"); wmEvent event; wm_event_init_from_window(win, ); @@ -1051,6 +1048,7 @@ static int actionzone_invoke(bContext *C, wmOperator *op, const wmEvent *event) sad->az = az; sad->x = event->xy[0]; sad->y = event->xy[1]; + sad->modifier = RNA_int_get(op->ptr, "modifier"); /* region azone directly reacts on mouse clicks */ if (ELEM(sad->az->type, AZONE_REGION, AZONE_FULLSCREEN)) { @@ -1114,7 +1112,17 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event) /* What area are we now in? */ ScrArea *area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, event->xy); - if (area == sad->sa1) { + if (sad->modifier == 1) { +/* Duplicate area into new window. */ +WM_cursor_set(win, WM_CURSOR_EDIT); +is_gesture = (delta_max > area_threshold); + } + else if (sad->modifier == 2) { +/* Swap areas. */ +WM_cursor_set(win, WM_CURSOR_SWAP_AREA); +is_gesture = true; + } + else if (area == sad->sa1) { /* Same area, so possible split. */ WM_cursor_set(win, SCREEN_DIR_IS_VERTICAL(sad->gesture_dir) ? WM_CURSOR_H_SPLIT : @@ -1320,8 +1328,9 @@ static int area_swap_modal(bContext *C, wmOperator *op, const
[Bf-blender-cvs] [55c90df316c] master: BLF: Enable Filtering of woff and woff2 Fonts
Commit: 55c90df316c7f5106b4ff97f1a6d6bcac3b195a3 Author: Harley Acheson Date: Tue Feb 8 08:43:01 2022 -0800 Branches: master https://developer.blender.org/rB55c90df316c7f5106b4ff97f1a6d6bcac3b195a3 BLF: Enable Filtering of woff and woff2 Fonts Add files with extension ".woff" and ".woff2" to FILE_TYPE_FTFONT file type. Allows selecting and using these types of font files. See D13822 for more details. Differential Revision: https://developer.blender.org/D13822 Reviewed by Campbell Barton === M source/blender/blenfont/intern/blf_font.c M source/blender/editors/space_file/filelist.c === diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index c1410447de6..3ac9fdc7f41 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -1238,6 +1238,12 @@ FontBLF *blf_font_new(const char *name, const char *filename) font = (FontBLF *)MEM_callocN(sizeof(FontBLF), "blf_font_new"); err = FT_New_Face(ft_lib, filename, 0, >face); if (err) { +if (ELEM(err, FT_Err_Unknown_File_Format, FT_Err_Unimplemented_Feature)) { + printf("Format of this font file is not supported\n"); +} +else { + printf("Error encountered while opening font file\n"); +} MEM_freeN(font); return NULL; } diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 044d7aba88f..6be17bbd355 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -2783,7 +2783,8 @@ int ED_path_extension_type(const char *path) NULL)) { return FILE_TYPE_TEXT; } - if (BLI_path_extension_check_n(path, ".ttf", ".ttc", ".pfb", ".otf", ".otc", NULL)) { + if (BLI_path_extension_check_n( + path, ".ttf", ".ttc", ".pfb", ".otf", ".otc", ".woff", ".woff2", NULL)) { return FILE_TYPE_FTFONT; } if (BLI_path_extension_check(path, ".btx")) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [835dd950467] master: BLF: Cleanup blf_glyph_cache_find & blf_font_size
Commit: 835dd950467fe5215911a81485393fb6ce3a03cd Author: Harley Acheson Date: Fri Feb 4 18:32:32 2022 -0800 Branches: master https://developer.blender.org/rB835dd950467fe5215911a81485393fb6ce3a03cd BLF: Cleanup blf_glyph_cache_find & blf_font_size Removes unnecessary calls to blf_glyph_cache_find, simplifies blf_font_size, and reduces calls to it. blf_glyph_cache_new and blf_glyph_cache_find made static. See D13374 for more details. Differential Revision: https://developer.blender.org/D13374 Reviewed by Campbell Barton === M source/blender/blenfont/intern/blf_font.c M source/blender/blenfont/intern/blf_glyph.c M source/blender/blenfont/intern/blf_internal.h M source/blender/blenfont/intern/blf_thumbs.c M source/blender/editors/interface/interface_style.c === diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index da533820d72..c1410447de6 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -1342,35 +1342,25 @@ void blf_font_free(FontBLF *font) /** \name Font Configure * \{ */ -void blf_font_size(FontBLF *font, float size, unsigned int dpi) +bool blf_font_size(FontBLF *font, float size, unsigned int dpi) { - blf_glyph_cache_acquire(font); - /* FreeType uses fixed-point integers in 64ths. */ FT_F26Dot6 ft_size = lroundf(size * 64.0f); - /* Adjust our size to be on even 64ths. */ + /* Adjust our new size to be on even 64ths. */ size = (float)ft_size / 64.0f; - GlyphCacheBLF *gc = blf_glyph_cache_find(font, size, dpi); - if (gc && (font->size == size && font->dpi == dpi)) { -/* Optimization: do not call FT_Set_Char_Size if size did not change. */ - } - else { -const FT_Error err = FT_Set_Char_Size(font->face, 0, ft_size, dpi, dpi); -if (err) { - /* FIXME: here we can go through the fixed size and choice a close one */ - printf("The current font don't support the size, %f and dpi, %u\n", size, dpi); -} -else { + if (font->size != size || font->dpi != dpi) { +if (FT_Set_Char_Size(font->face, 0, ft_size, dpi, dpi) == 0) { font->size = size; font->dpi = dpi; - if (gc == NULL) { -blf_glyph_cache_new(font); - } +} +else { + printf("The current font does not support the size, %f and dpi, %u\n", size, dpi); + return false; } } - blf_glyph_cache_release(font); + return true; } /** \} */ diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index c8cc15e804b..bcd9e1fb3a2 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -74,7 +74,7 @@ static FT_Fixed to_16dot16(double val) /** \name Glyph Cache * \{ */ -GlyphCacheBLF *blf_glyph_cache_find(FontBLF *font, float size, unsigned int dpi) +static GlyphCacheBLF *blf_glyph_cache_find(FontBLF *font, float size, unsigned int dpi) { GlyphCacheBLF *gc = (GlyphCacheBLF *)font->cache.first; while (gc) { @@ -87,7 +87,7 @@ GlyphCacheBLF *blf_glyph_cache_find(FontBLF *font, float size, unsigned int dpi) return NULL; } -GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font) +static GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font) { GlyphCacheBLF *gc = (GlyphCacheBLF *)MEM_callocN(sizeof(GlyphCacheBLF), "blf_glyph_cache_new"); diff --git a/source/blender/blenfont/intern/blf_internal.h b/source/blender/blenfont/intern/blf_internal.h index 1a80be0503c..d0bb3385e2c 100644 --- a/source/blender/blenfont/intern/blf_internal.h +++ b/source/blender/blenfont/intern/blf_internal.h @@ -56,7 +56,11 @@ struct FontBLF *blf_font_new(const char *name, const char *filename); struct FontBLF *blf_font_new_from_mem(const char *name, const unsigned char *mem, int mem_size); void blf_font_attach_from_mem(struct FontBLF *font, const unsigned char *mem, int mem_size); -void blf_font_size(struct FontBLF *font, float size, unsigned int dpi); +/** + * Change font's output size. Returns true if successful in changing the size. + */ +bool blf_font_size(struct FontBLF *font, float size, unsigned int dpi); + void blf_font_draw(struct FontBLF *font, const char *str, size_t str_len, @@ -134,14 +138,6 @@ int blf_font_count_missing_chars(struct FontBLF *font, void blf_font_free(struct FontBLF *font); -/** - * Find a glyph cache that matches a size, DPI & styles. - */ -struct GlyphCacheBLF *blf_glyph_cache_find(struct FontBLF *font, float size, unsigned int dpi); -/** - * Create a new glyph cache for the current size, DPI & styles. - */ -struct GlyphCacheBLF *blf_glyph_cache_new(struct FontBLF *font); struct GlyphCacheBLF *blf_glyph_cache_acquire(struct FontBLF *fo
[Bf-blender-cvs] [b1cee361906] master: BLF: Default Size as Float
Commit: b1cee3619062124497c73a24c3d87853f544c5f1 Author: Harley Acheson Date: Fri Feb 4 18:04:16 2022 -0800 Branches: master https://developer.blender.org/rBb1cee3619062124497c73a24c3d87853f544c5f1 BLF: Default Size as Float Allowing setting and storing of the default font size as float. See D13230 for more details. Differential Revision: https://developer.blender.org/D13230 Reviewed by Campbell Barton === M source/blender/blenfont/BLF_api.h M source/blender/blenfont/intern/blf_default.c === diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h index 169107b19cb..638c5b727a6 100644 --- a/source/blender/blenfont/BLF_api.h +++ b/source/blender/blenfont/BLF_api.h @@ -309,7 +309,7 @@ void BLF_thumb_preview(const char *filename, /* blf_default.c */ void BLF_default_dpi(int dpi); -void BLF_default_size(int size); +void BLF_default_size(float size); void BLF_default_set(int fontid); /** * Get default font ID so we can pass it to other functions. diff --git a/source/blender/blenfont/intern/blf_default.c b/source/blender/blenfont/intern/blf_default.c index 57eeaa6768d..d5a0d514b5f 100644 --- a/source/blender/blenfont/intern/blf_default.c +++ b/source/blender/blenfont/intern/blf_default.c @@ -37,15 +37,15 @@ /* Default size and dpi, for BLF_draw_default. */ static int global_font_default = -1; static int global_font_dpi = 72; -/* Keep in sync with `UI_style_get()->widgetlabel.points` */ -static int global_font_size = 11; +/* Keep in sync with `UI_DEFAULT_TEXT_POINTS` */ +static float global_font_size = 11.0f; void BLF_default_dpi(int dpi) { global_font_dpi = dpi; } -void BLF_default_size(int size) +void BLF_default_size(float size) { global_font_size = size; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [fbd5b854569] master: BLF: Removal of blf_font_draw_ascii Declaration
Commit: fbd5b85456928ca9e195101f97d7677bf9308b56 Author: Harley Acheson Date: Fri Feb 4 17:55:50 2022 -0800 Branches: master https://developer.blender.org/rBfbd5b85456928ca9e195101f97d7677bf9308b56 BLF: Removal of blf_font_draw_ascii Declaration Removal of declaration of unused blf_font_draw_ascii See D13624 for more details. Differential Revision: https://developer.blender.org/D13624 Reviewed by Campbell Barton === M source/blender/blenfont/intern/blf_internal.h === diff --git a/source/blender/blenfont/intern/blf_internal.h b/source/blender/blenfont/intern/blf_internal.h index 04b7a3ca13b..1a80be0503c 100644 --- a/source/blender/blenfont/intern/blf_internal.h +++ b/source/blender/blenfont/intern/blf_internal.h @@ -65,10 +65,7 @@ void blf_font_draw__wrap(struct FontBLF *font, const char *str, size_t str_len, struct ResultBLF *r_info); -void blf_font_draw_ascii(struct FontBLF *font, - const char *str, - size_t str_len, - struct ResultBLF *r_info); + /** * Use fixed column width, but an utf8 character may occupy multiple columns. */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [bb3bcf744c9] master: BLF: Save fixed_width value in cache
Commit: bb3bcf744c9c4d316ddbdcffcdf81c1367bab2b1 Author: Harley Acheson Date: Fri Feb 4 17:49:21 2022 -0800 Branches: master https://developer.blender.org/rBbb3bcf744c9c4d316ddbdcffcdf81c1367bab2b1 BLF: Save fixed_width value in cache Cache the font size's ideal fixed width column size in the glyph cache rather than the font itself to improve performance. See D13226 for more details. Differential Revision: https://developer.blender.org/D13226 Reviewed by Campbell Barton === M source/blender/blenfont/intern/blf_font.c M source/blender/blenfont/intern/blf_glyph.c M source/blender/blenfont/intern/blf_internal_types.h === diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index c03cdc3d16d..da533820d72 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -34,7 +34,6 @@ #include FT_FREETYPE_H #include FT_GLYPH_H -#include FT_ADVANCES_H /* For FT_Get_Advance */ #include "MEM_guardedalloc.h" @@ -826,7 +825,10 @@ float blf_font_height(FontBLF *font, float blf_font_fixed_width(FontBLF *font) { - return (float)font->fixed_width; + GlyphCacheBLF *gc = blf_glyph_cache_acquire(font); + float width = (gc) ? (float)gc->fixed_width : font->size / 2.0f; + blf_glyph_cache_release(font); + return width; } static void blf_font_boundbox_foreach_glyph_ex(FontBLF *font, @@ -1369,22 +1371,6 @@ void blf_font_size(FontBLF *font, float size, unsigned int dpi) } blf_glyph_cache_release(font); - - /* Set fixed-width size for monospaced output. */ - FT_UInt gindex = FT_Get_Char_Index(font->face, U'0'); - if (gindex) { -FT_Fixed advance = 0; -FT_Get_Advance(font->face, gindex, FT_LOAD_NO_HINTING, ); -/* Use CSS 'ch unit' width, advance of zero character. */ -font->fixed_width = (int)(advance >> 16); - } - else { -/* Font does not contain "0" so use CSS fallback of 1/2 of em. */ -font->fixed_width = (int)((font->face->size->metrics.height / 2) >> 6); - } - if (font->fixed_width < 1) { -font->fixed_width = 1; - } } /** \} */ diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index b87a784adff..c8cc15e804b 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -34,6 +34,7 @@ #include FT_GLYPH_H #include FT_OUTLINE_H #include FT_BITMAP_H +#include FT_ADVANCES_H /* For FT_Get_Advance. */ #include "MEM_guardedalloc.h" @@ -100,6 +101,22 @@ GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font) memset(gc->glyph_ascii_table, 0, sizeof(gc->glyph_ascii_table)); memset(gc->bucket, 0, sizeof(gc->bucket)); + /* Determine ideal fixed-width size for monospaced output. */ + FT_UInt gindex = FT_Get_Char_Index(font->face, U'0'); + if (gindex) { +FT_Fixed advance = 0; +FT_Get_Advance(font->face, gindex, FT_LOAD_NO_HINTING, ); +/* Use CSS 'ch unit' width, advance of zero character. */ +gc->fixed_width = (int)(advance >> 16); + } + else { +/* Font does not contain "0" so use CSS fallback of 1/2 of em. */ +gc->fixed_width = (int)((font->face->size->metrics.height / 2) >> 6); + } + if (gc->fixed_width < 1) { +gc->fixed_width = 1; + } + BLI_addhead(>cache, gc); return gc; } diff --git a/source/blender/blenfont/intern/blf_internal_types.h b/source/blender/blenfont/intern/blf_internal_types.h index 46156edbb1f..c96febd71ae 100644 --- a/source/blender/blenfont/intern/blf_internal_types.h +++ b/source/blender/blenfont/intern/blf_internal_types.h @@ -73,6 +73,9 @@ typedef struct GlyphCacheBLF { bool bold; bool italic; + /* Column width when printing monospaced. */ + int fixed_width; + /* and the glyphs. */ ListBase bucket[257]; @@ -207,9 +210,6 @@ typedef struct FontBLF { /* font size. */ float size; - /* Column width when printing monospaced. */ - int fixed_width; - /* max texture size. */ int tex_size_max; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [2a967d444f1] master: BLF: blf_glyph_cache_free Made Static
Commit: 2a967d444f11514891c5d229993d486df06c066e Author: Harley Acheson Date: Fri Feb 4 17:37:23 2022 -0800 Branches: master https://developer.blender.org/rB2a967d444f11514891c5d229993d486df06c066e BLF: blf_glyph_cache_free Made Static blf_glyph_cache_free does not need to be public. See D13395 for more details. Differential Revision: https://developer.blender.org/D13395 Reviewed by Campbell Barton === M source/blender/blenfont/intern/blf_font.c M source/blender/blenfont/intern/blf_glyph.c M source/blender/blenfont/intern/blf_internal.h === diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 14d3a208f69..c03cdc3d16d 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -1318,12 +1318,7 @@ FontBLF *blf_font_new_from_mem(const char *name, const unsigned char *mem, int m void blf_font_free(FontBLF *font) { - BLI_spin_lock(_glyph_cache_mutex); - GlyphCacheBLF *gc; - - while ((gc = BLI_pophead(>cache))) { -blf_glyph_cache_free(gc); - } + blf_glyph_cache_clear(font); if (font->kerning_cache) { MEM_freeN(font->kerning_cache); @@ -1337,8 +1332,6 @@ void blf_font_free(FontBLF *font) MEM_freeN(font->name); } MEM_freeN(font); - - BLI_spin_unlock(_glyph_cache_mutex); } /** \} */ diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 4f25f99b65c..b87a784adff 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -122,20 +122,7 @@ void blf_glyph_cache_release(FontBLF *font) BLI_spin_unlock(font->glyph_cache_mutex); } -void blf_glyph_cache_clear(FontBLF *font) -{ - GlyphCacheBLF *gc; - - BLI_spin_lock(font->glyph_cache_mutex); - - while ((gc = BLI_pophead(>cache))) { -blf_glyph_cache_free(gc); - } - - BLI_spin_unlock(font->glyph_cache_mutex); -} - -void blf_glyph_cache_free(GlyphCacheBLF *gc) +static void blf_glyph_cache_free(GlyphCacheBLF *gc) { GlyphBLF *g; for (uint i = 0; i < ARRAY_SIZE(gc->bucket); i++) { @@ -152,6 +139,19 @@ void blf_glyph_cache_free(GlyphCacheBLF *gc) MEM_freeN(gc); } +void blf_glyph_cache_clear(FontBLF *font) +{ + GlyphCacheBLF *gc; + + BLI_spin_lock(font->glyph_cache_mutex); + + while ((gc = BLI_pophead(>cache))) { +blf_glyph_cache_free(gc); + } + + BLI_spin_unlock(font->glyph_cache_mutex); +} + /** * Try to find a glyph in cache. * diff --git a/source/blender/blenfont/intern/blf_internal.h b/source/blender/blenfont/intern/blf_internal.h index 4e36f522981..04b7a3ca13b 100644 --- a/source/blender/blenfont/intern/blf_internal.h +++ b/source/blender/blenfont/intern/blf_internal.h @@ -148,7 +148,6 @@ struct GlyphCacheBLF *blf_glyph_cache_new(struct FontBLF *font); struct GlyphCacheBLF *blf_glyph_cache_acquire(struct FontBLF *font); void blf_glyph_cache_release(struct FontBLF *font); void blf_glyph_cache_clear(struct FontBLF *font); -void blf_glyph_cache_free(struct GlyphCacheBLF *gc); /** * Create (or load from cache) a fully-rendered bitmap glyph. ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [fd1078e1055] master: Fix T62651: Win32 Multiple Adapters Warning
Commit: fd1078e1055e6932fc539a1fae4c7d433b1839d9 Author: Harley Acheson Date: Fri Jan 28 15:19:05 2022 -0800 Branches: master https://developer.blender.org/rBfd1078e1055e6932fc539a1fae4c7d433b1839d9 Fix T62651: Win32 Multiple Adapters Warning Show a more instructive error message for users who have plugged multiple monitors into multiple display adapters. And do not exit if unable to open a child window when in this state. See D13885 for more details Differential Revision: https://developer.blender.org/D13885 Reviewed by Ray Molenkamp === M intern/ghost/intern/GHOST_WindowWin32.cpp === diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp index 7993772a94b..47d4ff77d17 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.cpp +++ b/intern/ghost/intern/GHOST_WindowWin32.cpp @@ -132,8 +132,24 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system, m_hDC = ::GetDC(m_hWnd); if (!setDrawingContextType(type)) { +const char *title = "Blender - Unsupported Graphics Card Configuration"; +const char *text = +"A graphics card and driver with support for OpenGL 3.3 or higher is " +"required.\n\nInstalling the latest driver for your graphics card might resolve the " +"issue."; +if (GetSystemMetrics(SM_CMONITORS) > 1) { + text = + "A graphics card and driver with support for OpenGL 3.3 or higher is " + "required.\n\nPlugging all monitors into your primary graphics card might resolve " + "this issue. Installing the latest driver for your graphics card could also help."; +} +MessageBox(m_hWnd, text, title, MB_OK | MB_ICONERROR); +::ReleaseDC(m_hWnd, m_hDC); ::DestroyWindow(m_hWnd); m_hWnd = NULL; +if (!parentwindow) { + exit(0); +} return; } @@ -567,20 +583,13 @@ GHOST_Context *GHOST_WindowWin32::newDrawingContext(GHOST_TDrawingContextType ty (m_debug_context ? WGL_CONTEXT_DEBUG_BIT_ARB : 0), GHOST_OPENGL_WGL_RESET_NOTIFICATION_STRATEGY); -if (context->initializeDrawingContext()) { - return context; -} -else { - MessageBox(m_hWnd, - "A graphics card and driver with support for OpenGL 3.3 or higher is required.\n" - "Installing the latest driver for your graphics card may resolve the issue.\n\n" - "The program will now close.", - "Blender - Unsupported Graphics Card or Driver", - MB_OK | MB_ICONERROR); +if (context && !context->initializeDrawingContext()) { delete context; - exit(0); + context = nullptr; } +return context; + #elif defined(WITH_GL_PROFILE_COMPAT) // ask for 2.1 context, driver gives any GL version >= 2.1 // (hopefully the latest compatibility profile) ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [6b7756279f7] master: Fix T93626: Win IME Chinese Numpad Decimal
Commit: 6b7756279f719a434505d461fb03b5faa5ce9aa0 Author: Harley Acheson Date: Fri Jan 28 13:32:46 2022 -0800 Branches: master https://developer.blender.org/rB6b7756279f719a434505d461fb03b5faa5ce9aa0 Fix T93626: Win IME Chinese Numpad Decimal Allow Windows IME Pinyin, when in Chinese mode, to use numpad decimal key to enter decimal point. See D13902 for more details. Differential Revision: https://developer.blender.org/D13902 Reviewed by Brecht Van Lommel === M intern/ghost/intern/GHOST_ImeWin32.cpp M intern/ghost/intern/GHOST_ImeWin32.h M intern/ghost/intern/GHOST_SystemWin32.cpp === diff --git a/intern/ghost/intern/GHOST_ImeWin32.cpp b/intern/ghost/intern/GHOST_ImeWin32.cpp index d1fc80adf56..2a1bfb633b3 100644 --- a/intern/ghost/intern/GHOST_ImeWin32.cpp +++ b/intern/ghost/intern/GHOST_ImeWin32.cpp @@ -96,7 +96,7 @@ bool GHOST_ImeWin32::IsEnglishMode() !(conversion_modes_ & (IME_CMODE_NATIVE | IME_CMODE_FULLSHAPE)); } -bool GHOST_ImeWin32::IsImeKeyEvent(char ascii) +bool GHOST_ImeWin32::IsImeKeyEvent(char ascii, GHOST_TKey key) { if (!(IsEnglishMode())) { /* In Chinese, Japanese, Korean, all alpha keys are processed by IME. */ @@ -106,7 +106,8 @@ bool GHOST_ImeWin32::IsImeKeyEvent(char ascii) if (IsLanguage(IMELANG_JAPANESE) && (ascii >= ' ' && ascii <= '~')) { return true; } -else if (IsLanguage(IMELANG_CHINESE) && ascii && strchr("!\"$'(),.:;<>?[\\]^_`/", ascii)) { +else if (IsLanguage(IMELANG_CHINESE) && ascii && strchr("!\"$'(),.:;<>?[\\]^_`/", ascii) && + !(key == GHOST_kKeyNumpadPeriod)) { return true; } } diff --git a/intern/ghost/intern/GHOST_ImeWin32.h b/intern/ghost/intern/GHOST_ImeWin32.h index ce0e4d64d53..d17a6d79503 100644 --- a/intern/ghost/intern/GHOST_ImeWin32.h +++ b/intern/ghost/intern/GHOST_ImeWin32.h @@ -161,7 +161,7 @@ class GHOST_ImeWin32 { bool IsEnglishMode(); /* Checks a key whether IME has to do handling. */ - bool IsImeKeyEvent(char ascii); + bool IsImeKeyEvent(char ascii, GHOST_TKey key); /** * Create the IME windows, and allocate required resources for them. diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index 5251dd01b29..64e1ac3b9b3 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -1220,7 +1220,7 @@ GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_WindowWin32 *window, RA } #ifdef WITH_INPUT_IME -if (window->getImeInput()->IsImeKeyEvent(ascii)) { +if (window->getImeInput()->IsImeKeyEvent(ascii, key)) { return NULL; } #endif /* WITH_INPUT_IME */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [4311a32bc2d] master: Win IME: Ideographic Full Stop to Decimal Point
Commit: 4311a32bc2d9c9e5db475a75cac5b11760f4db71 Author: Harley Acheson Date: Fri Jan 28 13:11:56 2022 -0800 Branches: master https://developer.blender.org/rB4311a32bc2d9c9e5db475a75cac5b11760f4db71 Win IME: Ideographic Full Stop to Decimal Point Convert Ideographic Full Stop, used in Simplified Chinese and Japanese, to Decimal Point when entering numbers into numerical inputs. See D13903 for more details Differential Revision: https://developer.blender.org/D13903 Reviewed by Brecht Van Lommel === M source/blender/editors/interface/interface_handlers.c === diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 905fd452b6c..a171160d020 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -3957,7 +3957,14 @@ static void ui_do_but_textedit( ui_textedit_delete_selection(but, data); } if (event->type == WM_IME_COMPOSITE_EVENT && ime_data->result_len) { - ui_textedit_insert_buf(but, data, ime_data->str_result, ime_data->result_len); + if (ELEM(but->type, UI_BTYPE_NUM, UI_BTYPE_NUM_SLIDER) && + strcmp(ime_data->str_result, "\xE3\x80\x82") == 0) { +/* Convert Ideographic Full Stop (U+3002) to decimal point when entering numbers. */ +ui_textedit_insert_ascii(but, data, '.'); + } + else { +ui_textedit_insert_buf(but, data, ime_data->str_result, ime_data->result_len); + } } } else if (event->type == WM_IME_COMPOSITE_END) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [ace1b6a73a0] master: UI: Add OneDrive to System List for Windows
Commit: ace1b6a73a0b3e8360640f9251ac30d874365cf8 Author: Harley Acheson Date: Fri Jan 28 12:22:42 2022 -0800 Branches: master https://developer.blender.org/rBace1b6a73a0b3e8360640f9251ac30d874365cf8 UI: Add OneDrive to System List for Windows This patch adds a "OneDrive" icon to the File Manager System list for Windows (only!). See D11133 for more details. Differential Revision: https://developer.blender.org/D11133 Reviewed by Julian Eisel === M source/blender/editors/space_file/fsmenu.c === diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index 14f596ae7bf..0a69d0f9b39 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -745,14 +745,17 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) N_("Fonts"), ICON_FILE_FONT, FS_INSERT_LAST); + fsmenu_add_windows_folder(fsmenu, +FS_CATEGORY_SYSTEM_BOOKMARKS, +_SkyDrive, +N_("OneDrive"), +ICON_URL, +FS_INSERT_LAST); /* These items are just put in path cache for thumbnail views and if bookmarked. */ fsmenu_add_windows_folder( fsmenu, FS_CATEGORY_OTHER, _UserProfiles, NULL, ICON_COMMUNITY, FS_INSERT_LAST); - - fsmenu_add_windows_folder( - fsmenu, FS_CATEGORY_OTHER, _SkyDrive, NULL, ICON_URL, FS_INSERT_LAST); } } #elif defined(__APPLE__) ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [26e608d8202] master: Win32: Initialize GHOST_WindowWin32 Members
Commit: 26e608d820280340857fa547d477bc560e8cf605 Author: Harley Acheson Date: Fri Jan 28 12:03:20 2022 -0800 Branches: master https://developer.blender.org/rB26e608d820280340857fa547d477bc560e8cf605 Win32: Initialize GHOST_WindowWin32 Members Initialize m_Bar, m_dropTarget, & m_hWnd members of GHOST_WindowWin32 in constructor's member initializer list. This ensures they are are set or NULL in destructor if constructor does not complete. See D13886 for more details. Differential Revision: https://developer.blender.org/D13886 Reviewed by Jesse Yurkovich === M intern/ghost/intern/GHOST_WindowWin32.cpp === diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp index b5d0fd8e6db..7993772a94b 100644 --- a/intern/ghost/intern/GHOST_WindowWin32.cpp +++ b/intern/ghost/intern/GHOST_WindowWin32.cpp @@ -71,6 +71,8 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system, m_mousePresent(false), m_inLiveResize(false), m_system(system), + m_dropTarget(NULL), + m_hWnd(0), m_hDC(0), m_isDialog(dialog), m_hasMouseCaptured(false), @@ -78,6 +80,7 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system, m_nPressedButtons(0), m_customCursor(0), m_wantAlphaBackground(alphaBackground), + m_Bar(NULL), m_wintab(NULL), m_lastPointerTabletData(GHOST_TABLET_DATA_NONE), m_normal_state(GHOST_kWindowStateNormal), ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [a311fa96aa4] master: Fix T85706: wm_window_make_drawable update DPI
Commit: a311fa96aa428b611bc07c4d7f8a002dd3e6b462 Author: Harley Acheson Date: Wed Jan 12 10:37:52 2022 -0800 Branches: master https://developer.blender.org/rBa311fa96aa428b611bc07c4d7f8a002dd3e6b462 Fix T85706: wm_window_make_drawable update DPI When drawing windows on monitors that differ in DPI, we can sometimes have UI elements draw at an incorrect scale. This patch just ensures that `wm_window_make_drawable` always updates DPI. See D10483 for more details. Differential Revision: https://developer.blender.org/D10483 Reviewed by Brecht Van Lommel === M source/blender/windowmanager/intern/wm_window.c === diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 29c9f53f735..a1854a8ed86 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -1033,7 +1033,9 @@ void wm_window_make_drawable(wmWindowManager *wm, wmWindow *win) } wm_window_set_drawable(wm, win, true); + } + if (win->ghostwin) { /* this can change per window */ WM_window_set_dpi(win); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [fa8c2c78857] master: Fix T94071: Area Split Improvements
Commit: fa8c2c78857989c23262915921722cf69399d58d Author: Harley Acheson Date: Wed Jan 12 09:41:46 2022 -0800 Branches: master https://developer.blender.org/rBfa8c2c78857989c23262915921722cf69399d58d Fix T94071: Area Split Improvements Allow area Split to be initiated in any area and give better feedback when not allowed. See D13599 for more details and usage examples. Differential Revision: https://developer.blender.org/D13599 Reviewed by Campbell Barton === M source/blender/editors/screen/screen_ops.c === diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index b9c92c1664d..757b1a4c0c4 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -2083,15 +2083,31 @@ typedef struct sAreaSplitData { } sAreaSplitData; +static bool area_split_allowed(const ScrArea *area, const eScreenAxis dir_axis) +{ + if (!area || area->global) { +/* Must be a non-global area. */ +return false; + } + + if ((dir_axis == SCREEN_AXIS_V && area->winx <= 2 * AREAMINX) || + (dir_axis == SCREEN_AXIS_H && area->winy <= 2 * ED_area_headersize())) { +/* Must be at least double minimum sizes to split into two. */ +return false; + } + + return true; +} + static void area_split_draw_cb(const struct wmWindow *UNUSED(win), void *userdata) { const wmOperator *op = userdata; sAreaSplitData *sd = op->customdata; - if (sd->sarea) { -const eScreenAxis dir_axis = RNA_enum_get(op->ptr, "direction"); -float fac = RNA_float_get(op->ptr, "factor"); + const eScreenAxis dir_axis = RNA_enum_get(op->ptr, "direction"); + if (area_split_allowed(sd->sarea, dir_axis)) { +float fac = RNA_float_get(op->ptr, "factor"); screen_draw_split_preview(sd->sarea, dir_axis, fac); } } @@ -2121,18 +2137,6 @@ static bool area_split_init(bContext *C, wmOperator *op) /* required properties */ const eScreenAxis dir_axis = RNA_enum_get(op->ptr, "direction"); - /* minimal size */ - if (dir_axis == SCREEN_AXIS_V) { -if (area->winx < 2 * AREAMINX) { - return false; -} - } - else { -if (area->winy < 2 * ED_area_headersize()) { - return false; -} - } - /* custom data */ sAreaSplitData *sd = (sAreaSplitData *)MEM_callocN(sizeof(sAreaSplitData), "op_area_split"); op->customdata = sd; @@ -2189,6 +2193,10 @@ static bool area_split_apply(bContext *C, wmOperator *op) float fac = RNA_float_get(op->ptr, "factor"); const eScreenAxis dir_axis = RNA_enum_get(op->ptr, "direction"); + if (!area_split_allowed(sd->sarea, dir_axis)) { +return false; + } + sd->narea = area_split(win, screen, sd->sarea, dir_axis, fac, false); /* false = no merge */ if (sd->narea == NULL) { @@ -2254,9 +2262,15 @@ static void area_split_exit(bContext *C, wmOperator *op) static void area_split_preview_update_cursor(bContext *C, wmOperator *op) { - wmWindow *win = CTX_wm_window(C); + sAreaSplitData *sd = (sAreaSplitData *)op->customdata; const eScreenAxis dir_axis = RNA_enum_get(op->ptr, "direction"); - WM_cursor_set(win, (dir_axis == SCREEN_AXIS_H) ? WM_CURSOR_H_SPLIT : WM_CURSOR_V_SPLIT); + if (area_split_allowed(sd->sarea, dir_axis)) { +WM_cursor_set(CTX_wm_window(C), + (dir_axis == SCREEN_AXIS_H) ? WM_CURSOR_H_SPLIT : WM_CURSOR_V_SPLIT); + } + else { +WM_cursor_set(CTX_wm_window(C), WM_CURSOR_STOP); + } } /* UI callback, adds new handler */ @@ -2509,6 +2523,9 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event) if (sd->sarea) { ED_area_tag_redraw(sd->sarea); } + + area_split_preview_update_cursor(C, op); + /* area context not set */ sd->sarea = BKE_screen_find_area_xy(CTX_wm_screen(C), SPACE_TYPE_ANY, event->xy); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [89145341e5d] master: BLF: UI_fontstyle_draw Usage
Commit: 89145341e5ddcefbe71c664db8a853abe3b93344 Author: Harley Acheson Date: Tue Jan 11 14:52:39 2022 -0800 Branches: master https://developer.blender.org/rB89145341e5ddcefbe71c664db8a853abe3b93344 BLF: UI_fontstyle_draw Usage Add maximum string length argument to UI_fontstyle_draw to reduce usage of BLF_DRAW_STR_DUMMY_MAX. Reorders arguments to UI_fontstyle_draw_ex See D13794 for more details. Differential Revision: https://developer.blender.org/D13794 Reviewed by Campbell Barton === M source/blender/editors/include/UI_interface.h M source/blender/editors/interface/interface_panel.c M source/blender/editors/interface/interface_region_tooltip.c M source/blender/editors/interface/interface_style.c M source/blender/editors/interface/interface_widgets.c M source/blender/editors/space_file/file_draw.c === diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index f01b8318e98..5ecc43a9fc9 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -2957,15 +2957,17 @@ void UI_fontstyle_set(const struct uiFontStyle *fs); void UI_fontstyle_draw_ex(const struct uiFontStyle *fs, const struct rcti *rect, const char *str, + size_t str_len, const uchar col[4], const struct uiFontStyleDraw_Params *fs_params, - size_t len, int *r_xofs, int *r_yofs, struct ResultBLF *r_info); + void UI_fontstyle_draw(const struct uiFontStyle *fs, const struct rcti *rect, const char *str, + size_t str_len, const uchar col[4], const struct uiFontStyleDraw_Params *fs_params); /** diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index bc1d3387ad7..135cef5fe53 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -1146,6 +1146,7 @@ static void panel_draw_aligned_widgets(const uiStyle *style, UI_fontstyle_draw(fontstyle, _rect, panel->drawname, + sizeof(panel->drawname), title_color, &(struct uiFontStyleDraw_Params){ .align = UI_STYLE_TEXT_LEFT, diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c index e146443faaa..fe58a6a05ae 100644 --- a/source/blender/editors/interface/interface_region_tooltip.c +++ b/source/blender/editors/interface/interface_region_tooltip.c @@ -74,6 +74,8 @@ #define UI_TIP_PADDING (int)(UI_TIP_PAD_FAC * UI_UNIT_Y) #define UI_TIP_MAXWIDTH 600 +#define UI_TIP_STR_MAX 1024 + typedef struct uiTooltipFormat { enum { UI_TIP_STYLE_NORMAL = 0, @@ -214,7 +216,7 @@ static void ui_tooltip_region_draw_cb(const bContext *UNUSED(C), ARegion *region /* draw header and active data (is done here to be able to change color) */ rgb_float_to_uchar(drawcol, tip_colors[UI_TIP_LC_MAIN]); UI_fontstyle_set(>fstyle); - UI_fontstyle_draw(>fstyle, , field->text, drawcol, _params); + UI_fontstyle_draw(>fstyle, , field->text, UI_TIP_STR_MAX, drawcol, _params); /* offset to the end of the last line */ if (field->text_suffix) { @@ -224,7 +226,8 @@ static void ui_tooltip_region_draw_cb(const bContext *UNUSED(C), ARegion *region bbox.ymax -= yofs; rgb_float_to_uchar(drawcol, tip_colors[UI_TIP_LC_ACTIVE]); -UI_fontstyle_draw(>fstyle, , field->text_suffix, drawcol, _params); +UI_fontstyle_draw( +>fstyle, , field->text_suffix, UI_TIP_STR_MAX, drawcol, _params); /* undo offset */ bbox.xmin -= xofs; @@ -243,7 +246,7 @@ static void ui_tooltip_region_draw_cb(const bContext *UNUSED(C), ARegion *region /* XXX, needed because we don't have mono in 'U.uifonts' */ BLF_size(fstyle_mono.uifont_id, fstyle_mono.points * U.pixelsize, U.dpi); rgb_float_to_uchar(drawcol, tip_colors[field->format.color_id]); - UI_fontstyle_draw(_mono, , field->text, drawcol, _params); + UI_fontstyle_draw(_mono, , field->text, UI_TIP_STR_MAX, drawcol, _params); } else { BLI_assert(field->format.style == UI_TIP_STYLE_NORMAL); @@ -255,7 +258,7 @@ static void ui_tooltip_region_draw_cb(const bContext *UNUSED(C), ARegion *region /* draw remaining data */
[Bf-blender-cvs] [bbe59c60145] master: BLF: Reduction of use of BLF_DRAW_STR_DUMMY_MAX
Commit: bbe59c6014535b125e39f7466ee0930a07116571 Author: Harley Acheson Date: Tue Jan 11 14:07:40 2022 -0800 Branches: master https://developer.blender.org/rBbbe59c6014535b125e39f7466ee0930a07116571 BLF: Reduction of use of BLF_DRAW_STR_DUMMY_MAX Reduction of the number of uses of the define BLF_DRAW_STR_DUMMY_MAX by using actual sizes of static character arrays. See D13793 for more details. Differential Revision: https://developer.blender.org/D13793 Reviewed by Campbell Barton === M source/blender/blenkernel/intern/image.c M source/blender/editors/interface/interface_widgets.c M source/blender/editors/space_node/node_draw.cc M source/blender/editors/util/ed_draw.c M source/blender/sequencer/intern/effects.c === diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 4899c3671aa..23b1054f814 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -2446,7 +2446,7 @@ void BKE_image_stamp_buf(Scene *scene, /* and draw the text. */ BLF_position(mono, x, y + y_ofs, 0.0); -BLF_draw_buffer(mono, stamp_data.file, BLF_DRAW_STR_DUMMY_MAX); +BLF_draw_buffer(mono, stamp_data.file, sizeof(stamp_data.file)); /* the extra pixel for background. */ y -= BUFF_MARGIN_Y * 2; @@ -2469,7 +2469,7 @@ void BKE_image_stamp_buf(Scene *scene, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); -BLF_draw_buffer(mono, stamp_data.date, BLF_DRAW_STR_DUMMY_MAX); +BLF_draw_buffer(mono, stamp_data.date, sizeof(stamp_data.date)); /* the extra pixel for background. */ y -= BUFF_MARGIN_Y * 2; @@ -2492,7 +2492,7 @@ void BKE_image_stamp_buf(Scene *scene, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); -BLF_draw_buffer(mono, stamp_data.rendertime, BLF_DRAW_STR_DUMMY_MAX); +BLF_draw_buffer(mono, stamp_data.rendertime, sizeof(stamp_data.rendertime)); /* the extra pixel for background. */ y -= BUFF_MARGIN_Y * 2; @@ -2515,7 +2515,7 @@ void BKE_image_stamp_buf(Scene *scene, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); -BLF_draw_buffer(mono, stamp_data.memory, BLF_DRAW_STR_DUMMY_MAX); +BLF_draw_buffer(mono, stamp_data.memory, sizeof(stamp_data.memory)); /* the extra pixel for background. */ y -= BUFF_MARGIN_Y * 2; @@ -2538,7 +2538,7 @@ void BKE_image_stamp_buf(Scene *scene, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); -BLF_draw_buffer(mono, stamp_data.hostname, BLF_DRAW_STR_DUMMY_MAX); +BLF_draw_buffer(mono, stamp_data.hostname, sizeof(stamp_data.hostname)); /* the extra pixel for background. */ y -= BUFF_MARGIN_Y * 2; @@ -2562,7 +2562,7 @@ void BKE_image_stamp_buf(Scene *scene, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs + (h - h_fixed), 0.0); -BLF_draw_buffer(mono, stamp_data.note, BLF_DRAW_STR_DUMMY_MAX); +BLF_draw_buffer(mono, stamp_data.note, sizeof(stamp_data.note)); } BLF_disable(mono, BLF_WORD_WRAP); @@ -2586,7 +2586,7 @@ void BKE_image_stamp_buf(Scene *scene, /* and pad the text. */ BLF_position(mono, x, y + y_ofs, 0.0); -BLF_draw_buffer(mono, stamp_data.marker, BLF_DRAW_STR_DUMMY_MAX); +BLF_draw_buffer(mono, stamp_data.marker, sizeof(stamp_data.marker)); /* space width. */ x += w + pad; @@ -2609,7 +2609,7 @@ void BKE_image_stamp_buf(Scene *scene, /* and pad the text. */ BLF_position(mono, x, y + y_ofs, 0.0); -BLF_draw_buffer(mono, stamp_data.time, BLF_DRAW_STR_DUMMY_MAX); +BLF_draw_buffer(mono, stamp_data.time, sizeof(stamp_data.time)); /* space width. */ x += w + pad; @@ -2631,7 +2631,7 @@ void BKE_image_stamp_buf(Scene *scene, /* and pad the text. */ BLF_position(mono, x, y + y_ofs, 0.0); -BLF_draw_buffer(mono, stamp_data.frame, BLF_DRAW_STR_DUMMY_MAX); +BLF_draw_buffer(mono, stamp_data.frame, sizeof(stamp_data.frame)); /* space width. */ x += w + pad; @@ -2651,7 +2651,7 @@ void BKE_image_stamp_buf(Scene *scene, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); -BLF_draw_buffer(mono, stamp_data.camera, BLF_DRAW_STR_DUMMY_MAX); +BLF_draw_buffer(mono, stamp_data.camera, sizeof(stamp_data.camera)); /* space width. */ x += w + pad; @@ -2671,7 +2671,7 @@ void BKE_image_stamp_buf(Scene *scene, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); -BLF_draw_buffer(mono, stamp_data.cameralens, BLF_DRAW_STR_DUMMY_MAX); +BLF_draw_buffer(mono
[Bf-blender-cvs] [45bb6b836a2] master: IME Cleanup: Unused GHOST_TEventImeData Member
Commit: 45bb6b836a21fc6fd53f9c4d83447c1805df4f26 Author: Harley Acheson Date: Tue Jan 11 12:35:11 2022 -0800 Branches: master https://developer.blender.org/rB45bb6b836a21fc6fd53f9c4d83447c1805df4f26 IME Cleanup: Unused GHOST_TEventImeData Member Removal of unused tmp member of GHOST_TEventImeData. Not used now, nor was it used by the commit that added it to begin with. Differential Revision: https://developer.blender.org/D11799 Reviewed by Ray Molenkamp === M intern/ghost/GHOST_Types.h === diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h index ce0185bc7d0..7fe9300ec3f 100644 --- a/intern/ghost/GHOST_Types.h +++ b/intern/ghost/GHOST_Types.h @@ -496,8 +496,6 @@ typedef struct { int target_start; /** Represents the position of the end of the selection */ int target_end; - /** custom temporal data */ - GHOST_TUserDataPtr tmp; } GHOST_TEventImeData; typedef struct { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [e53f3954a44] blender-v3.0-release: Fix T93949: Preview Image Error When No Screen
Commit: e53f3954a44b3d527cf2ef3ad8bd9c23ca810817 Author: Harley Acheson Date: Tue Dec 14 13:50:40 2021 -0800 Branches: blender-v3.0-release https://developer.blender.org/rBe53f3954a44b3d527cf2ef3ad8bd9c23ca810817 Fix T93949: Preview Image Error When No Screen Fix an error if "File Preview Type" is "Auto" and there is no screen. See D13574 for details. Differential Revision: https://developer.blender.org/D13574 Reviewed by Julian Eisel === M source/blender/windowmanager/intern/wm_files.c === diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index e95ce98352a..c21567eaaf6 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -1820,8 +1820,9 @@ static bool wm_file_write(bContext *C, if (file_preview_type == USER_FILE_PREVIEW_AUTO) { Scene *scene = CTX_data_scene(C); -bool do_render = (scene != NULL && scene->camera != NULL && - (BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_VIEW3D, 0) != NULL)); +bScreen *screen = CTX_wm_screen(C); +bool do_render = (scene != NULL && scene->camera != NULL && screen != NULL && + (BKE_screen_find_big_area(screen, SPACE_VIEW3D, 0) != NULL)); file_preview_type = do_render ? USER_FILE_PREVIEW_CAMERA : USER_FILE_PREVIEW_SCREENSHOT; } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [08226693cfa] blender-v3.0-release: Fix T94334: 3DView View Menu Close Error
Commit: 08226693cfa2b18a89af91d6c3488d92820fed35 Author: Harley Acheson Date: Tue Jan 11 10:01:14 2022 +0100 Branches: blender-v3.0-release https://developer.blender.org/rB08226693cfa2b18a89af91d6c3488d92820fed35 Fix T94334: 3DView View Menu Close Error Add Error checking to `do_view3d_header_buttons` so that it does not crash if area->win does not exist because it has been closed. Note this is a temporary simple fix that will be replaced by D13660. --- Selecting "Close Area" from the 3DView View / Area menu will crash when `do_view3d_header_buttons` is called afterward even though the area has closed. It gets a NULL result from CTX_wm_window(C) and dies. This patch just adds a check for this being NULL and exits out in this case. `uiTemplateEditModeSelection` is a bit dodgy adding `do_view3d_header_buttons` as a handler for the entire uiBlock. This patch is meant to be a simple and temporary solution in 3.01, replaced later by {D13660} which fixes this area by using an operator instead. === M source/blender/editors/space_view3d/view3d_header.c === diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 607ca110d0f..ed9722ba9af 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -101,6 +101,10 @@ void VIEW3D_OT_toggle_matcap_flip(wmOperatorType *ot) static void do_view3d_header_buttons(bContext *C, void *UNUSED(arg), int event) { wmWindow *win = CTX_wm_window(C); + if (!win) { +return; + } + const int ctrl = win->eventstate->ctrl, shift = win->eventstate->shift; /* watch it: if area->win does not exist, check that when calling direct drawing routines */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [ccf06fffbcd] master: UI: Allow AltGr Key + C, V, X Text Input
Commit: ccf06fffbcdc6895732491dec68c3136e8785432 Author: Harley Acheson Date: Mon Jan 10 09:52:19 2022 -0800 Branches: master https://developer.blender.org/rBccf06fffbcdc6895732491dec68c3136e8785432 UI: Allow AltGr Key + C,V,X Text Input Slight change to our processing of Ctrl-C, Ctrl-V, and Ctrl-X so that they will not be triggered if Alt is also pressed. This allows entry of AltGr-C, -V, -X when using International keyboard layouts. See D13781 for more details Differential Revision: https://developer.blender.org/D13781 Reviewed by Brecht Van Lommel === M source/blender/editors/interface/interface_handlers.c === diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 7521ccf4e4c..6ecaead67ce 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -3762,7 +3762,12 @@ static void ui_do_but_textedit( case EVT_VKEY: case EVT_XKEY: case EVT_CKEY: -if (IS_EVENT_MOD(event, ctrl, oskey)) { +#if defined(__APPLE__) +if ((event->oskey && !IS_EVENT_MOD(event, shift, alt, ctrl)) || +(event->ctrl && !IS_EVENT_MOD(event, shift, alt, oskey))) { +#else +if (event->ctrl && !IS_EVENT_MOD(event, shift, alt, oskey)) { +#endif if (event->type == EVT_VKEY) { changed = ui_textedit_copypaste(but, data, UI_TEXTEDIT_PASTE); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs