summaryrefslogtreecommitdiff
path: root/src/ui/text.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/text.c')
-rw-r--r--src/ui/text.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/src/ui/text.c b/src/ui/text.c
index be1685ad..786e11ff 100644
--- a/src/ui/text.c
+++ b/src/ui/text.c
@@ -50,6 +50,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
50# include <hb.h> 50# include <hb.h>
51#endif 51#endif
52 52
53#if defined (LAGRANGE_ENABLE_FRIBIDI)
54# include <fribidi/fribidi.h>
55#endif
56
53#if SDL_VERSION_ATLEAST(2, 0, 10) 57#if SDL_VERSION_ATLEAST(2, 0, 10)
54# define LAGRANGE_RASTER_DEPTH 8 58# define LAGRANGE_RASTER_DEPTH 8
55# define LAGRANGE_RASTER_FORMAT SDL_PIXELFORMAT_INDEX8 59# define LAGRANGE_RASTER_FORMAT SDL_PIXELFORMAT_INDEX8
@@ -76,7 +80,6 @@ enum iGlyphFlag {
76struct Impl_Glyph { 80struct Impl_Glyph {
77 iHashNode node; 81 iHashNode node;
78 int flags; 82 int flags;
79// uint32_t glyphIndex;
80 iFont *font; /* may come from symbols/emoji */ 83 iFont *font; /* may come from symbols/emoji */
81 iRect rect[2]; /* zero and half pixel offset */ 84 iRect rect[2]; /* zero and half pixel offset */
82 iInt2 d[2]; 85 iInt2 d[2];
@@ -86,7 +89,6 @@ struct Impl_Glyph {
86void init_Glyph(iGlyph *d, uint32_t glyphIndex) { 89void init_Glyph(iGlyph *d, uint32_t glyphIndex) {
87 d->node.key = glyphIndex; 90 d->node.key = glyphIndex;
88 d->flags = 0; 91 d->flags = 0;
89 //d->glyphIndex = 0;
90 d->font = NULL; 92 d->font = NULL;
91 d->rect[0] = zero_Rect(); 93 d->rect[0] = zero_Rect();
92 d->rect[1] = zero_Rect(); 94 d->rect[1] = zero_Rect();
@@ -97,9 +99,6 @@ void deinit_Glyph(iGlyph *d) {
97 iUnused(d); 99 iUnused(d);
98} 100}
99 101
100//static iChar codepoint_Glyph_(const iGlyph *d) {
101// return d->node.key;
102//}
103static uint32_t index_Glyph_(const iGlyph *d) { 102static uint32_t index_Glyph_(const iGlyph *d) {
104 return d->node.key; 103 return d->node.key;
105} 104}
@@ -131,7 +130,6 @@ struct Impl_Font {
131 int baseline; 130 int baseline;
132 iHash glyphs; /* key is glyph index in the font */ /* TODO: does not need to be a Hash */ 131 iHash glyphs; /* key is glyph index in the font */ /* TODO: does not need to be a Hash */
133 iBool isMonospaced; 132 iBool isMonospaced;
134// iBool manualKernOnly;
135 enum iFontSize sizeId; /* used to look up different fonts of matching size */ 133 enum iFontSize sizeId; /* used to look up different fonts of matching size */
136 uint32_t indexTable[128 - 32]; /* quick ASCII lookup */ 134 uint32_t indexTable[128 - 32]; /* quick ASCII lookup */
137#if defined (LAGRANGE_ENABLE_HARFBUZZ) 135#if defined (LAGRANGE_ENABLE_HARFBUZZ)
@@ -419,9 +417,6 @@ static void initFonts_Text_(iText *d) {
419 fontData[i].scaling, 417 fontData[i].scaling,
420 fontData[i].sizeId, 418 fontData[i].sizeId,
421 fontData[i].ttf == &fontIosevkaTermExtended_Embedded); 419 fontData[i].ttf == &fontIosevkaTermExtended_Embedded);
422// if (i == default_FontId || i == defaultMedium_FontId) {
423// font->manualKernOnly = iTrue;
424// }
425 } 420 }
426 gap_Text = iRound(gap_UI * d->contentFontSize); 421 gap_Text = iRound(gap_UI * d->contentFontSize);
427} 422}
@@ -1123,7 +1118,6 @@ static iRect run_Font_(iFont *d, const iRunArgs *args) {
1123 float xCursor = 0.0f; 1118 float xCursor = 0.0f;
1124 float yCursor = 0.0f; 1119 float yCursor = 0.0f;
1125 float xCursorMax = 0.0f; 1120 float xCursorMax = 0.0f;
1126 iRangecc wrapRange = args->text;
1127 const iBool isMonospaced = d->isMonospaced; 1121 const iBool isMonospaced = d->isMonospaced;
1128 const float monoAdvance = isMonospaced ? glyph_Font_(d, 'M')->advance : 0.0f; 1122 const float monoAdvance = isMonospaced ? glyph_Font_(d, 'M')->advance : 0.0f;
1129 iAssert(args->text.end >= args->text.start); 1123 iAssert(args->text.end >= args->text.start);
@@ -1266,12 +1260,10 @@ static iRect run_Font_(iFont *d, const iRunArgs *args) {
1266 } 1260 }
1267 /* We have determined a possible wrap position inside the text run, so now we can 1261 /* We have determined a possible wrap position inside the text run, so now we can
1268 draw the glyphs. */ 1262 draw the glyphs. */
1269 float surplusAdvance = 0.0f;
1270 for (unsigned int i = 0; i < glyphCount; i++) { 1263 for (unsigned int i = 0; i < glyphCount; i++) {
1271 const hb_glyph_info_t *info = &glyphInfo[i]; 1264 const hb_glyph_info_t *info = &glyphInfo[i];
1272 const hb_codepoint_t glyphId = info->codepoint; 1265 const hb_codepoint_t glyphId = info->codepoint;
1273 const char *textPos = runText.start + info->cluster; 1266 const char *textPos = runText.start + info->cluster;
1274 const int glyphFlags = hb_glyph_info_get_glyph_flags(info);
1275 const float xOffset = run->font->xScale * glyphPos[i].x_offset; 1267 const float xOffset = run->font->xScale * glyphPos[i].x_offset;
1276 const float yOffset = run->font->yScale * glyphPos[i].y_offset; 1268 const float yOffset = run->font->yScale * glyphPos[i].y_offset;
1277 const float xAdvance = run->font->xScale * glyphPos[i].x_advance; 1269 const float xAdvance = run->font->xScale * glyphPos[i].x_advance;
@@ -1413,8 +1405,9 @@ iInt2 tryAdvance_Text(int fontId, iRangecc text, int width, const char **endPos)
1413 iWrapText wrap = { .mode = word_WrapTextMode, 1405 iWrapText wrap = { .mode = word_WrapTextMode,
1414 .text = text, .maxWidth = width, 1406 .text = text, .maxWidth = width,
1415 .wrapFunc = cbAdvanceOneLine_, .context = endPos }; 1407 .wrapFunc = cbAdvanceOneLine_, .context = endPos };
1416 const int x = advance_WrapText(&wrap, fontId).x; 1408 //const int x = advance_WrapText(&wrap, fontId).x;
1417 return init_I2(x, lineHeight_Text(fontId)); 1409 //return init_I2(x, lineHeight_Text(fontId));
1410 return addY_I2(advance_WrapText(&wrap, fontId), lineHeight_Text(fontId));
1418 1411
1419#if 0 1412#if 0
1420 int advance; 1413 int advance;