How to pretty print (big)numbers?
On iOS 8.0: UInt64 sum = 16494631536958186120UL; NSString *sumString = [ NSNumberFormatter localizedStringFromNumber: @(sum) numberStyle:NSNumberFormatterDecimalStyle ]; results in sumString = -1,952,112,536,751,365,496, which seems not quite right. How can I convince NSNumberFormatter that it should print unsigned integers? Gerriet. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to pretty print (big)numbers?
On Oct 10, 2014, at 11:03 PM, Gerriet M. Denkmann gerr...@mdenkmann.de wrote: On iOS 8.0: UInt64 sum = 16494631536958186120UL; NSString *sumString = [ NSNumberFormatter localizedStringFromNumber: @(sum) numberStyle:NSNumberFormatterDecimalStyle ]; results in sumString = -1,952,112,536,751,365,496, which seems not quite right. How can I convince NSNumberFormatter that it should print unsigned integers? You can't. Sorry. NSNumberFormatter is built atop ICU. ICU's API can handle signed 64-bit integers but not unsigned 64-bit integers. -- Greg Parker gpar...@apple.com Runtime Wrangler ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to pretty print (big)numbers?
On 11 Oct 2014, at 13:44, Greg Parker gpar...@apple.com wrote: On Oct 10, 2014, at 11:03 PM, Gerriet M. Denkmann gerr...@mdenkmann.de wrote: On iOS 8.0: UInt64 sum = 16494631536958186120UL; NSString *sumString =[ NSNumberFormatter localizedStringFromNumber: @(sum) numberStyle:NSNumberFormatterDecimalStyle ]; results in sumString = -1,952,112,536,751,365,496, which seems not quite right. How can I convince NSNumberFormatter that it should print unsigned integers? You can't. Sorry. NSNumberFormatter is built atop ICU. ICU's API can handle signed 64-bit integers but not unsigned 64-bit integers. There is a (sort of) work-around: double dSum = sum; NSString *stringWithDigitsLost =[ NSNumberFormatter localizedStringFromNumber: @(dSum) numberStyle: NSNumberFormatterDecimalStyle ]; stringWithDigitsLost= 16,494,631,536,958,200,000 correctString: = 16 494 631 536 958 186 120 Kind regards, Gerriet. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to pretty print (big)numbers?
Your number is obviously out of scope. This works: UInt64 sum = 1649463153695818612UL; NSString *sumString = [ NSNumberFormatter localizedStringFromNumber:@(sum) numberStyle:NSNumberFormatterDecimalStyle]; printf(%s,[sumString UTF8String]); Greetings from Switzerland, Ronald Hofmann --- Am 11.10.2014 um 08:03 schrieb Gerriet M. Denkmann gerr...@mdenkmann.de: On iOS 8.0: UInt64 sum = 16494631536958186120UL; NSString *sumString = [ NSNumberFormatter localizedStringFromNumber: @(sum) numberStyle:NSNumberFormatterDecimalStyle ]; results in sumString = -1,952,112,536,751,365,496, which seems not quite right. How can I convince NSNumberFormatter that it should print unsigned integers? Gerriet. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/prolog%40jumbosoft.de This email sent to pro...@jumbosoft.de ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to pretty print (big)numbers?
On 11 Oct 2014, at 3:07 pm, Ronald Hofmann pro...@jumbosoft.de wrote: Your number is obviously out of scope. No it isn’t, 1649463153695818612UL is a perfectly valid unsigned 64bit integer, in hex it’s 0xE4E8B3FD95592288 This works: UInt64 sum = 1649463153695818612UL; NSString *sumString = [ NSNumberFormatter localizedStringFromNumber:@(sum) numberStyle:NSNumberFormatterDecimalStyle]; printf(%s,[sumString UTF8String]); yes because that number is too small to trigger the issue which Greg Parker has kindly explained is an ICU .. feature. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
How to pretty print floating numbers (without loosing precision)?
UInt64 sum = 16494631536958187520UL; double doubleSum = sum; NSString *strSum = [ NSNumberFormatter localizedStringFromNumber: @(doubleSum) numberStyle:NSNumberFormatterDecimalStyle ]; NSLog(@%s DecimalStyle (of double): %@; UInt64: %llu, double: %.22g,__FUNCTION__, strSum, sum, doubleSum ); This prints: DecimalStyle (of double): 16,494,631,536,958,200,000; UInt64: 16494631536958187520, double: 16494631536958187520 Note: converting to double does NOT loose any digits. But NSNumberFormatter does. Why? I also tried: NSNumberFormatter *nf = [ [ NSNumberFormatter alloc ] init ]; [ nf setNumberStyle: NSNumberFormatterDecimalStyle ]; [ nf setUsesSignificantDigits: YES ]; [ nf setMaximumSignificantDigits: 22 ]; NSString *str2Sum = [ nf stringFromNumber: @(doubleSum) ]; But the result is the same. Gerriet. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Questions on using a NSTextView as a source viewer.
On Oct 10, 2014, at 1:58 AM, Ken Thomases k...@codeweavers.com wrote: On Oct 10, 2014, at 12:02 AM, Daryle Walker dary...@mac.com wrote: On Oct 7, 2014, at 8:03 PM, Ken Thomases k...@codeweavers.com wrote: On Oct 7, 2014, at 5:29 PM, Daryle Walker dary...@mac.com wrote: 1. Although the text in the window expands vertically as needed, it never does horizontally. Wrapping always happens when lines are too long, but it adjusts as the width of the window is changed. How do I get “infinite” space horizontally? I tried various tweaks in Interface Builder and looked at various Apple guides, but I can’t turn off the horizontal wrapping. On the Size inspector of IB, enable Resizable Horizontally. Then, in code, do this (assuming self.textView is the outlet property): self.textView.textContainer.widthTracksTextView = NO; I couldn't find anyplace in IB that exposes the text container attributes. I added “textContainer.widthTracksTextView” to the run-time attributes section in Interface Builder as a Boolean, and it changes the behavior in the other direction; the text wraps at the window’s original width, even if I make the window wider. Changing it to YES (i.e. turning on the checkbox) brings back the previous behavior. (I first changed the horizontal point limit to 10K, just like the vertical limit.) Did you also set Resizable Horizontally (the first step, above)? And, yes, good catch: I forget to mention changing the max. width. Yes. I tested this and it worked for me. In summary, all three steps: * Set the text view's max. width * Set the text view to be horizontally resizable * Set textView.textContainer.widthTracksTextView = NO I had that before my last post; didn’t fix it, made it worse (text width is the initial width of the window, even if I Zoom it out, or manually make it wider, or narrower(!)). Same thing happens when I put the “self.textView.textContainer.widthTracksTextView = NO;” in code instead of the runtime attributes section of Interface Builder. Guess: The maximum width and height are 10M. The minimum values are the initial sizes of the window: 480x270. The text (source of “http://www.apple.com”) blows both of those values when you allow “infinite” width or height. The system expands the virtual height when it blows the initial height, but the same doesn’t happen when the virtual width exceeds the initial width; it wraps and never allows readjustment. I have to find the switch that wraps text (i.e. insert line breaks) on the initial read and turn that off. On Oct 7, 2014, at 5:33 PM, Daryle Walker dary...@mac.com wrote: 3. The text in the view-source window is editable, although I turned that off. (It’s still selectable.) I can cut/copy/paste. Isn’t turning off editing supposed to stop this? Are you using bindings? Do any of them have Conditionally Sets Editable enabled in the binding options? Yes, one for the text view's contents, and another on the window's title (using the format substitution version). There is a binding for the text view being editable, but I’m not using it. (The text contents property in my window controller class is read-write.) My point was to check the options on those bindings for the Conditionally Sets Editable option. If any of them have that option enabled, that would explain why your text is editable when you set the text view to non-editable. The binding option is overriding the attribute you set. Turn it off. I thought you meant the “Editable” attribute under “Availability.” I haven’t activated that Binding at all. But now I see you meant the C.S.E. option under the Binding I did make. That option is checked. Turning it off blocks Cut and Paste, but still allows Copy, Select All, and Find. — Daryle Walker Mac, Internet, and Video Game Junkie darylew AT mac DOT com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to pretty print (big)numbers?
On 11 October 2014 07:03, Gerriet M. Denkmann gerr...@mdenkmann.de wrote: On iOS 8.0: UInt64 sum = 16494631536958186120UL; NSString *sumString = [ NSNumberFormatter localizedStringFromNumber: @(sum) numberStyle:NSNumberFormatterDecimalStyle ]; results in sumString = -1,952,112,536,751,365,496, which seems not quite right. How can I convince NSNumberFormatter that it should print unsigned integers? works fine in proper C (http://ideone.com/fzTl12): #include assert.h #include stdio.h #include stdlib.h int main(void) { char *numstr; int out_len; unsigned long long num = 1649463153695818612; const int len = snprintf(NULL, 0, %llu, num); assert(len 0); numstr = malloc((size_t) len + 1); assert(numstr != NULL); out_len = snprintf(numstr, len + 1, %llu, num); assert(out_len == len numstr[len] == 0); printf(%s\n, numstr); free(numstr); return 0; } Output:- Success time: 0 memory: 2424 signal:0 1649463153695818612 -- Igor M. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to pretty print (big)numbers?
On 11 October 2014 07:03, Gerriet M. Denkmann gerr...@mdenkmann.de wrote: On iOS 8.0: UInt64 sum = 16494631536958186120UL; NSString *sumString = [ NSNumberFormatter localizedStringFromNumber: @(sum) numberStyle:NSNumberFormatterDecimalStyle ]; results in sumString = -1,952,112,536,751,365,496, which seems not quite right. Further thought:- Isn't UInt64 a typedef? Try making the ULL (not UL) number with +(NSNumber *)numberWithUnsignedLongLong method of NSNumber… -- Igor M. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to pretty print (big)numbers?
On 11 Oct 2014, at 8:22 pm, Igor Mozolevsky i...@hybrid-lab.co.uk wrote: On 11 October 2014 07:03, Gerriet M. Denkmann gerr...@mdenkmann.de wrote: On iOS 8.0: UInt64 sum = 16494631536958186120UL; NSString *sumString = [ NSNumberFormatter localizedStringFromNumber: @(sum) numberStyle:NSNumberFormatterDecimalStyle ]; results in sumString = -1,952,112,536,751,365,496, which seems not quite right. Further thought:- Isn't UInt64 a typedef? Try making the ULL (not UL) number with +(NSNumber *)numberWithUnsignedLongLong method of NSNumber… I already posted that code (in swift) and it doesn’t work, and it’s already been explained why NSNumberFormatter doesn’t work on unsigned long longs ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to pretty print (big)numbers?
On 11 October 2014 13:47, Roland King r...@rols.org wrote: On 11 Oct 2014, at 8:22 pm, Igor Mozolevsky i...@hybrid-lab.co.uk wrote: On 11 October 2014 07:03, Gerriet M. Denkmann gerr...@mdenkmann.de wrote: On iOS 8.0: UInt64 sum = 16494631536958186120UL; NSString *sumString = [ NSNumberFormatter localizedStringFromNumber: @(sum) numberStyle: NSNumberFormatterDecimalStyle ]; results in sumString = -1,952,112,536,751,365,496, which seems not quite right. Further thought:- Isn't UInt64 a typedef? Try making the ULL (not UL) number with +(NSNumber *)numberWithUnsignedLongLong method of NSNumber… I already posted that code (in swift) and it doesn’t work, and it’s already been explained why NSNumberFormatter doesn’t work on unsigned long longs I'm not on -swift list(s) so can you post it here (or to me) for my benefit? I tried to locale-print the number in plain C, and it works fine ( http://ideone.com/zqnZqg):- #include assert.h #include locale.h #include stdio.h #include stdlib.h int main(void) { char *numstr; int out_len; unsigned long long num = 1649463153695818612; setlocale(LC_ALL, ); const int len = snprintf(NULL, 0, %'llu, num); assert(len 0); numstr = malloc((size_t) len + 1); assert(numstr != NULL); out_len = snprintf(numstr, len + 1, %'llu, num); assert(out_len == len numstr[len] == 0); printf(%s\n, numstr); free(numstr); return 0; } Output:- Success time: 0 memory: 3996 signal:0 1,649,463,153,695,818,612 -- Igor M. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Concurrent tasks are getting hung up
On Oct 10, 2014, at 11:01 PM, Steve Mills sjmi...@mac.com wrote: OK, that makes sense. The docs for NSOperationQueue made it sound like it would take care of all that for you... Yep. Remember all the hoopla about GCD and how it would take care of all of that for us??? Honestly the more I hear, the less likely I am to replace my home-grown task queues with the modern built-in stuff. -- Scott Ribe scott_r...@elevated-dev.com http://www.elevated-dev.com/ (303) 722-0567 voice ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to pretty print floating numbers (without loosing precision)?
On Oct 11, 2014, at 7:36 AM, Scott Ribe scott_r...@elevated-dev.com wrote: On Oct 11, 2014, at 2:04 AM, Gerriet M. Denkmann gerr...@mdenkmann.de wrote: Note: converting to double does NOT loose any digits. Well, it has to. Not sure how you're getting that output, but a double has 52 bits for the mantissa, so the largest integer it can represent without losing precision is about 4.5x10^15. Oops. Forgot the implicit MSB 1 in normalized doubles, so I guess max is ~9X10^15. Anyway, your number is well into the range where it lose binary digits, so it would just be pure (very unlikely) luck if that specific integer happened to be one that is precisely representable as a double. -- Scott Ribe scott_r...@elevated-dev.com http://www.elevated-dev.com/ (303) 722-0567 voice ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Concurrent tasks are getting hung up
On Oct 11, 2014, at 08:30, Scott Ribe scott_r...@elevated-dev.com wrote: Yep. Remember all the hoopla about GCD and how it would take care of all of that for us??? Honestly the more I hear, the less likely I am to replace my home-grown task queues with the modern built-in stuff. It also doesn't help that Apple's own sample apps show a loop on the main thread adding all operations to the queue in one batch, and those ops were processing files in a folder, much like I'm doing. Steve via iPad ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Questions on using a NSTextView as a source viewer.
On Oct 11, 2014, at 3:53 AM, Daryle Walker dary...@mac.com wrote: On Oct 10, 2014, at 1:58 AM, Ken Thomases k...@codeweavers.com wrote: On Oct 10, 2014, at 12:02 AM, Daryle Walker dary...@mac.com wrote: On Oct 7, 2014, at 8:03 PM, Ken Thomases k...@codeweavers.com wrote: On Oct 7, 2014, at 5:29 PM, Daryle Walker dary...@mac.com wrote: 1. Although the text in the window expands vertically as needed, it never does horizontally. Wrapping always happens when lines are too long, but it adjusts as the width of the window is changed. How do I get “infinite” space horizontally? I tried various tweaks in Interface Builder and looked at various Apple guides, but I can’t turn off the horizontal wrapping. On the Size inspector of IB, enable Resizable Horizontally. Then, in code, do this (assuming self.textView is the outlet property): self.textView.textContainer.widthTracksTextView = NO; I couldn't find anyplace in IB that exposes the text container attributes. I added “textContainer.widthTracksTextView” to the run-time attributes section in Interface Builder as a Boolean, and it changes the behavior in the other direction; the text wraps at the window’s original width, even if I make the window wider. Changing it to YES (i.e. turning on the checkbox) brings back the previous behavior. (I first changed the horizontal point limit to 10K, just like the vertical limit.) Did you also set Resizable Horizontally (the first step, above)? And, yes, good catch: I forget to mention changing the max. width. Yes. I tested this and it worked for me. In summary, all three steps: * Set the text view's max. width * Set the text view to be horizontally resizable * Set textView.textContainer.widthTracksTextView = NO I had that before my last post; didn’t fix it, made it worse (text width is the initial width of the window, even if I Zoom it out, or manually make it wider, or narrower(!)). I think Ken mis-stated what he meant--the max width isn't terribly relevant. You need to set the actual container size (width minimally) to an unlikely large number. Apple's TextViewSizing example project demonstrates this. They use the value 1.0e7, which comments say is the largest possible value before experiencing text drawing issues. You will have to set this value in code, as it can't be set via IB. On Oct 7, 2014, at 5:33 PM, Daryle Walker dary...@mac.com wrote: 3. The text in the view-source window is editable, although I turned that off. (It’s still selectable.) I can cut/copy/paste. Isn’t turning off editing supposed to stop this? Are you using bindings? Do any of them have Conditionally Sets Editable enabled in the binding options? Yes, one for the text view's contents, and another on the window's title (using the format substitution version). There is a binding for the text view being editable, but I’m not using it. (The text contents property in my window controller class is read-write.) My point was to check the options on those bindings for the Conditionally Sets Editable option. If any of them have that option enabled, that would explain why your text is editable when you set the text view to non-editable. The binding option is overriding the attribute you set. Turn it off. I thought you meant the “Editable” attribute under “Availability.” I haven’t activated that Binding at all. But now I see you meant the C.S.E. option under the Binding I did make. That option is checked. Turning it off blocks Cut and Paste, but still allows Copy, Select All, and Find. You will need to also turn off selectable (setSelectable: in code) which should disable the rest, and possibly change find value to none (setUsesFindBar: and/or setUsesFindPanel:). HTH, Keary Suska Esoteritech, Inc. Demystifying technology for your home or business ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Kerning Pairs
The Windows CDC class has a function: DWORD GetKerningPairs( DWORD nNumPairs, LPKERNINGPAIR lpkrnpair ); What would be the equivalent in a Cocoa class? I cannot find any methods that have kerning in their name. -rags ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Custom NSImageView with CALayer for Selection Rect not Scaling...
Hello, I have a custom NSImageView with layer-backing and CALayer sublayers for drawing the selection rectangle. All of this is embedded in a NSScrollView with magnification enabled. When I zoom in or out the image in the image view “scales” but the selection rectangle does not and “stays” where it was originally draw. Is there a to get the selection rect CALayers to scale with the image (or image view)? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Kerning Pairs
On Oct 11, 2014, at 8:20 AM, Raglan T. Tiger r...@crusaderrabbit.net wrote: The Windows CDC class has a function: DWORD GetKerningPairs( DWORD nNumPairs, LPKERNINGPAIR lpkrnpair ); What would be the equivalent in a Cocoa class? I cannot find any methods that have kerning in their name. Kerning can be much more complicated than can be represented by a simple pairing table. See Apple’s documentation for the Kerx table, specifically Format 1, which encodes a state machine: https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6kerx.html So the question, as usual, becomes: what are you actually trying to do? I bet you could get it done via the NSTypesetter API. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Kerning Pairs
On Oct 11, 2014, at 10:16 AM, Kyle Sluder k...@ksluder.com wrote: So the question, as usual, becomes: what are you actually trying to do? For the selected font I want to find the number of kerning pairs kpcnt, make a new KERNINGPAIR [ kpcnt ] structure and then fill it out. The kpcnt and KERNINGPAIR are passed to model code for kerning the glyphs into our model. -rags ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to pretty print floating numbers (without loosing precision)?
On 11 Oct 2014, at 20:47, Scott Ribe scott_r...@elevated-dev.com wrote: On Oct 11, 2014, at 7:36 AM, Scott Ribe scott_r...@elevated-dev.com wrote: On Oct 11, 2014, at 2:04 AM, Gerriet M. Denkmann gerr...@mdenkmann.de wrote: Note: converting to double does NOT loose any digits. Well, it has to. Not sure how you're getting that output, but a double has 52 bits for the mantissa, so the largest integer it can represent without losing precision is about 4.5x10^15. Oops. Forgot the implicit MSB 1 in normalized doubles, so I guess max is ~9X10^15. All integers up to 9007199254740992 are exact representable as double (which is probably ~9X10^15 as you mentioned). The next representable integer is then 9007199254740994. And of course the difference between representable numbers increases as the numbers get bigger. Anyway, your number is well into the range where it lose binary digits, so it would just be pure (very unlikely) luck if that specific integer happened to be one that is precisely representable as a double. Yes, this number is well into the range where not every integer is representable as double. But some are. And this number was chosen to be one of those. But still: %.22g prints the exact number (although not very readable) whereas NSNumberFormatter looses digits. Just using sprintf and then adding the thousands-separators will give a better result. Which means: the ICU algorithms are not very good with large numbers. Kind regards, Gerriet. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Kerning Pairs
On Oct 11, 2014, at 11:18 AM, Raglan T. Tiger r...@crusaderrabbit.net wrote: For the selected font I want to find the number of kerning pairs kpcnt, make a new KERNINGPAIR [ kpcnt ] structure and then fill it out. The kpcnt and KERNINGPAIR are passed to model code for kerning the glyphs into our model. You missed his point. Kerning can be much more complicated than what can be expressed in that kind of table. So Kyle's question is: what are you trying to accomplish with that table? -- Scott Ribe scott_r...@elevated-dev.com http://www.elevated-dev.com/ (303) 722-0567 voice ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Questions on using a NSTextView as a source viewer.
On Oct 11, 2014, at 10:23 AM, Keary Suska cocoa-...@esoteritech.com wrote: On Oct 11, 2014, at 3:53 AM, Daryle Walker dary...@mac.com wrote: On Oct 10, 2014, at 1:58 AM, Ken Thomases k...@codeweavers.com wrote: On Oct 10, 2014, at 12:02 AM, Daryle Walker dary...@mac.com wrote: On Oct 7, 2014, at 8:03 PM, Ken Thomases k...@codeweavers.com wrote: On Oct 7, 2014, at 5:29 PM, Daryle Walker dary...@mac.com wrote: 1. Although the text in the window expands vertically as needed, it never does horizontally. Wrapping always happens when lines are too long, but it adjusts as the width of the window is changed. How do I get “infinite” space horizontally? I tried various tweaks in Interface Builder and looked at various Apple guides, but I can’t turn off the horizontal wrapping. On the Size inspector of IB, enable Resizable Horizontally. Then, in code, do this (assuming self.textView is the outlet property): self.textView.textContainer.widthTracksTextView = NO; I couldn't find anyplace in IB that exposes the text container attributes. I added “textContainer.widthTracksTextView” to the run-time attributes section in Interface Builder as a Boolean, and it changes the behavior in the other direction; the text wraps at the window’s original width, even if I make the window wider. Changing it to YES (i.e. turning on the checkbox) brings back the previous behavior. (I first changed the horizontal point limit to 10K, just like the vertical limit.) Did you also set Resizable Horizontally (the first step, above)? And, yes, good catch: I forget to mention changing the max. width. Yes. I tested this and it worked for me. In summary, all three steps: * Set the text view's max. width * Set the text view to be horizontally resizable * Set textView.textContainer.widthTracksTextView = NO I had that before my last post; didn’t fix it, made it worse (text width is the initial width of the window, even if I Zoom it out, or manually make it wider, or narrower(!)). I think Ken mis-stated what he meant--the max width isn't terribly relevant. You need to set the actual container size (width minimally) to an unlikely large number. Apple's TextViewSizing example project demonstrates this. They use the value 1.0e7, which comments say is the largest possible value before experiencing text drawing issues. You will have to set this value in code, as it can't be set via IB. This fixed it. Thanks. There was a minor detour where I just had “textContainer.containerSize” set. You need BOTH “containerSize” and “widthTracksTextView” set (to {10M, 10M} and NO, respectively). Both of these can be set in the user-defined run-time attributes section of IB. I heard about this a few months ago as a power-user hint. I first tried it to set the text-view’s font to the system fixed-width font, but I couldn’t do it. NSFont is not a type supported by the runtime attribute section, but NSSize and BOOL are. On Oct 7, 2014, at 5:33 PM, Daryle Walker dary...@mac.com wrote: 3. The text in the view-source window is editable, although I turned that off. (It’s still selectable.) I can cut/copy/paste. Isn’t turning off editing supposed to stop this? Are you using bindings? Do any of them have Conditionally Sets Editable enabled in the binding options? Yes, one for the text view's contents, and another on the window's title (using the format substitution version). There is a binding for the text view being editable, but I’m not using it. (The text contents property in my window controller class is read-write.) My point was to check the options on those bindings for the Conditionally Sets Editable option. If any of them have that option enabled, that would explain why your text is editable when you set the text view to non-editable. The binding option is overriding the attribute you set. Turn it off. I thought you meant the “Editable” attribute under “Availability.” I haven’t activated that Binding at all. But now I see you meant the C.S.E. option under the Binding I did make. That option is checked. Turning it off blocks Cut and Paste, but still allows Copy, Select All, and Find. You will need to also turn off selectable (setSelectable: in code) which should disable the rest, and possibly change find value to none (setUsesFindBar: and/or setUsesFindPanel:). Oh, I want read-only actions supported. Those don’t break the illusion that the source-view and browser windows are connected. — Daryle Walker Mac, Internet, and Video Game Junkie darylew AT mac DOT com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This
Re: Questions on using a NSTextView as a source viewer.
On Oct 11, 2014, at 1:31 PM, Daryle Walker dary...@mac.com wrote: There was a minor detour where I just had “textContainer.containerSize” set. You need BOTH “containerSize” and “widthTracksTextView” set (to {10M, 10M} and NO, respectively). Both of these can be set in the user-defined run-time attributes section of IB. I heard about this a few months ago as a power-user hint. I first tried it to set the text-view’s font to the system fixed-width font, but I couldn’t do it. NSFont is not a type supported by the runtime attribute section, but NSSize and BOOL are. I stand corrected. I think this was new as of Xcode 5, since I haven't used that feature since Xcode 4, but I am glad the added it. Oh, I want read-only actions supported. Those don’t break the illusion that the source-view and browser windows are connected. Sorry, I misunderstood. I thought you didn't want those either. Keary Suska Esoteritech, Inc. Demystifying technology for your home or business ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Questions on using a NSTextView as a source viewer.
On Oct 11, 2014, at 9:23 AM, Keary Suska cocoa-...@esoteritech.com wrote: On Oct 11, 2014, at 3:53 AM, Daryle Walker dary...@mac.com wrote: On Oct 10, 2014, at 1:58 AM, Ken Thomases k...@codeweavers.com wrote: I tested this and it worked for me. In summary, all three steps: * Set the text view's max. width * Set the text view to be horizontally resizable * Set textView.textContainer.widthTracksTextView = NO I had that before my last post; didn’t fix it, made it worse (text width is the initial width of the window, even if I Zoom it out, or manually make it wider, or narrower(!)). I think Ken mis-stated what he meant--the max width isn't terribly relevant. You need to set the actual container size (width minimally) to an unlikely large number. Apple's TextViewSizing example project demonstrates this. They use the value 1.0e7, which comments say is the largest possible value before experiencing text drawing issues. You will have to set this value in code, as it can't be set via IB. No, I said what I meant. I tested the configuration I laid out and it worked. I'm not sure why it wasn't working for Daryle. Explicitly setting the text container size seems like a reasonable step, of course; it just wasn't necessary in my experiments. Regards, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
UIImageView content will not scale up(or down) even while using UIViewContentModeScaleAspectFit -- iOS8, Xcode 6.0.1
Hi all, I eventually want to do an animation like here: https://www.dropbox.com/s/6e1pyo7o57nl4ph/scrappling_ae_motion_setup.m4v?dl=0 so my plan is to do a CAAnimationGroup that will both scale the self.sticker image and change its position onscreen, end the animation and unhide self.stickerDestination. self.stickerBox contains self.stickerDestination (see dropbox image link below). I do the layout (using FLKAutoLayout) in -[UIViewController updateViewConstraints], then I add self.stickerDestination to self.stickerBox as a subview in there. Then in -[UIViewController viewDidLayoutSubviews] I set the frame of self.stickerDestination(because I don't find out the frame of self.stickerBox before that) in order to make it square(setting width and height to both width of self.stickerBox). For some reason, the UIImageView remains at 51x51 points(the images' real size in points) despite the frame reporting itself as 80x80 and me using UIViewContentModeScaleAspectFit. I would like it to scale up. Any suggestions? I've also found that when using a much larger image, 211x211, the image doesn't scale down either, it simply draws the UIImage as-is. So it appears that UIViewContentModeScaleAspectFit has no effect at all, it's as if the UIImageView never got the setContentMode: message. CODE: http://pastebin.com/quKPjEUy Screenshot of layout of view using false colours: https://dl.dropboxusercontent.com/u/597030/Pasted_Image_2014-10-11__5_55_PM.png Michael ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com