Units of Measurement in TRichView

<< Click to display table of contents >>

Units of Measurement in TRichView

Glossary

Pica (pc) typographic unit of measure corresponding to 1/6 of inch. The pica contains 12 points.

Point (pt) typographic unit of measure corresponding to 1/72 of inch. This is a measuring unit for font size.

Twip (tw, “twentieth of a point”) is defined as 1/20 of point. It equals to 1/1440 of inch.

English metric unit (EMU) is useful for representation of decimal fractions of inches and millimeters as integer values. 1 inch = 914400 EMU, 1 mm = 36000 EMU.

Pixel (px) a single point in a raster image or device. To convert inch (or other absolute unit of measurement) to pixels, a pixel density (referred as "pixels per inch" (PPI) or "dots per inch" (DPI)) of this device must be known. For some devices (like printers), this value is precise. For other devices (like computer displays), this value is logical and can be changed by the user. For screens, a typical "pixels per inch" value is 96 (accessible as Screen.PixelsPerInch).

In TRichView, DPI of values measured in pixels is defined in UnitsPixelsPerInch property of TRVStyle component. When rendering on a device (screen or paper), sizes are recalculated according to the device DPI as:

value * (device DPI) / UnitsPixelsPerInch

Screen DPI can be read from Screen.PixelsPerInch, or it can be overridden in RichViewPixelsPerInch global variable.

Properties measured in points

Font size (Size property of text styles)

Properties measured in  “standard” pixels

1  “standard” pixel = 1/TRVStyle.UnitsPixelsPerInch of an inch.

The following properties of TCustomRichView are measured in “standard” pixels:

LeftMargin, RightMargin, TopMargin, BottomMargin – margins;

MaxTextWidth – maximal width for word wrapping;

MinTextWidth – minimal width for word wrapping (minimal width of scrollable area, not including margins).

Properties measured in TRVUnits

Properties of the type TRVLength are measured in TRVUnits. They are values of a floating point type (Extended) that can represent lengths measured in inches, centimeters, millimeters, picas, points, or “standard” pixels.

In TRichView, this type is used for:

properties of TRichView.DocParameters; they are measured in TRichView.DocParameters.Units.

properties of TRVPrint; they are measured in TRVPrint.Units.

In RichViewActions, this type is used to define units of values displayed in dialog windows. They are measured in TRVAControlPanel.UnitsDisplay.

In ScaleRichView, this type is used for properties of TSRichViewEdit.PageProperty and TSRichViewEdit.ViewProperty. They are measured in TSRichViewEdit.UnitsProgram.

Properties measured in TRVStyleUnits

Properties of the type TRVStyleLength are measured in TRVStyleUnits. They are values of an integer type that can represent lengths measured in “standard” pixels, twips, or EMU.

The property TRVStyle.Units defines units for properties (and sub-properties) of this TRVStyle component as well as for properties of items in documents loaded in linked TRichView controls.

Properties of TRVStyle measured in TRVStyleUnits

The following properties are measured in TRVStyleUnits:

DefTabWidth;

CharSpacing of text style;

FirstIndent, LeftIndent, RightIndent, SpaceBefore, SpaceAfter of paragraph style;

Position of item in a tab stop collection of paragraph style;

Left, Right, Top, Bottom of background padding rectangle (Background.BorderOffsets) of paragraph style;

Left, Right, Top, Bottom of border padding rectangle (Border.BorderOffsets) of paragraph style, as well as border's Width and InternalWidth;

MarkerIndent, FirstIndent, LeftIndent in list levels of list style.

Item properties measured in TRVStyleUnits

The following items properties are measured in TRVStyleUnits:

rvepSpacing, rvepImageWidth, rvepImageHeight, rvepVShift (the latter only if rvepVShiftAbs is nonzero)

The following table properties are measured in TRVStyleUnits:

BorderWidth, CellBorderWidth;

BorderHSpacing, BorderVSpacing, CellHSpacing, CellVSpacing;

CellHPadding, CellVPadding, CellPadding;

HRuleWidth, VRuleWidth;

BestWidth (only if value is positive).

The following table cell properties are measured in TRVStyleUnits:

BestHeight;

BestWidth (only if value is positive).

A width of break (horizontal line) is measured in TRVStyleUnits as well.

The following label item properties are measured in TRVStyleUnits:

MinWidth.

The following sidenote properties are measured in TRVStyleUnits:

BoxProperties.Width and Height (if WidthType and HeightType are “absolute”);

BoxPosition.HorizontalOffset and VerticalOffset (only if HorizontalPositionKind and VerticalPositionKind are “absolute”).

In RichViewActions, this type is used for TRVAControlPanel.UnitsProgram (units of measurement for properties of several actions).

Import and export

In RTF (Rich Text Format) files, native units are twips, so all properties are saved as twips. When loading, they are converted to TRVStyle.Units.

In HTML, native units are pixels, so all properties are saved in pixels. In HTML CSS, these properties are saved either as integer values in pixels (if TRVStyle.Units=rvstuPixels), or as fractional values in points (if TRVStyle.Units=rvstuTwips).

In RVF (RichView Format) files, values are saved as TRVStyle.Units. When loading, they are either converted to TRVStyle.Units, or vice versa, TRVStyle.Units is changed. See “Units of measurement” in RVF Overview. Alternatively, TRichView can be converted to units from RVF file, if rvfoCanChangeUnits is included in RVFOptions.