略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: CairoContext::setFontFace

2024-04-19

CairoContext::setFontFace

cairo_set_font_face

(PECL cairo >= 0.1.0)

CairoContext::setFontFace -- cairo_set_font_faceThe setFontFace purpose

说明

面向对象风格 (method):

public CairoContext::setFontFace ( CairoFontFace $fontface ) : void

过程化风格:

cairo_set_font_face ( CairoContext $context , CairoFontFace $fontface ) : void

Sets the font-face for a given context.

参数

context

A CairoContext object to change the font-face for.

fontface

A CairoFontFace object

返回值

No value is returned

范例

Example #1 面向对象风格

<?php
// New surface with white background
$s = new CairoImageSurface(CairoFormat::ARGB32300100);
$c = new CairoContext($s);
$c->setSourceRgb(111);
$c->paint();

// Draw some text
$c->setSourceRgb(000);
$c->moveTo(1060);
// Create a new font face
$f = new CairoToyFontFace("sans-serif"CairoFontSlant::NORMALCairoFontWeight::NORMAL);
$c->setFontFace($f);
$c->setFontSize(30);
$c->showText('Hello, World!');
$s->writeToPng(dirname(__FILE__) . '/setFontFace.png');
?>

Example #2 过程化风格

<?php
/* ... */
?>

参见

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/cairocontext.setfontface.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3