mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-19 22:11:04 +01:00
Fix reading fonts from stdin (#1060)
We were passing the font path directly to freetype so rendering was broken when we are getting the font from stdin. This fixes it by using FT_New_Memory_Face instead. This fixes: * build/util/hb-view /dev/stdin text < font.ttf * build/util/hb-view - text < font.ttf * cat font.ttf | build/util/hb-view - text but doesn't work on * cat font.ttf | build/util/hb-view /dev/stdin text which I will try to fix separately.
This commit is contained in:
1 parent
3654d9be6b
commit
aa0c5df419
3 files changed
+15
-8
No files matched your search
+10
-4
@@ -89,10 +89,16 @@ helper_cairo_create_scaled_font (const font_options_t *font_opts)
|
||||
atexit (free_ft_library);
|
||||
#endif
|
||||
}
|
||||
FT_New_Face (ft_library,
|
||||
font_opts->font_file,
|
||||
font_opts->face_index,
|
||||
&ft_face);
|
||||
|
||||
unsigned int blob_length;
|
||||
const char *blob_data = hb_blob_get_data (font_opts->blob, &blob_length);
|
||||
|
||||
if (FT_New_Memory_Face (ft_library,
|
||||
(const FT_Byte *) blob_data,
|
||||
blob_length,
|
||||
font_opts->face_index,
|
||||
&ft_face))
|
||||
fail (false, "FT_New_Memory_Face fail");
|
||||
}
|
||||
if (!ft_face)
|
||||
{
|
||||
|
||||
+2
-3
@@ -643,8 +643,6 @@ font_options_t::get_font (void) const
|
||||
if (font)
|
||||
return font;
|
||||
|
||||
hb_blob_t *blob = nullptr;
|
||||
|
||||
/* Create the blob */
|
||||
if (!font_file)
|
||||
fail (true, "No font file set");
|
||||
@@ -663,8 +661,9 @@ font_options_t::get_font (void) const
|
||||
strerror (errno));
|
||||
g_string_append_len (gs, buf, ret);
|
||||
}
|
||||
unsigned int len = gs->len;
|
||||
char *font_data = g_string_free (gs, false);
|
||||
blob = hb_blob_create (font_data, gs->len,
|
||||
blob = hb_blob_create (font_data, len,
|
||||
HB_MEMORY_MODE_WRITABLE, font_data,
|
||||
(hb_destroy_func_t) g_free);
|
||||
} else {
|
||||
|
||||
+3
-1
@@ -455,6 +455,7 @@ struct font_options_t : option_group_t
|
||||
font_size_x = font_size_y = default_font_size;
|
||||
font_funcs = nullptr;
|
||||
|
||||
blob = nullptr;
|
||||
font = nullptr;
|
||||
|
||||
add_options (parser);
|
||||
@@ -471,6 +472,7 @@ struct font_options_t : option_group_t
|
||||
hb_font_t *get_font (void) const;
|
||||
|
||||
char *font_file;
|
||||
mutable hb_blob_t *blob;
|
||||
int face_index;
|
||||
hb_variation_t *variations;
|
||||
unsigned int num_variations;
|
||||
@@ -483,7 +485,7 @@ struct font_options_t : option_group_t
|
||||
mutable double font_size_y;
|
||||
char *font_funcs;
|
||||
|
||||
private:
|
||||
private:
|
||||
mutable hb_font_t *font;
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user