Infinciahttp://infincia.comInfincia blog RSS feedCodepoints 1.0.4http://infincia.com/blog/codepoints-104<p>The release of Mountain Lion brought an interesting bug in Codepoints to the surface that for some reason had never occurred on Lion.</p> <p>In certain cases, the background for some rows were being drawn transparent (technically zero height, but the end result is transparency).</p> <p>Details of the problem are below, but an update has already been submitted to the App Store to deal with this and an updated Retina icon has been included as well.</p> <h6>The problem: caching &amp; assumptions</h6> <p>Each row in Codepoints has a gradient background drawn in code (forgive the formatting):</p> <pre><code>-(void)drawBackgroundInRect:(NSRect)dirtyRect { // if cellBackground does not exist, create it if (!cellBackground) { // NSImage ivar cellBackground = [[NSImage alloc] initWithSize:dirtyRect.size]; [cellBackground lockFocus]; //cellGradient created elsewhere, just a basic gradient [cellGradient drawInRect:dirtyRect angle:270]; [cellBackground unlockFocus]; } // now actually draw the NSImage into the background rect [cellBackground drawInRect:dirtyRect fromRect:NSZeroRect operation:NSCompositeCopy fraction:1.0]; } </code></pre> <p>There is an assumption being made about the size of dirtyRect here, one that didn&rsquo;t seem to cause a problem on Lion for whatever reason.</p> <p>If this code were simply generating a new background image gradient every time the background needed to be drawn in a row, there would be no problem here as far as correctness, it would always work.</p> <p>But for performance reasons, it&rsquo;s caching that NSImage in an instance variable, and at times the cached version is not full height because dirtyRect is not always the full size of the row, occasionally it will be partial or zero height (likely when the row being drawn isn&rsquo;t on-screen yet). So a partial or zero height background image was being drawn into a fully visible row.</p> <p>The result was that some rows appeared transparent (a zero height background is essentially no background), which then caused scroll and click events to pass through the transparent area to whatever was under it, causing issues with scrolling and clicking.</p> <p>Instead the code now creates the background image ahead of time when each row view is created, using the actual size of the row, and then draws <em>that</em> into dirtyRect when the background needs to be drawn. This seems to have solved the problem :)</p>http://infincia.com/blog/codepoints-104Thu, 02 Aug 2012 17:49:47 UTCThe Mac App Store Sandbox deadline, Mi-Fi Monitor, and Codepointshttp://infincia.com/blog/sandbox-mifi-monitor-codepoints<p><img src="http://infincia.com/files/download/sandbox-deadline.jpg" title="Sandbox Day" alt="Sandbox Day" /></p> <p>Today, June 1st, is <a href="http://www.macworld.com/article/1167055/sandboxing_deadline_arrives_what_it_means_for_apple_developers_and_you.html">Sandbox day</a>. From now on, all new submissions to the Mac App Store must be sandboxed.</p> <p>Developers with non-sandboxed applications already on the store have a choice to make in the near future if they haven&rsquo;t acted already, they can either implement sandboxing, submit only bugfix updates (no new features), or pull out of the Mac App Store entirely in favor of selling direct to customers over the web, which is a viable option in some cases as the Mac is still a very open platform compared to iOS.</p> <p>For me, today isn&rsquo;t much of a deadline however, as both of the Mac software utilities I've published on the store are already sandboxed and don&rsquo;t require any special behaviors that would conflict with Apple&rsquo;s restrictions.</p> <h5>Codepoints</h5> <p><a href="http://infincia.com/apps/codepoints">Codepoints for Mac</a> is the simpler of the two utilities already on the store, it requires no &ldquo;entitlements&rdquo; of any kind. In addition, none of the features that are currently being added to it will run afoul of the sandbox rules either.</p> <p>Here&rsquo;s the sandbox config for it in Xcode:</p> <p><img src="http://infincia.com/files/download/codepoints-entitlements.png" title="Codepoints Entitlements" alt="Codepoints Entitlements" /></p> <p>It is essentially a happy resident of the Sandbox and has been there since it was released a few months ago.</p> <h5>Mi-Fi Monitor</h5> <p><a href="http://infincia.com/apps/mi-fi-monitor-mac">Mi-Fi Monitor for Mac</a> is also sandboxed, but does require one entitlement: Outgoing Network Connections.</p> <p>Here&rsquo;s the sandbox config for it in Xcode:</p> <p><img src="http://infincia.com/files/download/mi-fi-monitor-entitlements.png" title="Mi-Fi Monitor Entitlements" alt="Mi-Fi Monitor Entitlements" /></p> <p>As Mi-Fi Monitor is essentially a display for the status API available on Novatel&rsquo;s Mi-Fi, it must be able to communicate with it over the network. Specifically, it must make periodic HTTP requests to a CGI script running on the Mi-Fi itself.</p> <p>In addition there is a feature buried in the preferences area of Mi-Fi Monitor that allows users to manually submit debug information to me if something isn&rsquo;t working properly, and that also occurs with an HTTP POST connection to a special <a href="https://github.com/infincia/mifidemo">Google App Engine system</a> I created for it.</p> <p>This is all standard behavior for most applications though, so merely ticking the box to request that entitlement gives it everything it needs to do its job.</p>http://infincia.com/blog/sandbox-mifi-monitor-codepointsFri, 01 Jun 2012 19:12:28 UTCHotkeys in Codepoints and the Mac App Storehttp://infincia.com/blog/hotkeys-codepoints-app-store<p><strong>Update</strong>: Crisis <a href="http://www.macworld.com/article/1166857/apps_using_global_hotkeys_will_remain_welcome_in_the_mac_app_store.html#lsrc.twt_macworld">averted</a> :)</p> <p>Earlier today Erica Sadun at <a href="http://www.tuaw.com/2012/05/17/nanny-computing-and-the-future-of-os-x/">TUAW</a> posted an article about Apple potentially rejecting applications from the Mac App Store that use &ldquo;global hotkeys&rdquo;.</p> <p>As <a href="http://infincia.com/apps/codepoints">Codepoints for Mac</a> makes good use of global hotkeys, and ships on the Mac App Store, naturally I'm a bit concerned about how to handle the situation, if true.</p> <p>Codepoints uses an optional global hotkey so you can access it from anywhere, even if you're typing in a word processor or writing code in an IDE, or writing an email. The alternative (or one of them, see end) is to use the mouse and manually hit the Menu Bar icon each time.</p> <p>Codepoints doesn&rsquo;t set this hotkey on its own, it ships with the hotkey disabled and presents the user with a message in a small box noting this capability:</p> <p><a href="http://infincia.com/files/codepoints-hotkey.jpg" title="Hotkey in Codepoints"> <img src="http://infincia.com/files/download/codepoints-hotkey.jpg" title="Hotkey in Codepoints" alt="Hotkey in Codepoints" /> </a></p> <h5>Apple&rsquo;s Sandbox</h5> <p>The assumption being made is that this potential change is related to the <a href="http://arstechnica.com/apple/2011/07/mac-os-x-10-7/9/#sandboxing">Sandbox</a>, due to become mandatory on June 1st.</p> <p>However, Codepoints is <em>already</em> sandboxed, and has been since the day it became available on the store, so that doesn&rsquo;t make much sense to me unless Apple simply hadn&rsquo;t got around to excluding this public API (see below) from being used by sandboxed apps.</p> <p>More likely, if true, Apple just doesn&rsquo;t want Mac App Store software to let users override the keyboard commands of other applications or system actions. For instance the default keyboard commands for copy and paste are cmd-C and cmd-V, respectively. However, applications that allow the user to set global hotkeys can override both of those actions if the user accidentally picks those key sequences to do something else, which may cause confusion.</p> <p>Global hotkeys can also conflict with <em>local</em> hotkeys, those that have a specific action attached to them within an application. For instance, <a href="http://sparrowmailapp.com/">Sparrow</a> uses cmd-N to open a new mail dialog, however if cmd-N is set to be a global hotkey elsewhere, <em>that</em> action is the one that will actually take place when the user presses that key sequence, even if Sparrow has focus.</p> <p>It&rsquo;s also possible that Apple simply doesn&rsquo;t want Mac App Store software altering global behavior of the system, and global hotkeys definitely qualify there.</p> <h5>Global Hotkeys in OS X</h5> <p>If you don&rsquo;t know what global hotkeys are, they allow an application and the person using it to designate a specific key sequence that can be attached to a specific action in that application, which works even when the application isn&rsquo;t in focus. OS X also allows you to set global hotkeys for some OS level actions, you can see those in System Preferences under the Keyboard area.</p> <p>Global hotkeys aren&rsquo;t new on OS X, nor are they part of a private Apple API. The one Codepoints uses for this purpose is part of Carbon and is specifically made available in the public header files, which note that it has been there through the entire life of OS X, from 10.0 forward:</p> <pre><code>extern OSStatus RegisterEventHotKey( UInt32 inHotKeyCode, UInt32 inHotKeyModifiers, EventHotKeyID inHotKeyID, EventTargetRef inTarget, OptionBits inOptions, EventHotKeyRef * outRef) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER; </code></pre> <p>As this API is part of Carbon, my guess is this functionality predates OS X entirely and was available in Mac OS 9 and earlier.</p> <p>The API is not deprecated in Lion, and so far as I know it isn&rsquo;t deprecated in Mountain Lion either, but it seems if Erica is correct, Apple does not want Mac App Store applications to use it anymore going forward.</p> <h5>Codepoints</h5> <p>As for Codepoints, it&rsquo;s likely that it will remain on the Mac App Store and I can still issue bugfixes, but the first time I go to add a feature, Apple is likely to reject the update until I remove that global hotkey box.</p> <p>There may be alternatives I can look in to, other APIs to use that don&rsquo;t strictly involve setting a global hotkey but still provide the same functionality, I'll certainly check and update Codepoints if I find a good solution.</p>http://infincia.com/blog/hotkeys-codepoints-app-storeThu, 17 May 2012 19:23:04 UTCAbout font rendering in Codepointshttp://infincia.com/blog/codepoints-fonts<p>Earlier today I got a support email from a customer who found a bug few people are likely to hit in <a href="/apps/codepoints">Codepoints</a>, causing it to render characters small and in black:</p> <p><img src="/files/download/codepoints-black-bug.jpg" alt="Codepoints black font bug" /></p> <p>Both of those font rendering characteristics, size and color, are actually hardcoded in the app to be fairly large and white, which led me to believe there was something funny about the fonts on the system.</p> <p>As it turns out, the issue is caused by a font that was intentionally disabled by the user, and by chance it was the one font that Codepoints (and OS X itself) relies on to render a large number of Unicode glyphs, because it is the only one that ships with OS X that <em>can</em> render many of them: Arial Unicode MS.</p> <p>I'm preparing to update Codepoints to deal with situations like that, but I thought I would write a little about how font rendering in OS X actually works, and how Codepoints handles it.</p> <p>The Unicode 6.1 specification has 24,428 records in the database, however no single preinstalled font on OS X can render all of them. In fact, even when taken as a whole, OS X does not have font glyphs to render them all, and installing a 3rd party Unicode font is needed to get full coverage (<a href="http://unifoundry.com/unifont.html">GNU Unifont</a> is common and free).</p> <p>To deal with this, most operating systems use fallback behavior, they first try to render a character with the default or user selected font, and then cycle through other installed fonts until they either find a suitable glyph, or use the <a href="http://en.wikipedia.org/wiki/Fallback_font#The_Unicode_Last_Resort_Font">Last Resort</a> font, or give up entirely, which tends to look like a question mark or a black box.</p> <p>(Codepoints actually detects when the Last Resort font is about to be used and explicitly rejects it on a case by case basis, because most of the time the glyph returned by Last Resort is simply not useful as a preview)</p> <p>When automatic font selection is turned on in Codepoints, what the app does as of 1.0.2 is select Arial Unicode MS as the font to render things with, but will allow OS X to use the standard fallback mechanisms to render characters when Arial can&rsquo;t. This has the side effect of ensuring that most previews are rendered by the <em>same</em> font, giving at least some visual consistency to the list when scrolling.</p> <p>Selecting a specific font in the drop down menu is when things get interesting, instead of merely asking OS X to render a character with a specific font (which would trigger fallback behavior), Codepoints actually takes upon itself the job of determining whether or not the selected font <em>can</em> render a specific character, and by doing this it becomes possible to completely disable the fallback behavior. If you select Helvetica, you will not see any character at all if Helvetica cannot render it.</p> <p>The goal there is to not have the interface &ldquo;lying&rdquo; to the user, if you select a specific font, but then Codepoints allows a character to be rendered by something else, it would be misleading.</p> <p>If you want to know the reason a specific character was rendered or not rendered, you can mouse over the right side of the row and a tooltip will appear. Most of the time this tooltip is accurate, however there are some edge cases where a font <em>claims</em> to be able to render a character and Codepoints trusts it, but then the font doesn&rsquo;t actually return a glyph. You can sometimes see this in the higher Emoji range when the Apple Color Emoji font gets a little overzealous, but also with some obscure symbols in the lower range.</p> <p>I haven&rsquo;t decided whether or not to actually switch the default font yet, as I need to do some testing to see what exactly happens when you disable major fonts like this, however I do plan to deal with it in 1.0.x :)</p>http://infincia.com/blog/codepoints-fontsThu, 26 Apr 2012 19:14:37 UTCMi-Fi Monitor 1.4.1http://infincia.com/blog/mi-fi-monitor-141<p>Mi-Fi Monitor 1.4.1 should be making its way out to both App Stores right now, the primary changes are minor cosmetic/alignment bugs fixed, but a few of the core 3rd party libraries (CorePlot being the big one) have been updated too.</p> <p>I'm also finishing up the GPS support which will probably roll out on iOS first, though I'm working on the Mac component separately.</p>http://infincia.com/blog/mi-fi-monitor-141Mon, 09 Apr 2012 05:03:07 UTCCodepoints 1.0.2http://infincia.com/blog/codepoints-102<p>I've submitted an update for Codepoints to the App Store, which fixes 2 critical issues that affect certain users:</p> <ul> <li>Codepoints now carefully checks 3rd party fonts and ignore any that aren&rsquo;t usable (caused odd crashes)</li> <li>Resolve a rare timing issue where the app would appear empty after launching</li> </ul> <p>Both of those issues have been fixed and the update is simply waiting for approval, which on the Mac App Store tends to happen fast.</p>http://infincia.com/blog/codepoints-102Fri, 03 Feb 2012 20:02:39 UTCCodepoints 1.0.1http://infincia.com/blog/codepoints-101<p>I've submitted (and Apple has already approved) Codepoints 1.0.1, which should be making its way in to the Mac App Store right now.</p> <p>The only change is that Unicode 6.1 data is included with the update.</p> <p>A future Codepoints update will probably include the ability to update Unicode data automatically when new versions of the standard are announced.</p>http://infincia.com/blog/codepoints-101Thu, 02 Feb 2012 20:21:22 UTCCodepoints 1.0http://infincia.com/blog/codepoints-1<p><a href="http://infincia.com/apps/codepoints">Codepoints</a> for Mac is now available on the <a href="http://itunes.apple.com/app/codepoints/id499161264?mt=12">Mac App Store</a> :)</p> <p>Since this is the first release I thought I'd give a little background on why I wrote it.</p> <p>When I started working on <a href="http://infincia.com/apps/mi-fi-monitor-ios">Mi-Fi Monitor</a> back in 2010, I quickly discovered that the API for those little devices spits out a string of key=value pairs separated by an invisible character (escape). I remember having to google &ldquo;escape character&rdquo; repeatedly so I could copy it into the clipboard.</p> <p>That was not my first encounter with string encoding and parsing, but it was one of the first times I noticed how difficult it is to use characters that aren&rsquo;t easily accessible from the keyboard, particularly the control characters which have no width or visible representation.</p> <p>There are of couse ways for dealing with those invisible characters, in certain situations you can type \0 for null or \n for linefeed, but that doesn&rsquo;t apply everywhere.</p> <p>But ok, those are invisible control characters, nobody but a programmer should have to care about them anyway, right?</p> <p>Right. I and most other programmers eventually pick up on those and remember the few that we need, problem solved&hellip;&hellip; if you only care about invisible ASCII control characters.</p> <p>Now toss Unicode into the mix, with ~24,000 assigned codepoints. Any hope of even remembering the numbers so you can use them in one of the few places a Unicode escape sequence will work, goes right out the window.</p> <p>What&rsquo;s the Unicode escape sequence for the Euro currency symbol? Or any of the various musical note symbols? What about the Greek Omega? Or the Copyright symbol? Registered trademark?</p> <p>Should programmers have to remember all these? Or just some? Should you even have to be a programmer or know what an escape sequence is to use them?</p> <p>I don&rsquo;t think you should, so I wrote Codepoints for Mac.</p> <p>My goal with Codepoints was to make it easily accessible from anywhere on your Mac, very fast, and to make it disappear immediately once it is no longer needed.</p> <p>As a result, Codepoints is a Menu Bar app that can be accessed at any time with a single click (or global keyboard shortcut).</p> <p>Once the popup opens, you can search by typing immediately (no mouse work required), scroll the list using your mouse or arrow keys, and double click a row or select it and hit enter. This copies the character into your clipboard, closes Codepoints and returns focus to your previous application.</p> <p>I've got some interesting things to add to Codepoints soon, and I plan to keep it in sync with the newest Unicode standard, which was 6.0 when Codepoints was submitted to the App Store but has since been updated to 6.1. An update should be due out soon with that.</p>http://infincia.com/blog/codepoints-1Thu, 02 Feb 2012 15:42:55 UTCMi-Fi Monitor 1.4http://infincia.com/blog/mi-fi-monitor-14<p>Mi-Fi Monitor 1.4 is waiting for approval in both app stores.</p> <p>The primary change on Mac is the ability to selectively enable the signal, battery, or both icons in the menu bar. New icons are also included, I heard from more than one person that the old ones were too big so I started from scratch and made Mi-Fi Monitor draw them on-the-fly in code (using bezier paths and a ton of math :)</p> <p>On iOS and Mac the graph is now marked clearly with a time frame (45 seconds), and on iOS the graphs are back to being bubbles, the full screen graph was just too big especially on the iPad.</p> <p>I've also removed the password field on both platforms since it isn&rsquo;t used anymore.</p> <p>I've also fixed a minor memory leak in the Mac version. It was only a KB every few seconds but over the course of a few hours or more it could (and in one case did) add up to quite a bit of memory use.</p> <p>In the process of fixing that memory leak I decided to just take the time and convert Mi-Fi Monitor on all platforms to use <a href="http://arstechnica.com/apple/reviews/2011/07/mac-os-x-10-7.ars/10">ARC</a>, which should help prevent leaks in the future and make the entire codebase more maintainable.</p> <p>The switch to using ARC means 32-bit Macs can&rsquo;t be supported anymore because ARC doesn&rsquo;t work on 32-bit machines. Everyone on Lion has a 64-bit machine, but there are probably still a few 32-bit Snow Leopard users around.</p>http://infincia.com/blog/mi-fi-monitor-14Mon, 23 Jan 2012 04:43:53 UTCMi-Fi Monitor 1.3.3http://infincia.com/blog/mi-fi-monitor-133<p>I've submitted an update for Mi-Fi Monitor to both app stores, the primary change is the option to select a specific Novatel Mi-Fi model. This should make it more clear which devices are supported, and 2 of the settings handle specific cases for AT&amp;T and WiMAX devices that have slightly different behavior.</p> <p>I've also made the Mac version Snow Leopard compatible and updated the Growl SDK</p>http://infincia.com/blog/mi-fi-monitor-133Thu, 15 Dec 2011 04:26:50 UTCMi-Fi Monitor for Mac approvedhttp://infincia.com/blog/mi-fi-monitor-mac-approved<p>Today the <a href="http://infincia.com/apps/mi-fi-monitor-mac">Mac version</a> of Mi-Fi Monitor was approved and released for sale on the <a href="http://itunes.apple.com/app/mi-fi-monitor/id483152719?mt=12">App Store</a>.</p> <p>Though the version number is 1.3.2, this is only because Mi-Fi Monitor is a universal app across iPod, iPhone, iPad and Mac, they all share about 80% of the same codebase with platform-specific interfaces built on top.</p> <p>The Mac UI is relatively new and may need to be refined a bit, but the core functionality should be very stable.</p>http://infincia.com/blog/mi-fi-monitor-mac-approvedSat, 10 Dec 2011 04:26:50 UTCMi-Fi Monitor 1.3.2http://infincia.com/blog/mi-fi-monitor-132<p>Mi-Fi Monitor for iOS 1.3.2 is in review right now:</p> <ul> <li>Fixed a rare bug where attempting to open the support form <em>right after</em> installing the app (before letting it try to connect to the Mi-Fi) would cause a crash</li> <li>Fixed the incorrect version number in settings</li> </ul> <p>Mi-Fi Monitor for Mac is at the stage where I'm comfortable releasing it on the Mac App Store, so 1.3.2 will be the first version there when it is approved.</p> <p>I'm still working on the GPS stuff for 2.0, and plan to add some requested features to 1.4 in the meantime. The signal graph is probably going to revert back to its previous look but offer a button to expand it to fill the screen. I'm also adding a slider to the settings area so you can set how often you want the app to check your Mi-Fi for battery and signal status.</p>http://infincia.com/blog/mi-fi-monitor-132Tue, 06 Dec 2011 04:26:50 UTC