Skip to content

Commit

Permalink
expose vkvg_glyph_t
Browse files Browse the repository at this point in the history
  • Loading branch information
jpbruyere committed Feb 26, 2022
1 parent c48cafb commit aab2e3d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
20 changes: 16 additions & 4 deletions include/vkvg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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);
/** @}*/

/**
Expand Down
16 changes: 7 additions & 9 deletions src/vkvg_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 0 additions & 10 deletions src/vkvg_fonts.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit aab2e3d

Please sign in to comment.