@@ -85,9 +85,9 @@ freetype_face::metrics freetype_face::get_metrics(unsigned font_size) const
8585 this ->set_size (font_size);
8686 using std::ceil;
8787 return {
88- ceil (real (this ->face .f ->size ->metrics .height ) / real (freetype_granularity)), // height
89- -ceil (real (this ->face .f ->size ->metrics .descender ) / real (freetype_granularity)), // descender
90- ceil (real (this ->face .f ->size ->metrics .ascender ) / real (freetype_granularity)) // ascender
88+ . height = ceil (real (this ->face .f ->size ->metrics .height ) / real (freetype_granularity)), //
89+ . descender = -ceil (real (this ->face .f ->size ->metrics .descender ) / real (freetype_granularity)),
90+ . ascender = ceil (real (this ->face .f ->size ->metrics .ascender ) / real (freetype_granularity))
9191 };
9292}
9393
@@ -102,13 +102,13 @@ freetype_face::glyph freetype_face::load_glyph(char32_t c, unsigned font_size) c
102102 " texture_font::load_glyph(): could not load 'unknown character' glyph (UTF-32: 0xfffd)"
103103 );
104104 }
105- LOG ([&](auto & o) {
105+ utki::log_debug ([&](auto & o) {
106106 o << " texture_font::load_glyph(" << std::hex << uint32_t (c) << " ): failed to load glyph" << std::endl;
107- })
107+ });
108108 return {
109- {}, // vertices
110- {}, // image
111- -1 // advance
109+ . vertices = {}, //
110+ . image = {},
111+ . advance = -1 // negative means invalid
112112 };
113113 }
114114
@@ -123,32 +123,31 @@ freetype_face::glyph freetype_face::load_glyph(char32_t c, unsigned font_size) c
123123 if (!slot->bitmap .buffer ) {
124124 // empty glyph (space)
125125 return glyph{
126- {}, // vertices
127- {}, // image
128- advance
126+ . vertices = {}, //
127+ . image = {},
128+ . advance = advance
129129 };
130130 }
131131
132- ASSERT (slot->format == FT_GLYPH_FORMAT_BITMAP)
133- ASSERT (slot->bitmap .pixel_mode == FT_PIXEL_MODE_GRAY)
134- ASSERT (slot->bitmap .pitch >= 0 )
132+ utki::assert (slot->format == FT_GLYPH_FORMAT_BITMAP);
133+ utki::assert (slot->bitmap .pixel_mode == FT_PIXEL_MODE_GRAY);
134+ utki::assert (slot->bitmap .pitch >= 0 );
135135
136136 return glyph{
137- // vertices
138- {
139- (ruis::vec2 (real (m->horiBearingX ), -real (m->horiBearingY )) / real (freetype_granularity)),
140- (ruis::vec2 (real (m->horiBearingX ), real (m->height - m->horiBearingY )) / real (freetype_granularity)),
141- (ruis::vec2 (real (m->horiBearingX + m->width ), real (m->height - m->horiBearingY )) /
142- real (freetype_granularity)),
143- (ruis::vec2 (real (m->horiBearingX + m->width ), -real (m->horiBearingY )) / real (freetype_granularity)) //
144- },
145- // image
146- rasterimage::image<uint8_t , 1 >::make (
137+ .vertices =
138+ {
139+ (ruis::vec2 (real (m->horiBearingX ), -real (m->horiBearingY )) / real (freetype_granularity)), //
140+ (ruis::vec2 (real (m->horiBearingX ), real (m->height - m->horiBearingY )) / real (freetype_granularity)),
141+ (ruis::vec2 (real (m->horiBearingX + m->width ), real (m->height - m->horiBearingY )) /
142+ real (freetype_granularity)),
143+ (ruis::vec2 (real (m->horiBearingX + m->width ), -real (m->horiBearingY )) / real (freetype_granularity)) //
144+ }, //
145+ .image = rasterimage::image<uint8_t , 1 >::make (
147146 {slot->bitmap .width , slot->bitmap .rows },
148147 slot->bitmap .buffer ,
149148 slot->bitmap .pitch
150149 ),
151- advance
150+ . advance = advance
152151 };
153152}
154153
@@ -188,7 +187,7 @@ texture_font::glyph texture_font::load_glyph(char32_t c) const
188187 g.tex = rc.make_texture_2d (
189188 std::move (ftg.image ),
190189 {
191- .min_filter = render::texture_2d::filter::nearest,
190+ .min_filter = render::texture_2d::filter::nearest, //
192191 .mag_filter = render::texture_2d::filter::nearest,
193192 .mipmap = render::texture_2d::mipmap::none
194193 }
@@ -233,7 +232,7 @@ const texture_font::glyph& texture_font::get_glyph(char32_t c) const
233232 auto i = this ->glyphs .find (c);
234233 if (i == this ->glyphs .end ()) {
235234 auto r = this ->glyphs .insert (std::make_pair (c, this ->load_glyph (c)));
236- ASSERT (r.second )
235+ utki::assert (r.second );
237236 i = r.first ;
238237 this ->last_used_order .push_front (c);
239238 i->second .last_used_iter = this ->last_used_order .begin ();
@@ -248,7 +247,7 @@ const texture_font::glyph& texture_font::get_glyph(char32_t c) const
248247 this ->last_used_order .splice (this ->last_used_order .begin (), this ->last_used_order , g.last_used_iter );
249248 }
250249
251- ASSERT (this ->last_used_order .size () <= this ->max_cached )
250+ utki::assert (this ->last_used_order .size () <= this ->max_cached );
252251
253252 return i->second ;
254253}
@@ -347,7 +346,10 @@ font::render_result texture_font::render_internal(
347346 size_t offset
348347) const
349348{
350- render_result ret = {0 , 0 };
349+ render_result ret = {
350+ .advance = 0 , //
351+ .length = 0
352+ };
351353
352354 if (str.size () == 0 ) {
353355 return ret;
0 commit comments