Existing unit tests are working with some minor differences
Change-Id: I78fb28a553f3aa9f8709708470c121bbe452fb8a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/233304
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Julia Lavrova <jlavrova@google.com>
diff --git a/modules/skparagraph/src/TextStyle.cpp b/modules/skparagraph/src/TextStyle.cpp
index 16de5b9..5f82452 100644
--- a/modules/skparagraph/src/TextStyle.cpp
+++ b/modules/skparagraph/src/TextStyle.cpp
@@ -125,13 +125,15 @@
void TextStyle::getFontMetrics(SkFontMetrics* metrics) const {
SkFont font(fTypeface, fFontSize);
font.getMetrics(metrics);
- if (fHeight == 0 || fHeight == 1) {
+ if (fHeightOverride) {
+ auto multiplier = fHeight * fFontSize;
+ auto height = metrics->fDescent - metrics->fAscent + metrics->fLeading;
+ metrics->fAscent = (metrics->fAscent - metrics->fLeading / 2) * multiplier / height;
+ metrics->fDescent = (metrics->fDescent + metrics->fLeading / 2) * multiplier / height;
+
+ } else {
metrics->fAscent = (metrics->fAscent - metrics->fLeading / 2);
metrics->fDescent = (metrics->fDescent + metrics->fLeading / 2);
- } else {
- auto height = metrics->fDescent - metrics->fAscent + metrics->fLeading;
- metrics->fAscent = (metrics->fAscent - metrics->fLeading / 2) * height / fHeight;
- metrics->fDescent = (metrics->fDescent + metrics->fLeading / 2) * height / fHeight;
}
}