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()
else
sFontname = sFontFamily;
//trim { }, {'}, {"}
sFontname = sFontname.replace(/^[\s|'|"]+|[\s|'|"]+$/g, '');
sFontname = sFontname.replace(/^[\s'"]+|[\s'"]+$/g, '');
if (0 == sFontname.length)
{
if (true === bDontReturnDef)
......@@ -2897,14 +2897,14 @@ function CApplicationFonts()
else
{
var oSelect = new CFontSelectFormat();
oSelect.wsName = sFontFamily;
oSelect.wsName = sFontname;
this.g_fontDictionary.CorrectParamsFromDictionary(oSelect);
if (null != oSelect.pPanose)
return oSelect.wsName;
else
{
g_fontApplication.GetFontInfoName(sFontFamily);
return g_fontApplication.GetFontInfoName(sFontname);
}
}
}
......
......@@ -4983,35 +4983,7 @@ PasteProcessor.prototype =
if ( computedStyle )
{
var fontFamily = computedStyle.getPropertyValue( "font-family" );
var sNewFF;
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};
this.oFonts[fontFamily] = {Name: g_fontApplication.GetFontNameDictionary(fontFamily, true), Index: -1};
}
}
else
......
......@@ -1267,7 +1267,7 @@
oNewItem.text = jqSpanObject.text().replace(/(\r|\t|\n|)/g,'');
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 == '')
oNewItem.format.fn = 'Calibri';
......@@ -1976,7 +1976,6 @@
for(var i in oFonts)
{
fontName = oFonts[i].Name;
fontName = this._checkFonts(fontName);
newFonts[fontName] = 1;
};
return newFonts;
......@@ -3072,10 +3071,9 @@
if(elem.getAttribute != undefined && elem.getAttribute("class") == "qPrefix")
parent = elem;
var style = window.getComputedStyle(parent);
var fn = getFontName(style);
var fn = g_fontApplication.GetFontNameDictionary(style.fontFamily, false);
if(fn == '')
fn = parent.style.fontFamily.replace(/'/g,"");
fn = t._checkFonts(fn);
fn = g_fontApplication.GetFontNameDictionary(parent.style.fontFamily, true);
var fs = Math.round(getFontSize(style));
var fb = style.fontWeight.toLowerCase();
var fi = style.fontStyle.toLowerCase();
......@@ -3162,29 +3160,6 @@
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) {
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