]> O.S.I.I.S - jp/vkvg.git/commitdiff
expose vkvg_glyph_t
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Fri, 25 Feb 2022 06:58:24 +0000 (07:58 +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
src/vkvg_fonts.h

index 67a2ec516dd781f1094be49ba3c8ea36d97d0ba4..541548290c244e83c7dbd880bf541aeb69f2c3de 100644 (file)
@@ -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);
 /** @}*/
 
 /**
index 7d1801854780f9dae9002a4f7af0f422e11d2fb6..bae24317ea96d0d8863dc3efed6c7c92c57289da 100644 (file)
@@ -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);
index 2b6284879a538f99abbfa16caae7a735cd76f27a..682e76311ce92341bec8f05f203c2dec8d151b1d 100644 (file)
@@ -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 */