summaryrefslogtreecommitdiff
path: root/gfx/thebes/gfxTextRun.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/thebes/gfxTextRun.cpp')
-rw-r--r--gfx/thebes/gfxTextRun.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/gfx/thebes/gfxTextRun.cpp b/gfx/thebes/gfxTextRun.cpp
index 8794efe688..1025abbd3e 100644
--- a/gfx/thebes/gfxTextRun.cpp
+++ b/gfx/thebes/gfxTextRun.cpp
@@ -1071,6 +1071,34 @@ gfxTextRun::GetAdvanceWidth(Range aRange, PropertyProvider *aProvider,
return result + GetAdvanceForGlyphs(ligatureRange);
}
+gfxFloat
+gfxTextRun::GetMinAdvanceWidth(Range aRange)
+{
+ MOZ_ASSERT(aRange.end <= GetLength(), "Substring out of range");
+
+ Range ligatureRange = aRange;
+ ShrinkToLigatureBoundaries(&ligatureRange);
+
+ gfxFloat result = std::max(
+ ComputePartialLigatureWidth(Range(aRange.start, ligatureRange.start),
+ nullptr),
+ ComputePartialLigatureWidth(Range(ligatureRange.end, aRange.end),
+ nullptr));
+
+ // XXX Do we need to take spacing into account? When each grapheme cluster
+ // takes its own line, we shouldn't be adding spacings around them.
+ gfxFloat clusterAdvance = 0;
+ for (uint32_t i = ligatureRange.start; i < ligatureRange.end; ++i) {
+ clusterAdvance += GetAdvanceForGlyph(i);
+ if (i + 1 == ligatureRange.end || IsClusterStart(i + 1)) {
+ result = std::max(result, clusterAdvance);
+ clusterAdvance = 0;
+ }
+ }
+
+ return result;
+}
+
bool
gfxTextRun::SetLineBreaks(Range aRange,
bool aLineBreakBefore, bool aLineBreakAfter,