![]() |
#1
|
|||
|
|||
![]()
Hi All,
I'm trying to import some polish text into a text shape. I can manually put the text in, change the encode to 1250-Central Europe and the font displays properly. If I replace the text programmatically, the text changes to 1252 causing the text to not display properly. My questions are: Why doesn't the shape keep the ENCODE setting on the object? and Is there a way to programmatically access the ENCODE setting to change back to 1250? Also, Is there a UTF-8 charset available - I can't find it? Thanks much, Craig... Here's the improper text: Odkryj Telefon Motoroli Który Pasuje do Twojego Stylu ¯ycia!Odkryj Telefon Motoroli Który The ¯ should be a Z with dot on top Ż |
#2
|
|||
|
|||
![]()
Hi All,
I found the CharSet property for the text object but it seems to be read only. Every time I set the CharSet value to 238 - it doesn't change and keeps the 0 value. loShape.Text.Selection.CharSet= 238 && cdrCharSetEastEurope Any help would be appreciated. Thanks, Craig... |
#3
|
||||
|
||||
![]()
Craig,
What version of CorelDRAW do you use? There are some subtle differences between v11 and v12 as far as text is concerned. v12 is now fully Unicode, while v11 was just "faking" it ![]() CharSet property really applies to v11 and has no real use in v12. In order to understand a bit more how all this work, let me explain the path text takes from your macro source code to Draw document. VBA editor itself is not Unicode. That is, you can't use both Greek, Russian and Polish characters in your macro. You can use only 256 characters from the current windows code page. If you have your system locale set to, say, Poland and therefore the code page is set to "Central Europe", character with code 175 will look like your Z with dot on top in your macro source. VBA itself uses COM to communicate with the host application (CorelDRAW). COM by definition is Unicode only. So the ANSI strings in your macro source file are converted to the Unicode using the current Windows code page, and sent to CorelDRAW. CorelDRAW 11 receives the Unicode string, converts it back to ANSI using the same system code page, then puts this string into text object. To make the text look right, CorelDRAW also uses the character set data to select the font to draw the text on screen. So, the same ANSI character will be displayed as Polish when Central European charset is specified, as Russian when Cyrillic is set or as Greek when Greek charset is selected. On the other hand, CorelDRAW 12 just uses the Unicode string as is and puts it into a text object. So, if your system code page is Cyrillic, there is no chance you can stick Central European characters into CorelDRAW by just typing the string in VBA editor. You can, however, generate the propert Unicode characters in VBA by using ChrW function and specifying the actual Unicode character code. However CorelDRAW 12 has some new text conversion methods which could help you overcome the hurdles of ANSI-based VBA editor. I'll show it a bit later. So, in CorelDRAW 11, here is a code which will create a few CE characters in document: Code:
Sub CentralEuropeanText() ActiveLayer.CreateArtisticText 0, 0, "Z with dot: ¯", cdrPolish, cdrCharSetEastEurope, "Arial", 20 End Sub Now, in CorelDRAW 12, the same code will work fine if you have the Windows locale set to any of the CE languages. But if you have English, Franch or other Western locales, you have to do some more tricks. One thing you can do, is to create text by specifying the Unicode characters directly (thus, bypassing VBA text editor limitations on ANSI strings only). You need to find the Unicode character code. For this, go to Start>Programs>Accessories>System Tools>Character Map. Locate the symbol you are interested in and see its unicode char code. For example, your Z with dot is shown as "U+017B". Which means that its code is 17B hexadecimal, which maps to 379 decimal. (You can use hexadecimal values in VBA too, just prepend them with "&h" like this: ChrW(&h17B). Code:
Sub CentralEuropeanText() ActiveLayer.CreateArtisticText 0, 0, "Z with dot: " & ChrW(379), cdrPolish, cdrCharSetEastEurope, "Arial", 20 End Sub Another way to do it, is to get the same ANSI string as in the case of CorelDRAW11, and then re-encode it from the current system code page, into the required (Central European, in our case, which is code page 1250). Code:
Sub CentralEuropeanText() Dim strUnicode As String strUnicode = Application.ConvertToUnicode("Z with dot: ¯", 1250) ActiveLayer.CreateArtisticText 0, 0, strUnicode, cdrPolish, cdrCharSetEastEurope, "Arial", 20 End Sub This should do it. |
#4
|
|||
|
|||
![]()
Hi Alex,
Here's where I'm at right now; Using CorelDRAW 12 - I was hoping to pass the Z with dot: ¯ and just set the "story" properties as in the below code. It's setting, but not working (am analyzing your previous post)... Thanks much, Craig... Code:
loShape = loDocument.ActivePage.FindShape(lcLookFor) IF !llIsLogo IF VARTYPE(loShape) = "O" loShape.Text.Story.CharSet=238 loShape.Text.Story.LanguageID=1045 loShape.Text.Contents = lcReplace IF loShape.Text.Type = cdrParagraphText AND llFTTF loShape.Text.FitTextToFrame() ENDIF ENDIF ELSE |
#5
|
||||
|
||||
![]()
Never use Contents property of the Text object. It is obsolete and is there only for compatibility with pre-11 versions of CorelDRAW. It is hidden for a reason
![]() Use Text.Story instead: Code:
loShape.Text.Story = lcReplace P.S. For other people reading this thread, the code above is a FoxPro code, not VBA, so the syntax is a bit different... |
#6
|
|||
|
|||
![]()
Hi Alex,
Oops-.Contents left over from v10 conversion....thx. I'm now getting the Z w/out a dot on top. Were you able to get your test to work? I'm not getting that either. Thanks, Craig... Code:
IF VARTYPE(loShape) = "O" loShape.Text.Story.CharSet=238 loShape.Text.Story.LanguageID=1045 loShape.Text.Story.Text = loCorel.ConvertToUnicode(lcReplace, 1250) IF loShape.Text.Type = cdrParagraphText AND llFTTF loShape.Text.FitTextToFrame() ENDIF *-Test strUnicode = loCorel.ConvertToUnicode(lcReplace, 1250) loPage.ActiveLayer.CreateArtisticText( 0, 0, strUnicode, 238, 1250, "Arial", 20) ENDIF |
#7
|
||||
|
||||
![]()
Yes, it worked fine in VBA. Maybe FoxPro doesn't use Unicode strings internally? I doublt it though, but it well could be.
Do you know if it has the stanard VB's variations of Chr function to work with single byte and double-byte characters? (ChrB, ChrW)? Is not, then it could be that FoxPro doesn't support Unicode, even internally as VBA does. In this case, the only option I see is to set your Windows locale to some CE country with code page 1250. Oh, by the way, you can try my code in your CorelDRAW's VBA to make sure it works (just to eliminate any other factors as OS regional settings, etc)... |
#8
|
|||
|
|||
![]()
Hi Alex,
VFP does have available UNICODE functions such as STRCONV() - but doesn't have a VFP Unicode-aware channel for its communications. As soon as I pass a UNICODE string to Corel, the windows messaging system is converting it to "CP 1252". I need a way to pass Upper 128 characters as an integer parameter to hopefully CorelDRAW 12's new ConvertToUnicode(). Any Suggestions? Thanks again very much, Craig... http://msdn.microsoft.com/library/de...rconvlp_rp.asp |
#9
|
|||
|
|||
![]()
Hi All,
Just a follow up to this thread - I never could make this work in VFP regardless of what I would try, switched back to VB6 and it is working perfectly. The new ConvertToUnicode function in 12 is great. Alex, thanks again for the heads up... Craig... |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
format text dialog box implement | graphicdesigner | CorelDRAW/Corel DESIGNER VBA | 5 | 22-12-2004 13:37 |
Getting the center X on a text shape | Rick Randall | CorelDRAW/Corel DESIGNER VBA | 4 | 03-08-2004 18:27 |
Reset text after text compression. | Bellekom | CorelDRAW/Corel DESIGNER VBA | 2 | 05-05-2004 06:14 |
Selection of Text off-page | D_Green | CorelDRAW/Corel DESIGNER VBA | 2 | 04-10-2003 16:34 |
Placing a custom envelope on Text | larrypanattoni | CorelDRAW/Corel DESIGNER VBA | 3 | 23-04-2003 09:18 |