unicode

5 posts

github

Don’t stop early: Case-folding source code at memory speed (opens in new tab)

Case folding converts text into a canonical, case-insensitive form for comparisons, making it essential to GitHub’s large-scale code search. GitHub optimized this operation by removing an apparent optimization: instead of stopping at the first non-ASCII byte, it scans the entire buffer branchlessly, enabling SIMD vectorization. The resulting Rust `casefold` crate processes ASCII at over 45 GiB/s—close to memory-bandwidth limits. ## Case Folding Is Not Lowercasing - Lowercasing is intended for display and can depend on locale or context. - Greek sigma may become `ς` or `σ`. - Turkish `I` has locale-specific behavior. - Case folding is intended for comparison and must be locale-independent and symmetric. - Unicode provides explicit rules in `CaseFolding.txt`. - The crate supports simple one-to-one folds (statuses C and S), but not: - Full folds such as `ß → ss` - Turkic-specific folds such as dotted `İ` - This restriction matches tools such as ripgrep and helps maintain consistent matching behavior. ## Why Case-Folding Performance Matters - GitHub’s Blackbird search engine indexes more than: - 180 million repositories - 480 TB of source code - Source bytes are case-folded before n-gram extraction and indexing. - Folding is also needed when evaluating potential query matches. - Since most source code is ASCII, optimizing the ASCII path provides the largest benefit. ## Removing the Early Exit - A conventional implementation scans until it finds a non-ASCII byte, then switches to Unicode processing. - On an Apple M4, this branch-heavy approach reached only about 3.1 GiB/s. - The optimized loop: - ORs every byte into an accumulator to detect non-ASCII data once. - Uses `b.wrapping_sub(b'A') < 26` as a branchless uppercase test. - Sets bit 5 with `| (is_upper << 5)` to lowercase uppercase ASCII letters. - The loop always processes and writes the entire buffer, then checks whether Unicode processing is necessary. ## Vectorization Beats Early Termination - Removing the data-dependent `break` allows LLVM to vectorize the loop with 16-byte NEON instructions. - Performance progression on a 5.7 KB ASCII buffer: - Naive branchy loop: 3.1 GiB/s - Branchless body with early exit: 2.6 GiB/s - Early exit removed: 7.6 GiB/s - Fully branchless loop: over 45 GiB/s - The early exit prevents vectorization even when the loop body is otherwise branch-free. - Branchless arithmetic then eliminates compare-and-blend overhead and enables full memory-speed performance. ## Why Branchless Code Can Be Slower - In scalar code, the branchless version writes every byte, even when no change is needed. - The branchy version skips stores for the majority of lowercase letters, digits, spaces, and other unchanged bytes. - Its conditional branch is highly predictable, so it is inexpensive. - Branchless writes become beneficial only after vectorization, where the processor handles a whole vector at once. The practical lesson is to avoid data-dependent loop exits when they block vectorization. For predominantly ASCII workloads, a complete branchless scan can outperform “stop as soon as possible” logic by a wide margin, while an accumulated high-bit check efficiently identifies inputs requiring Unicode handling.

discord

Discord Patch Notes: December 5, 2024 (opens in new tab)

Discord’s December 5, 2024 patch focuses on performance improvements, mobile design updates, compatibility, and bug fixes across the platform. Major changes include refreshed mobile profiles, a 90%+ faster iOS Media Picker, Unicode 15.1 emoji support, animated WebP embeds, and Webhook Events for apps. Discord noted that updates may still be rolling out and that Patch Notes would pause until early February. ## Major Product and Platform Updates - Mobile user profiles, including profile editing, were redesigned to more closely match the desktop experience. - The iOS Media Picker now loads images over 90% faster in most cases, with significantly less blank UI while content loads. - Unicode 15.1 emoji are supported; users may see placeholder or inconsistent emoji until they update their clients. - Desktop and web apps now support animated WebP content in embeds and favorites. - Animated emojis are requested in WebP instead of GIF to improve performance. - Webhook Events allow apps to receive events without maintaining gateway connections, which is useful for apps that do not require low latency. ## General Fixes and Usability Improvements - Bluesky URLs now receive proper embed support. - Fixed profile banner cropping, profile button rendering, shortened URL unfurling, streaming activity titles, and role-name display issues. - Mobile profile notification dots, Android button icons, localization, Nitro gifting themes, and server profile menus received various fixes. - Blocking a user from their profile now requires confirmation. - Adding roles through “Add Members” is capped at 30 users to prevent silent failures. - Fixed notification content, share-screen layout, poll-result indicators, and channel permission prompts. - Android incoming call notifications now show display names instead of usernames. ## Chat and Messaging - Message drafts now remain associated with the correct DM instead of moving between DM notifications. - Fixed emoji autocomplete in full-screen Text in Voice, user mentions displaying IDs, and iOS handling of text following an “@” symbol. - Thread creation, attachment layouts, typing indicators, chat input spacing, onboarding bars, and message forwarding themes were corrected. - Fixed unread mention indicators affecting surrounding background colors. - On iOS, opening certain threads no longer incorrectly navigates to the thread creator’s profile. ## Activities and Apps - Fixed username rendering problems in Activities on some servers. - App authorization widgets no longer incorrectly ask users to scroll when no scrollbar is present. ## Audio and Video - Corrected missing circular backgrounds on voice controls and sizing problems with Activity buttons in calls. - Switching between Push to Talk and Voice Activity now reliably reactivates Voice Activity. - Fixed Android microphone failures when sharing another application. - Resolved an iOS screen-sharing failure affecting app version 253; updating is required for affected users. - Fixed the mobile post-call feedback dialog and adjusted call-status icon styling. - On iOS speaker mode, the proximity sensor should no longer turn off the screen unexpectedly during calls.

figma

The power of emoji | Figma Blog (opens in new tab)

Emoji have become an essential layer of digital communication, helping convey emotion, tone, body language, and intent that are otherwise difficult to express through text. Jennifer Daniel, chair of Unicode’s Emoji Subcommittee, argues that emoji do not create new ideas; they translate long-standing human concepts into a flexible visual form. Because Unicode characters are permanent and globally interoperable, new emoji must be selected carefully, with an emphasis on broad usefulness and future relevance. ## Emoji supplement face-to-face communication - Digital communication lacks cues such as: - Rhythm and cadence - Volume - Eye contact - Body language - Emoji help restore some of these signals by clarifying a message’s emotional intent and tone. - As people become more familiar with emoji, choosing and placing them becomes almost instinctive. ## Emoji are contextual rather than a universal language - Emoji represent concepts that have existed throughout written and visual communication, rather than inventing new ones. - Their meanings can shift depending on context and cultural use. - For example, ❤️‍🔥 might suggest religious devotion, heartburn, or desire. - The way people actually use emoji often differs from how they believe they use them. ## Unicode makes emoji permanent - The Emoji Subcommittee operates within the Unicode Consortium, which standardizes digital writing systems worldwide. - Adding an emoji creates a permanent Unicode code point: - It cannot be removed or deprecated. - There are no “do-overs” if an idea becomes outdated. - This permanence contrasts with the fast, experimental cycle common in technology. - Unicode therefore tends to formalize concepts that already exist instead of rapidly creating new ones. ## Selecting useful, future-proof emoji - With more than 3,500 emoji, storage and implementation complexity are becoming constraints. - The committee is shifting away from overly specific objects—such as buckets, saws, and shorts—and toward symbols that support human expression and connection. - Strong candidates are: - Broadly relevant across cultures - Open to multiple meanings - Useful metaphorically or symbolically - Combinable with existing emoji to express new ideas - Adding one narrowly defined character can create pressure for related additions, such as needing both golden retriever and poodle emoji. - As a result, many valid proposals are rejected when their meaning is too specific or already expressible through existing characters. Emoji work best as flexible building blocks for communication, not as an attempt to represent every object or concept. Designers and standards bodies should prioritize symbols that are widely understandable, culturally adaptable, and capable of expressing multiple layers of human emotion and intent.

figma

When fonts fall | Figma Blog (opens in new tab)

Font fallback is the mechanism that lets computers display characters a font does not contain. It explains familiar problems such as missing-character boxes, broken emoji, shifted lines, inaccessible decorative “fonts,” and inconsistent kaomoji. Rather than random bugs, these effects arise from the gap between text data and the fonts available to render it. ## Everyday Symptoms of Font Fallback - Missing characters may appear as boxes, question marks, or other placeholder symbols. - Emoji can look assembled differently across devices when platforms support different glyphs or emoji sequences. - Decorative social-media “fonts” are often alternate Unicode characters, not actual font changes. - These characters can create accessibility problems for screen readers and display as empty boxes on unsupported systems. - Adding an emoji or unsupported character can change line height or spacing because a fallback font has different metrics. - Kaomoji and other symbol combinations may render differently depending on the available fonts. ## Why Fonts Cannot Contain Everything - A glyph is the visual form used to represent a character. - Even basic Western fonts require hundreds of glyphs for letters, numbers, punctuation, accents, symbols, ligatures, and OpenType alternatives. - Fonts supporting Chinese, Japanese, or other writing systems may contain thousands of glyphs. - Supporting additional languages and writing systems continually expands the required character set. - Font designers must eventually decide which characters their font will not support. ## The `.notdef` Glyph - Fonts include a special last-resort glyph called **`.notdef`**, used when a requested character is missing. - It commonly appears as a rectangle, sometimes with a cross or question mark. - `.notdef` is not a Unicode character; it is a visual substitute produced by the font. - The original character remains intact in the underlying text, so changing fonts or updating the font may reveal it correctly later. - Designers can choose how `.notdef` looks, from a simple blank square to more elaborate warning-like designs. ## Font Fallback as a Computer-Typography Problem - In physical typography, a piece of metal type inherently belonged to a specific font, so this mismatch was impossible. - Digital text can originate from another person, device, era, or font, creating a separation between the character and its visual representation. - Font fallback exists to bridge that gap by searching for another way to render unsupported characters—or displaying `.notdef` when no suitable glyph is available. Understanding font fallback makes many seemingly arbitrary typography failures predictable: the text is usually still present, but the chosen font lacks the glyph or the system’s fallback behavior differs.

figma

Happy Emoji Release Day at Figma 🎉 | Figma Blog (opens in new tab)

Figma introduced emoji support in 2017 after users repeatedly requested it, emphasizing that emojis had become essential to modern digital communication and interface design. The main technical challenge was ensuring consistent rendering across operating systems without sacrificing visual quality. Figma chose individually cached, 64×64 full-color PNGs, providing sharper and more memory-efficient results than Slack’s single large sprite image. ## Why Emoji Support Mattered - Designers need to preview interfaces with the same visual content users will see in real products. - Emojis communicate tone, emotion, and nuance in advertising, messaging, email, and social media designs. - Some teams reportedly left Figma because the feature was missing. - Native browser rendering was unsuitable because emoji appearance varies between operating systems and platforms. ## The History of Emoji and Unicode - Emojis originated in Japan in 1999, when Shigetaka Kurita created 176 pictorial characters to supplement text. - Competing mobile carriers developed incompatible emoji sets, causing inconsistent rendering. - In 2009, the Unicode Consortium standardized emoji identifiers alongside other written characters. - Unicode defines the character code and general design guidelines, but companies remain free to create their own artwork. - As a result, the same emoji can look substantially different on Apple, Google, Facebook, Twitter, Samsung, and other platforms. ## Why Cross-Platform Rendering Was Difficult - Figma is a collaborative, cross-platform application, so Mac and Windows users need to see identical designs. - Depending on each operating system’s emoji library could make the same file appear differently to different users. - Visual inconsistencies can alter an emoji’s perceived meaning, creating communication problems. ## Figma’s Rendering Approach - Slack’s approach used a large PNG containing Apple’s emoji set and displayed relevant regions as needed. - That method was fast but limited by lower color quality and poor scalability at larger sizes. - Figma rejected the sprite-image approach because designers are especially sensitive to low-resolution visuals. - Instead, Figma used separate 64×64 full-color PNG files for each emoji. - Individual emoji files load slightly slower the first time they are used, but are cached for faster subsequent use. - This approach provides higher resolution and uses memory more efficiently than one massive image. Figma’s solution prioritized consistent, high-quality rendering over the fastest possible initial load. For design tools and other visually demanding collaborative applications, individually cached assets can be a better tradeoff than relying on platform-native rendering or low-resolution sprite sheets.