Implement `list_family' for the haikufont driver
* src/haiku_font_support.cc (be_list_font_families): New function. * src/haiku_support.h: Update prototypes. * src/haikufont.c (haikufont_list_family): New function. (haikufont_driver): Add `haikufont_list_family'.
This commit is contained in:
parent
d41a5e7e33
commit
f96eee4e06
3 changed files with 59 additions and 1 deletions
|
@ -615,3 +615,27 @@ BFont_string_width (void *font, const char *utf8)
|
|||
{
|
||||
return ((BFont *) font)->StringWidth (utf8);
|
||||
}
|
||||
|
||||
haiku_font_family_or_style *
|
||||
be_list_font_families (size_t *length)
|
||||
{
|
||||
int32 families = count_font_families ();
|
||||
haiku_font_family_or_style *array;
|
||||
int32 idx;
|
||||
uint32 flags;
|
||||
|
||||
array = (haiku_font_family_or_style *) malloc (sizeof *array * families);
|
||||
|
||||
if (!array)
|
||||
return NULL;
|
||||
|
||||
for (idx = 0; idx < families; ++idx)
|
||||
{
|
||||
if (get_font_family (idx, &array[idx], &flags) != B_OK)
|
||||
array[idx][0] = '\0';
|
||||
}
|
||||
|
||||
*length = families;
|
||||
|
||||
return array;
|
||||
}
|
||||
|
|
|
@ -883,6 +883,9 @@ extern "C"
|
|||
extern void
|
||||
EmacsWindow_signal_menu_update_complete (void *window);
|
||||
|
||||
extern haiku_font_family_or_style *
|
||||
be_list_font_families (size_t *length);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern void *
|
||||
find_appropriate_view_for_draw (void *vw);
|
||||
|
|
|
@ -29,6 +29,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
|
|||
#include "fontset.h"
|
||||
#include "haikuterm.h"
|
||||
#include "character.h"
|
||||
#include "coding.h"
|
||||
#include "font.h"
|
||||
#include "termchar.h"
|
||||
#include "pdumper.h"
|
||||
|
@ -1023,6 +1024,35 @@ haikufont_draw (struct glyph_string *s, int from, int to,
|
|||
return 1;
|
||||
}
|
||||
|
||||
static Lisp_Object
|
||||
haikufont_list_family (struct frame *f)
|
||||
{
|
||||
Lisp_Object list = Qnil;
|
||||
size_t length;
|
||||
ptrdiff_t idx;
|
||||
haiku_font_family_or_style *styles;
|
||||
|
||||
block_input ();
|
||||
styles = be_list_font_families (&length);
|
||||
unblock_input ();
|
||||
|
||||
if (!styles)
|
||||
return list;
|
||||
|
||||
block_input ();
|
||||
for (idx = 0; idx < length; ++idx)
|
||||
{
|
||||
if (styles[idx][0])
|
||||
list = Fcons (build_string_from_utf8 ((char *) &styles[idx]),
|
||||
list);
|
||||
}
|
||||
|
||||
free (styles);
|
||||
unblock_input ();
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
struct font_driver const haikufont_driver =
|
||||
{
|
||||
.type = LISPSYM_INITIALLY (Qhaiku),
|
||||
|
@ -1036,7 +1066,8 @@ struct font_driver const haikufont_driver =
|
|||
.prepare_face = haikufont_prepare_face,
|
||||
.encode_char = haikufont_encode_char,
|
||||
.text_extents = haikufont_text_extents,
|
||||
.shape = haikufont_shape
|
||||
.shape = haikufont_shape,
|
||||
.list_family = haikufont_list_family
|
||||
};
|
||||
|
||||
void
|
||||
|
|
Loading…
Add table
Reference in a new issue