htmlArea

A directory of browser-based WYSIWYG editors

  MAIN
INDEX
SEARCH
POSTS
WHO'S
ONLINE
LOG
IN

Home: htmlArea 3 (beta): htmlArea 2 & 3 archive (read only): htmlArea v3.0 - Discussion:
Default font and Font size


The htmlArea 2 & 3 editors have been discontinued.

We've made these forums available as a read-only reference and knowledge-base for people using or developing editors based on htmlArea 2 or 3.

Anyone who is interested in taking over version 2 or 3 is free to do so. All we ask is that you choose a new name that doesn't have "htmlarea" in it to avoid confusion with this site. We'll even give you a link in the directory to make it easier for people to find you. If you are developing or hosting an htmlArea based-editor under a new name, please submit it to our directory.

 


pt2002
Novice

Apr 28, 2004, 9:06 AM

Post #1 of 21 (10244 views)
Shortcut
Default font and Font size Can't Post

Hello

Sorry this newbie questions.
Is there anyway to set default font to other than Times New Roman?
Can the font size be in px rather than pt?

Thanks in advance.

Greetings
pt2002


hubertus
User

Apr 28, 2004, 1:28 PM

Post #2 of 21 (10233 views)
Shortcut
Re: [pt2002] Default font and Font size [In reply to] Can't Post

Hi,

read this thread:
http://www.interactivetools.com/forum/gforum.cgi?post=26609;search_string=Change%20standard%20fontname%20and%20size;t=search_engine#26609

Hubertus
----------------------
CMS with HTMLArea (Username: testuser Password: test):
http://www.sundes.de/sundes_wcg/
HTMLArea direct(choose "Textinhalt"):
http://www.sundes.de/cgi-bin/sundes_wcg/egert.pl?layout&kundendir=gastzugang&idlog=RMNaNcMRMcLa2NP

http://www.sundes.de - http://www.hubertus-egert.de


pt2002
Novice

Apr 29, 2004, 3:23 AM

Post #3 of 21 (10222 views)
Shortcut
Re: [hubertus] Default font and Font size [In reply to] Can't Post

Hello

Thank you very much Hubertus.

One more question. You said in one message that you've changed the font size from pt to px. How can I do that? I took a look to the code but couldn't figure it out.

Greetings
pt2002


hubertus
User

Apr 29, 2004, 4:12 AM

Post #4 of 21 (10216 views)
Shortcut
Re: [pt2002] Default font and Font size [In reply to] Can't Post

Hi,

changing to px isn't easy to do, cause IE inserts font tags with size=1-7 which are corresponding to pt-sizes.
So I wrote a _getInput and a _updateOutput function which transforms font tags with size=1-7 in span tags with px values and back.

Code
HTMLArea.prototype._getInput = function(iscontent) { 
var editor=this;
var contents;
contents = (iscontent && iscontent != "") ? iscontent : editor._textArea.value;

...

var stoppen=0;
var sizesuch = /(<span style="font-size:(.*?px);">(.*?)<\/span>)/i;
while (sizesuch.exec(contents)) {
stoppen++;
var options = editor.config["fontsize"];
for (var j in options) {
if (j == RegExp.$2) {
contents = contents.replace(RegExp.$1, '<FONT size='+options[j]+'>'+RegExp.$3+'</FONT>');
break;
}
}
if (stoppen > 50)break;
}

...

return contents;
};

HTMLArea.prototype._updateOutput = function(iscontent) {
var editor=this;
var contents;
contents = (iscontent && iscontent != "")? iscontent : editor.getHTML();

...

contents = contents.replace(/<FONT([^>]+?)(\ssize="?\d"?)([^>]*?)>(.*?)<\/FONT>/gim, "<FONT$1$3><FONT$2>$4</FONT></FONT>");
var stoppen=0;
var sizesuch = /((<FONT\ssize="?(\d)"?>)(.*?)<\/FONT>)/i;
while (sizesuch.exec(contents)) {
stoppen++;
var setz1 = RegExp.$1;
var setz2 = RegExp.$2;
var setz3 = RegExp.$3;
var setz4 = RegExp.$4;
if (RegExp.$4.match(/<FONT/i)) {
if (setz4.match(/(<FONT\ssize="?(\d)"?>)/i)) {
var options = editor.config["fontsize"];
for (var j in options) {
if (options[j] == RegExp.$2) {
setz4 = setz4.replace(RegExp.$1, '<span style="font-size:'+j+';">');
contents = contents.replace(setz1, setz2+setz4+"</span>");
break;
}
}
}
else {
setz4 = setz4.replace(/<FONT/i, "<NO_T_YET");
contents = contents.replace(setz1, setz2+setz4+"</NO_T_YET>");
}
}
else {
var options = editor.config["fontsize"];
for (var j in options) {
if (options[j] == setz3) {
contents = contents.replace(setz1, '<span style="font-size:'+j+';">'+setz4+'</span>');
break;
}
}
}
if (stoppen > 100)break;
}
contents = contents.replace(/NO_T_YET/gi, "FONT");
contents = contents.replace(/<FONT[^>]*?><\/FONT>/gi, "");
contents = contents.replace(/<FONT>(.*?)<\/FONT>/gi, "$1");

...

return contents;
}


for this in "HTMLArea.Config = function ()" I use:

Code
	this.fontsize = { 
"10px": "1",
"13px": "2",
"16px": "3",
"18px": "4",
"21px": "5",
"31px": "6",
"47px": "7"
};


There might be a better code, but this is working for me...

Hubertus
----------------------
CMS with HTMLArea (Username: testuser Password: test):
http://www.sundes.de/sundes_wcg/
HTMLArea direct(choose "Textinhalt"):
http://www.sundes.de/cgi-bin/sundes_wcg/egert.pl?layout&kundendir=gastzugang&idlog=RMNaNcMRMcLa2NP

http://www.sundes.de - http://www.hubertus-egert.de


pt2002
Novice

Apr 29, 2004, 8:52 AM

Post #5 of 21 (10210 views)
Shortcut
Re: [hubertus] Default font and Font size [In reply to] Can't Post

Hi.

Thanky very much.

I guess that copying and pasting your code into htmlarea.js isn't enough.
what else must be added? I've tried but after submit it still showing <font face... size="2"> and not the <span>...</span> tags.

Greetings
pt2002


hubertus
User

Apr 29, 2004, 9:58 AM

Post #6 of 21 (10204 views)
Shortcut
Re: [pt2002] Default font and Font size [In reply to] Can't Post

Hi,

thats right...
You have to replace
editor._textArea.value = editor.getHTML();
with
editor._textArea.value = editor._updateOutput(editor.getHTML());
or
editor._textArea.value = editor._updateOutput();
and
this._textArea.value = this.getHTML();
with
this._textArea.value = this._updateOutput(this.getHTML());
or
this._textArea.value = this._updateOutput();
My htmlarea is different, so I can't tell you the linenumbers.
Also you have to replace
html += editor._textArea.value;
with
html += editor._getInput(editor._textArea.value);
or
html += editor._getInput();
and
var html = editor._textArea.value;
width
var html = editor._getInput(editor._textArea.value);
or
var html = editor._getInput();

Hubertus
----------------------
CMS with HTMLArea (Username: testuser Password: test):
http://www.sundes.de/sundes_wcg/
HTMLArea direct(choose "Textinhalt"):
http://www.sundes.de/cgi-bin/sundes_wcg/egert.pl?layout&kundendir=gastzugang&idlog=RMNaNcMRMcLa2NP

http://www.sundes.de - http://www.hubertus-egert.de


pt2002
Novice

Apr 29, 2004, 11:30 AM

Post #7 of 21 (10197 views)
Shortcut
Re: [pt2002] Default font and Font size [In reply to] Can't Post

Hello Hubertus

Thank you very much for your help. It's working fine!

Greetings
pt2002


pt2002
Novice

Apr 30, 2004, 3:34 AM

Post #8 of 21 (10184 views)
Shortcut
Re: [pt2002] Default font and Font size [In reply to] Can't Post

Heelo Hubertus

Sorry bother you again
You post this in the thread you tell me to read:

"Some notes to your setting:
this.pageStyle = "p {font-size:13px;font:Verdana}";
If you want your font-size to show in the toolbar you should use pt instead of px (my error, cause I changed the selector in my htmlArea for px).
In my test font:Verdana didn't work.
I tried also font: 13px Verdana, which is the correct use, cause font is in css a summary notation for font-size, font-style, font-variant, font-family, font-weight and line-height.
It also didn't work.
But your-tags{font-size:your-font-size;font-family:your-font-family} works. "



I've changed the code and it allright wih fontsize in px.
Now, I would like to start the htmlarea width verdana 13px and show it in the combo box but it starts with 10px. Is it possible to do what I need?

Greetings
pt2002


hubertus
User

Apr 30, 2004, 3:50 AM

Post #9 of 21 (10182 views)
Shortcut
Re: [pt2002] Default font and Font size [In reply to] Can't Post

Hi,

try this in your update toolbar function:

Code
		    case "fontname": 
case "fontsize":
case "formatblock":
if (!text) {
var value = ("" + doc.queryCommandValue(cmd)).toLowerCase();
if (!value || value=="null") {
if (cmd=="fontsize") { // Sundes(Hubertus Egert) <info@sundes.de>
var suchwas = doc.queryCommandValue("formatblock");
var such = suchwas.substr(suchwas.length-1,1);
if (such>0 && such<7) value = 7-such;
else value= 2;
value=value.toString();
}
else if (cmd=="fontname") {
btn.element.selectedIndex = 5;
break;
}
else {
btn.element.selectedIndex = 0;
break;
}
}
var options = this.config; // HACK!!
var k = 0;
for (var j in options) {
// FIXME: the following line is scary.
if (j.toLowerCase() == value || j.substr(0, value.length).toLowerCase() == value || options[j].substr(0, value.length).toLowerCase() == value) { // Hubertus Egert (sundes) <info@sundes.de>
btn.element.selectedIndex = k;
break;
}
++k;
}
}
break;


Hubertus
----------------------
CMS with HTMLArea (Username: testuser Password: test):
http://www.sundes.de/sundes_wcg/
HTMLArea direct(choose "Textinhalt"):
http://www.sundes.de/cgi-bin/sundes_wcg/egert.pl?layout&kundendir=gastzugang&idlog=RMNaNcMRMcLa2NP

http://www.sundes.de - http://www.hubertus-egert.de


pt2002
Novice

Apr 30, 2004, 7:09 AM

Post #10 of 21 (10181 views)
Shortcut
Re: [hubertus] Default font and Font size [In reply to] Can't Post

Hi Hubertus

Thank you very much again. Have a nice weekend.

Greetings
pt2002


barn
Novice

May 19, 2004, 8:10 AM

Post #11 of 21 (9901 views)
Shortcut
Re: [hubertus] Default font and Font size [In reply to] Can't Post

Hi,

I'm pretty new to this kind of stuff... and I have a question...

How do I implement the functions, described above?

I did a hard copy/paste of the code in the editor.js at the bottom of the file, and I changed the default config this.fontsizes...

and i cannot find the phrases i'd have to replace... and I have an editor.js instead of an htmlarea.js

Please help?


hubertus
User

May 19, 2004, 8:20 AM

Post #12 of 21 (9898 views)
Shortcut
Re: [barn] Default font and Font size [In reply to] Can't Post

If you have editor.js, you are working with v2.0!
This is for v3.0 only!

Hubertus
----------------------
CMS with HTMLArea (Username: testuser Password: test):
http://www.sundes.de/sundes_wcg/
HTMLArea direct(choose "Textinhalt"):
http://www.sundes.de/cgi-bin/sundes_wcg/egert.pl?layout&kundendir=gastzugang&idlog=RMNaNcMRMcLa2NP

http://www.sundes.de - http://www.hubertus-egert.de


fiscus
New User

May 29, 2004, 5:46 AM

Post #13 of 21 (9681 views)
Shortcut
Re: [hubertus] Default font and Font size [In reply to] Can't Post

Is this code still applicable in thelatest version? If anyone has got this to work in the latest version can you please give me some step by step instructions on what to do? Thanks


barn
Novice

Jun 27, 2004, 9:16 AM

Post #14 of 21 (9365 views)
Shortcut
Re: [hubertus] Default font and Font size [In reply to] Can't Post

Ok, I followed instructions above now with HTMLArea 3 ;)

But it still doesn't work correctly... When I load HTMLArea it all works fine... I can change font size and so on, and if I'm correct it's also in correct pixels instead of points... but that i don't know for sure...

The HTML wich is inserted, when I load htmlarea for the first time befor putting it in a database, is:

<p>First standard line</p>

<p><span style="font-size:7 (36px);">Second 36px line</span></p>

<p><span style="font-size:1 (8px);">And the 3rd small line</span></p>

Then I put it in a database, and load it from the database back and then it shows:

<p>First standard line</p>

<p><span>Second 36px line</span></p>

<p><span>And the 3rd small line</span></p>

In the database it's stored without the style="font-... tags. So, there is something missing... Or I missed a detail of the explanation above...


barn
Novice

Jun 27, 2004, 9:35 AM

Post #15 of 21 (9364 views)
Shortcut
Re: [barn] Default font and Font size [In reply to] Can't Post

I allready solved my own problem...

the config.fontsize should have been "10px" instead of "2 (10px)"


def9999
New User

Oct 31, 2004, 5:21 PM

Post #16 of 21 (8201 views)
Shortcut
Re: [hubertus] Default font and Font size [In reply to] Can't Post

Hi,hubertus:

That's greatLaugh!!! I followeed these steps,and it worked very nice.But I still have one problem.......your code transfers pt into px,

but dont has 12px......only 13px......

sorry for that......it's beause I use Chines,so we really need 12pxUnsure......could you help me to solve the problem,please.


(This post was edited by def9999 on Oct 31, 2004, 5:25 PM)


hubertus
User

Nov 1, 2004, 8:18 AM

Post #17 of 21 (8178 views)
Shortcut
Re: [def9999] Default font and Font size [In reply to] Can't Post

Hi,

I think everything you have to do is to replace this part of code:

Code
	this.fontsize = { 
"10px": "1",
"13px": "2",
"16px": "3",
"18px": "4",
"21px": "5",
"31px": "6",
"47px": "7"
};

with this:

Code
	this.fontsize = { 
"10px": "1",
"12px": "2",
"16px": "3",
"18px": "4",
"21px": "5",
"31px": "6",
"47px": "7"
};


Hubertus
----------------------
CMS with HTMLArea (Username: testuser Password: test):
http://www.sundes.de/sundes_wcg/
HTMLArea direct(choose "Textinhalt"):
http://www.sundes.de/cgi-bin/sundes_wcg/egert.pl?layout&kundendir=gastzugang&idlog=RMNaNcMRMcLa2NP

http://www.sundes.de - http://www.hubertus-egert.de


def9999
New User

Nov 1, 2004, 10:29 AM

Post #18 of 21 (8167 views)
Shortcut
Re: [hubertus] Default font and Font size [In reply to] Can't Post

Hi,hubertus:

thanks for your replySmile.

I have done it,but the word in the way of 12px is still larger than which I set by css,what problem with it??

My English is really poorBlush,sorry for that!!Laugh


hubertus
User

Nov 1, 2004, 3:54 PM

Post #19 of 21 (8141 views)
Shortcut
Re: [def9999] Default font and Font size [In reply to] Can't Post

Hi,

my code does nothing as to replace the font-tags which come from htmlarea with span-tags and css-styles.
The correspondending css-size for <font size=2> is about 13px.
So if you now use 12px, you can't see this in htmlarea!
But the code which you save to your server has the span-tag with style="font-size:12px".

Hubertus
----------------------
CMS with HTMLArea (Username: testuser Password: test):
http://www.sundes.de/sundes_wcg/
HTMLArea direct(choose "Textinhalt"):
http://www.sundes.de/cgi-bin/sundes_wcg/egert.pl?layout&kundendir=gastzugang&idlog=RMNaNcMRMcLa2NP

http://www.sundes.de - http://www.hubertus-egert.de


JBone
New User

Nov 3, 2004, 6:05 PM

Post #20 of 21 (8005 views)
Shortcut
Re: [hubertus] Default font and Font size [In reply to] Can't Post

Hi Hubertus,

I have tried to implement the above coding into my htmlarea.js

I load it up and get a Javascript Error of HTMLArea Undefinied

I noticed you had replace blah with blah or blah.. Confused me there. Isnt it replace blah with blah? What is the second blah for? :)

I really would like to implement this to stop the Internet Explorer view textsize option. I think it would be great if Interactive Forums incorporated this into the editor.

Thank you!!

John


danyliscia
Novice

Nov 4, 2004, 3:21 AM

Post #21 of 21 (7974 views)
Shortcut
Re: [hubertus] Default font and Font size [In reply to] Can't Post

I apologize for going back to the default font issue.
The links of your message of Apr 28, 2004 are outdated and
I still don't understand who to set the default fonts in
htmlarea 3.0 (beta). I have incorporated the core.html example in my web page and I am using Firefox 1.0 (on Linux and WinXP)
I have the impression that once that you chage the content of the htmlarea box, the rendering is not updated correctly.

I would be grateful for a reply

Best regards

Daniel Liscia
danyliscia@libero.it

 
 
 


Search for (options)