]> O.S.I.I.S - jp/vkvg.git/commitdiff
remove GlyphInfo, return individual positions elements
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Thu, 24 Feb 2022 02:56:33 +0000 (03:56 +0100)
committerj-p <jp_bruyere@hotmail.com>
Sat, 26 Feb 2022 10:05:24 +0000 (11:05 +0100)
include/vkvg.h
src/vkvg_context.c

index 2c57513b5a6f120255c6b811d07fca797da59127..270ebc90bda50c4c2f942cc1a92bc04f08c83f5d 100644 (file)
@@ -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);
 /** @}*/
 
 /**
index eef9be8d573f219d0e33d6b787ae8940e9263b9d..aab6acbaaf98aaaf0118198071d841837163f237 100644 (file)
@@ -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);