Commit 7eba7b23 authored by Oleg.Korshul's avatar Oleg.Korshul Committed by Alexander.Trofimov

SetFontInternal for textMeasurer

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@63121 954022d7-b5bf-4e40-9824-e11837661b57
parent 21f5e662
...@@ -43,12 +43,17 @@ CTextMeasurerWrapper.prototype = ...@@ -43,12 +43,17 @@ CTextMeasurerWrapper.prototype =
else if ( bItalic && bBold ) else if ( bItalic && bBold )
oFontStyle = FontStyle.FontStyleBoldItalic; oFontStyle = FontStyle.FontStyleBoldItalic;
this.SetFontInternal(font.FontFamily.Name, font.FontSize, oFontStyle);
},
SetFontInternal : function(_name, _size, _style)
{
var _lastSetUp = this.m_oLastFont; var _lastSetUp = this.m_oLastFont;
if (_lastSetUp.SetUpName != font.FontFamily.Name || _lastSetUp.SetUpSize != font.FontSize || _lastSetUp.SetUpStyle != oFontStyle) if (_lastSetUp.SetUpName != _name || _lastSetUp.SetUpSize != _size || _lastSetUp.SetUpStyle != _style)
{ {
_lastSetUp.SetUpName = font.FontFamily.Name; _lastSetUp.SetUpName = _name;
_lastSetUp.SetUpSize = font.FontSize; _lastSetUp.SetUpSize = _size;
_lastSetUp.SetUpStyle = oFontStyle; _lastSetUp.SetUpStyle = _style;
var _fontinfo = g_fontApplication.GetFontInfo(_lastSetUp.SetUpName, _lastSetUp.SetUpStyle, this.LastFontOriginInfo); var _fontinfo = g_fontApplication.GetFontInfo(_lastSetUp.SetUpName, _lastSetUp.SetUpStyle, this.LastFontOriginInfo);
var _info = GetLoadInfoForMeasurer(_fontinfo, _lastSetUp.SetUpStyle); var _info = GetLoadInfoForMeasurer(_fontinfo, _lastSetUp.SetUpStyle);
...@@ -135,29 +140,7 @@ CTextMeasurerWrapper.prototype = ...@@ -135,29 +140,7 @@ CTextMeasurerWrapper.prototype =
if (_lastFont.Bold) if (_lastFont.Bold)
_style += 1; _style += 1;
if (_lastFont.Name != _lastFont.SetUpName || _lastFont.Size != _lastFont.SetUpSize || _style != _lastFont.SetUpStyle) this.SetFontInternal(_lastFont.Name, _lastFont.Size, _style);
{
_lastFont.SetUpName = _lastFont.Name;
_lastFont.SetUpSize = _lastFont.Size;
_lastFont.SetUpStyle = _style;
var _fontinfo = g_fontApplication.GetFontInfo(_lastFont.SetUpName, _lastFont.SetUpStyle, this.LastFontOriginInfo);
var _info = GetLoadInfoForMeasurer(_fontinfo, _lastFont.SetUpStyle);
var flag = 0;
if (_info.NeedBold) flag |= 0x01;
if (_info.NeedItalic) flag |= 0x02;
if (_info.SrcBold) flag |= 0x04;
if (_info.SrcItalic) flag |= 0x08;
var _bounds = this.Measurer["LoadFont"](_info.Path, _info.FaceIndex, _lastFont.SetUpSize, flag);
this.UnitsPerEm = _bounds[3];
var dKoef = g_dKoef_pt_to_mm * _lastFont.SetUpSize / this.UnitsPerEm;
this.Ascender = _bounds[0] * dKoef;
this.Descender = _bounds[1] * dKoef;
this.Height = _bounds[2] * dKoef;
}
}, },
GetTextPr : function() GetTextPr : function()
......
...@@ -154,7 +154,7 @@ function CTextMeasurer() ...@@ -154,7 +154,7 @@ function CTextMeasurer()
this.Init = function() this.Init = function()
{ {
this.m_oManager.Initialize(); this.m_oManager.Initialize();
} };
this.SetFont = function(font) this.SetFont = function(font)
{ {
...@@ -183,7 +183,20 @@ function CTextMeasurer() ...@@ -183,7 +183,20 @@ function CTextMeasurer()
g_fontApplication.LoadFont(_lastSetUp.SetUpName, window.g_font_loader, this.m_oManager, _lastSetUp.SetUpSize, _lastSetUp.SetUpStyle, 72, 72, undefined, this.LastFontOriginInfo); g_fontApplication.LoadFont(_lastSetUp.SetUpName, window.g_font_loader, this.m_oManager, _lastSetUp.SetUpSize, _lastSetUp.SetUpStyle, 72, 72, undefined, this.LastFontOriginInfo);
} }
} };
this.SetFontInternal = function(_name, _size, _style)
{
var _lastSetUp = this.m_oLastFont;
if (_lastSetUp.SetUpName != _name || _lastSetUp.SetUpSize != _size || _lastSetUp.SetUpStyle != _style)
{
_lastSetUp.SetUpName = _name;
_lastSetUp.SetUpSize = _size;
_lastSetUp.SetUpStyle = _style;
g_fontApplication.LoadFont(_lastSetUp.SetUpName, window.g_font_loader, this.m_oManager, _lastSetUp.SetUpSize, _lastSetUp.SetUpStyle, 72, 72, undefined, this.LastFontOriginInfo);
}
};
this.SetTextPr = function(textPr, theme) this.SetTextPr = function(textPr, theme)
{ {
...@@ -194,7 +207,7 @@ function CTextMeasurer() ...@@ -194,7 +207,7 @@ function CTextMeasurer()
this.m_oTextPr.RFonts.EastAsia = {Name: FontScheme.checkFont(this.m_oTextPr.RFonts.EastAsia.Name), Index: -1}; this.m_oTextPr.RFonts.EastAsia = {Name: FontScheme.checkFont(this.m_oTextPr.RFonts.EastAsia.Name), Index: -1};
this.m_oTextPr.RFonts.HAnsi = {Name: FontScheme.checkFont(this.m_oTextPr.RFonts.HAnsi.Name), Index: -1}; this.m_oTextPr.RFonts.HAnsi = {Name: FontScheme.checkFont(this.m_oTextPr.RFonts.HAnsi.Name), Index: -1};
this.m_oTextPr.RFonts.CS = {Name: FontScheme.checkFont(this.m_oTextPr.RFonts.CS.Name), Index: -1}; this.m_oTextPr.RFonts.CS = {Name: FontScheme.checkFont(this.m_oTextPr.RFonts.CS.Name), Index: -1};
} };
this.SetFontSlot = function(slot, fontSizeKoef) this.SetFontSlot = function(slot, fontSizeKoef)
{ {
...@@ -267,17 +280,17 @@ function CTextMeasurer() ...@@ -267,17 +280,17 @@ function CTextMeasurer()
g_fontApplication.LoadFont(_lastFont.SetUpName, window.g_font_loader, this.m_oManager, _lastFont.SetUpSize, _lastFont.SetUpStyle, 72, 72, undefined, this.LastFontOriginInfo); g_fontApplication.LoadFont(_lastFont.SetUpName, window.g_font_loader, this.m_oManager, _lastFont.SetUpSize, _lastFont.SetUpStyle, 72, 72, undefined, this.LastFontOriginInfo);
} }
} };
this.GetTextPr = function() this.GetTextPr = function()
{ {
return this.m_oTextPr; return this.m_oTextPr;
} };
this.GetFont = function() this.GetFont = function()
{ {
return this.m_oFont; return this.m_oFont;
} };
this.Measure = function(text) this.Measure = function(text)
{ {
...@@ -294,7 +307,7 @@ function CTextMeasurer() ...@@ -294,7 +307,7 @@ function CTextMeasurer()
Height = 0;//Temp.fHeight; Height = 0;//Temp.fHeight;
return { Width : Width, Height : Height }; return { Width : Width, Height : Height };
} };
this.Measure2 = function(text) this.Measure2 = function(text)
{ {
var Width = 0; var Width = 0;
...@@ -309,7 +322,7 @@ function CTextMeasurer() ...@@ -309,7 +322,7 @@ function CTextMeasurer()
return { Width : Width, Ascent : (Temp.oBBox.fMaxY * 25.4 / 72), Height : ((Temp.oBBox.fMaxY - Temp.oBBox.fMinY) * 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)}; WidthG: ((Temp.oBBox.fMaxX - Temp.oBBox.fMinX) * 25.4 / 72)};
} };
this.MeasureCode = function(lUnicode) this.MeasureCode = function(lUnicode)
{ {
...@@ -325,7 +338,7 @@ function CTextMeasurer() ...@@ -325,7 +338,7 @@ function CTextMeasurer()
Height = 0;//Temp.fHeight; Height = 0;//Temp.fHeight;
return { Width : Width, Height : Height }; return { Width : Width, Height : Height };
} };
this.Measure2Code = function(lUnicode) this.Measure2Code = function(lUnicode)
{ {
var Width = 0; var Width = 0;
...@@ -339,7 +352,7 @@ function CTextMeasurer() ...@@ -339,7 +352,7 @@ function CTextMeasurer()
return { Width : Width, Ascent : (Temp.oBBox.fMaxY * 25.4 / 72), Height : ((Temp.oBBox.fMaxY - Temp.oBBox.fMinY) * 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)}; WidthG: ((Temp.oBBox.fMaxX - Temp.oBBox.fMinX) * 25.4 / 72)};
} };
this.GetAscender = function() this.GetAscender = function()
{ {
...@@ -347,21 +360,21 @@ function CTextMeasurer() ...@@ -347,21 +360,21 @@ function CTextMeasurer()
var Ascender = this.m_oManager.m_lAscender; var Ascender = this.m_oManager.m_lAscender;
return Ascender * this.m_oLastFont.SetUpSize / UnitsPerEm * g_dKoef_pt_to_mm; return Ascender * this.m_oLastFont.SetUpSize / UnitsPerEm * g_dKoef_pt_to_mm;
} };
this.GetDescender = function() this.GetDescender = function()
{ {
var UnitsPerEm = this.m_oManager.m_lUnits_Per_Em; var UnitsPerEm = this.m_oManager.m_lUnits_Per_Em;
var Descender = this.m_oManager.m_lDescender; var Descender = this.m_oManager.m_lDescender;
return Descender * this.m_oLastFont.SetUpSize / UnitsPerEm * g_dKoef_pt_to_mm; return Descender * this.m_oLastFont.SetUpSize / UnitsPerEm * g_dKoef_pt_to_mm;
} };
this.GetHeight = function() this.GetHeight = function()
{ {
var UnitsPerEm = this.m_oManager.m_lUnits_Per_Em; var UnitsPerEm = this.m_oManager.m_lUnits_Per_Em;
var Height = this.m_oManager.m_lLineHeight; var Height = this.m_oManager.m_lLineHeight;
return Height * this.m_oLastFont.SetUpSize / UnitsPerEm * g_dKoef_pt_to_mm; return Height * this.m_oLastFont.SetUpSize / UnitsPerEm * g_dKoef_pt_to_mm;
} };
} }
var g_oTextMeasurer = new CTextMeasurer(); var g_oTextMeasurer = new CTextMeasurer();
......
...@@ -310,7 +310,7 @@ function CTextMeasurer() ...@@ -310,7 +310,7 @@ function CTextMeasurer()
this.Init = function() this.Init = function()
{ {
this.m_oManager.Initialize(); this.m_oManager.Initialize();
} };
this.SetFont = function(font) this.SetFont = function(font)
{ {
...@@ -339,7 +339,20 @@ function CTextMeasurer() ...@@ -339,7 +339,20 @@ function CTextMeasurer()
g_fontApplication.LoadFont(_lastSetUp.SetUpName, window.g_font_loader, this.m_oManager, _lastSetUp.SetUpSize, _lastSetUp.SetUpStyle, 72, 72, undefined, this.LastFontOriginInfo); g_fontApplication.LoadFont(_lastSetUp.SetUpName, window.g_font_loader, this.m_oManager, _lastSetUp.SetUpSize, _lastSetUp.SetUpStyle, 72, 72, undefined, this.LastFontOriginInfo);
} }
} };
this.SetFontInternal = function(_name, _size, _style)
{
var _lastSetUp = this.m_oLastFont;
if (_lastSetUp.SetUpName != _name || _lastSetUp.SetUpSize != _size || _lastSetUp.SetUpStyle != _style)
{
_lastSetUp.SetUpName = _name;
_lastSetUp.SetUpSize = _size;
_lastSetUp.SetUpStyle = _style;
g_fontApplication.LoadFont(_lastSetUp.SetUpName, window.g_font_loader, this.m_oManager, _lastSetUp.SetUpSize, _lastSetUp.SetUpStyle, 72, 72, undefined, this.LastFontOriginInfo);
}
};
this.SetTextPr = function(textPr, theme) this.SetTextPr = function(textPr, theme)
{ {
......
...@@ -189,6 +189,19 @@ function CTextMeasurer() ...@@ -189,6 +189,19 @@ function CTextMeasurer()
} }
}; };
this.SetFontInternal = function(_name, _size, _style)
{
var _lastSetUp = this.m_oLastFont;
if (_lastSetUp.SetUpName != _name || _lastSetUp.SetUpSize != _size || _lastSetUp.SetUpStyle != _style)
{
_lastSetUp.SetUpName = _name;
_lastSetUp.SetUpSize = _size;
_lastSetUp.SetUpStyle = _style;
g_fontApplication.LoadFont(_lastSetUp.SetUpName, window.g_font_loader, this.m_oManager, _lastSetUp.SetUpSize, _lastSetUp.SetUpStyle, 72, 72, undefined, this.LastFontOriginInfo);
}
};
this.SetTextPr = function(textPr, theme) this.SetTextPr = function(textPr, theme)
{ {
this.m_oTextPr = textPr; this.m_oTextPr = textPr;
......
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