cancel
Showing results for 
Search instead for 
Did you mean: 

SMARTform dynamic use of font (e.g. CNSONG) for non-Latin characters (e.g. Chinese)

Former Member
0 Kudos

Is there a best practice position for how SMARTforms should be designed to cater for global implementations – in particular how Latin (e.g. English) and non-Latin (e.g. Simplified Chinese) characters can be printed by the same SMARTform?  

More specifically, is it possible to dynamically change the font being used for a SMARTform?

I saw the post http://scn.sap.com/thread/545537 (from 2007) which seemed to be quite similar, but posting the question again to see any progress has been made since 2007.

We have a global template invoice (using SMARTforms), and we need the ability to be able to print different fonts based on the output language (e.g. NAST-SPRAS).

We have created text modules to allow the literal texts to be translated (works well), but the problem is that when we have to print text elements (which contains value from some customizing table and can have Chinese characters depending on language). There we don't find any option for changing the font dynamically.

The reason for this is that it is only possible to pass a fixed font to the text element.

Scenario 1 – font HELVE is assigned to the Text Element

  • If the document is printed in English, the English texts do print OK
  • If the document is printed in Simplified Chinese, the Simplified Chinese do not print OK (as the chinese characters do not exist in font HELVE)

Scenario 2 – font CNSONG is assigned to the Text Element

  • If the document is printed in English, the English texts do print OK – but the font appearance is less desirable
  • If the document is printed in Simplified Chinese, the Simplified Chinese do print OK.
  • You could argue that this would meet the requirements if we only had to print English (or other Latin) and Simplified Chinese, but this is not the case.  Later on, we will also need other “special” characters which need their own font (e.g. JP… fonts for Japan, TH… fonts for Thailand etc).

So to repeat the question above, is it possible to dynamically specify the font at run-time of a SMARTform based on the language the form is being printed in (e.g. use CNSONG if language = ZH, use JP… if language = JA etc. etc.)

As an (bad) work around, we could have separate (text element) nodes in the SMARTform – one for English (i.e. Latin) and others for Simplified Chinese etc.  but this does not seem to be a very intelligent design.

Many thanks in advance for any help.

Alistair Crawshaw

andrea_cofani
Discoverer
0 Kudos

Hi, Piyush Payasi

please, can you detail more deeply the solution proposed ?

In particular where write the abap code to set the %header-stdstyle variable ... if is it possible with an example.

Thanks in advance.

Best Regards.

anne-petteroe
Community Manager
Community Manager
0 Kudos
Hello, While we're happy that you've come to SAP Community to get an answer to your question, you posted your question as an answer in an old thread.I've converted your answer to a comment, but even so -- posting in older threads is not the best way to get guidance.

If you're looking for help, you should ask a new question: https://answers.sap.com/questions/ask.html.

Best regards,
Anne

Accepted Solutions (0)

Answers (2)

Answers (2)

aidan_black
Active Contributor
0 Kudos

Hi Phil,

If you use the cascading fonts unicode windows device type SWINCF(see SAP note 812821) to process your Smart Form, the font used in the Smart Form is not relevant anymore. A suitable windows font will be chosen based on the unicode code point of the character. So if you print via SWINCF, then you will get a correct print for both scenarios above or for any mixture of languages. The SAP font is not so important when you print via SWINCF.

Regards,

Aidan

Former Member
0 Kudos

Hi Alistair,

Regarding your concern, Yes we can dynamically change the font in Smartform based on the language.

Let us take your requirement, To complete this please follow the below steps:

1st you need to create two SmartStyles, one for font HELVE and other for font CNSONG.

ZSS_STYLE1 - set default font HELVE
ZSS_STYLE2 - set default font as CNSONG

Both the Smartstyle must contain the all the paragraph & character format which all are used by Smartform.

Next In Smartform driver program you need to write code to get program name of Smartform.

for that by using FM "SSF_FUNCTION_MODULE_NAME" to get FM name of your created Smartform into the variable w_form_fmname. Now use following code to get program name:

CONSTANTS: c_sapl(4)     TYPE  c      VALUE 'SAPL'.
DATA: w_sf_progname     TYPE string,
         
           w_form_fmname      TYPE rs38l_fnam.

CLEAR w_sf_prog_name.

   IF e_form_function IS NOT INITIAL.

     CONCATENATE w_form_fmname+0(8) c_sapl w_form_fmname+8
     INTO w_sf_progname.

     CONDENSE w_sf_progname NO-GAPS.

   ENDIF.

Now the variable "w_sf_prog_name" contains the Smartform program name this you need to pass under Exporting parameter while calling Smartform function module.

Now get  this program name inside Smartform into a variable. Afer this access the structure %HEADER with the help of program name and Assign/Move new Smartstyle in the field  %header-stdstyle value based on the languages.


IF ie_langu eq 'E'.               "English
     MOVE 'ZSS_STYLE1' TO 
%header-stdstyle.   "HELVE
ELSE.                               " for other languages

     MOVE 'ZSS_STYLE2' TO %header-stdstyle.    "CNSONG
ENDIF.

**The field %header-stdstyle is containing the default smartstyle name which we set to Form Attributes->Output Options->Style field.

Hope it also works for you ,  let me know if you have any doubt related to above solution.

Thanks & Regards,

Piyush Payasi

andrea_cofani
Discoverer
0 Kudos

Hi, Piyush Payasi

please, can you detail more deeply the solution proposed ?

In particular where write the abap code to set the %header-stdstyle variable ... if is it possible with an example.

Thanks in advance.

Best Regards.

anne-petteroe
Community Manager
Community Manager
0 Kudos
Same here, please post a new question instead of posting in an old thread. Best regards,
Anne