Log in or register to post comments
Last post
How do you set default font and default font size?
Hi everyone

I'm using CKEditor 3.x and would like to know how I can change the defaut font and fontsize for the editor. I'd like to have it in Arial 12pt. Basically, I don't want the user to have any options, I would like to set a default via the config file.

Any ideas?

Thanks!
Jared
Re: How do you set default font and default font size?
the answer is inside the following API documentation
http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html#.font_style
Re: How do you set default font and default font size?
Thanks for the quick reply, I tried editing that and was unsuccessful. How can this be changed to make the default font Arial 12 pt font? Can you reply back with code correctly edited?

config.font_style =
{
element : 'span',
styles : { 'font-family' : '#(family)' },
overrides : [ { element : 'font', attributes : { 'face' : null } } ]
};

Thanks!
Re: How do you set default font and default font size?
try this....
config.font_defaultLabel = 'Arial';
config.fontSize_defaultLabel = '12px';
Re: How do you set default font and default font size?
Unfortunately, this does not work. Those two lines of code just set the default drop down values for the font and font size drop downs (if you have them enabled). In my case, the font and font size are not user selectable. This does not actually set the font and font size.

Any other ideas?
Re: How do you set default font and default font size?
You're right, I tried it myself and it didn't work for me. Not sure why, maybe someone else knows...I even found the following post with the same issue:
URL
viewtopic.php?f=11&t=16251
Re: How do you set default font and default font size?
Have you tried modifying the font styles in the contents.css file? Sometimes CSS change are stickier than you would think, try Shift+Refresh. Sometimes you even have to do that a couple of times.
Re: How do you set default font and default font size?
The CSS file already had the correct configuration (Arial, 12 pt). Even when I edited it to show font size 20 and made sure to refresh a few times, the font size in the editor did not change.

Anyone else have any ideas?

Thanks!
Re: How do you set default font and default font size?
Adding a contents.css did the trick for setting the default font and size:

body {
   font-family: Arial;
   font-size: 12px;
}


But setting

config.font_defaultLabel = 'Arial';
config.fontSize_defaultLabel = '12px';   


In the config.js file did nothing. The font and size drop-downs do not have any values selected.

Any ideas, anyone?
Re: How do you set default font and default font size?
Thank you! Editing contents.css with what you put worked!!
Re: How do you set default font and default font size?

But setting
Code: Select all
    config.font_defaultLabel = 'Arial';
    config.fontSize_defaultLabel = '12px';   




Sounds like a bug to me. I would check if this issue hasn't been logged already and if not, log a point.
Re: How do you set default font and default font size?
paulwesson wrote:Adding a contents.css did the trick for setting the default font and size:

body {
   font-family: Arial;
   font-size: 12px;
}



This sounds like what I need to simply change the font used in the editor to Arial by default. Where is this contents.css file?
Re: How do you set default font and default font size?
Me too having this problem I tried to change every bit of css code trying to change the default font but I couldn't :roll: .. I see somebody solve this dilemma and change it by editing (contents.css) but I can't find this file. Where it is?! .. I tried to make it but nothing happen.
Re: How do you set default font and default font size?
Solution:
It took me quite a while to figure this out.
Let us say you want to use Verdana as the default font. Here is what you can do:

1. Open contents.css and change the font tag:
font-family: Verdana;

2. In the application/page where the output will be published, add this style:
<style>
.entry-content {font-family: Tahoma;}
</style>

That's it! Now you have change the default font successfully. This works for the font size as well. I just finished developing this question2answer site, بنات بنات, which utilizes CKEditor and this tiny issue kept me awake for two days!
Re: How do you set default font and default font size?
Hi there,

This is working great in IE but not in Firefox.

Can we set a pre-defined font and font size for Firefox browser?

Please advise.

Thanks, Kris
Yes but if your font family

Yes but if your font family is a variable, how do you do ?

http://stackoverflow.com/questions/16339258/ckeditor-4-how-to-set-default-font