Commit d44977c2 authored by Sergey.Konovalov's avatar Sergey.Konovalov Committed by Alexander.Trofimov

g_fontApplication.GetFontNameDictionary для преобразования html fontFamily в имя шрифта

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@61176 954022d7-b5bf-4e40-9824-e11837661b57
parent ea03bc36
...@@ -2875,7 +2875,7 @@ function CApplicationFonts() ...@@ -2875,7 +2875,7 @@ function CApplicationFonts()
else else
sFontname = sFontFamily; sFontname = sFontFamily;
//trim { }, {'}, {"} //trim { }, {'}, {"}
sFontname = sFontname.replace(/^[\s|'|"]+|[\s|'|"]+$/g, ''); sFontname = sFontname.replace(/^[\s'"]+|[\s'"]+$/g, '');
if (0 == sFontname.length) if (0 == sFontname.length)
{ {
if (true === bDontReturnDef) if (true === bDontReturnDef)
...@@ -2897,14 +2897,14 @@ function CApplicationFonts() ...@@ -2897,14 +2897,14 @@ function CApplicationFonts()
else else
{ {
var oSelect = new CFontSelectFormat(); var oSelect = new CFontSelectFormat();
oSelect.wsName = sFontFamily; oSelect.wsName = sFontname;
this.g_fontDictionary.CorrectParamsFromDictionary(oSelect); this.g_fontDictionary.CorrectParamsFromDictionary(oSelect);
if (null != oSelect.pPanose) if (null != oSelect.pPanose)
return oSelect.wsName; return oSelect.wsName;
else else
{ {
g_fontApplication.GetFontInfoName(sFontFamily); return g_fontApplication.GetFontInfoName(sFontname);
} }
} }
} }
......
...@@ -4983,35 +4983,7 @@ PasteProcessor.prototype = ...@@ -4983,35 +4983,7 @@ PasteProcessor.prototype =
if ( computedStyle ) if ( computedStyle )
{ {
var fontFamily = computedStyle.getPropertyValue( "font-family" ); var fontFamily = computedStyle.getPropertyValue( "font-family" );
var sNewFF; this.oFonts[fontFamily] = {Name: g_fontApplication.GetFontNameDictionary(fontFamily, true), Index: -1};
var nIndex = fontFamily.indexOf(",");
if(-1 != nIndex)
sNewFF = fontFamily.substring(0, nIndex);
else
sNewFF = fontFamily;
//trim ' � "
var nLength = sNewFF.length
if(nLength >= 2)
{
var nStart = 0;
var nStop = nLength;
var cFirstChar = sNewFF[0];
var cLastChar = sNewFF[nLength - 1];
var bTrim = false;
if('\'' == cFirstChar || '\"' == cFirstChar)
{
bTrim = true;
nStart = 1;
}
if('\'' == cLastChar || '\"' == cLastChar)
{
bTrim = true;
nStop = nLength - 1;
}
if(bTrim)
sNewFF = sNewFF.substring(nStart, nStop);
}
this.oFonts[fontFamily] = {Name:sNewFF, Index: -1};
} }
} }
else else
......
...@@ -1267,7 +1267,7 @@ ...@@ -1267,7 +1267,7 @@
oNewItem.text = jqSpanObject.text().replace(/(\r|\t|\n|)/g,''); oNewItem.text = jqSpanObject.text().replace(/(\r|\t|\n|)/g,'');
oNewItem.format = {}; oNewItem.format = {};
oNewItem.format.fn = this._checkFonts(spanObject.style.fontFamily.replace(/'/g,"").split(',')[0]); oNewItem.format.fn = g_fontApplication.GetFontNameDictionary(spanObject.style.fontFamily, true);
if (oNewItem.format.fn == null || oNewItem.format.fn == '') if (oNewItem.format.fn == null || oNewItem.format.fn == '')
oNewItem.format.fn = 'Calibri'; oNewItem.format.fn = 'Calibri';
...@@ -1976,7 +1976,6 @@ ...@@ -1976,7 +1976,6 @@
for(var i in oFonts) for(var i in oFonts)
{ {
fontName = oFonts[i].Name; fontName = oFonts[i].Name;
fontName = this._checkFonts(fontName);
newFonts[fontName] = 1; newFonts[fontName] = 1;
}; };
return newFonts; return newFonts;
...@@ -3072,10 +3071,9 @@ ...@@ -3072,10 +3071,9 @@
if(elem.getAttribute != undefined && elem.getAttribute("class") == "qPrefix") if(elem.getAttribute != undefined && elem.getAttribute("class") == "qPrefix")
parent = elem; parent = elem;
var style = window.getComputedStyle(parent); var style = window.getComputedStyle(parent);
var fn = getFontName(style); var fn = g_fontApplication.GetFontNameDictionary(style.fontFamily, false);
if(fn == '') if(fn == '')
fn = parent.style.fontFamily.replace(/'/g,""); fn = g_fontApplication.GetFontNameDictionary(parent.style.fontFamily, true);
fn = t._checkFonts(fn);
var fs = Math.round(getFontSize(style)); var fs = Math.round(getFontSize(style));
var fb = style.fontWeight.toLowerCase(); var fb = style.fontWeight.toLowerCase();
var fi = style.fontStyle.toLowerCase(); var fi = style.fontStyle.toLowerCase();
...@@ -3162,29 +3160,6 @@ ...@@ -3162,29 +3160,6 @@
return res; return res;
}, },
_checkFonts: function (fontName) {
//var defaultFont = 'Arial';
var defaultFont = 'Calibri';
if (null === this.Api)
return defaultFont;
if(this.Api.FontLoader.map_font_index[fontName] != undefined)
return fontName;
var arrName = fontName.toLowerCase().split(' ');
var newFontName = '';
for(var i = 0;i < arrName.length;i++)
{
arrName[i] = arrName[i].substr(0,1).toUpperCase() + arrName[i].substr(1).toLowerCase();
if(i == arrName.length - 1)
newFontName += arrName[i];
else
newFontName += arrName[i] + ' ';
}
if(this.Api.FontLoader.map_font_index[newFontName] != undefined)
return newFontName;
else
return defaultFont;
},
_encode : function (input) { _encode : function (input) {
return Base64.encode(input).replace(/\//g, "_s").replace(/\+/g, "_p").replace(/=/g, "_e"); return Base64.encode(input).replace(/\//g, "_s").replace(/\+/g, "_p").replace(/=/g, "_e");
}, },
......
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