@@ -360,7 +360,7 @@ void shapeLines(Shaping& shaping,
360360 continue ;
361361 }
362362
363- float biggestHeight{0 }, baselineOffset{0 };
363+ float biggestHeight{0 . 0f }, baselineOffset{0 . 0f };
364364 std::size_t lineStartIndex = shaping.positionedGlyphs .size ();
365365 for (std::size_t i = 0 ; i < line.length (); i++) {
366366 const std::size_t sectionIndex = line.getSectionIndex (i);
@@ -377,13 +377,14 @@ void shapeLines(Shaping& shaping,
377377
378378 const Glyph& glyph = **it->second ;
379379
380- double ascender{0 }, descender{0 }, glyphOffset{0 };
380+ float ascender{0 . 0f }, descender{0 . 0f }, glyphOffset{0 . 0f };
381381 // In order to make different fonts aligned, they must share a general baseline that aligns with every
382- // font's real baseline. Glyph's position is counted from the top left corner, where is the ascender line
383- // starts. Since ascender is above the baseline, the glyphOffset is the negative shift. In order to make all
384- // the glyphs aligned with shaping box, for each line, we lock the heighest glyph (with scale) locating
385- // at the middle of the line, which will lead to a baseline shift. Then adjust the whole line with the
386- // baseline offset we calculated from the shift.
382+ // font's real baseline. Glyph's offset is counted from the top left corner, where is the ascender line
383+ // starts. First of all, every glyph's baseline lies on the middle line of each shaping line. Since ascender
384+ // is above the baseline, the glyphOffset is the negative shift. Then, in order to make glyphs fit in the
385+ // shaping box, for each line, we shift the glyph with biggest height(with scale) to make its middle line
386+ // lie on the middle line of the line, which will lead to a baseline shift. Then adjust the whole line with
387+ // the baseline offset we calculated from the shift.
387388 if (hasBaseline) {
388389 assert (glyphs->second .ascender && glyphs->second .descender );
389390 ascender = std::abs (glyphs->second .ascender .value ());
@@ -395,9 +396,9 @@ void shapeLines(Shaping& shaping,
395396 }
396397 glyphOffset = -ascender * section.scale ;
397398 } else {
398- // If font's baseline is not applicable, fall back to use a default baseline
399- // offset, see shaping. yOffset. Since we're laying out at 24 points, we need also calculate how much it
400- // will move when we scale up or down.
399+ // If font's baseline is not applicable, fall back to use a default baseline offset, see
400+ // Shaping:: yOffset. Since we're laying out at 24 points, we need also calculate how much it will move
401+ // when we scale up or down.
401402 glyphOffset = Shaping::yOffset + (lineMaxScale - section.scale ) * util::ONE_EM;
402403 }
403404
0 commit comments