[ft] Add hb_ft_face_create_from_file_or_fail()

New API:
+hb_ft_face_create_from_file_or_fail()
pull/4895/head
Behdad Esfahbod 4 months ago
parent 89c83b5b08
commit 12fc715dd6
  1. 1
      docs/harfbuzz-sections.txt
  2. 2
      src/hb-coretext-shape.cc
  3. 37
      src/hb-ft.cc
  4. 3
      src/hb-ft.h

@ -517,6 +517,7 @@ hb_glyph_extents_t
hb_ft_face_create
hb_ft_face_create_cached
hb_ft_face_create_referenced
hb_ft_face_create_from_file_or_fail
hb_ft_font_create
hb_ft_font_create_referenced
hb_ft_font_changed

@ -361,7 +361,7 @@ hb_coretext_face_create (CGFontRef cg_font)
* Return value: (transfer full): The new face object, or `NULL` if
* no face is found at the specified index or the file cannot be read.
*
* Since: 0.9.10
* XSince: REPLACEME
*/
hb_face_t *
hb_coretext_face_create_from_file_or_fail (const char *file_name,

@ -1469,6 +1469,43 @@ get_ft_library ()
return static_ft_library.get_unconst ();
}
/**
* hb_ft_face_create_from_file_or_fail:
* @file_name: A font filename
* @index: The index of the face within the file
*
* Creates an #hb_face_t face object from the specified
* font file and face index.
*
* This is similar in functionality to hb_face_create_for_from_file_or_fail(),
* but uses the FreeType library for loading the font file.
*
* Return value: (transfer full): The new face object, or `NULL` if
* no face is found at the specified index or the file cannot be read.
*
* XSince: REPLACEME
*/
hb_face_t *
hb_ft_face_create_from_file_or_fail (const char *file_name,
unsigned int index)
{
FT_Face ft_face;
FT_Error error = FT_New_Face (get_ft_library (),
file_name,
index,
&ft_face);
if (error)
return nullptr;
hb_face_t *face = hb_ft_face_create_referenced (ft_face);
FT_Done_Face (ft_face);
if (hb_face_is_immutable (face))
return nullptr;
return face;
}
static void
_release_blob (void *arg)
{

@ -84,6 +84,9 @@ hb_ft_face_create_cached (FT_Face ft_face);
HB_EXTERN hb_face_t *
hb_ft_face_create_referenced (FT_Face ft_face);
HB_EXTERN hb_face_t *
hb_ft_face_create_from_file_or_fail (const char *file_name,
unsigned int index);
/*
* hb-font from ft-face.

Loading…
Cancel
Save