Font Class

 

About Font Class

 

Font class is mainly used for loading and managing fonts.

 

Font Class Methods

 

Font.Add( string Name, long CharSet, long Size, long Weight, bool Italic, bool Underline, bool StrikeOut ) adds a logical font with the specified characteristics.

string Name: string that specifies the typeface name of the font.
long CharSet: the character set.
long Size: size of the font.
long Weight: weight of the font in the range 0 through 1000. If this value is zero, a default weight is used.
bool Italic: specifies an italic font if set to true.
bool Underline: specifies an underlined font if set to true.
bool StrikeOut: specifies a strikeout font if set to true.

CharSet parameter can be one of the following constants.

ANSI_CHARSET ansi character set.

DEFAULT_CHARSET specifies a character set that is based on the current system locale. For example, when the system locale is English (United States), it is set as ANSI_CHARSET.

SYMBOL_CHARSET symbol character set.

SHIFTJIS_CHARSET shiftjis character set.

HANGEUL_CHARSET hangeul character set.

HANGUL_CHARSET hangul character set.

GB2312_CHARSET gb2312 character set.

CHINESEBIG5_CHARSET chinesebig5 character set.

OEM_CHARSET specifies a character set that is operating-system dependent.

JOHAB_CHARSET johab character set.

HEBREW_CHARSET hebrew character set.

ARABIC_CHARSET arabic character set.

GREEK_CHARSET greek character set.

TURKISH_CHARSET turkish character set.

VIETNAMESE_CHARSET vietnamese character set.

THAI_CHARSET thai character set.

EASTEUROPE_CHARSET east europe character set.

RUSSIAN_CHARSET russian character set.

MAC_CHARSET mac character set.

BALTIC_CHARSET baltic character set.

The Weight parameter can be one of the following constants.

FW_DONTCARE 0

FW_THIN 100

FW_EXTRALIGHT 200

FW_ULTRALIGHT 200

FW_LIGHT 300

FW_NORMAL 400

FW_REGULAR 400

FW_MEDIUM 500

FW_SEMIBOLD 600

FW_DEMIBOLD 600

FW_BOLD 700

FW_EXTRABOLD 800

FW_ULTRABOLD 800

FW_HEAVY 900

FW_BLACK 900

 

Font.Delete( long FontHandle ) Deletes a font and frees any memory the font occupied. If the function succeeds, the return value is true. If the function fails, the return value is false.

long FontHandle: font handle.

 

Code Example

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Giavapps.Windows.API;

public class CodeExample : MonoBehaviour
{

private long WindowHandle = 0;
private long ButtonHandle = 0;
private long FontHandle = 0;

void Start()
{
Plugin.Initialize();//Initializes Giavapps Windows API
FontHandle = Giavapps.Windows.API.Font.Add("Arial", Constant.ANSI_CHARSET, 20, 0, false, false, false);//Adds a new font
WindowHandle = Window.Create(0, 100, 100, 400, 400, Constant.WS_VISIBLE | Constant.WS_SYSMENU | Constant.WS_MINIMIZEBOX | Constant.WS_MAXIMIZEBOX | Constant.WS_SIZEBOX, Constant.WS_EX_TOPMOST);//Creates a new window
Control.SetText(WindowHandle, "Giavapps Windows API");//Sets a new title for the specified window
ButtonHandle = Button.Create(WindowHandle, 10, 10, 150, 32, Constant.WS_VISIBLE | Constant.WS_CHILD, 0);//creates a new button
Control.SetText(ButtonHandle, "Text");//Sets a new text for the specified button
Control.SetFont(ButtonHandle, FontHandle);//Sets the previously added font to the specified button
}

void Update()
{

//Checks if the specified window has been closed
if(Window.GetClosed(WindowHandle))
{
Control.Destroy(WindowHandle);//Destroys the specified window
}

}

void OnApplicationQuit()
{
Giavapps.Windows.API.Font.Delete(FontHandle);//deletes the previously added font
Plugin.Deinitialize();//Deinitializes Giavapps Windows API
}

}

 

I am Luigi Piscopo, also known as DJ GiDeejay / Producer / Remixer in the music world. I am a Producer with a lot of experience in photo editing, video editing, audio editing, graphic design, web design, programming and promotion.

Comments are closed.