mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 01:48:05 +00:00
I do not notice the tree is frozen.
Back out my last checkin.
This commit is contained in:
parent
b0afb7c7d3
commit
4681a7723b
@ -1068,6 +1068,10 @@ nsFontPSXft::GetWidth(const char* aString, PRUint32 aLength)
|
||||
nscoord
|
||||
nsFontPSXft::GetWidth(const PRUnichar* aString, PRUint32 aLength)
|
||||
{
|
||||
FT_UInt glyph_index;
|
||||
FT_Glyph glyph;
|
||||
double origin_x = 0;
|
||||
|
||||
// get the face/size from the FreeType cache
|
||||
FT_Face face = getFTFace();
|
||||
NS_ASSERTION(face, "failed to get face/size");
|
||||
@ -1075,15 +1079,15 @@ nsFontPSXft::GetWidth(const PRUnichar* aString, PRUint32 aLength)
|
||||
return 0;
|
||||
|
||||
// XXX : we might need some caching here
|
||||
double em_size = 1.0 * face->units_per_EM;
|
||||
double x_scale = face->size->metrics.x_ppem / em_size;
|
||||
double origin_x = 0;
|
||||
for (PRUint32 i=0; i<aLength; i++) {
|
||||
FT_UInt glyph_index = FT_Get_Char_Index((FT_Face)face, aString[i]);
|
||||
if (FT_Load_Glyph(face, glyph_index, FT_LOAD_NO_SCALE ))
|
||||
origin_x += face->size->metrics.x_ppem/2 + 2;
|
||||
else
|
||||
origin_x += (face->glyph->advance.x) * x_scale;
|
||||
glyph_index = FT_Get_Char_Index((FT_Face)face, aString[i]);
|
||||
if (FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT) ||
|
||||
FT_Get_Glyph(face->glyph, &glyph)) {
|
||||
origin_x += FT_REG_TO_16_16(face->size->metrics.x_ppem/2 + 2);
|
||||
continue;
|
||||
}
|
||||
origin_x += glyph->advance.x;
|
||||
FT_Done_Glyph(glyph);
|
||||
}
|
||||
|
||||
NS_ENSURE_TRUE(mFontMetrics, 0);
|
||||
@ -1091,7 +1095,10 @@ nsFontPSXft::GetWidth(const PRUnichar* aString, PRUint32 aLength)
|
||||
nsDeviceContextPS* dc = mFontMetrics->GetDeviceContext();
|
||||
NS_ENSURE_TRUE(dc, 0);
|
||||
|
||||
origin_x *= dc->DevUnitsToAppUnits();
|
||||
float dev2app;
|
||||
dev2app = dc->DevUnitsToAppUnits();
|
||||
origin_x *= dev2app;
|
||||
origin_x /= FT_REG_TO_16_16(1);
|
||||
|
||||
return NSToCoordRound((nscoord)origin_x);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user