CSS, fonts and HTML layout

Effective declarations, eight-byte class keys and the original drawing limits.

The original V2 CSS reader recognises 81 property names, but only fifteen change the examined style structure. The distinction between parsing, layout and drawing is essential: a stored font size does not select a larger bitmap, and a recognised border style need not have its conventional appearance. These findings cover Japanese V2, American V2 and European ARM9 code. [1]

Supplying CSS

Use one external stylesheet and a semicolon after every declaration, including the last. The box readers collect values up to a semicolon. CSS comments have a skip path; an at sign instead skips towards a line ending, rather than providing media queries, imports or font loading. Property names and named values are case-sensitive. [1]

PropertyIDImplemented effect
background-color2Box colour
border-color12One to four side colours
border-style22One to four style bytes
border-width27One to four integer side widths
color32Inherited text colour
float35none, left or right; left/right also select relative positioning
font-size38Eight-bit size field
height4216-bit integer height
line-height45Inherited 16-bit line height
margin50One to four side margins
padding62One to four side paddings
position67static, relative, absolute or fixed
text-decoration71Decoration flags
width7816-bit integer width
z-index80Low eight bits, later interpreted as signed

The remaining recognised names leave all eighty style bytes unchanged in the declaration tests: [1]

background background-attachment background-image background-position background-repeat
border border-bottom border-bottom-color border-bottom-style border-bottom-width
border-collapse border-left border-left-color border-left-style border-left-width
border-right border-right-color border-right-style border-right-width border-spacing
border-top border-top-color border-top-style border-top-width bottom caption-side
clear clip display empty-cells font font-family font-style font-varient font-weight
left letter-spacing list-style list-style-image list-style-position list-style-type
margin-bottom margin-left margin-right margin-top max-height max-width min-height
min-width overflow overflow-x overflow-y padding-bottom padding-left padding-right
padding-top right table-layout text-align text-indent text-transform top
vertical-align visibility white-space word-spacing

The spelling font-varient is present in the original table. Border-radius, opacity, box-shadow, transform, flex and grid have no property implementation here. Use the separate border declarations, margin and padding shorthands, and supported HTML alignment attributes. Do not rely on display or visibility to hide controls. [1]

Selectors and precedence

A lookup key consists of a tag ID and eight class bytes. A plain tag or a single tag.class rule works; a class alone, an ID or a wildcard does not. Tag spelling is case-insensitive, but class bytes are not. Longer class names are truncated, so names sharing their first eight bytes collide. [1]

SelectorObserved interpretation
divTag rule
div.cardTag plus one class
.card / #card / *No ordinary rule
div#cardUnrecognised tag token
div,p / div > p / div:hoverA div rule; no list, descendant or state matching
div.card spanA div.card rule; no descendant matching

The first matching rule wins; repeated rules are not merged. Within one rule, the last declaration of a property wins. Default and inherited text fields are applied first, followed by the first tag rule and then its class rule. A class colour can therefore override a tag colour while retaining the tag's width. Keep each complete tag/class definition in one rule. [1]

Inheritance copies selected text and border flags, rather than the entire box. Margins, padding, dimensions, background, float and positioning have separate application. Unspecified values include colour 0x8000 and signed -127 in several fields. If a rule supplies font-size without line-height, the style tail assigns size plus two; an explicit line-height in that rule is retained. [1]

Dimensions and colour

Numeric values use decimal prefixes without unit conversion. Values 12px, 12pt, 12em and 12% all store 12; 1.5px stores one and auto stores zero. One shorthand value applies to all sides; two mean top/bottom then right/left; three mean top, right/left, bottom; four mean top, right, bottom, left. The same expansion applies to border widths, colours and styles. Values are truncated into eight- or sixteen-bit fields and may later be read as signed. [1]

The colour reader accepts 140 lowercase names and six hexadecimal digits. Hexadecimal letter case is unrestricted, but named RED differs from red. Three-digit shorthand does not work: #fff becomes black through the checked helper. Rgb functions and transparent return the unspecified sentinel. RGB15 is calculated as follows: [1]

(red >> 3) | ((green >> 3) << 5) | ((blue >> 3) << 10)

Text has fifteen distinct RGB15 slots, with equal colours deduplicated. A sixteenth distinct colour uses slot zero. Texture colours and rectangle backgrounds use separate storage. Border-style accepts none, solid, double, groove, ridge, inset, outset, dotted and dashed, but the examined block painter emits identical solid side strips for every nonzero style with a positive width. Use solid when describing the result. [1]

The body font

The American V2 browser obtains its body font from the font manager's +24 slot, loaded from LocalizeData/Common/FontData/NITRO_LC_Font_s.ZFTR. The text manager keeps that font at +81960. Its NFTR has 7,282 glyphs, a 9 × 12 cell, line feed 12, ascent 10, one bit per pixel and default advance nine. Individual advances differ: A, M and W use five pixels, i uses one, space two and a full stop three. Use CWDH widths and CMAP lookup; an unmapped 0xFFFF result selects the replacement glyph. [1]

CSS keywordStored size
xx-small / x-small / small8
medium10
large12
x-large16
xx-large20
smaller8
larger12

Smaller and larger are fixed assignments. The size field affects line spacing, culling and decoration placement, but the inspected glyph callback receives the same font, bitmap, width metrics and position at sizes 8, 10, 12, 16 and 20. That caller does not scale the bitmap. Underline and overline produce one-pixel rectangles; line-through and blink produce the same examined glyph output as none. Larger display lettering requires a native title or a prepared image, rather than another body font-family declaration. [1]

Layout and budgets

Ordinary static blocks calculate their bounds from the containing box, margins, padding and borders without reading stored width or height. Other position branches read width, but ignored top, left, right and bottom declarations prevent conventional CSS positioning. Floats participate in the original geometry; that does not establish support for every modern float arrangement. Z-index is signed eight-bit data used in a packed depth calculation. [1]

The inline engine decodes one-, two- and three-byte UTF-8, measures the fixed font and wraps at the containing edge. It tracks runs in character range 0x21–0x7FF when moving a word to the next line; this is not general Unicode line breaking. The glyph list stops accepting entries at 10,240. Table columns are counted from the first row, including colspan; a positive count of at most sixteen and a temporary layout object are required. The checked allocator assigns equal widths and returns its temporary object, while row layout is tested separately. [1]

CSS rules have a 256-record pool, distinct from the 512 per-node style records. Pagination, shallow tables and a small set of complete rules keep these limits separate from the image and text budgets. Original instruction checks establish the listed parsing and drawing operations; they do not substitute for a complete visual test on the target client. [1]

Styles must be prepared before layout

Original CSS-to-text path, American V2
  1. Parse CSS and construct DOM
  2. Apply inheritance and prepare colours
  3. Lay out block and inline geometry
  4. Measure glyphs through original NFTR advances

Ten connected comparisons join CSS parser 0207716C, DOM construction 020791F8, preparation 0207C1B0, layout 0207C1E4, recursive blocks 0207C688, inline choice 0207D9A0 and text records 0207DADC. Nested margins/padding, inherited versus overridden colours and glyph positions agree with independently calculated records. The built-in style template has letter spacing one; assuming zero changes the expected geometry. Final rectangle publication and draw-list reset remain output boundaries. [2]

Unused rules still consume text colours

Preparation first reserves native RGB15 values zero and decimal 619, then visits rule and per-node styles through 02076178 and colour admission 0207EF38. The pool holds fifteen entries. Unused class rules can consume entries before a later used style is visited. Once full, a green style can retain its RGB15 value in the node while its emitted glyphs fall back to slot zero. Keep stylesheets focused: a collection of unused colour variants is not free in this renderer. [2]

The second reserved value is 619, not white. These checks establish the preparation order, palette admission and the checked block/inline records. Complete tables, every selector, final pixels and physical palette composition remain unverified. [2]

Sources

  1. [1] Flipnote Decompilation Project — Original V2 CSS, text layout and drawing
  2. [2] Flipnote Decompilation Project — Connected CSS layout and finite text-colour admission

← All documentation