cancel
Showing results for 
Search instead for 
Did you mean: 

BTF: How to change default font

Former Member
0 Kudos

Hi there,

can somebody tell me how you can change the default font for the BTF editor? Default is TimesRoman and I want to use Arial...

already checked out editor_default.js and the CL_BTF_BSP_EDITOR, but cant find where to hack in

Thanks

Gerald

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos
Hi,

the editor's default font and size is readed from browser settings:
    • - IE: Tools => Internet Options => Fonts

    • - Firefox: Tools => Options => Content




This configuration is set up with javascript code (editor_default.js)

function UpdateUI_BTFEditor(id)+ { ... var listbox = document.getElementById("BTFEditor_FontName_"+id); if (listbox) listbox.value = doc.queryCommandValue("FontName");

listbox = document.getElementById("BTFEditor_FontSize_"+id); if (listbox) listbox.value = doc.queryCommandValue("FontSize"); }

queryCommandValue on IE http://msdn.microsoft.com/en-us/library/ms536683(VS.85).aspx

queryCommandValue on IE

Solution a) Redefine/Overwritte the event handler for select change (BTFEditor_OnSelectionChange_<%controller->component_id%>_btf1) b) Initialize BTF Editor's content with this code (MailBody.htm): <% DATA: lv_xcontent TYPE xstring, lv_content TYPE string, lv_encoding TYPE string, lv_lang TYPE tdspras, lr_conv TYPE REF TO CL_ABAP_CONV_IN_CE. s_documentdata-btf_doc->get_content( importing text = lv_xcontent encoding = lv_encoding language = lv_lang ). lr_conv = cl_abap_conv_in_ce=>create( input = lv_xcontent ). lr_conv->read( importing data = lv_content ). IF lv_content is not initial AND lv_content EQ '<HTML><HEAD><STYLE></STYLE></HEAD><BODY></BODY></HTML>'. lv_content = '<HTML><HEAD><STYLE></STYLE></HEAD><BODY style="font-family:Arial; font-size:10pt"></BODY></HTML>'. CALL FUNCTION 'SCMS_STRING_TO_XSTRING' EXPORTING text = lv_content IMPORTING buffer = lv_xcontent EXCEPTIONS failed = 1. s_documentdata-btf_doc->set_content( exporting text = lv_xcontent encoding = lv_encoding ). ENDIF. %>

Edited by: Alberto Martínez Galindo on Sep 2, 2009 12:54 PM

Edited by: Alberto Martínez Galindo on Sep 2, 2009 12:55 PM
Former Member
0 Kudos

This post was very helpful.

I had the same requirement and it worked.

This should be stickied somewhere.

eddy_declercq
Active Contributor
0 Kudos

Hi,

Pls check this forum thread

Eddy

Former Member
0 Kudos

Thanks Eddy for the interesting link. Hmm couldnt find my answer there though...

Actually I dont need to add or config a font. just changing the preselected font in the dropdownbox to Arial would be nice (It's about the BTF Extension within BSP).

Any ideas?

Thanks

Gerald

athavanraja
Active Contributor
0 Kudos

after the btf editor declaration in the layout add the highlighted java script

<btf:editor id                  = "btf1"
                      document            = "<%= btf_document_ds %>"
                      disabled            = "<%= disabled %>"
                      height              = "100%"
                      width               = "100%"
                      onClientInsertImage = "InsertImage_BTFEditor(id);"
                      onClientInsertLink  = "InsertLink_BTFEditor(id);"
                      sourceView          = "FALSE" />

<b><script>

document.myform.BTFEditor_FontName_btf1.options[0].selected = true ;

</script></b>

in the above javascript

myform = form id

BTFEditor_FontName_btf1 =btf1 is the id of your btf editor

options[0] = Arial

options[1] = Courier New ,etc

Regards

Raja

Former Member
0 Kudos

Dear Raja,

thanks for ur suggestion. I've already tried that, but it doesnt seem to be the solution.

font and fontsize are not selected yet once the editor starts with an empty document. only when I place the cursor in the imput area "times roman" and "3(12pt)" are automatically selected by the extension. it seems that these values are set upon an event like "placed curso into input area" and read by the class from some variables or js-file...

any idea?

Thanks

Gerald

ps.

when I start the application in firefox I can see that your code kind of works as now arial is selected. but the extension has its problem in fox as the the dropdowns are grayed out and the text is not shown properly...

athavanraja
Active Contributor
0 Kudos

one way to achieve is set some info text in the empty document with the rquired font.

something like below

move '<font face="Arial">Enter the definition here... <br>You can add pictures, web addresses and use HTML markup!</font>' to temp_text.
     assign temp_text to <string> casting type x.
****Convert the Text Input and Cast it to a Binary String
     move <string> to  desc.


**** encoding is a string constant with value 'utf-8'
     btf_document_ds->set_content(
      text     =  desc
      encoding =  encoding ).

Regards

Raja

Former Member
0 Kudos

also tried that, looks nice in the editor, but the generated HTML in the background gets messed up by this.

guess found where the defaults can be set. check out interface IF_BTF_CONFIGURATION, method SET_DEFAULT_FONT.

as old school abaper, i'm not yet pro in OO.. any idea how to implement that IF in my OnCreate handler?

here my handler OnCreate:


IF g_s_documentdata-btf_doc IS INITIAL.

   DATA: l_v_errtxt TYPE string.

   DATA: l_r_btf      TYPE REF TO if_btf.
   DATA: l_r_document TYPE REF TO if_btf_document.

*  create reference to editor
   l_r_btf = cl_btf=>get_reference( ).

   DATA: l_r_exc_r TYPE REF TO cx_btf_runtime_error,
         l_r_exc_p TYPE REF TO cx_btf_parameter_error.
   TRY.
       l_r_document = l_r_btf->create_document( sy-langu ).
     CATCH cx_btf_runtime_error INTO l_r_exc_r.
       l_v_errtxt = l_r_exc_r->get_text( ).
   ENDTRY.

*  connect document with editor
   g_s_documentdata-btf_doc = l_r_document.

 ENDIF.

thanks

Gerald

athavanraja
Active Contributor
0 Kudos
data: btf_config	TYPE REF TO	IF_BTF_CONFIGURATION .
DATA: font TYPE tdfamily .


CALL METHOD l_r_btf->create_configuration
     EXPORTING
       language      = sy-langu
     RECEIVING
       configuration = btf_config.

 IF NOT btf_config IS INITIAL .
     CLEAR font .
     MOVE: 'HELVE' TO font .
     CALL METHOD btf_config->set_default_font
       EXPORTING
         font = font.
   ENDIF .

IF  l_r_document  IS INITIAL.

*TRY.
   CALL METHOD l_r_btf->create_document
     EXPORTING
       language      = sy-langu
       configuration = btf_config
     RECEIVING
       rval          = l_r_document .
* CATCH CX_BTF_RUNTIME_ERROR .
*ENDTRY.

the interal value for fonts are as follows

Arial                |HELVE   
Courier New          |COURIER 
OCRA                 |OCRA    
OCRB                 |OCRB    
Times New Roman      |TIMES   

This is the way to do it. however, this doesnt seems to solve the problem. it still defaults to Times new Roman.

Regards

Raja

Former Member
0 Kudos

Thanks Raja for explaining hmm, yeah unfortunately the problem still persists...

client will have to live with it for the meantime...

will try to debug a bit more around when I find the time and hope x-mas will bring the solution or that sb from SAP will read this - looks to me like one of these bugs

thanks again and take care

Gerald

Former Member
0 Kudos

Hi Gerald,

We are having exactly the same requirement as to change the default font to ARIAL instead of TIMES.

I have tried all the above suggestions, but nothing positive.

We are using SAP CRM 2007.

Request you to please share on how did you proceed.

Many thanks

Rakesh