NINCH and EMU
People have been asking about a couple of acronyms fairly often these days, so here’s a blog post on them. They are described on the web already if you type the right queries, but a little more motivation might be useful. The acronyms are NINCH for “no input no change” and EMU for “English Metric Unit”, not the large Australian flightness bird so popular in crossword puzzles.
Some programming object models, such as RichEdit’s TOM and Word’s Object Model, have formatting objects that you can apply to a range of text. These objects, such as the TOM ITextFont, work in two distinct modes: immediate and acquire. In the immediate mode, a specific property is applied to the associated range of text. For example in Visual Basic notation, r.font.bold = tomTrue sets the text in the range r to bold. In this mode, only a single property is changed; all other properties remain unchanged.
In the acquire mode, the programmer gets a “duplicate” formatting object that isn’t associated with a range or even a text story and sets values for whatever properties need to be changed. Setting the properties is very fast, since they are not yet being applied to text. When all the desired properties are set, the programmer can apply the object to a range of text all in one fell swoop. In effect, the object is a specialized “format painter”, if you’re familiar with the little paint-brush icon on the Word Home ribbon. In this format-painter mode, the properties that should not be altered need to have a special value to convey this fact. The value is the NINCH value, meaning “no input no change”. It’s called tomUndefined in TOM and wdUndefined in Word, and it works with longs, floats, and COLOREFs. For strings, such as the font name, NINCH is represented by the null string.
A related value is needed when properties for a range are retrieved using the formatting object. Specifically if the characters in the range do not all have the same value of a property, the value returned should indicate ambiguity. Such a value is useful for displaying a grayed check box or empty field in property dialogs. The term tomUndefined sort of makes sense, whereas NINCH really doesn’t since no input is involved. Maybe tomAmbiguous would be a reasonable name. In practice, we just use the tomUndefined (or wdUndefined) value and interpret it appropriately on set and get operations. In addition, TOM and Word can toggle simple binary properties by setting them equal to tomToggle and wdToggle, respectively. As such a binary property like bold can be set with four possible values: tomTrue, tomFalse, tomUndefined, and tomToggle (or True, False, wdUndefined, wdToggle for Word). To distinguish such values from ordinary booleans, we call their type “tomBool”. By the way, technically bold is not a binary property: fonts may one or more weights. But for years people have concentrated on two: normal and bold.
Back in 1959, one of the greatest years for Bordeaux wines, the three nearly equal definitions of the inch became standardized so that the inch equals exactly 2.54 centimeters. The centimeter itself was still defined as one hundredth the length of a special meter long bar until 1983. At that time, the meter was redefined very slightly to be the distance light travels in vacuum in 1/299,792,458 of a second. Advances in physics had allowed people to measure time far more accurately than distance, but I digress. The choice of 2.54 cm/in allows one to define a length unit that is equally at home with both English and metric units: the EMU. There are 914400 EMUs per inch. Note the 1440 in the middle of 914400. You may recognize 1440 as the number of twips/inch, where a twip is 1/20 of a point and a point is 1/72 of an inch. And sure enough there are exactly 914400/1440 = 635 EMUs in a twip and 914400/2.54 = 360000 EMUs in a centimeter. This gives lots of resolution to describe paper sizes around the world accurately and still to be usable with 32-bit integers (4294967296/360000 ≅ 11,930 cm).
It’s nice to have word processing software that lays out a page without depending on the printer or screen resolution and the EMU is handy for that purpose. Another popular unit is the floating-point point, since font heights are usually given in points, single-precision floating-point arithmetic offers reasonably high resolution, and today’s computers are facile with floating point arithmetic. And for what it’s worth an Australian emu may very well be 65,620,800 EMUs in height (6 feet).