66#include <font-chef/character-mapping.h>
77
88
9- #define fc_fabs (x ) ((float) fabs((double) x))
10-
119struct fc_font * fc_construct (
1210 uint8_t const * font_data ,
1311 struct fc_font_size font_size ,
@@ -104,7 +102,7 @@ void fc_cook(struct fc_font * font) {
104102 free (pixels_1bpp );
105103}
106104
107- int fc_render (
105+ struct fc_render_result fc_render (
108106 struct fc_font const * font ,
109107 unsigned char const * text ,
110108 size_t byte_count ,
@@ -154,11 +152,6 @@ int fc_render(
154152
155153 m -> codepoint = decode .codepoint ;
156154
157- /* stores the top offset to add it later to the mappings, to make sure
158- * that rendering starts at 0 */
159- // if ((dst->top < top_offset) || target_index == 0)
160- // top_offset = dst->top;
161-
162155 /* checks to see if there is kerning to add to the next character, and
163156 * sets it to be used in the next iteration */
164157 kern = 0 ;
@@ -171,18 +164,13 @@ int fc_render(
171164 }
172165 }
173166
174- /* characters are rendered around a baseline, which was set to 0 when
175- * fc_cook was called. the following loop goes through all glyph
176- * mappings and adjusts them to remove the "empty" space on top caused
177- * by that. */
178- // top_offset = fc_fabs(top_offset);
179- // for (size_t i = 0; i < target_index; i++) {
180- // mapping[i].target.top += top_offset;
181- // mapping[i].target.bottom += top_offset;
182- // }
183-
184167 /* end of the loop, target_index will be the amount of decoded glyphs */
185- return (int ) target_index ;
168+ struct fc_render_result result = {
169+ .line_count = 1 ,
170+ .glyph_count = (uint32_t ) target_index
171+ };
172+
173+ return result ;
186174}
187175
188176struct fc_font_size fc_get_font_size (struct fc_font const * font ) {
@@ -229,7 +217,7 @@ void fc_destruct(struct fc_font * font) {
229217 free (font );
230218}
231219
232- int fc_render_wrapped (
220+ struct fc_render_result fc_render_wrapped (
233221 struct fc_font const * font ,
234222 unsigned char const * text ,
235223 size_t byte_count ,
@@ -238,10 +226,10 @@ int fc_render_wrapped(
238226 enum fc_alignment alignment ,
239227 struct fc_character_mapping * mapping
240228) {
241- int rendered = fc_render (font , text , byte_count , mapping );
229+ struct fc_render_result result = fc_render (font , text , byte_count , mapping );
242230 struct fc_size space_metrics = fc_get_space_metrics (font );
243- fc_wrap (mapping , rendered , (float ) line_width , font -> metrics .line_height * line_height_multiplier , space_metrics .width , alignment );
244- return rendered ;
231+ result . line_count = fc_wrap (mapping , result . glyph_count , (float ) line_width , font -> metrics .line_height * line_height_multiplier , space_metrics .width , alignment );
232+ return result ;
245233}
246234
247235struct fc_size fc_get_space_metrics (struct fc_font const * font ) {
0 commit comments