查詢

UI\Draw\Text\Font\Descriptor::__construct()函式—用法及示例

「 建立 UI\Draw\Text\Font\Descriptor 類的新例項 」


函式名稱:UI\Draw\Text\Font\Descriptor::__construct()

適用版本:PHP 7.4.0 及以上版本

函式用法: UI\Draw\Text\Font\Descriptor::__construct() 函式用於建立 UI\Draw\Text\Font\Descriptor 類的新例項。該類用於描述字型的特性,例如字型名稱、大小、樣式等。

語法:

public UI\Draw\Text\Font\Descriptor::__construct(string $family, float $size, int $weight, int $italic)

引數:

  • $family:字型名稱,字串型別,表示要使用的字型的名稱。
  • $size:字型大小,浮點數型別,表示要使用的字型的大小。
  • $weight:字型粗細,整數型別,表示要使用的字型的粗細程度。可選值有:
    • 0:正常(預設值)
    • 1:粗體
  • $italic:字型斜體,整數型別,表示要使用的字型是否為斜體。可選值有:
    • 0:非斜體(預設值)
    • 1:斜體

示例:

$fontDescriptor = new UI\Draw\Text\Font\Descriptor("Arial", 12.0, 0, 0);

以上示例將建立一個 UI\Draw\Text\Font\Descriptor 類的例項,使用 Arial 字型,大小為 12.0,正常粗細,非斜體。

注意:上述示例需要在 PHP 7.4.0 及以上版本中執行,且需要安裝並啟用 UI 擴充套件。

補充糾錯
熱門PHP函式
分享連結