diff options
author | Robin Watts <Robin.Watts@artifex.com> | 2016-09-28 16:46:10 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2016-10-05 19:37:11 +0100 |
commit | 9e88b088ea2ddcb6f85584750eb3c989af101905 (patch) | |
tree | 19db41ec596cc347fd1b77389821135f8e934e84 /source/html | |
parent | 14109acf198d9371a4e2cb09ea4a125af67d441d (diff) | |
download | mupdf-9e88b088ea2ddcb6f85584750eb3c989af101905.tar.xz |
Move fz_font definition to be private.
Move the definition of fz_font to be in a private header file
rather than in the public API. Add accessors for specific
parts of the structure and use them as appropriate.
The font flags, and the harfbuzz records remain public.
This means that only 3 files now need access to the font
implementation (font.c, pdf-font.c and pdf-type3.c). This
may be able to be improved further in future.
Diffstat (limited to 'source/html')
-rw-r--r-- | source/html/html-font.c | 11 | ||||
-rw-r--r-- | source/html/html-layout.c | 17 |
2 files changed, 15 insertions, 13 deletions
diff --git a/source/html/html-font.c b/source/html/html-font.c index 3b8f7c72..01ec10f5 100644 --- a/source/html/html-font.c +++ b/source/html/html-font.c @@ -19,7 +19,7 @@ fz_load_html_default_font(fz_context *ctx, fz_html_font_set *set, const char *fa if (!data) fz_throw(ctx, FZ_ERROR_GENERIC, "cannot load html font: %s", real_family); set->fonts[idx] = fz_new_font_from_memory(ctx, NULL, data, size, 0, 1); - set->fonts[idx]->is_serif = !is_sans; + fz_font_flags(set->fonts[idx])->is_serif = !is_sans; } return set->fonts[idx]; } @@ -60,10 +60,11 @@ fz_load_html_font(fz_context *ctx, fz_html_font_set *set, const char *family, in if (data) { fz_font *font = fz_new_font_from_memory(ctx, NULL, data, size, 0, 0); - if (is_bold && !font->is_bold) - font->fake_bold = 1; - if (is_italic && !font->is_italic) - font->fake_italic = 1; + fz_font_flags_t *flags = fz_font_flags(font); + if (is_bold && !flags->is_bold) + flags->fake_bold = 1; + if (is_italic && !flags->is_italic) + flags->fake_italic = 1; fz_add_html_font_face(ctx, set, family, is_bold, is_italic, "<builtin>", font); fz_drop_font(ctx, font); return font; diff --git a/source/html/html-layout.c b/source/html/html-layout.c index e671c64d..2fe6de82 100644 --- a/source/html/html-layout.c +++ b/source/html/html-layout.c @@ -791,7 +791,7 @@ static int quick_ligature_mov(fz_context *ctx, string_walker *walker, unsigned i static int quick_ligature(fz_context *ctx, string_walker *walker, unsigned int i) { - if (walker->glyph_info[i].codepoint == 'f' && i + 1 < walker->glyph_count && !walker->font->is_mono) + if (walker->glyph_info[i].codepoint == 'f' && i + 1 < walker->glyph_count && !fz_font_flags(walker->font)->is_mono) { if (walker->glyph_info[i+1].codepoint == 'f') { @@ -873,13 +873,13 @@ static int walk_string(string_walker *walker) /* Disable harfbuzz shaping if script is common or LGC and there are no opentype tables. */ quickshape = 0; - if (walker->script <= 3 && !walker->rtl && !walker->font->has_opentype) + if (walker->script <= 3 && !walker->rtl && !fz_font_flags(walker->font)->has_opentype) quickshape = 1; hb_lock(ctx); fz_try(ctx) { - face = walker->font->ft_face; + face = fz_font_ft_face(walker->font); walker->scale = face->units_per_EM; fterr = FT_Set_Char_Size(face, walker->scale, walker->scale, 72, 72); if (fterr) @@ -899,11 +899,12 @@ static int walk_string(string_walker *walker) if (!quickshape) { - if (walker->font->hb_font == NULL) + fz_hb_t *hb = fz_font_hb(walker->font); + if (hb->font == NULL) { Memento_startLeaking(); /* HarfBuzz leaks harmlessly */ - walker->font->hb_destroy = (fz_hb_font_destructor_t *)hb_font_destroy; - walker->font->hb_font = hb_ft_font_create(face, NULL); + hb->destroy = (fz_hb_font_destructor_t *)hb_font_destroy; + hb->font = hb_ft_font_create(face, NULL); Memento_stopLeaking(); } @@ -911,7 +912,7 @@ static int walk_string(string_walker *walker) hb_buffer_guess_segment_properties(walker->hb_buf); Memento_stopLeaking(); - hb_shape(walker->font->hb_font, walker->hb_buf, NULL, 0); + hb_shape(hb->font, walker->hb_buf, NULL, 0); } walker->glyph_pos = hb_buffer_get_glyph_positions(walker->hb_buf, &walker->glyph_count); @@ -1978,7 +1979,7 @@ void fz_print_css_style(fz_context *ctx, fz_css_style *style, int boxtype, int n) { indent(n); printf("font_size %g%c\n", style->font_size.value, style->font_size.unit); - indent(n); printf("font %s\n", style->font ? style->font->name : "NULL"); + indent(n); printf("font %s\n", style->font ? fz_font_name(style->font) : "NULL"); indent(n); printf("width = %g%c;\n", style->width.value, style->width.unit); indent(n); printf("height = %g%c;\n", style->height.value, style->height.unit); if (boxtype == BOX_BLOCK) |