D2PointsToDIPs, D2DIPsToPoints Functions

Requires: Direct2D.lg32

Purpose

Converts font size from Points to DIPs and vice versa.

Syntax

fntsizedips! = D2PointsToDIPs(points!)

points! = D2DIPsToPoints(fntsizedips!)

fntsizedips!, points!: single expression

Description

Helper functions to simply convert from one fontsize system to another. They help in converting point size values returned by the Ocx-property FontSize and vice versa.

Example

'

' D2Font sample

' (dpi-unaware & dpi-aware)

'

$Library "direct2d"

$Library "gfawinx"

OpenW 1, 0, 0, 320, 300, 16 + 32

Global Object Win1RT

Set Win1RT = D2GetRT()

Global Object Fnt, FntBold   ' cache the fonts

Set Fnt = D2Font("Gabriola", D2PointsToDIPs(13))

Set FntBold = D2Font("Gabriola", D2PointsToDIPs(13), DWRITE_FONT_WEIGHT_BOLD)

Do

Sleep

Until Me Is Nothing

 

Sub Win_1_Paint

D2BeginDraw Win1RT, D2C_White

D2SetFont Fnt     ' high performance

D2Text 16, 16, "Hello Direct2D (Normal)"

D2SetFont FntBold

D2Text 16, 40, "DirectWrite (Bold)"

D2EndDraw

EndSub

See Also

FontSize

{Created by Sjouke Hamstra; Last updated: 09/05/2020 by James Gaite}