Đoạn code ví dụ cách đếm glyphs của font bằng cách sử dụng tiện ích FontLib.
$font_file = get_post_meta( $post_id, 'font_file', true );
if ( $this->is_media_file_exists( $font_file ) ) {
$font = FontLib\Font::load( get_attached_file( $font_file ) );
$font->parse();
$table = $font->getTableObject( 'maxp' );
$glyphs = $table->data['numGlyphs'] ?? '';
}
Đầu vào là chúng ta có meta key của bài viết là ‘font_file‘ và $post_id là id của bài viết font cần lấy thông tin.