Commit fc75f973 authored by Oleg.Korshul's avatar Oleg.Korshul

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@55686 954022d7-b5bf-4e40-9824-e11837661b57
parent 1ac044ae
......@@ -889,7 +889,7 @@ function CFontFile(fileName, faceIndex)
this.UpdateMatrix1();
}
var pCurGlyph = pString.m_pGlyphsBuffer[0]
var pCurGlyph = pString.m_pGlyphsBuffer[0];
var ushUnicode = pCurGlyph.lUnicode;
var unGID = 0;
......@@ -1227,7 +1227,7 @@ function CFontFile(fileName, faceIndex)
return nCharIndex;
}
this.GetChar = function(lUnicode)
this.GetChar = function(lUnicode, is_raster_distances)
{
var pFace = this.m_pFace;
var pCurentGliph = pFace.glyph;
......@@ -1337,6 +1337,14 @@ function CFontFile(fileName, faceIndex)
oSizes.bBitmap = false;
oSizes.oBitmap = null;
if (is_raster_distances === true)
{
if (0 == FT_Render_Glyph(pCurentGliph, REND_MODE))
{
oSizes.oBBox.rasterDistances = get_raster_bounds(raster_memory.m_oBuffer.data, pCurentGliph.bitmap.width, pCurentGliph.bitmap.rows, raster_memory.pitch);
}
}
this.m_arrCacheSizes[oSizes.ushUnicode] = oSizes;
Result = oSizes;
}
......
var g_bIsAppleDevices = AscBrowser.isAppleDevices;
function get_raster_bounds(data, width, height, stride)
{
var ret = { dist_l : 0, dist_t : 0, dist_r : 0, dist_b : 0 };
// left
var bIsBreak = false;
for (var i = 0; i < width; i++)
{
var _ind = i * 4 + 3;
for (var j = 0; j < height; j++, _ind += stride)
{
if (data[_ind] != 0)
{
bIsBreak = true;
break;
}
}
if (bIsBreak)
break;
ret.dist_l++;
}
// right
bIsBreak = false;
for (var i = width - 1; i >= 0; i--)
{
var _ind = i * 4 + 3;
for (var j = 0; j < height; j++, _ind += stride)
{
if (data[_ind] != 0)
{
bIsBreak = true;
break;
}
}
if (bIsBreak)
break;
ret.dist_r++;
}
// top
var bIsBreak = false;
for (var j = 0; j < height; j++)
{
var _ind = j * stride + 3;
for (var i = 0; i < width; i++, _ind += 4)
{
if (data[_ind] != 0)
{
bIsBreak = true;
break;
}
}
if (bIsBreak)
break;
ret.dist_t++;
}
// bottom
var bIsBreak = false;
for (var j = height - 1; j >= 0; j--)
{
var _ind = j * stride + 3;
for (var i = 0; i < width; i++, _ind += 4)
{
if (data[_ind] != 0)
{
bIsBreak = true;
break;
}
}
if (bIsBreak)
break;
ret.dist_b++;
}
// clear
if (null != raster_memory.m_oBuffer)
{
var nIndexDst = 3;
var nPitch = 4 * (raster_memory.width - width);
var dst = raster_memory.m_oBuffer.data;
for (var j = 0; j < height; j++)
{
for (var i = 0; i < width; i++)
{
dst[nIndexDst] = 0;
nIndexDst += 4;
}
nIndexDst += nPitch;
}
}
return ret;
}
function CGlyphData()
{
this.m_oCanvas = null;
......@@ -794,10 +894,12 @@ function TGlyph()
function TBBox()
{
this.fMinX;
this.fMaxX;
this.fMinY;
this.fMaxY;
this.fMinX = 0;
this.fMaxX = 0;
this.fMinY = 0;
this.fMaxY = 0;
this.rasterDistances = null;
}
function TFontCacheSizes()
......@@ -1357,12 +1459,12 @@ function CFontManager()
return this.m_pFont.GetChar2(lUnicode);
}
this.MeasureChar = function(lUnicode)
this.MeasureChar = function(lUnicode, is_raster_distances)
{
if (!this.m_pFont)
return;
return this.m_pFont.GetChar(lUnicode);
return this.m_pFont.GetChar(lUnicode, is_raster_distances);
}
this.GetKerning = function(unPrevGID, unGID)
......
......@@ -314,14 +314,29 @@ function CTextMeasurer()
{
var Width = 0;
var Temp = this.m_oManager.MeasureChar( text.charCodeAt(0) );
var Temp = this.m_oManager.MeasureChar( text.charCodeAt(0), true );
Width = Temp.fAdvanceX * 25.4 / 72;
return { Width : Width, Ascent : (Temp.oBBox.fMaxY * 25.4 / 72), Height : ((Temp.oBBox.fMaxY - Temp.oBBox.fMinY) * 25.4 / 72),
WidthG: ((Temp.oBBox.fMaxX - Temp.oBBox.fMinX) * 25.4 / 72),
rasterOffsetX: Temp.oBBox.fMinX * 25.4 / 72,
rasterOffsetY: Temp.oBBox.fMinY * 25.4 / 72
if (Temp.oBBox.rasterDistances == null)
{
return {
Width : Width,
Ascent : (Temp.oBBox.fMaxY * 25.4 / 72),
Height : ((Temp.oBBox.fMaxY - Temp.oBBox.fMinY) * 25.4 / 72),
WidthG : ((Temp.oBBox.fMaxX - Temp.oBBox.fMinX) * 25.4 / 72),
rasterOffsetX: 0,
rasterOffsetY: 0
};
}
return {
Width : Width,
Ascent : (Temp.oBBox.fMaxY * 25.4 / 72),
Height : ((Temp.oBBox.fMaxY - Temp.oBBox.fMinY) * 25.4 / 72),
WidthG : ((Temp.oBBox.fMaxX - Temp.oBBox.fMinX) * 25.4 / 72),
rasterOffsetX: Temp.oBBox.rasterDistances.dist_l * 25.4 / 72,
rasterOffsetY: Temp.oBBox.rasterDistances.dist_t * 25.4 / 72
};
}
......@@ -333,7 +348,7 @@ function CTextMeasurer()
var Temp = this.m_oManager.MeasureChar( lUnicode );
Width = Temp.fAdvanceX * 25.4 / 72;
Height = 0;//Temp.fHeight;
Height = ((Temp.oBBox.fMaxY - Temp.oBBox.fMinY) * 25.4 / 72);
return { Width : Width, Height : Height };
}
......@@ -341,14 +356,29 @@ function CTextMeasurer()
{
var Width = 0;
var Temp = this.m_oManager.MeasureChar( lUnicode );
var Temp = this.m_oManager.MeasureChar( lUnicode, true );
Width = Temp.fAdvanceX * 25.4 / 72;
return { Width : Width, Ascent : (Temp.oBBox.fMaxY * 25.4 / 72), Height : ((Temp.oBBox.fMaxY - Temp.oBBox.fMinY) * 25.4 / 72),
WidthG: ((Temp.oBBox.fMaxX - Temp.oBBox.fMinX) * 25.4 / 72),
rasterOffsetX: Temp.oBBox.fMinX * 25.4 / 72,
rasterOffsetY: Temp.oBBox.fMinY * 25.4 / 72
if (Temp.oBBox.rasterDistances == null)
{
return {
Width : Width,
Ascent : (Temp.oBBox.fMaxY * 25.4 / 72),
Height : ((Temp.oBBox.fMaxY - Temp.oBBox.fMinY) * 25.4 / 72),
WidthG : ((Temp.oBBox.fMaxX - Temp.oBBox.fMinX) * 25.4 / 72),
rasterOffsetX: 0,
rasterOffsetY: 0
};
}
return {
Width : Width,
Ascent : (Temp.oBBox.fMaxY * 25.4 / 72),
Height : ((Temp.oBBox.fMaxY - Temp.oBBox.fMinY) * 25.4 / 72),
WidthG : ((Temp.oBBox.fMaxX - Temp.oBBox.fMinX) * 25.4 / 72),
rasterOffsetX: Temp.oBBox.rasterDistances.dist_l * 25.4 / 72,
rasterOffsetY: Temp.oBBox.rasterDistances.dist_t * 25.4 / 72
};
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment