From 25c7a74c4573149cafee13170272a98027b31b33 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Thu, 24 Feb 2022 03:56:33 +0100 Subject: [PATCH] remove GlyphInfo, return individual positions elements --- include/vkvg.h | 17 ++++++----------- src/vkvg_context.c | 17 ++++++++++++++--- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/include/vkvg.h b/include/vkvg.h index 2c57513..270ebc9 100644 --- a/include/vkvg.h +++ b/include/vkvg.h @@ -316,13 +316,6 @@ typedef struct _vkvg_device_t* VkvgDevice; * configurable parameters such as the wrap mode, the filtering, etc... */ typedef struct _vkvg_pattern_t* VkvgPattern; -/** - * @brief Opaque pointer on a Vkvg glyph info structure. - * @ingroup context - * - * glyph info contains glyph positions in a text run. - */ -typedef struct vkvg_glyph_info_t* VkvgGlyphInfo; #if VKVG_DBG_STATS /** @@ -1594,12 +1587,14 @@ void vkvg_text_run_get_extents (VkvgText textRun, vkvg_text_extents_t* extents); /** * @brief retrieve glyph positions. * - * @param textRun - * @param pGlyphPositions - * @param pGlyphCount */ vkvg_public -void vkvg_text_run_get_glyph_positions (VkvgText textRun, VkvgGlyphInfo* pGlyphPositions, uint32_t* pGlyphCount); +void vkvg_text_run_get_glyph_position (VkvgText textRun, + uint32_t index, + int32_t* const x_advance, + int32_t* const y_advance, + int32_t* const x_offset, + int32_t* const y_offset); /** @}*/ /** diff --git a/src/vkvg_context.c b/src/vkvg_context.c index eef9be8..aab6acb 100644 --- a/src/vkvg_context.c +++ b/src/vkvg_context.c @@ -1167,9 +1167,20 @@ VkvgText vkvg_text_run_create_with_length (VkvgContext ctx, const char* text, ui _font_cache_create_text_run(ctx, text, length, tr); return tr; } -void vkvg_text_run_get_glyph_positions (VkvgText textRun, VkvgGlyphInfo *pGlyphPositions, uint32_t* pGlyphCount) { - *pGlyphPositions = (VkvgGlyphInfo)textRun->glyphs; - *pGlyphCount = textRun->glyph_count; +void vkvg_text_run_get_glyph_position (VkvgText textRun, + uint32_t index, + int32_t* const x_advance, + int32_t* const y_advance, + int32_t* const x_offset, + int32_t* const y_offset) { + if (index >= textRun->glyph_count) { + *x_advance = *y_advance = *x_offset = *y_offset = 0; + return; + } + *x_advance = textRun->glyphs[index].x_advance; + *y_advance = textRun->glyphs[index].y_advance; + *x_offset = textRun->glyphs[index].x_offset; + *y_offset = textRun->glyphs[index].y_offset; } void vkvg_text_run_destroy (VkvgText textRun) { _font_cache_destroy_text_run (textRun); -- 2.47.3