@@ -80,6 +80,7 @@ static bool CommonRender(
8080 SamplerDescriptor sampler_desc;
8181 sampler_desc.min_filter = MinMagFilter::kLinear ;
8282 sampler_desc.mag_filter = MinMagFilter::kLinear ;
83+ sampler_desc.mip_filter = MipFilter::kNone ;
8384
8485 typename FS::FragInfo frag_info;
8586 frag_info.text_color = ToVector (color.Premultiply ());
@@ -103,9 +104,9 @@ static bool CommonRender(
103104 // interpolated vertex information is also used in the fragment shader to
104105 // sample from the glyph atlas.
105106
106- const std::vector <Point> unit_vertex_points = {
107- { 0 , 0 }, { 1 , 0 }, {0 , 1 }, {1 , 1 }};
108- const std::vector <uint32_t > indices = {0 , 1 , 2 , 1 , 2 , 3 };
107+ const std::array <Point, 4 > unit_points = {Point{ 0 , 0 }, Point{ 1 , 0 },
108+ Point {0 , 1 }, Point {1 , 1 }};
109+ const std::array <uint32_t , 6 > indices = {0 , 1 , 2 , 1 , 2 , 3 };
109110
110111 VertexBufferBuilder<typename VS::PerVertexData> vertex_builder;
111112
@@ -127,7 +128,7 @@ static bool CommonRender(
127128
128129 for (const auto & run : frame.GetRuns ()) {
129130 auto font = run.GetFont ();
130- auto glyph_size_ = ISize::Ceil ( font.GetMetrics ().GetBoundingBox ().size ) ;
131+ auto glyph_size_ = font.GetMetrics ().GetBoundingBox ().size ;
131132 auto glyph_size = Point{static_cast <Scalar>(glyph_size_.width ),
132133 static_cast <Scalar>(glyph_size_.height )};
133134 auto metrics_offset =
@@ -141,22 +142,20 @@ static bool CommonRender(
141142 return false ;
142143 }
143144
144- auto atlas_position =
145- atlas_glyph_pos->origin + Point{1 / atlas_glyph_pos->size .width ,
146- 1 / atlas_glyph_pos->size .height };
145+ auto atlas_position = atlas_glyph_pos->origin ;
147146 auto atlas_glyph_size =
148147 Point{atlas_glyph_pos->size .width , atlas_glyph_pos->size .height };
149148 auto offset_glyph_position = glyph_position.position + metrics_offset;
150149
151- for (const auto & point : unit_vertex_points ) {
150+ for (const auto & point : unit_points ) {
152151 typename VS::PerVertexData vtx;
153- vtx.unit_vertex = point;
154- vtx.glyph_position = offset_glyph_position;
155- vtx.glyph_size = glyph_size;
156- vtx.atlas_position = atlas_position;
157- vtx.atlas_glyph_size = atlas_glyph_size;
152+ vtx.unit_position = point;
153+ vtx.destination_position = offset_glyph_position + Point ( 0.5 , 0.5 ) ;
154+ vtx.destination_size = glyph_size - Point ( 1.0 , 1.0 ) ;
155+ vtx.source_position = atlas_position + Point ( 0.5 , 0.5 ) ;
156+ vtx.source_glyph_size = atlas_glyph_size - Point ( 1.0 , 1.0 ) ;
158157 if constexpr (std::is_same_v<TPipeline, GlyphAtlasPipeline>) {
159- vtx.color_glyph =
158+ vtx.has_color =
160159 glyph_position.glyph .type == Glyph::Type::kBitmap ? 1.0 : 0.0 ;
161160 }
162161 vertex_builder.AppendVertex (std::move (vtx));
0 commit comments