From: Jean-Philippe Bruyère Date: Fri, 25 Feb 2022 06:58:24 +0000 (+0100) Subject: expose vkvg_glyph_t X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=aab2e3d28787fbd6b8c6adafc049ba195ffb262b;p=jp%2Fvkvg.git expose vkvg_glyph_t --- diff --git a/include/vkvg.h b/include/vkvg.h index 67a2ec5..5415482 100644 --- a/include/vkvg.h +++ b/include/vkvg.h @@ -263,6 +263,21 @@ typedef struct { float y_advance; /*!< distance to advance in the Y direction after drawing these glyphs. Will typically be zero except for vertical text layout as found in East-Asian languages.*/ } vkvg_text_extents_t; +/** + * @brief glyphs position in a @ref VkvgText + * + * structure defining glyph position as computed for rendering a text run. + * the codepoint field is for internal use only. + */ +typedef struct _glyph_info_t { + int32_t x_advance; + int32_t y_advance; + int32_t x_offset; + int32_t y_offset; + /* private */ + uint32_t codepoint;//should be named glyphIndex, but for harfbuzz compatibility... +} vkvg_glyph_info_t; + /** * @brief Opaque pointer on a vkvg text run. * @@ -1598,10 +1613,7 @@ uint32_t vkvg_text_run_get_glyph_count (VkvgText textRun); vkvg_public 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); + vkvg_glyph_info_t* pGlyphInfo); /** @}*/ /** diff --git a/src/vkvg_context.c b/src/vkvg_context.c index 7d18018..bae2431 100644 --- a/src/vkvg_context.c +++ b/src/vkvg_context.c @@ -1172,18 +1172,16 @@ uint32_t vkvg_text_run_get_glyph_count (VkvgText textRun) { } 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) { + vkvg_glyph_info_t* pGlyphInfo) { if (index >= textRun->glyph_count) { - *x_advance = *y_advance = *x_offset = *y_offset = 0; + *pGlyphInfo = (vkvg_glyph_info_t){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; +#if VKVG_USE_HARFBUZZ + memcpy (pGlyphInfo, &textRun->glyphs[index], sizeof(vkvg_glyph_info_t)); +#else + *pGlyphInfo = textRun->glyphs[index]; +#endif } void vkvg_text_run_destroy (VkvgText textRun) { _font_cache_destroy_text_run (textRun); diff --git a/src/vkvg_fonts.h b/src/vkvg_fonts.h index 2b62848..682e763 100644 --- a/src/vkvg_fonts.h +++ b/src/vkvg_fonts.h @@ -159,16 +159,6 @@ typedef struct { if (dev->threadAware)\ mtx_unlock (&dev->fontCache->mutex); -#ifndef VKVG_USE_HARFBUZZ -typedef struct _glyph_info_t { - int32_t x_advance; - int32_t y_advance; - int32_t x_offset; - int32_t y_offset; - uint32_t codepoint;//should be named glyphIndex, but for harfbuzz compatibility... -} vkvg_glyph_info_t; -#endif - // Precompute everything necessary to measure and draw one line of text, usefull to draw the same text multiple times. typedef struct _vkvg_text_run_t { _vkvg_font_identity_t* fontId; /* vkvg font structure pointer */