diff options
author | Po Lu <luangruo@yahoo.com> | 2022-05-02 05:48:48 +0000 |
---|---|---|
committer | Po Lu <luangruo@yahoo.com> | 2022-05-02 05:49:42 +0000 |
commit | 3ea1a6672b1cc8c7ea505585e8687500014e524b (patch) | |
tree | 29e7ebd531f1accfe3d8405b2f4d59ee105ac1be /src/haiku_font_support.cc | |
parent | 2fa11123e5e3ebe3703da1968f66d14265358ac5 (diff) | |
download | emacs-3ea1a6672b1cc8c7ea505585e8687500014e524b.tar.gz emacs-3ea1a6672b1cc8c7ea505585e8687500014e524b.tar.bz2 emacs-3ea1a6672b1cc8c7ea505585e8687500014e524b.zip |
Default to currently selected font in Haiku font dialogs
* src/haiku_font_support.cc (be_find_font_indices): New
function.
* src/haiku_support.cc (class EmacsFontSelectionDialog)
(UpdateStylesForIndex, EmacsFontSelectionDialog): Allow
specifying an initial font family and style.
(be_select_font): New parameters `initial_family' and
`initial_style'.
* src/haiku_support.h: Update prototypes.
* src/haikufont.c (haikufont_lisp_to_weight)
(haikufont_lisp_to_slant, haikufont_lisp_to_width): Handle
`regular'.
(haikufont_pattern_from_object): New function.
(haikufont_spec_or_entity_to_pattern): Fix coding style.
(Fx_select_font): Compute indices based on currently selected
font.
(syms_of_haikufont): New defsyms.
Diffstat (limited to 'src/haiku_font_support.cc')
-rw-r--r-- | src/haiku_font_support.cc | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/haiku_font_support.cc b/src/haiku_font_support.cc index 95a0db8ae68..de55ad2001a 100644 --- a/src/haiku_font_support.cc +++ b/src/haiku_font_support.cc @@ -815,3 +815,38 @@ be_font_style_to_flags (char *style, struct haiku_font_pattern *pattern) font_style_to_flags (style, pattern); } + +int +be_find_font_indices (struct haiku_font_pattern *pattern, + int *family_index, int *style_index) +{ + int32 i, j, n_families, n_styles; + font_family family; + font_style style; + uint32 flags; + + n_families = count_font_families (); + + for (i = 0; i < n_families; ++i) + { + if (get_font_family (i, &family, &flags) == B_OK) + { + n_styles = count_font_styles (family); + + for (j = 0; j < n_styles; ++j) + { + if (get_font_style (family, j, &style, &flags) == B_OK + && font_family_style_matches_p (family, style, + flags, pattern)) + { + *family_index = i; + *style_index = j; + + return 0; + } + } + } + } + + return 1; +} |