SShortSingh.
Back to feed

Developer finds Chinese text renders larger than English at equal font sizes

0
·1 views

A developer audited 62 places in an app where English and Chinese lines are stacked, finding that a simple rule of making the Chinese line one notch smaller produced visually larger Chinese text in most cases. The developer attributes this to a difference in glyph metrics: Han characters fill a taller ink box than Latin cap heights or x-heights at the same font size. Canvas measurements at 14px showed Han ink about 17% taller than capital H and about 56% taller than lowercase x. Applying this to the codebase, the median pair rendered Chinese larger than the English line it was meant to subordinate. The developer's earlier font-metric check missed the problem because it measured the primary font's bounding box rather than the rendered ink of each script.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Docker Disk Usage Persists After Pruning Containers, Due to Persistent Volumes

A Linux user found their disk still full after removing old containers and images with Docker cleanup commands. Investigation with du showed that the Docker directory under /var/lib was consuming about 79 GB, the largest share of disk usage on the machine. The author used docker system df to examine storage across images, containers, volumes, and build cache. The main takeaway is that persistent volumes hold much of this space and are not removed by ordinary pruning. The article explains how to locate and clean up unused resources without deleting data belonging to active containers.

0
ProgrammingHacker News ·

Reactor essay argues Children of Men reflects the present more than the future

A piece published on Reactor Magazine examines the 2006 film Children of Men and its depiction of a near-future world facing infertility and societal collapse. The essay contends that the film's dystopian themes resonate more strongly with contemporary anxieties than with any forecast of what lies ahead. It is framed as a critical reading of the movie rather than a report on a new event. The source text provided is limited to the link and Hacker News metadata, so the argument is described only at a high level.

0
ProgrammingDEV Community ·

Five chmod Permission Traps That Catch Developers Out

Standard tutorials recommend chmod 755 and 644 without explaining the permissions they grant. On directories, the read, write and execute bits behave differently: read lists names, write creates or deletes entries, and execute allows traversal, so a directory set to 666 is readable but unusable. The author also highlights confusion around chmod's = and + operators, the capital X flag for applying execute only where appropriate, and how umask is applied. Misplaced digits can unintentionally set setuid or setgid bits, while redirected file creation can yield overly permissive modes such as 644 for SSH keys. The article recommends install -m 600 for sensitive files and suggests a chmod calculator for verifying modes.

0
ProgrammingDEV Community ·

Loop order alone makes a 4096x4096 grid sum 13x slower due to CPU cache misses

A DEV Community author compared two functions that sum the same 4096 by 4096 grid, differing only in whether the outer loop walks rows or columns. Row-order summing took about 11 ms on an Apple M3 laptop, while column-order summing took about 146 ms, roughly 13 times slower. The explanation is that the CPU loads memory in fixed-size cache lines, so reading neighboring elements in a row reuses cached data, while jumping between rows in a column forces a memory fetch on nearly every read. The gap appears once the grid exceeds the cache size, and the author notes that a Float64Array shows the same pattern, indicating the cause is memory layout rather than JavaScript arrays. Suggested fixes include keeping the row loop outermost and accumulating column totals in a separate array, which matched the results of the column-order method at about 12 ms.

Developer finds Chinese text renders larger than English at equal font sizes · ShortSingh