I am having trouble laying out text. I render each word individually and handle bold, italic, wordwrapping etc. When I use the CgFont>>textWidth: method it doesn't seem to give me a big enough number. Some of the words will run into each other. The effect is reproducible. I can use different printers and fonts but it doesn't really make much difference. textWidth: string "Answer the width in pixels of the given string using the receiver as its font." | osString hdc oldHfont size | "If the size of the string is zero, return a size of zero." string size == 0 ifTrue: [^0]. PlatformString == String ifTrue: [ osString := string asSBString ] ifFalse: [ osString := PlatformString fromString: (serverResource validateLeadBytes: string) ]. server beginRequest. hdc := server deviceContext. oldHfont := hdc selectObject: serverResource handle. hdc getTextExtentPoint: osString cbString: osString size lpSize: (size := OSSize new). hdc selectObject: oldHfont. server endRequest. ^size cx Any ideas? Thanks, -Carl You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
Hi Carl,
I think getTextExtentPoint does not really take intercharacter spacing or justification into account. You might want to try to print using winapi call ExtTextOut. Did you already try to use winApi call DrawText instead? I saw that this method is even used in OSWidget textExtent: I know that problem and I know that there is a solution on that, but I do now more have aceess to my former implementation. Sorry. Sebastian Am 27.05.2015 um 14:02 schrieb Carl Gundel:
-- You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
Thanks Sebastian. I expect it to work correctly because I am porting this from VSE. In either case (VSE or VA) the GetTextExtentPointA api is called. It works in our VSE app. Strange. -Carl On Wednesday, May 27, 2015 at 5:23:18 PM UTC-4, Sebastian Heidbrink wrote:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
In reply to this post by Instantiations mailing list
Okay, I've had a look at the DrawText method. That might work but the code I'm porting doesn't lay out while it is rendering. It computes all this in advance and then prints later, so using a drawing routine to compute spacing isn't a good fit. Perhaps I can make it work. Still at a loss why the textWidth: method works for this in our VSE app, but doesn't in the VAST version. I will dig harder on this first before I abandon it. Thanks again! -Carl On Wednesday, May 27, 2015 at 5:23:18 PM UTC-4, Sebastian Heidbrink wrote:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
Hi Carl,
according to MSDN there is a slight change that you might get more accurate results using "getTextExtentPoint32: arg1 arg3: arg2 arg4: arg3 " Did you give that a try already? Sebastian Am 28.05.2015 um 08:11 schrieb Carl Gundel:
-- You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
I'll have a look at that. Thanks. :-) On Thursday, May 28, 2015 at 11:20:49 AM UTC-4, Sebastian Heidbrink wrote:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
Free forum by Nabble | Edit this page |