7 Replies Latest reply on Jul 19, 2016 8:58 AM by Robin West

    Use proportional font to print arabic text?

    BELFAR N.

      hello,

      is it possible to make arabic text centred like if we use ^FB? i have no good result with using ^FB and ^PA commands.

      also, can i use proportional font to print arabic text (font with the same width for allc haracters)?

        • Re: Use proportional font to print arabic text?
          Robin West

          Hello, I would not recommend using a monospace font (same width for all characters) for Arabic.  Arabic is a script, so the characters change depending on the previous and next characters.  They intentionally flow into each other similarly to English Cursive script.  A monospace font would break that.  You may have a hard time even finding one.  As for centering with a ^FB, I'm not sure.  Can you maybe attach a picture of what it's doing and the ZPL you are using?

          Robin

            • Re: Use proportional font to print arabic text?
              BELFAR N.

              In the picture, you will see first the red text which is in proportional font (CONSOLAS). the red text contains no more characters than the the black text in the fourth position and the red text looks with a smaller width.

               

              Then you will see the same red text in another font which is not proportional (ARIAL). in this case, the same red text looks with a bigger width.

               

              As i can not use ^FB for centering, i'm forced to use a proportional font to calculate position of each line

              depending of the number of the characters. But using the number of characters of each line with ZPL produces the same second picture.

              Texte en arabe .png

               

              here is my zpl code :

              ----------------

              ^XA                                                                                                                                                                                                    

              ^FXDébut étiquette article : 033/30016500100^FS                                                                                                                                                        

              ^CWZ,E:TT0003M_.FNT^FS                                                                                                                                                                                 

              ^LH30, 80                                                                                                                                                                                              

                                                                                                                                                                                              

              ^PA1,1,1,1^FS                                                                                                                                                                                          

              ^FO406, 120                                                                                                                                                                                            

              ^CI28                                                                                                                                                                                                  

              ^AZN,57, 53                                                                                                                                                                                            

              ^FDشمعة معطرة^FS                                                                                                                                                                                      

                                                                                                                                                                                                    

              ^PA1,1,1,1^FS                                                                                                                                                                                          

              ^FO55, 190                                                                                                                                                                                             

              ^CI28                                                                                                                                                                                                  

              ^AZN,57, 53                                                                                                                                                                                            

              ^FDتنبيه: تبقى بعيداً عن متناول الأطفال.لا تترك شمعة^FS                                                                                                                                                

                                                                                                                                                             

              ^PA1,1,1,1^FS                                                                                                                                                                                          

              ^FO10, 260                                                                                                                                                                                             

              ^CI28                                                                                                                                                                                                  

              ^AZN,57, 53                                                                                                                                                                                            

              ^FDمشتعلة غير المراقب. لا تقم بتحريك شمعة مضاءة. الابتعاد^FS                                                                                                                                           

                                                                                                                                                         

              ^PA1,1,1,1^FS                                                                                                                                                                                          

              ^FO28, 330                                                                                                                                                                                             

              ^CI28                                                                                                                                                                                                  

              ^AZN,57, 53                                                                                                                                                                                            

              ^FDعن ماتيريو القابلة للاحتراق. تبقى الفتيل قلص إلى 1/4^FS                                                                                                                                             

                                                                                                                                                           

              ^PA1,1,1,1^FS                                                                                                                                                                                          

              ^FO10, 400                                                                                                                                                                                             

              ^CI28                                                                                                                                                                                                  

              ^AZN,57, 53                                                                                                                                                                                            

              ^FDبوصة أو أقل. حرق فقط على سطح مستقرة.حرق فقط في^FS                                                                                                                                                   

                                                                                                                                                              

              ^PA1,1,1,1^FS                                                                                                                                                                                          

              ^FO379, 470                                                                                                                                                                                            

              ^CI28                                                                                                                                                                                                  

              ^AZN,57, 53                                                                                                                                                                                            

              ^FDحاويات مقاومة^FS                                                                                                                                                                                    

                                                                                                                                                                                                                                                                                                                                                                                                  

              ^PQ1                                                                                                                                                                                                   

              ^XZ                                             

              ----------------

              • Re: Use proportional font to print arabic text?
                BELFAR N.

                hello Robin and thanks for your replay.

                I've missed this in my prévious message.

                • Re: Use proportional font to print arabic text?
                  BELFAR N.

                  Hi Robin,

                  i need some help.

                  i have posted a picture and zpl code.

                   

                  All i need is :

                  - is it possible to center arabic text ?

                  - Or, is it possible to use proportional font to print arabic text?

                   

                  thanks

                  Noureddine.

                    • Re: Use proportional font to print arabic text?
                      Robin West

                      Hi Belfar,

                      It is possible to center Arabic text using the ^FB command.  I used the command below:

                       

                      ^XA

                      ^FXDébut étiquette article : 033/30016500100^FS

                      ^CWZ,E:TT0003M_.FNT^FS

                      ^LH0,0

                      ^PA1,1,1,1^FS

                      ^CFZ,57,53^FS

                      ^CI28

                      ^FO20,120

                      ^FB1600,10,12,C,0

                      ^FDشمعة معطرة\&

                      تنبيه: تبقى بعيداً عن متناول الأطفال.لا تترك شمعة\&

                      مشتعلة غير المراقب. لا تقم بتحريك شمعة مضاءة. الابتعاد\&

                      عن ماتيريو القابلة للاحتراق. تبقى الفتيل قلص إلى 1/4\&

                      بوصة أو أقل. حرق فقط على سطح مستقرة.حرق فقط في\&

                      حاويات مقاومة^FS

                      ^XZ

                       

                      As you saw, you were able to print with a monospace (proportional) font, but the line lengths were different.  That will always be an issue with monospace fonts.  The line lengths will rarely match the line lengths for regular fonts and each line will differ by different amounts.  In a non-monospace font an 'm' takes up more width than a 'i'.  In monospace fonts the characters will always take up the same amount of space ( 'm' vs 'i'  ), so you can calculate a center point for each line if you know the number of characters you are printing in each line.  As you saw though, it doesn't look quite right and is not recommended for Arabic.  It is your choice though. 

                      Does this answer your question?

                      Robin

                        • Re: Use proportional font to print arabic text?
                          BELFAR N.

                          Hi Robin,

                          Thanks for your replay.

                           

                          Your have written :

                          ...

                          ^PA1,1,1,1^FS

                          .

                          .

                          .

                          ^FB1600,10,12,C,0

                          ...

                          I have to note that ^PA command is not compatible with ^FB command when we use arabic text.

                          text is printed left to write and each character is printed alone.

                          To understand my replay, try to print using your code and my code and compare each line : you will

                          see quickly the difference.

                           

                          In my code, i do not use ^FB command for this reason. My only way to center arabic text is to use proportional font and calculate a center point for each line.

                          Do you how can i do this?

                           

                          Best thanks one more time.

                            • Re: Use proportional font to print arabic text?
                              Robin West

                              Hi Belfar,

                              Sorry about the incorrect ZPL.  I don't know arabic and couldn't see it wasn't printing right.

                              Based on this, the only real way to handle centering in your application code. There is no other ZPL to do it. Here is some psudo code that should do it.  Let me know if this doesn't work for you:

                               

                              The font_width may have to be adjusted for your specific font and the widths can be slightly different than specified for different fonts.  I had to guess at your label width.

                               

                              int page_width = 900;

                              int font_width = 53;

                              string header = "^XA^FXDébut étiquette article : 033/30016500100^FS^CWZ,E:TT0003M_.FNT^FS^LH30, 80^PA1,1,1,1^CI28^FS";

                              string footer = "^PQ1^XZ";

                               

                              function string center_line(string arabic_text, int y)

                              {

                                int text_width = arabic_text.length * font_width;

                                int x = Round((page_width - text_width) / 2);

                                return "^FO" + x + "," + y + "^AZN,57,53^FD" + arabic_text + "^FS";

                              }

                               

                              function string print_centered_arabic(string[] arabic_lines)

                              {

                                int y = 120;

                                string zpl = header;

                               

                                for (int i = 0; i < arabic_lines.length; i++)

                                {

                                zpl += center_line(arabic_lines[i], y);

                                y += 70;

                                }

                               

                                zpl += footer;

                                return zpl;

                              }