@@ -329,7 +329,6 @@ void shapeLines(Shaping& shaping,
329329 float y = 0 ;
330330 float maxLineLength = 0 ;
331331
332-
333332 const float justify = textJustify == style::TextJustifyType::Right ? 1 :
334333 textJustify == style::TextJustifyType::Left ? 0 :
335334 0.5 ;
@@ -365,15 +364,17 @@ void shapeLines(Shaping& shaping,
365364 // from the horizontal baseline to the highest ‘character’ coordinate in a font face.
366365 // Since we're laying out at 24 points, we need also calculate how much it will move
367366 // when we scale up or down.
368- const double baselineOffset =
369- -glyph.metrics .ascender * section.scale + (lineMaxScale - section.scale ) * util::ONE_EM;
367+ const bool hasBaseline = glyph.metrics .ascender != 0 && glyph.metrics .descender != 0 ;
368+ const double baselineOffset = (hasBaseline ? (-glyph.metrics .ascender * section.scale ) : shaping.yOffset ) +
369+ (lineMaxScale - section.scale ) * util::ONE_EM;
370370
371371 if (writingMode == WritingModeType::Horizontal ||
372372 // Don't verticalize glyphs that have no upright orientation if vertical placement is disabled.
373373 (!allowVerticalPlacement && !util::i18n::hasUprightVerticalOrientation (codePoint)) ||
374374 // If vertical placement is ebabled, don't verticalize glyphs that
375375 // are from complex text layout script, or whitespaces.
376- (allowVerticalPlacement && (util::i18n::isWhitespace (codePoint) || util::i18n::isCharInComplexShapingScript (codePoint)))) {
376+ (allowVerticalPlacement &&
377+ (util::i18n::isWhitespace (codePoint) || util::i18n::isCharInComplexShapingScript (codePoint)))) {
377378 shaping.positionedGlyphs .emplace_back (
378379 codePoint, x, y + baselineOffset, false , section.fontStackHash , section.scale , sectionIndex);
379380 x += glyph.metrics .advance * section.scale + spacing;
@@ -400,7 +401,7 @@ void shapeLines(Shaping& shaping,
400401
401402 align (shaping, justify, anchorAlign.horizontalAlign , anchorAlign.verticalAlign , maxLineLength,
402403 lineHeight, lines.size ());
403- const float height = y - Shaping::yOffset ;
404+ const float height = y;
404405 // Calculate the bounding box
405406 shaping.top += -anchorAlign.verticalAlign * height;
406407 shaping.bottom = shaping.top + height;
0 commit comments