OpenKODE Core extension: KD_ACR_system_font


NameACR_system_font
Name stringsKD_ACR_system_font
ContributorsMasahiro Suda, Acrodea
ContactsAcrodea
StatusDraft
VersionVersion 1, 2011-06-14
NumberTBD
Dependencies Requires OpenKODE Core 1.0 or later. This extension is written based on the wording of the OpenKODE Core 1.0 specification.

1. Overview

This function creates an image from system font

2. Header file

When this extension is present, its facilities are accessed by including its header file:

#include <KD/ACR_system_font.h>

3. Defines

3.1. Defines

SystemFont defines.

Synopsis

#define KD_SYSTEM_FONT_TYPE_SANSSERIF_ACR   0x00000000
#define KD_SYSTEM_FONT_TYPE_MONOSPACE_ACR   0x00000001
#define KD_SYSTEM_FONT_TYPE_SERIF_ACR       0x00000002

#define KD_SYSTEM_FONT_FLAG_BOLD_ACR                0x00000001
#define KD_SYSTEM_FONT_FLAG_ITALIC_ACR              0x00000002
#define KD_SYSTEM_FONT_FLAG_OVERFLOW_WRAP_ACR       0x00000004
#define KD_SYSTEM_FONT_FLAG_OVERFLOW_ELLIPSIS_ACR   0x00000008

Font type

typeusage
KD_SYSTEM_FONT_TYPE_SANSSERIF_ACRSans-serif font
KD_SYSTEM_FONT_TYPE_MONOSPACE_ACRMonospaced font
KD_SYSTEM_FONT_TYPE_SERIF_ACRSerif font

Font flag

flagusage
KD_SYSTEM_FONT_FLAG_BOLD_ACRBOLD font (Availability depends on a device environment.)
KD_SYSTEM_FONT_FLAG_ITALIC_ACRITALIC font (Availability depends on a device environment.)
KD_SYSTEM_FONT_FLAG_OVERFLOW_WRAP_ACRIt inserts line feeds in w length. (Availability depends on a device environment.)
KD_SYSTEM_FONT_FLAG_OVERFLOW_ELLIPSIS_ACRIt displays “…” for the part which is over w length. If KD_SYSTEM_FONT_FLAG_OVERFLOW_WRAP_ACR is also selected, KD_SYSTEM_FONT_FLAG_OVERFLOW_WRAP_ACR is available. (Availability depends on a device environment.)

4. New function

4.1. kdSystemFontGetTextSizeACR

Gets system font width and height.

Synopsis

KDint kdSystemFontGetTextSizeACR(KDint32 size,
 KDint32 locale,
 KDint32 type,
 KDint32 flag,
 const KDchar * utf8string,
 KDint32 w,
 KDint32 * result_w,
 KDint32 * result_h);
 

Description

This function acquires width and height to draw by system font.

Parameters
size

A font size.

locale

A local information. (Unsupported)

type

A font type.

flag

A font flag.

utf8string

A UTF-8 string to acquire.

w

A width to display. This parameter is available only for KD_SYSTEM_FONT_FLAG_OVERFLOW_WRAP_ACR and KD_SYSTEM_FONT_FLAG_OVERFLOW_ELLIPSIS_ACR.

result_w

A pointer to an area to store a width of display area.

result_h

A pointer to an area to store a height of display area.

Return value

On success, this function returns 0. On failure, it returns -1 and can get an error detail by kdGetError.

Error codes

KD_EIO

General I/O error.

KD_EINVAL

A parameter is invalid.

4.2. kdSystemFontRenderTextACR

Stores a system font image to a buffer.

Synopsis

KDint kdSystemFontRenderTextACR(KDint32 size,
 KDint32 locale,
 KDint32 type,
 KDint32 flag,
 const KDchar * utf8string,
 KDint32 w,
 KDint32 h,
 KDint32 pitch,
 void * buffer);
 

Description

This function draws system font on a specified area. It is stored by 0-255 description of 1byte-1pixel.

Parameters
size

A font size.

locale

A local information.

type

A font type.

flag

A font flag.

utf8string

A UTF-8 strung to acquire.

w

A width of display area.

h

A height of display area.

pitch

A buffer pitch.

buffer

A buffer.

Return value

On success, this function returns 0. On failure, it returns -1 and can get error detail by kdGetError.

Error codes

KD_EIO

General I/O error.

KD_EINVAL

A parameter is invalid.

5. Revision history

5.1. Version 1, 2011-06-14

Initial version.