OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 27-02-2005, 10:37
geHucKa
Guest
 
Posts: n/a
Default Can't resize text

Hello.

Where is my fault?

IDrawShapeRangePtr pFrameTemplateRange = pFrameTemplate->UngroupAllEx(); // After this line pFrameTemplateRange is not NULL

IDrawShapePtr pName = pFrameTemplateRange->GetItem(TEXT("NAME")); // This item really exist. After this line pName is not NULL

IDrawStructFontPropertiesPtr pFontProperties = pName->Text->GetFontProperties(cdrAllFrames); // After this line pFontProperties is not NULL

float f = pFontProperties->GetSize(); // After this line f = 1.1754944e-038, but not 8.0

pFontProperties->PutSize((float) (f * 6.0));

pName->Text->PutFontProperties(cdrAllFrames, pFontProperties); // After this line in CD text size is 0.0

Thanks.
Reply With Quote
  #2  
Old 27-02-2005, 11:08
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default Re: Can't resize text

Quote:
Originally Posted by geHucKa
float f = pFontProperties->GetSize(); // After this line f = 1.1754944e-038, but not 8.0
This means that the characters in the selected text object have different sizes (for example, a word in 6 pt font and a word in 8 pt).

In case there are different font size in the text block, the size property returns that weird value which actually equals to the one returned by "Application.cdrMixedSingle":

Code:
float f = pFontProperties->GetSize();
if(f == pApplicationPtr->cdrMixedSingle())
{
    // ... mixed font sizes
}
else
{
    // f contains a valid font size
}
I hope this helps
Reply With Quote
  #3  
Old 27-02-2005, 17:05
geHucKa
Guest
 
Posts: n/a
Default

Thanks.

And how I can proportionally increase the size of a whole text in my situation?
Reply With Quote
  #4  
Old 28-02-2005, 09:38
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

Quote:
Originally Posted by geHucKa
And how I can proportionally increase the size of a whole text in my situation?
No easy way. Character by character probably, or try to identify the ranges of text with the same attribute and then apply the change to the whole range, and proceed with another one.

Here is a sample VBA function which goes through a text stream, identifies ranges of characters with the same size, then scales them by the specified scale factor and continues with another range.

Code:
Sub ScaleTextSize(ByVal trText As TextRange, ByVal dScale As Single)
    Dim dSize As Double
    Dim trDup As TextRange
    Dim trTemp As TextRange
    
    If trText.Size = Application.cdrMixedSingle Then
        Set trDup = trText.Duplicate
        While trDup.Start < trDup.End - 1
            Set trTemp = trText.Duplicate
            trTemp.End = (trDup.Start + trDup.End) / 2
            If trTemp.Size = Application.cdrMixedSingle Then
                trDup.End = trTemp.End
            Else
                trDup.Start = trTemp.End
            End If
        Wend
        
        Set trTemp = trText.Duplicate
        trTemp.End = trDup.Start
        trTemp.Size = trTemp.Size * dScale
        trTemp.SetRange trDup.Start, trText.End
        ScaleTextSize trTemp, dScale
    ElseIf trText.Start <> trText.End Then
        trText.Size = trText.Size * dScale
    End If
End Sub
Here's how to use this function to scale each character of the selected text object by 200%:

Code:
Sub Test()
    ScaleTextSize ActiveShape.Text.Story, 2
End Sub
Reply With Quote
  #5  
Old 28-02-2005, 15:40
geHucKa
Guest
 
Posts: n/a
Default

Thanks.

Now I changed my code, but it works not correct anyway:

IDrawShapeRangePtr pFrameTemplateRange = pFrameTemplate->UngroupAllEx();

IDrawShapePtr pName = pFrameTemplateRange->GetItem(TEXT("NAME"));

IDrawStructFontPropertiesPtr pFontProperties = pName->Text->GetFontPropertiesInRange(0, 1, cdrCharacterIndexing);

float f = pFontProperties->GetSize(); // f == pApplication->cdrMixedSingle() anyway
Reply With Quote
  #6  
Old 28-02-2005, 16:20
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

Quote:
Originally Posted by geHucKa
IDrawStructFontPropertiesPtr pFontProperties = pName->Text->GetFontPropertiesInRange(0, 1, cdrCharacterIndexing);
If you want to use the old FontPropertiesInRange, you need to keep in mind that the first character is indexed by 1. So, in your case you should have specified Text->GetFontPropertiesInRange(1, 1, cdrCharacterIndexing) to get the size of the first character.

However with the new TextRange-based approach, the indexing is done by the caret position. So, the text range to include the first character would start at 0 and end at 1:

Code:
MsgBox ActiveShape.Text.Story.Range(0, 1).Size
Or in this particular instance, you can just use the Characters collection instead:

Code:
MsgBox ActiveShape.Text.Story.Characters(1).Size
Reply With Quote
  #7  
Old 28-02-2005, 16:51
geHucKa
Guest
 
Posts: n/a
Default

Thanks. Everything works perfectly.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Text ENCODE Craig Tucker CorelDRAW/Corel DESIGNER VBA 10 26-01-2005 14:59
format text dialog box implement graphicdesigner CorelDRAW/Corel DESIGNER VBA 5 22-12-2004 14:37
Getting the center X on a text shape Rick Randall CorelDRAW/Corel DESIGNER VBA 4 03-08-2004 19:27
Reset text after text compression. Bellekom CorelDRAW/Corel DESIGNER VBA 2 05-05-2004 07:14
Placing a custom envelope on Text larrypanattoni CorelDRAW/Corel DESIGNER VBA 3 23-04-2003 10:18


All times are GMT -5. The time now is 08:23.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com