mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 381128. Remove gfxPangoFonts::Measure, it's kinda broken and not all that helpful right now. r=pavlov
This commit is contained in:
parent
6d35d9dde0
commit
e118c4fcb4
@ -83,11 +83,6 @@ public:
|
||||
PRBool HasGlyph(const PRUint32 aChar);
|
||||
PRUint32 GetGlyph(const PRUint32 aChar);
|
||||
|
||||
virtual gfxTextRun::Metrics Measure(gfxTextRun *aTextRun,
|
||||
PRUint32 aStart, PRUint32 aEnd,
|
||||
PRBool aTightBoundingBox,
|
||||
Spacing *aSpacing);
|
||||
|
||||
virtual nsString GetUniqueName();
|
||||
|
||||
// Get the glyphID of a space
|
||||
|
@ -874,116 +874,6 @@ gfxPangoFontGroup::InitTextRun(gfxTextRun *aTextRun, const gchar *aUTF8Text,
|
||||
#endif
|
||||
}
|
||||
|
||||
static gfxTextRun::Metrics
|
||||
GetPangoMetrics(PangoGlyphString *aGlyphs, PangoFont *aPangoFont,
|
||||
PRUint32 aPixelsToUnits, PRUint32 aClusterCount)
|
||||
{
|
||||
PangoRectangle inkRect;
|
||||
PangoRectangle logicalRect;
|
||||
pango_glyph_string_extents(aGlyphs, aPangoFont, &inkRect, &logicalRect);
|
||||
|
||||
gfxFloat scale = gfxFloat(aPixelsToUnits)/PANGO_SCALE;
|
||||
|
||||
gfxTextRun::Metrics metrics;
|
||||
NS_ASSERTION(logicalRect.x == 0, "Weird logical rect...");
|
||||
metrics.mAdvanceWidth = logicalRect.width*scale;
|
||||
metrics.mAscent = PANGO_ASCENT(logicalRect)*scale;
|
||||
metrics.mDescent = PANGO_DESCENT(logicalRect)*scale;
|
||||
gfxFloat x = inkRect.x*scale;
|
||||
gfxFloat y = inkRect.y*scale;
|
||||
metrics.mBoundingBox = gfxRect(x, y, (inkRect.x + inkRect.width)*scale - x,
|
||||
(inkRect.y + inkRect.height)*scale - y);
|
||||
metrics.mClusterCount = aClusterCount;
|
||||
return metrics;
|
||||
}
|
||||
|
||||
gfxTextRun::Metrics
|
||||
gfxPangoFont::Measure(gfxTextRun *aTextRun,
|
||||
PRUint32 aStart, PRUint32 aEnd,
|
||||
PRBool aTightBoundingBox,
|
||||
gfxTextRun::PropertyProvider::Spacing *aSpacing)
|
||||
{
|
||||
if (aEnd <= aStart)
|
||||
return gfxTextRun::Metrics();
|
||||
|
||||
const gfxTextRun::CompressedGlyph *charGlyphs = aTextRun->GetCharacterGlyphs();
|
||||
nsAutoTArray<PangoGlyphInfo,200> glyphBuffer;
|
||||
gfxFloat appUnitsToPango = gfxFloat(PANGO_SCALE)/aTextRun->GetAppUnitsPerDevUnit();
|
||||
|
||||
// We start by assuming every character is a cluster and subtract off
|
||||
// characters where that's not true
|
||||
PRUint32 clusterCount = aEnd - aStart;
|
||||
PRBool isRTL = aTextRun->IsRightToLeft();
|
||||
|
||||
PRUint32 i;
|
||||
for (i = aStart; i < aEnd; ++i) {
|
||||
PRUint32 leftSpacePango = 0;
|
||||
PRUint32 rightSpacePango = 0;
|
||||
if (aSpacing) {
|
||||
gfxTextRun::PropertyProvider::Spacing *space = &aSpacing[i - aStart];
|
||||
leftSpacePango =
|
||||
NS_lround((isRTL ? space->mAfter : space->mBefore)*appUnitsToPango);
|
||||
rightSpacePango =
|
||||
NS_lround((isRTL ? space->mBefore : space->mAfter)*appUnitsToPango);
|
||||
}
|
||||
const gfxTextRun::CompressedGlyph *glyphData = &charGlyphs[i];
|
||||
if (glyphData->IsSimpleGlyph()) {
|
||||
PangoGlyphInfo *glyphInfo = glyphBuffer.AppendElement();
|
||||
if (!glyphInfo)
|
||||
return gfxTextRun::Metrics();
|
||||
glyphInfo->attr.is_cluster_start = 0;
|
||||
glyphInfo->glyph = glyphData->GetSimpleGlyph();
|
||||
glyphInfo->geometry.width = leftSpacePango + rightSpacePango +
|
||||
NS_lround(glyphData->GetSimpleAdvance()*appUnitsToPango);
|
||||
glyphInfo->geometry.x_offset = leftSpacePango;
|
||||
glyphInfo->geometry.y_offset = 0;
|
||||
} else if (glyphData->IsComplexCluster()) {
|
||||
const gfxTextRun::DetailedGlyph *details = aTextRun->GetDetailedGlyphs(i);
|
||||
PRBool firstGlyph = PR_FALSE;
|
||||
for (;;) {
|
||||
PangoGlyphInfo *glyphInfo = glyphBuffer.AppendElement();
|
||||
if (!glyphInfo)
|
||||
return gfxTextRun::Metrics();
|
||||
glyphInfo->attr.is_cluster_start = 0;
|
||||
glyphInfo->glyph = details->mGlyphID;
|
||||
glyphInfo->geometry.width = NS_lround(details->mAdvance*appUnitsToPango);
|
||||
glyphInfo->geometry.x_offset = NS_lround(details->mXOffset*appUnitsToPango);
|
||||
if (firstGlyph) {
|
||||
glyphInfo->geometry.width += leftSpacePango;
|
||||
glyphInfo->geometry.x_offset += leftSpacePango;
|
||||
firstGlyph = PR_FALSE;
|
||||
}
|
||||
glyphInfo->geometry.y_offset = NS_lround(details->mYOffset*appUnitsToPango);
|
||||
if (details->mIsLastGlyph) {
|
||||
glyphInfo->geometry.width += rightSpacePango;
|
||||
break;
|
||||
}
|
||||
++details;
|
||||
}
|
||||
} else if (!glyphData->IsClusterStart()) {
|
||||
--clusterCount;
|
||||
}
|
||||
}
|
||||
|
||||
if (aTextRun->IsRightToLeft()) {
|
||||
// Reverse glyph order
|
||||
for (i = 0; i < (glyphBuffer.Length() >> 1); ++i) {
|
||||
PangoGlyphInfo *a = &glyphBuffer[i];
|
||||
PangoGlyphInfo *b = &glyphBuffer[glyphBuffer.Length() - 1 - i];
|
||||
PangoGlyphInfo tmp = *a;
|
||||
*a = *b;
|
||||
*b = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
PangoGlyphString glyphs;
|
||||
glyphs.num_glyphs = glyphBuffer.Length();
|
||||
glyphs.glyphs = glyphBuffer.Elements();
|
||||
glyphs.log_clusters = nsnull;
|
||||
glyphs.space = glyphBuffer.Length();
|
||||
return GetPangoMetrics(&glyphs, GetPangoFont(), aTextRun->GetAppUnitsPerDevUnit(), clusterCount);
|
||||
}
|
||||
|
||||
static cairo_scaled_font_t*
|
||||
CreateScaledFont(cairo_t *aCR, cairo_matrix_t *aCTM, PangoFont *aPangoFont)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user