Rename hb_outline_decompose to hb_font_draw_glyph and hb_outline_decompose_funcs_t to hb_draw_funcs_t

This commit is contained in:
Ebrahim Byagowi 2020-01-28 12:34:47 +03:30
parent cf5f946756
commit ac81e94016
19 changed files with 237 additions and 236 deletions

View File

@ -221,6 +221,24 @@ hb_directwrite_face_get_font_face
hb_directwrite_shape_experimental_width hb_directwrite_shape_experimental_width
</SECTION> </SECTION>
<SECTION>
<FILE>hb-draw</FILE>
hb_draw_funcs_t
hb_draw_close_path_func_t
hb_draw_conic_to_func_t
hb_draw_cubic_to_func_t
hb_draw_line_to_func_t
hb_draw_move_to_func_t
hb_draw_funcs_create
hb_draw_funcs_destroy
hb_draw_funcs_reference
hb_draw_funcs_set_close_path_func
hb_draw_funcs_set_conic_to_func
hb_draw_funcs_set_cubic_to_func
hb_draw_funcs_set_line_to_func
hb_draw_funcs_set_move_to_func
</SECTION>
<SECTION> <SECTION>
<FILE>hb-face</FILE> <FILE>hb-face</FILE>
hb_face_count hb_face_count
@ -256,6 +274,7 @@ hb_font_add_glyph_origin_for_direction
hb_font_create hb_font_create
hb_font_create_sub_font hb_font_create_sub_font
hb_font_destroy hb_font_destroy
hb_font_draw_glyph
hb_font_funcs_create hb_font_funcs_create
hb_font_funcs_destroy hb_font_funcs_destroy
hb_font_funcs_get_empty hb_font_funcs_get_empty
@ -656,25 +675,6 @@ hb_ot_var_normalize_variations
hb_ot_var_normalize_coords hb_ot_var_normalize_coords
</SECTION> </SECTION>
<SECTION>
<FILE>hb-outline</FILE>
hb_outline_decompose_funcs_t
hb_outline_decompose_close_path_func_t
hb_outline_decompose_conic_to_func_t
hb_outline_decompose_cubic_to_func_t
hb_outline_decompose_line_to_func_t
hb_outline_decompose_move_to_func_t
hb_outline_decompose
hb_outline_decompose_funcs_create
hb_outline_decompose_funcs_destroy
hb_outline_decompose_funcs_reference
hb_outline_decompose_funcs_set_close_path_func
hb_outline_decompose_funcs_set_conic_to_func
hb_outline_decompose_funcs_set_cubic_to_func
hb_outline_decompose_funcs_set_line_to_func
hb_outline_decompose_funcs_set_move_to_func
</SECTION>
<SECTION> <SECTION>
<FILE>hb-set</FILE> <FILE>hb-set</FILE>
HB_SET_VALUE_INVALID HB_SET_VALUE_INVALID

View File

@ -35,13 +35,13 @@ HB_BASE_sources = \
hb-config.hh \ hb-config.hh \
hb-debug.hh \ hb-debug.hh \
hb-dispatch.hh \ hb-dispatch.hh \
hb-draw.cc \
hb-draw.hh \
hb-face.cc \ hb-face.cc \
hb-face.hh \ hb-face.hh \
hb-fallback-shape.cc \ hb-fallback-shape.cc \
hb-font.cc \ hb-font.cc \
hb-font.hh \ hb-font.hh \
hb-outline.cc \
hb-outline.hh \
hb-iter.hh \ hb-iter.hh \
hb-kern.hh \ hb-kern.hh \
hb-machinery.hh \ hb-machinery.hh \
@ -195,9 +195,9 @@ HB_BASE_headers = \
hb-buffer.h \ hb-buffer.h \
hb-common.h \ hb-common.h \
hb-deprecated.h \ hb-deprecated.h \
hb-draw.h \
hb-face.h \ hb-face.h \
hb-font.h \ hb-font.h \
hb-outline.h \
hb-map.h \ hb-map.h \
hb-ot-color.h \ hb-ot-color.h \
hb-ot-deprecated.h \ hb-ot-deprecated.h \

View File

@ -4,10 +4,10 @@
#include "hb-buffer-serialize.cc" #include "hb-buffer-serialize.cc"
#include "hb-buffer.cc" #include "hb-buffer.cc"
#include "hb-common.cc" #include "hb-common.cc"
#include "hb-draw.cc"
#include "hb-face.cc" #include "hb-face.cc"
#include "hb-fallback-shape.cc" #include "hb-fallback-shape.cc"
#include "hb-font.cc" #include "hb-font.cc"
#include "hb-outline.cc"
#include "hb-map.cc" #include "hb-map.cc"
#include "hb-number.cc" #include "hb-number.cc"
#include "hb-ot-cff1-table.cc" #include "hb-ot-cff1-table.cc"

View File

@ -58,6 +58,7 @@
#define HB_NO_BITMAP #define HB_NO_BITMAP
#define HB_NO_CFF #define HB_NO_CFF
#define HB_NO_COLOR #define HB_NO_COLOR
#define HB_NO_DRAW
#define HB_NO_ERRNO #define HB_NO_ERRNO
#define HB_NO_FACE_COLLECT_UNICODES #define HB_NO_FACE_COLLECT_UNICODES
#define HB_NO_GETENV #define HB_NO_GETENV
@ -72,7 +73,6 @@
#define HB_NO_MMAP #define HB_NO_MMAP
#define HB_NO_NAME #define HB_NO_NAME
#define HB_NO_OPEN #define HB_NO_OPEN
#define HB_NO_OUTLINE
#define HB_NO_SETLOCALE #define HB_NO_SETLOCALE
#define HB_NO_OT_FONT_GLYPH_NAMES #define HB_NO_OT_FONT_GLYPH_NAMES
#define HB_NO_OT_SHAPE_FRACTIONS #define HB_NO_OT_SHAPE_FRACTIONS

View File

@ -24,16 +24,16 @@
#include "hb.hh" #include "hb.hh"
#ifndef HB_NO_OUTLINE #ifndef HB_NO_DRAW
#include "hb-draw.hh"
#include "hb-ot.h" #include "hb-ot.h"
#include "hb-ot-glyf-table.hh" #include "hb-ot-glyf-table.hh"
#include "hb-ot-cff1-table.hh" #include "hb-ot-cff1-table.hh"
#include "hb-ot-cff2-table.hh" #include "hb-ot-cff2-table.hh"
#include "hb-outline.hh"
/** /**
* hb_outline_decompose_funcs_set_move_to_func: * hb_draw_funcs_set_move_to_func:
* @funcs: decompose functions object * @funcs: decompose functions object
* @move_to: move-to callback * @move_to: move-to callback
* *
@ -42,15 +42,15 @@
* Since: REPLACEME * Since: REPLACEME
**/ **/
void void
hb_outline_decompose_funcs_set_move_to_func (hb_outline_decompose_funcs_t *funcs, hb_draw_funcs_set_move_to_func (hb_draw_funcs_t *funcs,
hb_outline_decompose_move_to_func_t move_to) hb_draw_move_to_func_t move_to)
{ {
if (unlikely (hb_object_is_immutable (funcs))) return; if (unlikely (hb_object_is_immutable (funcs))) return;
funcs->move_to = move_to; funcs->move_to = move_to;
} }
/** /**
* hb_outline_decompose_funcs_set_line_to_func: * hb_draw_funcs_set_line_to_func:
* @funcs: decompose functions object * @funcs: decompose functions object
* @line_to: line-to callback * @line_to: line-to callback
* *
@ -59,32 +59,32 @@ hb_outline_decompose_funcs_set_move_to_func (hb_outline_decompose_funcs_t
* Since: REPLACEME * Since: REPLACEME
**/ **/
void void
hb_outline_decompose_funcs_set_line_to_func (hb_outline_decompose_funcs_t *funcs, hb_draw_funcs_set_line_to_func (hb_draw_funcs_t *funcs,
hb_outline_decompose_line_to_func_t line_to) hb_draw_line_to_func_t line_to)
{ {
if (unlikely (hb_object_is_immutable (funcs))) return; if (unlikely (hb_object_is_immutable (funcs))) return;
funcs->line_to = line_to; funcs->line_to = line_to;
} }
/** /**
* hb_outline_decompose_funcs_set_conic_to_func: * hb_draw_funcs_set_conic_to_func:
* @funcs: decompose functions object * @funcs: decompose functions object
* @move_to: conic-to callback * @move_to: quadratic-to callback
* *
* Sets conic-to callback to the decompose functions object. * Sets quadratic-to callback to the decompose functions object.
* *
* Since: REPLACEME * Since: REPLACEME
**/ **/
void void
hb_outline_decompose_funcs_set_conic_to_func (hb_outline_decompose_funcs_t *funcs, hb_draw_funcs_set_conic_to_func (hb_draw_funcs_t *funcs,
hb_outline_decompose_conic_to_func_t conic_to) hb_draw_conic_to_func_t conic_to)
{ {
if (unlikely (hb_object_is_immutable (funcs))) return; if (unlikely (hb_object_is_immutable (funcs))) return;
funcs->conic_to = conic_to; funcs->conic_to = conic_to;
} }
/** /**
* hb_outline_decompose_funcs_set_cubic_to_func: * hb_draw_funcs_set_cubic_to_func:
* @funcs: decompose functions * @funcs: decompose functions
* @cubic_to: cubic-to callback * @cubic_to: cubic-to callback
* *
@ -93,15 +93,15 @@ hb_outline_decompose_funcs_set_conic_to_func (hb_outline_decompose_funcs_t
* Since: REPLACEME * Since: REPLACEME
**/ **/
void void
hb_outline_decompose_funcs_set_cubic_to_func (hb_outline_decompose_funcs_t *funcs, hb_draw_funcs_set_cubic_to_func (hb_draw_funcs_t *funcs,
hb_outline_decompose_cubic_to_func_t cubic_to) hb_draw_cubic_to_func_t cubic_to)
{ {
if (unlikely (hb_object_is_immutable (funcs))) return; if (unlikely (hb_object_is_immutable (funcs))) return;
funcs->cubic_to = cubic_to; funcs->cubic_to = cubic_to;
} }
/** /**
* hb_outline_decompose_funcs_set_close_path_func: * hb_draw_funcs_set_close_path_func:
* @funcs: decompose functions object * @funcs: decompose functions object
* @close_path: close-path callback * @close_path: close-path callback
* *
@ -110,8 +110,8 @@ hb_outline_decompose_funcs_set_cubic_to_func (hb_outline_decompose_funcs_t
* Since: REPLACEME * Since: REPLACEME
**/ **/
void void
hb_outline_decompose_funcs_set_close_path_func (hb_outline_decompose_funcs_t *funcs, hb_draw_funcs_set_close_path_func (hb_draw_funcs_t *funcs,
hb_outline_decompose_close_path_func_t close_path) hb_draw_close_path_func_t close_path)
{ {
if (unlikely (hb_object_is_immutable (funcs))) return; if (unlikely (hb_object_is_immutable (funcs))) return;
funcs->close_path = close_path; funcs->close_path = close_path;
@ -125,41 +125,42 @@ _line_to_nil (hb_position_t to_x HB_UNUSED, hb_position_t to_y HB_UNUSED, void *
static void static void
_conic_to_nil (hb_position_t control_x HB_UNUSED, hb_position_t control_y HB_UNUSED, _conic_to_nil (hb_position_t control_x HB_UNUSED, hb_position_t control_y HB_UNUSED,
hb_position_t to_x HB_UNUSED, hb_position_t to_y HB_UNUSED, hb_position_t to_x HB_UNUSED, hb_position_t to_y HB_UNUSED,
void *user_data HB_UNUSED) {} void *user_data HB_UNUSED) {}
static void static void
_cubic_to_nil (hb_position_t control1_x HB_UNUSED, hb_position_t control1_y HB_UNUSED, _cubic_to_nil (hb_position_t control1_x HB_UNUSED, hb_position_t control1_y HB_UNUSED,
hb_position_t control2_x HB_UNUSED, hb_position_t control2_y HB_UNUSED, hb_position_t control2_x HB_UNUSED, hb_position_t control2_y HB_UNUSED,
hb_position_t to_x HB_UNUSED, hb_position_t to_y HB_UNUSED, hb_position_t to_x HB_UNUSED, hb_position_t to_y HB_UNUSED,
void *user_data HB_UNUSED) {} void *user_data HB_UNUSED) {}
static void static void
_close_path_nil (void *user_data HB_UNUSED) {} _close_path_nil (void *user_data HB_UNUSED) {}
/** /**
* hb_outline_decompose_funcs_create: * hb_draw_funcs_create:
* *
* Creates a new decompose callbacks object. * Creates a new decompose callbacks object.
* *
* Since: REPLACEME * Since: REPLACEME
**/ **/
hb_outline_decompose_funcs_t * hb_draw_funcs_t *
hb_outline_decompose_funcs_create () hb_draw_funcs_create ()
{ {
hb_outline_decompose_funcs_t *funcs; hb_draw_funcs_t *funcs;
if (unlikely (!(funcs = hb_object_create<hb_outline_decompose_funcs_t> ()))) if (unlikely (!(funcs = hb_object_create<hb_draw_funcs_t> ())))
return const_cast<hb_outline_decompose_funcs_t *> (&Null (hb_outline_decompose_funcs_t)); return const_cast<hb_draw_funcs_t *> (&Null (hb_draw_funcs_t));
funcs->move_to = (hb_outline_decompose_move_to_func_t) _move_to_nil; funcs->move_to = (hb_draw_move_to_func_t) _move_to_nil;
funcs->line_to = (hb_outline_decompose_line_to_func_t) _line_to_nil; funcs->line_to = (hb_draw_line_to_func_t) _line_to_nil;
funcs->conic_to = (hb_outline_decompose_conic_to_func_t) _conic_to_nil; funcs->conic_to = (hb_draw_conic_to_func_t) _conic_to_nil;
funcs->cubic_to = (hb_outline_decompose_cubic_to_func_t) _cubic_to_nil; funcs->cubic_to = (hb_draw_cubic_to_func_t) _cubic_to_nil;
funcs->close_path = (hb_outline_decompose_close_path_func_t) _close_path_nil; funcs->close_path = (hb_draw_close_path_func_t) _close_path_nil;
return funcs; return funcs;
} }
/** /**
* hb_outline_decompose_funcs_reference: * hb_draw_funcs_reference:
* @funcs: decompose functions * @funcs: decompose functions
* *
* Add to callbacks object refcount. * Add to callbacks object refcount.
@ -167,14 +168,14 @@ hb_outline_decompose_funcs_create ()
* Returns: The same object. * Returns: The same object.
* Since: REPLACEME * Since: REPLACEME
**/ **/
hb_outline_decompose_funcs_t * hb_draw_funcs_t *
hb_outline_decompose_funcs_reference (hb_outline_decompose_funcs_t *funcs) hb_draw_funcs_reference (hb_draw_funcs_t *funcs)
{ {
return hb_object_reference (funcs); return hb_object_reference (funcs);
} }
/** /**
* hb_outline_decompose_funcs_destroy: * hb_draw_funcs_destroy:
* @funcs: decompose functions * @funcs: decompose functions
* *
* Decreases refcount of callbacks object and deletes the object if it reaches * Decreases refcount of callbacks object and deletes the object if it reaches
@ -183,7 +184,7 @@ hb_outline_decompose_funcs_reference (hb_outline_decompose_funcs_t *funcs)
* Since: REPLACEME * Since: REPLACEME
**/ **/
void void
hb_outline_decompose_funcs_destroy (hb_outline_decompose_funcs_t *funcs) hb_draw_funcs_destroy (hb_draw_funcs_t *funcs)
{ {
if (!hb_object_destroy (funcs)) return; if (!hb_object_destroy (funcs)) return;
@ -191,7 +192,7 @@ hb_outline_decompose_funcs_destroy (hb_outline_decompose_funcs_t *funcs)
} }
/** /**
* hb_outline_decompose: * hb_draw:
* @font: a font object * @font: a font object
* @glyph: a glyph id * @glyph: a glyph id
* @funcs: decompose callbacks object * @funcs: decompose callbacks object
@ -203,11 +204,11 @@ hb_outline_decompose_funcs_destroy (hb_outline_decompose_funcs_t *funcs)
* Since: REPLACEME * Since: REPLACEME
**/ **/
hb_bool_t hb_bool_t
hb_outline_decompose (hb_font_t *font, hb_codepoint_t glyph, hb_font_draw_glyph (hb_font_t *font, hb_codepoint_t glyph,
const hb_outline_decompose_funcs_t *funcs, const hb_draw_funcs_t *funcs,
void *user_data) void *user_data)
{ {
if (unlikely (funcs == &Null (hb_outline_decompose_funcs_t) || if (unlikely (funcs == &Null (hb_draw_funcs_t) ||
glyph >= font->face->get_num_glyphs ())) glyph >= font->face->get_num_glyphs ()))
return false; return false;

87
src/hb-draw.h Normal file
View File

@ -0,0 +1,87 @@
/*
* Copyright © 2019-2020 Ebrahim Byagowi
*
* This is part of HarfBuzz, a text shaping library.
*
* Permission is hereby granted, without written agreement and without
* license or royalty fees, to use, copy, modify, and distribute this
* software and its documentation for any purpose, provided that the
* above copyright notice and the following two paragraphs appear in
* all copies of this software.
*
* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*/
#ifndef HB_H_IN
#error "Include <hb.h> instead."
#endif
#ifndef HB_DRAW_H
#define HB_DRAW_H
#include "hb.h"
HB_BEGIN_DECLS
typedef void (*hb_draw_move_to_func_t) (hb_position_t to_x, hb_position_t to_y, void *user_data);
typedef void (*hb_draw_line_to_func_t) (hb_position_t to_x, hb_position_t to_y, void *user_data);
typedef void (*hb_draw_conic_to_func_t) (hb_position_t control_x, hb_position_t control_y,
hb_position_t to_x, hb_position_t to_y,
void *user_data);
typedef void (*hb_draw_cubic_to_func_t) (hb_position_t control1_x, hb_position_t control1_y,
hb_position_t control2_x, hb_position_t control2_y,
hb_position_t to_x, hb_position_t to_y,
void *user_data);
typedef void (*hb_draw_close_path_func_t) (void *user_data);
/**
* hb_draw_funcs_t:
*
* Glyph decompose callbacks.
*
* Since: REPLACEME
**/
typedef struct hb_draw_funcs_t hb_draw_funcs_t;
HB_EXTERN void
hb_draw_funcs_set_move_to_func (hb_draw_funcs_t *funcs,
hb_draw_move_to_func_t move_to);
HB_EXTERN void
hb_draw_funcs_set_line_to_func (hb_draw_funcs_t *funcs,
hb_draw_move_to_func_t line_to);
HB_EXTERN void
hb_draw_funcs_set_conic_to_func (hb_draw_funcs_t *funcs,
hb_draw_conic_to_func_t conic_to);
HB_EXTERN void
hb_draw_funcs_set_cubic_to_func (hb_draw_funcs_t *funcs,
hb_draw_cubic_to_func_t cubic_to);
HB_EXTERN void
hb_draw_funcs_set_close_path_func (hb_draw_funcs_t *funcs,
hb_draw_close_path_func_t close_path);
HB_EXTERN hb_draw_funcs_t *
hb_draw_funcs_create (void);
HB_EXTERN hb_draw_funcs_t *
hb_draw_funcs_reference (hb_draw_funcs_t *funcs);
HB_EXTERN void
hb_draw_funcs_destroy (hb_draw_funcs_t *funcs);
HB_END_DECLS
#endif /* HB_DRAW_H */

View File

@ -22,21 +22,21 @@
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*/ */
#ifndef HB_OUTLINE_HH #ifndef HB_DRAW_HH
#define HB_OUTLINE_HH #define HB_DRAW_HH
#include "hb.hh" #include "hb.hh"
struct hb_outline_decompose_funcs_t struct hb_draw_funcs_t
{ {
hb_object_header_t header; hb_object_header_t header;
hb_outline_decompose_move_to_func_t move_to; hb_draw_move_to_func_t move_to;
hb_outline_decompose_line_to_func_t line_to; hb_draw_line_to_func_t line_to;
hb_outline_decompose_conic_to_func_t conic_to; hb_draw_conic_to_func_t conic_to;
hb_outline_decompose_cubic_to_func_t cubic_to; hb_draw_cubic_to_func_t cubic_to;
hb_outline_decompose_close_path_func_t close_path; hb_draw_close_path_func_t close_path;
}; };
#endif /* HB_OUTLINE_HH */ #endif /* HB_DRAW_HH */

View File

@ -33,6 +33,7 @@
#include "hb-common.h" #include "hb-common.h"
#include "hb-face.h" #include "hb-face.h"
#include "hb-draw.h"
HB_BEGIN_DECLS HB_BEGIN_DECLS
@ -717,6 +718,10 @@ HB_EXTERN void
hb_font_set_var_named_instance (hb_font_t *font, hb_font_set_var_named_instance (hb_font_t *font,
unsigned instance_index); unsigned instance_index);
HB_EXTERN hb_bool_t
hb_font_draw_glyph (hb_font_t *font, hb_codepoint_t glyph,
const hb_draw_funcs_t *funcs, void *user_data);
HB_END_DECLS HB_END_DECLS
#endif /* HB_FONT_H */ #endif /* HB_FONT_H */

View File

@ -28,7 +28,7 @@
#ifndef HB_NO_CFF #ifndef HB_NO_CFF
#include "hb-outline.hh" #include "hb-draw.hh"
#include "hb-ot-cff1-table.hh" #include "hb-ot-cff1-table.hh"
#include "hb-cff1-interp-cs.hh" #include "hb-cff1-interp-cs.hh"
@ -346,7 +346,7 @@ bool OT::cff1::accelerator_t::get_extents (hb_font_t *font, hb_codepoint_t glyph
struct cff1_path_param_t struct cff1_path_param_t
{ {
cff1_path_param_t (const OT::cff1::accelerator_t *cff_, hb_font_t *font_, cff1_path_param_t (const OT::cff1::accelerator_t *cff_, hb_font_t *font_,
const hb_outline_decompose_funcs_t *funcs_, void *user_data_, const hb_draw_funcs_t *funcs_, void *user_data_,
point_t *delta_) point_t *delta_)
{ {
path_open = false; path_open = false;
@ -395,7 +395,7 @@ struct cff1_path_param_t
bool path_open; bool path_open;
hb_font_t *font; hb_font_t *font;
const hb_outline_decompose_funcs_t *funcs; const hb_draw_funcs_t *funcs;
void *user_data; void *user_data;
point_t *delta; point_t *delta;
@ -427,7 +427,7 @@ struct cff1_path_procs_path_t : path_procs_t<cff1_path_procs_path_t, cff1_cs_int
}; };
static bool _get_path (const OT::cff1::accelerator_t *cff, hb_font_t *font, hb_codepoint_t glyph, static bool _get_path (const OT::cff1::accelerator_t *cff, hb_font_t *font, hb_codepoint_t glyph,
const hb_outline_decompose_funcs_t *funcs, void *user_data, const hb_draw_funcs_t *funcs, void *user_data,
bool in_seac = false, point_t *delta = nullptr); bool in_seac = false, point_t *delta = nullptr);
struct cff1_cs_opset_path_t : cff1_cs_opset_t<cff1_cs_opset_path_t, cff1_path_param_t, cff1_path_procs_path_t> struct cff1_cs_opset_path_t : cff1_cs_opset_t<cff1_cs_opset_path_t, cff1_path_param_t, cff1_path_procs_path_t>
@ -449,7 +449,7 @@ struct cff1_cs_opset_path_t : cff1_cs_opset_t<cff1_cs_opset_path_t, cff1_path_pa
}; };
bool _get_path (const OT::cff1::accelerator_t *cff, hb_font_t *font, hb_codepoint_t glyph, bool _get_path (const OT::cff1::accelerator_t *cff, hb_font_t *font, hb_codepoint_t glyph,
const hb_outline_decompose_funcs_t *funcs, void *user_data, bool in_seac, point_t *delta) const hb_draw_funcs_t *funcs, void *user_data, bool in_seac, point_t *delta)
{ {
if (unlikely (!cff->is_valid () || (glyph >= cff->num_glyphs))) return false; if (unlikely (!cff->is_valid () || (glyph >= cff->num_glyphs))) return false;
@ -464,7 +464,7 @@ bool _get_path (const OT::cff1::accelerator_t *cff, hb_font_t *font, hb_codepoin
} }
bool OT::cff1::accelerator_t::get_path (hb_font_t *font, hb_codepoint_t glyph, bool OT::cff1::accelerator_t::get_path (hb_font_t *font, hb_codepoint_t glyph,
const hb_outline_decompose_funcs_t *funcs, void *user_data) const const hb_draw_funcs_t *funcs, void *user_data) const
{ {
#ifdef HB_NO_OT_FONT_CFF #ifdef HB_NO_OT_FONT_CFF
/* XXX Remove check when this code moves to .hh file. */ /* XXX Remove check when this code moves to .hh file. */

View File

@ -1348,7 +1348,7 @@ struct cff1
HB_INTERNAL bool get_extents (hb_font_t *font, hb_codepoint_t glyph, hb_glyph_extents_t *extents) const; HB_INTERNAL bool get_extents (hb_font_t *font, hb_codepoint_t glyph, hb_glyph_extents_t *extents) const;
HB_INTERNAL bool get_seac_components (hb_codepoint_t glyph, hb_codepoint_t *base, hb_codepoint_t *accent) const; HB_INTERNAL bool get_seac_components (hb_codepoint_t glyph, hb_codepoint_t *base, hb_codepoint_t *accent) const;
HB_INTERNAL bool get_path (hb_font_t *font, hb_codepoint_t glyph, HB_INTERNAL bool get_path (hb_font_t *font, hb_codepoint_t glyph,
const hb_outline_decompose_funcs_t *funcs, void *user_data) const; const hb_draw_funcs_t *funcs, void *user_data) const;
private: private:
struct gname_t struct gname_t

View File

@ -30,7 +30,7 @@
#include "hb-ot-cff2-table.hh" #include "hb-ot-cff2-table.hh"
#include "hb-cff2-interp-cs.hh" #include "hb-cff2-interp-cs.hh"
#include "hb-outline.hh" #include "hb-draw.hh"
using namespace CFF; using namespace CFF;
@ -145,7 +145,7 @@ bool OT::cff2::accelerator_t::get_extents (hb_font_t *font,
struct cff2_path_param_t struct cff2_path_param_t
{ {
cff2_path_param_t (hb_font_t *font_, const hb_outline_decompose_funcs_t *funcs_, void *user_data_) cff2_path_param_t (hb_font_t *font_, const hb_draw_funcs_t *funcs_, void *user_data_)
{ {
path_open = false; path_open = false;
font = font_; font = font_;
@ -180,7 +180,7 @@ struct cff2_path_param_t
bool path_open; bool path_open;
hb_font_t *font; hb_font_t *font;
const hb_outline_decompose_funcs_t *funcs; const hb_draw_funcs_t *funcs;
void *user_data; void *user_data;
}; };
@ -211,7 +211,7 @@ struct cff2_path_procs_path_t : path_procs_t<cff2_path_procs_path_t, cff2_cs_int
struct cff2_cs_opset_path_t : cff2_cs_opset_t<cff2_cs_opset_path_t, cff2_path_param_t, cff2_path_procs_path_t> {}; struct cff2_cs_opset_path_t : cff2_cs_opset_t<cff2_cs_opset_path_t, cff2_path_param_t, cff2_path_procs_path_t> {};
bool OT::cff2::accelerator_t::get_path (hb_font_t *font, hb_codepoint_t glyph, bool OT::cff2::accelerator_t::get_path (hb_font_t *font, hb_codepoint_t glyph,
const hb_outline_decompose_funcs_t *funcs, void *user_data) const const hb_draw_funcs_t *funcs, void *user_data) const
{ {
#ifdef HB_NO_OT_FONT_CFF #ifdef HB_NO_OT_FONT_CFF
/* XXX Remove check when this code moves to .hh file. */ /* XXX Remove check when this code moves to .hh file. */

View File

@ -534,7 +534,7 @@ struct cff2
hb_codepoint_t glyph, hb_codepoint_t glyph,
hb_glyph_extents_t *extents) const; hb_glyph_extents_t *extents) const;
HB_INTERNAL bool get_path (hb_font_t *font, hb_codepoint_t glyph, HB_INTERNAL bool get_path (hb_font_t *font, hb_codepoint_t glyph,
const hb_outline_decompose_funcs_t *funcs, void *user_data) const; const hb_draw_funcs_t *funcs, void *user_data) const;
}; };
typedef accelerator_templ_t<cff2_private_dict_opset_subset_t, cff2_private_dict_values_subset_t> accelerator_subset_t; typedef accelerator_templ_t<cff2_private_dict_opset_subset_t, cff2_private_dict_values_subset_t> accelerator_subset_t;

View File

@ -34,7 +34,7 @@
#include "hb-ot-head-table.hh" #include "hb-ot-head-table.hh"
#include "hb-ot-hmtx-table.hh" #include "hb-ot-hmtx-table.hh"
#include "hb-ot-var-gvar-table.hh" #include "hb-ot-var-gvar-table.hh"
#include "hb-outline.hh" #include "hb-draw.hh"
#include <float.h> #include <float.h>
@ -1045,7 +1045,7 @@ struct glyf
bool bool
get_path (hb_font_t *font, hb_codepoint_t gid, get_path (hb_font_t *font, hb_codepoint_t gid,
const hb_outline_decompose_funcs_t *funcs, void *user_data) const const hb_draw_funcs_t *funcs, void *user_data) const
{ {
/* Making this completely alloc free is not that easy /* Making this completely alloc free is not that easy
https://github.com/harfbuzz/harfbuzz/issues/2095 https://github.com/harfbuzz/harfbuzz/issues/2095

View File

@ -1,92 +0,0 @@
/*
* Copyright © 2019-2020 Ebrahim Byagowi
*
* This is part of HarfBuzz, a text shaping library.
*
* Permission is hereby granted, without written agreement and without
* license or royalty fees, to use, copy, modify, and distribute this
* software and its documentation for any purpose, provided that the
* above copyright notice and the following two paragraphs appear in
* all copies of this software.
*
* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*/
#ifndef HB_H_IN
#error "Include <hb.h> instead."
#endif
#ifndef HB_OUTLINE_H
#define HB_OUTLINE_H
#include "hb.h"
HB_BEGIN_DECLS
typedef void (*hb_outline_decompose_move_to_func_t) (hb_position_t to_x, hb_position_t to_y, void *user_data);
typedef void (*hb_outline_decompose_line_to_func_t) (hb_position_t to_x, hb_position_t to_y, void *user_data);
typedef void (*hb_outline_decompose_conic_to_func_t) (hb_position_t control_x, hb_position_t control_y,
hb_position_t to_x, hb_position_t to_y,
void *user_data);
typedef void (*hb_outline_decompose_cubic_to_func_t) (hb_position_t control1_x, hb_position_t control1_y,
hb_position_t control2_x, hb_position_t control2_y,
hb_position_t to_x, hb_position_t to_y,
void *user_data);
typedef void (*hb_outline_decompose_close_path_func_t) (void *user_data);
/**
* hb_outline_decompose_funcs_t:
*
* Glyph decompose callbacks.
*
* Since: REPLACEME
**/
typedef struct hb_outline_decompose_funcs_t hb_outline_decompose_funcs_t;
HB_EXTERN void
hb_outline_decompose_funcs_set_move_to_func (hb_outline_decompose_funcs_t *funcs,
hb_outline_decompose_move_to_func_t move_to);
HB_EXTERN void
hb_outline_decompose_funcs_set_line_to_func (hb_outline_decompose_funcs_t *funcs,
hb_outline_decompose_move_to_func_t line_to);
HB_EXTERN void
hb_outline_decompose_funcs_set_conic_to_func (hb_outline_decompose_funcs_t *funcs,
hb_outline_decompose_conic_to_func_t conic_to);
HB_EXTERN void
hb_outline_decompose_funcs_set_cubic_to_func (hb_outline_decompose_funcs_t *funcs,
hb_outline_decompose_cubic_to_func_t cubic_to);
HB_EXTERN void
hb_outline_decompose_funcs_set_close_path_func (hb_outline_decompose_funcs_t *funcs,
hb_outline_decompose_close_path_func_t close_path);
HB_EXTERN hb_outline_decompose_funcs_t *
hb_outline_decompose_funcs_create (void);
HB_EXTERN hb_outline_decompose_funcs_t *
hb_outline_decompose_funcs_reference (hb_outline_decompose_funcs_t *funcs);
HB_EXTERN void
hb_outline_decompose_funcs_destroy (hb_outline_decompose_funcs_t *funcs);
HB_EXTERN hb_bool_t
hb_outline_decompose (hb_font_t *font, hb_codepoint_t glyph,
const hb_outline_decompose_funcs_t *funcs,
void *user_data);
HB_END_DECLS
#endif /* HB_OUTLINE_H */

View File

@ -32,9 +32,9 @@
#include "hb-buffer.h" #include "hb-buffer.h"
#include "hb-common.h" #include "hb-common.h"
#include "hb-deprecated.h" #include "hb-deprecated.h"
#include "hb-draw.h"
#include "hb-face.h" #include "hb-face.h"
#include "hb-font.h" #include "hb-font.h"
#include "hb-outline.h"
#include "hb-map.h" #include "hb-map.h"
#include "hb-set.h" #include "hb-set.h"
#include "hb-shape.h" #include "hb-shape.h"

View File

@ -37,7 +37,7 @@
#define hb_blob_create_from_file(x) hb_blob_get_empty () #define hb_blob_create_from_file(x) hb_blob_get_empty ()
#endif #endif
#if !defined(HB_NO_COLOR) && !defined(HB_NO_OUTLINE) #if !defined(HB_NO_COLOR) && !defined(HB_NO_DRAW)
static void static void
svg_dump (hb_face_t *face, unsigned face_index) svg_dump (hb_face_t *face, unsigned face_index)
{ {
@ -169,7 +169,7 @@ close_path (user_data_t &user_data)
} }
static void static void
layered_glyph_dump (hb_font_t *font, hb_outline_decompose_funcs_t *funcs, unsigned face_index) layered_glyph_dump (hb_font_t *font, hb_draw_funcs_t *funcs, unsigned face_index)
{ {
hb_face_t *face = hb_font_get_face (font); hb_face_t *face = hb_font_get_face (font);
unsigned num_glyphs = hb_face_get_glyph_count (face); unsigned num_glyphs = hb_face_get_glyph_count (face);
@ -224,7 +224,7 @@ layered_glyph_dump (hb_font_t *font, hb_outline_decompose_funcs_t *funcs, unsign
if (hb_color_get_alpha (color) != 255) if (hb_color_get_alpha (color) != 255)
fprintf (f, "fill-opacity=\"%.3f\"", (double) hb_color_get_alpha (color) / 255.); fprintf (f, "fill-opacity=\"%.3f\"", (double) hb_color_get_alpha (color) / 255.);
fprintf (f, "d=\""); fprintf (f, "d=\"");
if (!hb_outline_decompose (font, layers[layer].glyph, funcs, &user_data)) if (!hb_font_draw_glyph (font, layers[layer].glyph, funcs, &user_data))
printf ("Failed to decompose layer %d while %d\n", layers[layer].glyph, gid); printf ("Failed to decompose layer %d while %d\n", layers[layer].glyph, gid);
fprintf (f, "\"/>\n"); fprintf (f, "\"/>\n");
} }
@ -242,7 +242,7 @@ layered_glyph_dump (hb_font_t *font, hb_outline_decompose_funcs_t *funcs, unsign
} }
static void static void
dump_glyphs (hb_font_t *font, hb_outline_decompose_funcs_t *funcs, unsigned face_index) dump_glyphs (hb_font_t *font, hb_draw_funcs_t *funcs, unsigned face_index)
{ {
unsigned num_glyphs = hb_face_get_glyph_count (hb_font_get_face (font)); unsigned num_glyphs = hb_face_get_glyph_count (hb_font_get_face (font));
for (unsigned gid = 0; gid < num_glyphs; ++gid) for (unsigned gid = 0; gid < num_glyphs; ++gid)
@ -266,7 +266,7 @@ dump_glyphs (hb_font_t *font, hb_outline_decompose_funcs_t *funcs, unsigned face
user_data_t user_data; user_data_t user_data;
user_data.ascender = font_extents.ascender; user_data.ascender = font_extents.ascender;
user_data.f = f; user_data.f = f;
if (!hb_outline_decompose (font, gid, funcs, &user_data)) if (!hb_font_draw_glyph (font, gid, funcs, &user_data))
printf ("Failed to decompose gid: %d\n", gid); printf ("Failed to decompose gid: %d\n", gid);
fprintf (f, "\"/></svg>"); fprintf (f, "\"/></svg>");
fclose (f); fclose (f);
@ -293,12 +293,12 @@ dump_glyphs (hb_blob_t *blob, const char *font_name)
fwrite (font_name, 1, strlen (font_name), font_name_file); fwrite (font_name, 1, strlen (font_name), font_name_file);
fclose (font_name_file); fclose (font_name_file);
hb_outline_decompose_funcs_t *funcs = hb_outline_decompose_funcs_create (); hb_draw_funcs_t *funcs = hb_draw_funcs_create ();
hb_outline_decompose_funcs_set_move_to_func (funcs, (hb_outline_decompose_move_to_func_t) move_to); hb_draw_funcs_set_move_to_func (funcs, (hb_draw_move_to_func_t) move_to);
hb_outline_decompose_funcs_set_line_to_func (funcs, (hb_outline_decompose_line_to_func_t) line_to); hb_draw_funcs_set_line_to_func (funcs, (hb_draw_line_to_func_t) line_to);
hb_outline_decompose_funcs_set_conic_to_func (funcs, (hb_outline_decompose_conic_to_func_t) conic_to); hb_draw_funcs_set_conic_to_func (funcs, (hb_draw_conic_to_func_t) conic_to);
hb_outline_decompose_funcs_set_cubic_to_func (funcs, (hb_outline_decompose_cubic_to_func_t) cubic_to); hb_draw_funcs_set_cubic_to_func (funcs, (hb_draw_cubic_to_func_t) cubic_to);
hb_outline_decompose_funcs_set_close_path_func (funcs, (hb_outline_decompose_close_path_func_t) close_path); hb_draw_funcs_set_close_path_func (funcs, (hb_draw_close_path_func_t) close_path);
unsigned num_faces = hb_face_count (blob); unsigned num_faces = hb_face_count (blob);
for (unsigned face_index = 0; face_index < num_faces; ++face_index) for (unsigned face_index = 0; face_index < num_faces; ++face_index)
@ -324,7 +324,7 @@ dump_glyphs (hb_blob_t *blob, const char *font_name)
hb_face_destroy (face); hb_face_destroy (face);
} }
hb_outline_decompose_funcs_destroy (funcs); hb_draw_funcs_destroy (funcs);
} }
#endif #endif
@ -501,7 +501,7 @@ main (int argc, char **argv)
hb_blob_t *blob = hb_blob_create_from_file (argv[1]); hb_blob_t *blob = hb_blob_create_from_file (argv[1]);
printf ("Opened font file %s: %d bytes long\n", argv[1], hb_blob_get_length (blob)); printf ("Opened font file %s: %d bytes long\n", argv[1], hb_blob_get_length (blob));
print_layout_info_using_private_api (blob); print_layout_info_using_private_api (blob);
#if !defined(HB_NO_COLOR) && !defined(HB_NO_OUTLINE) #if !defined(HB_NO_COLOR) && !defined(HB_NO_DRAW)
dump_glyphs (blob, argv[1]); dump_glyphs (blob, argv[1]);
#endif #endif
hb_blob_destroy (blob); hb_blob_destroy (blob);

View File

@ -34,12 +34,12 @@ TEST_PROGS = \
test-buffer \ test-buffer \
test-collect-unicodes \ test-collect-unicodes \
test-common \ test-common \
test-draw \
test-font \ test-font \
test-map \ test-map \
test-object \ test-object \
test-ot-face \ test-ot-face \
test-ot-glyphname \ test-ot-glyphname \
test-outline \
test-set \ test-set \
test-shape \ test-shape \
test-subset \ test-subset \

View File

@ -159,12 +159,12 @@ close_path (user_data_t *user_data)
user_data->str[user_data->consumed++] = 'Z'; user_data->str[user_data->consumed++] = 'Z';
} }
static hb_outline_decompose_funcs_t *funcs; static hb_draw_funcs_t *funcs;
static void static void
test_hb_glyph_empty (void) test_hb_glyph_empty (void)
{ {
g_assert (!hb_outline_decompose (hb_font_get_empty (), 3, funcs, NULL)); g_assert (!hb_font_draw_glyph (hb_font_get_empty (), 3, funcs, NULL));
} }
static void static void
@ -182,9 +182,9 @@ test_hb_glyph_glyf (void)
}; };
user_data.consumed = 0; user_data.consumed = 0;
g_assert (!hb_outline_decompose (font, 4, funcs, &user_data)); g_assert (!hb_font_draw_glyph (font, 4, funcs, &user_data));
user_data.consumed = 0; user_data.consumed = 0;
g_assert (hb_outline_decompose (font, 3, funcs, &user_data)); g_assert (hb_font_draw_glyph (font, 3, funcs, &user_data));
char expected[] = "M275,442L275,442Q232,442 198,420Q164,397 145,353Q126,309 126,245L126,245" char expected[] = "M275,442L275,442Q232,442 198,420Q164,397 145,353Q126,309 126,245L126,245"
"Q126,182 147,139Q167,95 204,73Q240,50 287,50L287,50Q330,50 367,70" "Q126,182 147,139Q167,95 204,73Q240,50 287,50L287,50Q330,50 367,70"
"Q404,90 427,128L427,128L451,116Q431,54 384,21Q336,-13 266,-13L266,-13Q198,-13 148,18" "Q404,90 427,128L427,128L451,116Q431,54 384,21Q336,-13 266,-13L266,-13Q198,-13 148,18"
@ -199,7 +199,7 @@ test_hb_glyph_glyf (void)
hb_font_set_variations (font, &var, 1); hb_font_set_variations (font, &var, 1);
user_data.consumed = 0; user_data.consumed = 0;
g_assert (hb_outline_decompose (font, 3, funcs, &user_data)); g_assert (hb_font_draw_glyph (font, 3, funcs, &user_data));
char expected2[] = "M323,448L323,448Q297,448 271,430Q244,412 227,371" char expected2[] = "M323,448L323,448Q297,448 271,430Q244,412 227,371"
"Q209,330 209,261L209,261Q209,204 226,166Q242,127 273,107Q303,86 344,86L344,86Q378,86 404,101" "Q209,330 209,261L209,261Q209,204 226,166Q242,127 273,107Q303,86 344,86L344,86Q378,86 404,101"
"Q430,115 451,137L451,137L488,103Q458,42 404,13Q350,-16 279,-16L279,-16Q211,-16 153,13Q95,41 60,99" "Q430,115 451,137L451,137L488,103Q458,42 404,13Q350,-16 279,-16L279,-16Q211,-16 153,13Q95,41 60,99"
@ -224,7 +224,7 @@ test_hb_glyph_cff1 (void)
.size = sizeof (str), .size = sizeof (str),
.consumed = 0 .consumed = 0
}; };
g_assert (hb_outline_decompose (font, 3, funcs, &user_data)); g_assert (hb_font_draw_glyph (font, 3, funcs, &user_data));
char expected[] = "M203,367C227,440 248,512 268,588L272,588C293,512 314,440 338,367L369,267L172,267Z" char expected[] = "M203,367C227,440 248,512 268,588L272,588C293,512 314,440 338,367L369,267L172,267Z"
"M3,0L88,0L151,200L390,200L452,0L541,0L319,656L225,656Z" "M3,0L88,0L151,200L390,200L452,0L541,0L319,656L225,656Z"
"M300,653L342,694L201,861L143,806Z"; "M300,653L342,694L201,861L143,806Z";
@ -247,7 +247,7 @@ test_hb_glyph_cff1_rline (void)
.size = sizeof (str), .size = sizeof (str),
.consumed = 0 .consumed = 0
}; };
g_assert (hb_outline_decompose (font, 1, funcs, &user_data)); g_assert (hb_font_draw_glyph (font, 1, funcs, &user_data));
char expected[] = "M775,400C705,400 650,343 650,274L650,250L391,250L713,572L392,893" char expected[] = "M775,400C705,400 650,343 650,274L650,250L391,250L713,572L392,893"
"L287,1000C311,942 296,869 250,823C250,823 286,858 321,823L571,572" "L287,1000C311,942 296,869 250,823C250,823 286,858 321,823L571,572"
"L150,150L750,150L750,276C750,289 761,300 775,300C789,300 800,289 800,276" "L150,150L750,150L750,276C750,289 761,300 775,300C789,300 800,289 800,276"
@ -272,7 +272,7 @@ test_hb_glyph_cff2 (void)
}; };
user_data.consumed = 0; user_data.consumed = 0;
g_assert (hb_outline_decompose (font, 3, funcs, &user_data)); g_assert (hb_font_draw_glyph (font, 3, funcs, &user_data));
char expected[] = "M275,442C303,442 337,435 371,417L325,454L350,366" char expected[] = "M275,442C303,442 337,435 371,417L325,454L350,366"
"C357,341 370,321 403,321C428,321 443,333 448,358" "C357,341 370,321 403,321C428,321 443,333 448,358"
"C435,432 361,487 272,487C153,487 43,393 43,236" "C435,432 361,487 272,487C153,487 43,393 43,236"
@ -286,7 +286,7 @@ test_hb_glyph_cff2 (void)
hb_font_set_variations (font, &var, 1); hb_font_set_variations (font, &var, 1);
user_data.consumed = 0; user_data.consumed = 0;
g_assert (hb_outline_decompose (font, 3, funcs, &user_data)); g_assert (hb_font_draw_glyph (font, 3, funcs, &user_data));
char expected2[] = "M323,448C356,448 380,441 411,427L333,469L339,401" char expected2[] = "M323,448C356,448 380,441 411,427L333,469L339,401"
"C343,322 379,297 420,297C458,297 480,314 492,352" "C343,322 379,297 420,297C458,297 480,314 492,352"
"C486,433 412,501 303,501C148,501 25,406 25,241" "C486,433 412,501 303,501C148,501 25,406 25,241"
@ -313,19 +313,19 @@ test_hb_glyph_ttf_parser_tests (void)
{ {
/* We aren't identical on paths points for glyf with ttf-parser but visually, investigate */ /* We aren't identical on paths points for glyf with ttf-parser but visually, investigate */
user_data.consumed = 0; user_data.consumed = 0;
g_assert (hb_outline_decompose (font, 0, funcs, &user_data)); g_assert (hb_font_draw_glyph (font, 0, funcs, &user_data));
char expected[] = "M450,0L50,0L50,750L450,750L450,0Z"; char expected[] = "M450,0L50,0L50,750L450,750L450,0Z";
g_assert_cmpmem (str, user_data.consumed, expected, sizeof (expected) - 1); g_assert_cmpmem (str, user_data.consumed, expected, sizeof (expected) - 1);
} }
{ {
user_data.consumed = 0; user_data.consumed = 0;
g_assert (hb_outline_decompose (font, 1, funcs, &user_data)); g_assert (hb_font_draw_glyph (font, 1, funcs, &user_data));
char expected[] = "M514,416L56,416L56,487L514,487L514,416ZM514,217L56,217L56,288L514,288L514,217Z"; char expected[] = "M514,416L56,416L56,487L514,487L514,416ZM514,217L56,217L56,288L514,288L514,217Z";
g_assert_cmpmem (str, user_data.consumed, expected, sizeof (expected) - 1); g_assert_cmpmem (str, user_data.consumed, expected, sizeof (expected) - 1);
} }
{ {
user_data.consumed = 0; user_data.consumed = 0;
g_assert (hb_outline_decompose (font, 4, funcs, &user_data)); g_assert (hb_font_draw_glyph (font, 4, funcs, &user_data));
char expected[] = "M332,536L332,468L197,468L197,0L109,0L109,468L15,468L15,509L109,539L109,570" char expected[] = "M332,536L332,468L197,468L197,0L109,0L109,468L15,468L15,509L109,539L109,570"
"Q109,674 155,720Q201,765 283,765L283,765Q315,765 342,760Q368,754 387,747" "Q109,674 155,720Q201,765 283,765L283,765Q315,765 342,760Q368,754 387,747"
"L387,747L364,678Q348,683 327,688Q306,693 284,693L284,693Q240,693 219,664" "L387,747L364,678Q348,683 327,688Q306,693 284,693L284,693Q240,693 219,664"
@ -338,13 +338,13 @@ test_hb_glyph_ttf_parser_tests (void)
{ {
/* According to tests on tts-parser we should return an empty on single point but we aren't */ /* According to tests on tts-parser we should return an empty on single point but we aren't */
user_data.consumed = 0; user_data.consumed = 0;
g_assert (hb_outline_decompose (font, 5, funcs, &user_data)); g_assert (hb_font_draw_glyph (font, 5, funcs, &user_data));
char expected[] = "M15,0Q15,0 15,0Z"; char expected[] = "M15,0Q15,0 15,0Z";
g_assert_cmpmem (str, user_data.consumed, expected, sizeof (expected) - 1); g_assert_cmpmem (str, user_data.consumed, expected, sizeof (expected) - 1);
} }
{ {
user_data.consumed = 0; user_data.consumed = 0;
g_assert (hb_outline_decompose (font, 6, funcs, &user_data)); g_assert (hb_font_draw_glyph (font, 6, funcs, &user_data));
char expected[] = "M346,536L346,468L211,468L211,0L123,0L123,468L29,468" char expected[] = "M346,536L346,468L211,468L211,0L123,0L123,468L29,468"
"L29,509L123,539L123,570Q123,674 169,720Q215,765 297,765" "L29,509L123,539L123,570Q123,674 169,720Q215,765 297,765"
"L297,765Q329,765 356,760Q382,754 401,747L401,747L378,678" "L297,765Q329,765 356,760Q382,754 401,747L401,747L378,678"
@ -361,7 +361,7 @@ test_hb_glyph_ttf_parser_tests (void)
hb_face_destroy (face); hb_face_destroy (face);
user_data.consumed = 0; user_data.consumed = 0;
g_assert (hb_outline_decompose (font, 1, funcs, &user_data)); g_assert (hb_font_draw_glyph (font, 1, funcs, &user_data));
char expected[] = "M0,0C100,0 150,-20 250,-20C350,-20 400,0 500,0C500,100 520,150 520,250" char expected[] = "M0,0C100,0 150,-20 250,-20C350,-20 400,0 500,0C500,100 520,150 520,250"
"C520,350 500,400 500,500C400,500 350,520 250,520C150,520 100,500 0,500" "C520,350 500,400 500,500C400,500 350,520 250,520C150,520 100,500 0,500"
"C0,400 -20,350 -20,250C-20,150 0,100 0,0ZM50,50C50,130 34,170 34,250" "C0,400 -20,350 -20,250C-20,150 0,100 0,0ZM50,50C50,130 34,170 34,250"
@ -378,7 +378,7 @@ test_hb_glyph_ttf_parser_tests (void)
hb_face_destroy (face); hb_face_destroy (face);
user_data.consumed = 0; user_data.consumed = 0;
g_assert (hb_outline_decompose (font, 1, funcs, &user_data)); g_assert (hb_font_draw_glyph (font, 1, funcs, &user_data));
char expected[] = "M82,0L164,0L164,486L82,486ZM124,586C156,586 181,608 181,639" char expected[] = "M82,0L164,0L164,486L82,486ZM124,586C156,586 181,608 181,639"
"C181,671 156,692 124,692C92,692 67,671 67,639C67,608 92,586 124,586Z"; "C181,671 156,692 124,692C92,692 67,671 67,639C67,608 92,586 124,586Z";
g_assert_cmpmem (str, user_data.consumed, expected, sizeof (expected) - 1); g_assert_cmpmem (str, user_data.consumed, expected, sizeof (expected) - 1);
@ -404,7 +404,7 @@ test_hb_glyph_font_kit_glyphs_tests (void)
/* should get a path for the glyph */ /* should get a path for the glyph */
user_data.consumed = 0; user_data.consumed = 0;
g_assert (hb_outline_decompose (font, 37, funcs, &user_data)); g_assert (hb_font_draw_glyph (font, 37, funcs, &user_data));
char expected[] = "M201,0L201,1462L614,1462Q905,1462 1035,1375Q1165,1288 1165,1100" char expected[] = "M201,0L201,1462L614,1462Q905,1462 1035,1375Q1165,1288 1165,1100"
"L1165,1100Q1165,970 1093,886Q1020,801 881,776L881,776L881,766" "L1165,1100Q1165,970 1093,886Q1020,801 881,776L881,776L881,766"
"Q1214,709 1214,416L1214,416Q1214,220 1082,110Q949,0 711,0L711,0L201,0Z" "Q1214,709 1214,416L1214,416Q1214,220 1082,110Q949,0 711,0L711,0L201,0Z"
@ -416,7 +416,7 @@ test_hb_glyph_font_kit_glyphs_tests (void)
/* should get a path for the glyph */ /* should get a path for the glyph */
user_data.consumed = 0; user_data.consumed = 0;
g_assert (hb_outline_decompose (font, 171, funcs, &user_data)); g_assert (hb_font_draw_glyph (font, 171, funcs, &user_data));
char expected2[] = "M639,-20L639,-20Q396,-20 256,128Q115,276 115,539L115,539" char expected2[] = "M639,-20L639,-20Q396,-20 256,128Q115,276 115,539L115,539"
"Q115,804 246,960Q376,1116 596,1116L596,1116Q802,1116 922,981" "Q115,804 246,960Q376,1116 596,1116L596,1116Q802,1116 922,981"
"Q1042,845 1042,623L1042,623L1042,518L287,518Q292,325 385,225" "Q1042,845 1042,623L1042,623L1042,518L287,518Q292,325 385,225"
@ -445,7 +445,7 @@ test_hb_glyph_font_kit_glyphs_tests (void)
/* should resolve composite glyphs recursively */ /* should resolve composite glyphs recursively */
user_data.consumed = 0; user_data.consumed = 0;
g_assert (hb_outline_decompose (font, codepoint, funcs, &user_data)); g_assert (hb_font_draw_glyph (font, codepoint, funcs, &user_data));
char expected[] = "M581,170L581,274L443,274Q409,274 384,259Q359,243 348,219" char expected[] = "M581,170L581,274L443,274Q409,274 384,259Q359,243 348,219"
"Q336,194 340,166Q343,138 365,111L365,111L468,-13Q470,-10 473,-7" "Q336,194 340,166Q343,138 365,111L365,111L468,-13Q470,-10 473,-7"
"Q475,-3 477,0L477,0L253,0Q225,0 203,8Q180,15 168,32Q155,48 155,73" "Q475,-3 477,0L477,0L253,0Q225,0 203,8Q180,15 168,32Q155,48 155,73"
@ -463,7 +463,7 @@ test_hb_glyph_font_kit_glyphs_tests (void)
/* should transform points of a composite glyph */ /* should transform points of a composite glyph */
user_data.consumed = 0; user_data.consumed = 0;
g_assert (hb_outline_decompose (font, 2, funcs, &user_data)); /* 2 == arAlef.fina */ g_assert (hb_font_draw_glyph (font, 2, funcs, &user_data)); /* 2 == arAlef.fina */
char expected2[] = "M50,624L155,624L155,84Q150,90 146,95Q141,99 136,105L136,105" char expected2[] = "M50,624L155,624L155,84Q150,90 146,95Q141,99 136,105L136,105"
"L292,105L292,0L156,0Q128,0 104,14Q79,27 65,51Q50,74 50,104" "L292,105L292,0L156,0Q128,0 104,14Q79,27 65,51Q50,74 50,104"
"L50,104L50,624ZM282,0L282,105L312,105L312,0L282,0Z"; "L50,104L50,624ZM282,0L282,105L312,105L312,0L282,0Z";
@ -478,7 +478,7 @@ test_hb_glyph_font_kit_glyphs_tests (void)
hb_face_destroy (face); hb_face_destroy (face);
user_data.consumed = 0; user_data.consumed = 0;
g_assert (hb_outline_decompose (font, 5, funcs, &user_data)); g_assert (hb_font_draw_glyph (font, 5, funcs, &user_data));
char expected[] = "M90,0L258,0C456,0 564,122 564,331C564,539 456,656 254,656L90,656ZM173,68" char expected[] = "M90,0L258,0C456,0 564,122 564,331C564,539 456,656 254,656L90,656ZM173,68"
"L173,588L248,588C401,588 478,496 478,331C478,165 401,68 248,68Z"; "L173,588L248,588C401,588 478,496 478,331C478,165 401,68 248,68Z";
g_assert_cmpmem (str, user_data.consumed, expected, sizeof (expected) - 1); g_assert_cmpmem (str, user_data.consumed, expected, sizeof (expected) - 1);
@ -493,7 +493,7 @@ test_hb_glyph_font_kit_glyphs_tests (void)
hb_face_destroy (face); hb_face_destroy (face);
user_data.consumed = 0; user_data.consumed = 0;
g_assert (hb_outline_decompose (font, 1, funcs, &user_data)); g_assert (hb_font_draw_glyph (font, 1, funcs, &user_data));
char expected[] = "M139,390C175,390 205,419 205,459C205,501 175,530 139,530C103,530 73,501 73,459" char expected[] = "M139,390C175,390 205,419 205,459C205,501 175,530 139,530C103,530 73,501 73,459"
"C73,419 103,390 139,390ZM139,-13C175,-13 205,15 205,56C205,97 175,127 139,127" "C73,419 103,390 139,390ZM139,-13C175,-13 205,15 205,56C205,97 175,127 139,127"
"C103,127 73,97 73,56C73,15 103,-13 139,-13Z"; "C103,127 73,97 73,56C73,15 103,-13 139,-13Z";
@ -538,7 +538,7 @@ test_hb_glyph_font_kit_variations_tests (void)
hb_buffer_destroy (buffer); hb_buffer_destroy (buffer);
user_data.consumed = 0; user_data.consumed = 0;
g_assert (hb_outline_decompose (font, codepoint, funcs, &user_data)); g_assert (hb_font_draw_glyph (font, codepoint, funcs, &user_data));
char expected[] = "M414,-102L371,-102L371,539L914,539L914,-27Q914,-102 840,-102L840,-102Q796,-102 755,-98" char expected[] = "M414,-102L371,-102L371,539L914,539L914,-27Q914,-102 840,-102L840,-102Q796,-102 755,-98"
"L755,-98L742,-59Q790,-66 836,-66L836,-66Q871,-66 871,-31L871,-31L871,504L414,504L414,-102Z" "L755,-98L742,-59Q790,-66 836,-66L836,-66Q871,-66 871,-31L871,-31L871,504L414,504L414,-102Z"
"M203,-94L203,-94Q138,-94 86,-90L86,-90L74,-52Q137,-59 188,-59L188,-59Q211,-59 222,-47" "M203,-94L203,-94Q138,-94 86,-90L86,-90L74,-52Q137,-59 188,-59L188,-59Q211,-59 222,-47"
@ -584,7 +584,7 @@ test_hb_glyph_font_kit_variations_tests (void)
hb_buffer_destroy (buffer); hb_buffer_destroy (buffer);
user_data.consumed = 0; user_data.consumed = 0;
g_assert (hb_outline_decompose (font, codepoint, funcs, &user_data)); g_assert (hb_font_draw_glyph (font, codepoint, funcs, &user_data));
char expected[] = "M414,-102L371,-102L371,539L914,539L914,-27Q914,-102 840,-102L840,-102Q796,-102 755,-98" char expected[] = "M414,-102L371,-102L371,539L914,539L914,-27Q914,-102 840,-102L840,-102Q796,-102 755,-98"
"L755,-98L742,-59Q790,-66 836,-66L836,-66Q871,-66 871,-31L871,-31L871,504L414,504" "L755,-98L742,-59Q790,-66 836,-66L836,-66Q871,-66 871,-31L871,-31L871,504L414,504"
"L414,-102ZM203,-94L203,-94Q138,-94 86,-90L86,-90L74,-52Q137,-59 188,-59L188,-59" "L414,-102ZM203,-94L203,-94Q138,-94 86,-90L86,-90L74,-52Q137,-59 188,-59L188,-59"
@ -630,7 +630,7 @@ test_hb_glyph_font_kit_variations_tests (void)
hb_buffer_destroy (buffer); hb_buffer_destroy (buffer);
user_data.consumed = 0; user_data.consumed = 0;
g_assert (hb_outline_decompose (font, codepoint, funcs, &user_data)); g_assert (hb_font_draw_glyph (font, codepoint, funcs, &user_data));
char expected[] = "M414,-102L371,-102L371,539L914,539L914,-27Q914,-102 840,-102L840,-102" char expected[] = "M414,-102L371,-102L371,539L914,539L914,-27Q914,-102 840,-102L840,-102"
"Q796,-102 755,-98L755,-98L742,-59Q790,-66 836,-66L836,-66Q871,-66 871,-31" "Q796,-102 755,-98L755,-98L742,-59Q790,-66 836,-66L836,-66Q871,-66 871,-31"
"L871,-31L871,504L414,504L414,-102ZM203,-94L203,-94Q138,-94 86,-90" "L871,-31L871,504L414,504L414,-102ZM203,-94L203,-94Q138,-94 86,-90"
@ -680,7 +680,7 @@ test_hb_glyph_font_kit_variations_tests (void)
hb_buffer_destroy (buffer); hb_buffer_destroy (buffer);
user_data.consumed = 0; user_data.consumed = 0;
g_assert (hb_outline_decompose (font, codepoint, funcs, &user_data)); g_assert (hb_font_draw_glyph (font, codepoint, funcs, &user_data));
char expected[] = "M246,15C188,15 147,27 101,68L142,23L117,117C111,143 96,149 81,149" char expected[] = "M246,15C188,15 147,27 101,68L142,23L117,117C111,143 96,149 81,149"
"C65,149 56,141 52,126C71,40 137,-13 244,-13C348,-13 436,46 436,156" "C65,149 56,141 52,126C71,40 137,-13 244,-13C348,-13 436,46 436,156"
"C436,229 405,295 271,349L247,359C160,393 119,439 119,506" "C436,229 405,295 271,349L247,359C160,393 119,439 119,506"
@ -704,7 +704,7 @@ test_hb_glyph_font_kit_variations_tests (void)
hb_buffer_destroy (buffer); hb_buffer_destroy (buffer);
user_data.consumed = 0; user_data.consumed = 0;
g_assert (hb_outline_decompose (font, codepoint, funcs, &user_data)); g_assert (hb_font_draw_glyph (font, codepoint, funcs, &user_data));
char expected[] = "M251,36C206,36 165,42 118,61L176,21L161,99C151,152 129,167 101,167" char expected[] = "M251,36C206,36 165,42 118,61L176,21L161,99C151,152 129,167 101,167"
"C78,167 61,155 51,131C54,43 133,-14 247,-14C388,-14 474,64 474,171" "C78,167 61,155 51,131C54,43 133,-14 247,-14C388,-14 474,64 474,171"
"C474,258 430,321 294,370L257,383C188,406 150,438 150,499" "C474,258 430,321 294,370L257,383C188,406 150,438 150,499"
@ -729,7 +729,7 @@ test_hb_glyph_font_kit_variations_tests (void)
hb_buffer_destroy (buffer); hb_buffer_destroy (buffer);
user_data.consumed = 0; user_data.consumed = 0;
g_assert (hb_outline_decompose (font, codepoint, funcs, &user_data)); g_assert (hb_font_draw_glyph (font, codepoint, funcs, &user_data));
char expected[] = "M258,38C197,38 167,48 118,71L192,19L183,103C177,155 155,174 115,174" char expected[] = "M258,38C197,38 167,48 118,71L192,19L183,103C177,155 155,174 115,174"
"C89,174 64,161 51,125C52,36 124,-16 258,-16C417,-16 513,67 513,175" "C89,174 64,161 51,125C52,36 124,-16 258,-16C417,-16 513,67 513,175"
"C513,278 457,328 322,388L289,403C232,429 203,452 203,500C203,562 244,589 301,589" "C513,278 457,328 322,388L289,403C232,429 203,452 203,500C203,562 244,589 301,589"
@ -747,12 +747,12 @@ test_hb_glyph_font_kit_variations_tests (void)
int int
main (int argc, char **argv) main (int argc, char **argv)
{ {
funcs = hb_outline_decompose_funcs_create (); funcs = hb_draw_funcs_create ();
hb_outline_decompose_funcs_set_move_to_func (funcs, (hb_outline_decompose_move_to_func_t) move_to); hb_draw_funcs_set_move_to_func (funcs, (hb_draw_move_to_func_t) move_to);
hb_outline_decompose_funcs_set_line_to_func (funcs, (hb_outline_decompose_line_to_func_t) line_to); hb_draw_funcs_set_line_to_func (funcs, (hb_draw_line_to_func_t) line_to);
hb_outline_decompose_funcs_set_conic_to_func (funcs, (hb_outline_decompose_conic_to_func_t) conic_to); hb_draw_funcs_set_conic_to_func (funcs, (hb_draw_conic_to_func_t) conic_to);
hb_outline_decompose_funcs_set_cubic_to_func (funcs, (hb_outline_decompose_cubic_to_func_t) cubic_to); hb_draw_funcs_set_cubic_to_func (funcs, (hb_draw_cubic_to_func_t) cubic_to);
hb_outline_decompose_funcs_set_close_path_func (funcs, (hb_outline_decompose_close_path_func_t) close_path); hb_draw_funcs_set_close_path_func (funcs, (hb_draw_close_path_func_t) close_path);
hb_test_init (&argc, &argv); hb_test_init (&argc, &argv);
hb_test_add (test_itoa); hb_test_add (test_itoa);
@ -766,6 +766,6 @@ main (int argc, char **argv)
hb_test_add (test_hb_glyph_font_kit_variations_tests); hb_test_add (test_hb_glyph_font_kit_variations_tests);
unsigned result = hb_test_run (); unsigned result = hb_test_run ();
hb_outline_decompose_funcs_destroy (funcs); hb_draw_funcs_destroy (funcs);
return result; return result;
} }

View File

@ -121,10 +121,10 @@ test_face (hb_face_t *face,
hb_ot_var_normalize_variations (face, NULL, 0, NULL, 0); hb_ot_var_normalize_variations (face, NULL, 0, NULL, 0);
hb_ot_var_normalize_coords (face, 0, NULL, NULL); hb_ot_var_normalize_coords (face, 0, NULL, NULL);
hb_outline_decompose_funcs_t *funcs = hb_outline_decompose_funcs_create (); hb_draw_funcs_t *funcs = hb_draw_funcs_create ();
for (unsigned gid = 0; gid < 10; ++gid) for (unsigned gid = 0; gid < 10; ++gid)
hb_outline_decompose (font, gid, funcs, NULL); hb_font_draw_glyph (font, gid, funcs, NULL);
hb_outline_decompose_funcs_destroy (funcs); hb_draw_funcs_destroy (funcs);
hb_set_destroy (set); hb_set_destroy (set);
hb_font_destroy (font); hb_font_destroy (font);