Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using 2 fonts depending on a field value

Status
Not open for further replies.

kllick123

Technical User
Sep 24, 2002
22
IN
Hi,

I had a program running on Foxpro for windows 2.6.
Now I had a requirement for changing the font between
English and Hindi depending on the entry done by the user.
The font E/H is stored in one saperate field.

Now I want to Browse and print reports (from a .PRG file)
depending on the font field E/H.

Can I be able to do so.

I also want to store the output in a file with both
English and Hindi Font.

Please help me..................

 
If you inspect the contents of the field prior to browsing or reporting, you should be able to. It may be easier to define a separate report containing the same layout, using different fonts for the fields. You could do something like:
Code:
USE MyTable
IF BETWEEN(ASC(UPPER(ALLTRIM('ABC'))), 65, 90)   &&... A-Z
   DEFINE WINDOW MyWindow;
      FONT "Arial", 10  .....

   BROWSE IN WINDOW MyWindow

   REPORT FORM E_Report ....   &&... English font version
ELSE
   DEFINE WINDOW MyWindow;
      FONT "Hindi", 10 .....

   BROWSE IN WINDOW MyWindow

   REPORT FORM H_Report ....   &&... Hindii font version
ENDIF
Dave S.
 
If you are wanting to have one single screen / report set in either language E or language H, then my personal recommendation would be to create 2 separate sets of screens and reports and use the appropriate set depending on the variable value (like suggested above by Dave S.).

BUT if you were wanting to have a single screen /report set possibly in both language E and language H, then you can define the @SAY's and @GET's using macros (see below)

m.cFont_C = " FONT 'COURIER'"
m.cFont_I = " FONT 'IMPACT'"
m.cFont_E = " FONT 'TIMES NEW ROMAN'"

DO CASE
CASE m.cTriggr = "Font 1"
m.cUseFont = m.cFont_C

CASE m.cTriggr = "Font 2"
m.cUseFont = m.cFont_I

CASE m.cTriggr = "Font 3"
m.cUseFont = m.cFont_E
ENDCASE

* --- As Part of Screen or Report Code ---
@ 5,5 SAY "HELLO" &cUseFont

Use of macros will also work in a similar manner for defining the Browse command prior to actually executing it. I have used this approach to define dynamically changing Browse window sizes and fields.

m.cBrwsChar1 = " FONT 'IMPACT' " ;
+ " FIELDS item_no, descrip, n_a"

m.cBrwsChar2 = " FONT 'TIMES NEW ROMAN' " ;
+ " FIELDS item_no, descrip, n_a"

IF m.cTriggr = "1"
m.cBrwsChar = m.cBrwsChar1
ELSE
m.cBrwsChar = m.cBrwsChar2
ENDIF

BROWSE &cBrwsChar

Feel free to substitute your Hindi font name(s) in where desired. Also feel free to define the desired font point size and Bold, Italics, etc. within the m.cFont_x string.

Keep in mind that how the screen and report appear will vary since it is most likely that the fonts will not "behave" the same. Some are proportional and some are not. Some are only BOLD and some are not, etc.

Good Luck, JRB-Bldr
VisionQuest Consulting
Business Analyst & CIO Consulting Services
CIOServices@yahoo.com
 

Thanks for your reply.

This I had already done.

BUT........

I am preparing a Library Software in which book title is
both in English and Hindi.
The List of all books in library should come in a serial
order (on Book No.) and this will have the book font
English / Hindi at any place in the same report.

For getting the Input from the user, I had done as follows :

@4,26 say "Font (E-English/H-Hindi" get m.book_font picture "!"
Read
if m.book_font='H'
@ 7,11 get m.title font "Arjun"
@ 8,11 get m.sub_title font "Arjun"
@ 9,11 get m.author_1 font "Arjun"
@10,11 get m.author_2 font "Arjun"
else
@ 7,11 get m.title
@ 8,11 get m.sub_title
@ 9,11 get m.author_1
@10,11 get m.author_2
endif
Read

Now comes the printing of report with Book title in both English and Hindi in the same report I had done as follows :

if book_font='H'
@row,19 say Title font "Arjun"
else
@row,19 say Title
endif
row=row+1
if book_font='H'
@row,19 say alltrim(author_1) +","+ alltrim(author_2) font "Arjun"
else
@row,19 say alltrim(author_1) +","+ alltrim(author_2)
endif


This all worked for the report directly to Printer.

BUT.....................................

I had to Save the output of the above in a FILE and
then show the output on the screen to the user.

I had used
MODIFY COMMAND &FILE_NAME nomodify
But this does not show the report in both English/Hindi.
It shows everything in only one font.


MY PROBLEMS..

1) How to solve the issue to show the output to the user
on screen.

2) Browse command
I had given
Browse field book_no, title, Book_font
What it should show is
a) the book title in English where BOOK_FONT="E"
b) the book title in Hindi where BOOK_FONT="H"


I will be very thankfull to you, If you could help me in this typical situation.

Hope a positive response...


Regards

Arun Tayal
 
Then to use your scenario without a lot of changes, do something like:

IF m.book_font='H'
DEFINE WINDOW MyWindow;
FONT "Arjun", 10 .....

ELSE
DEFINE WINDOW MyWindow;
FONT "Arial", 10 .....

ENDIF
BROWSE IN WINDOW MyWindow

Now you can use the same window for your MODIFY FILE:

MODIFY FILE &FILE_NAME nomodify WINDOW MyWindow
Dave S.
 
Well you answered my question when you say:
"show the report in both English/Hindi."

To display the single font output you might want to try:
m.cDispFontH = " FONT 'ARJUN'"
m.cDispFontE = " FONT 'FIXEDSYS'"

if book_font='H'
m.cDispFont = m.cDispFontH
else
m.cDispFont = m.cDispFontE
endif

@row,19 say Title &cDispFont
row = row+1
@row,19 say alltrim(author_1) +","+ alltrim(author_2) &cDispFont

But to display the both font output you might want to try:
m.cDispFontH = " FONT 'ARJUN'"
m.cDispFontE = " FONT 'FIXEDSYS'"

if book_font='H'
m.cDispFont = m.cDispFontH
else
m.cDispFont = m.cDispFontE
endif

@row,19 say Title &cDispFontE
row = row+1
@row,19 say Title &cDispFontH
row = row+1
@row,19 say alltrim(author_1) +","+ alltrim(author_2) &cDispFontE
row = row+1
@row,19 say alltrim(author_1) +","+ alltrim(author_2) &cDispFontH

Or, alternatively, display the two font messages horizontally instead.

For the Browse:
Browse field book_no, title &cDispFont

In FPW the entire Browse is in only one font.
You cannot have separate Fonts for separate fields.

But I am still confused when you say:
"I had used
MODIFY COMMAND &FILE_NAME nomodify
But this does not show the report in both English/Hindi.
It shows everything in only one font."

Are you trying to show the program's source code in the font? That is what you appear to be doing in the above statement.

Lastly, and you must forgive my ignorance on the language, I would assume that, like most other languages, Hindi words and English words are not a one-to-one direct character translation from each other. Therefore when you have as English title such as "My Little Book", then the Hindi title would not be merely the same characters displayed in a different font.

If this is true, then you will need to not only display different fonts, by also have 2 different title values (TitleE & TitleH). This most likely would also pertain to the author names as well (AuthorE_1, AuthorH_1, AuthorE_2, AuthorH_2).

Good Luck,
JRB-Bldr
VisionQuest Consulting
Business Analyst & CIO Consulting Services
CIOServices@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top