getnum java_java-Font.getNumGlyphs()返回的数字

公孙河
2023-12-01

Font.getNumGlyphs()返回的数字实际上代表什么?

Returns the number of glyphs in this Font. Glyph codes for this Font range from 0 to getNumGlyphs() - 1.

注意:在这里,要处理200多种字体的100万个代码点(countGlyphs方法)大约需要30秒.运行时要有耐心.

import java.awt.*;

import java.util.Date;

import javax.swing.*;

import javax.swing.table.DefaultTableModel;

class FontGlyphCheck {

public static int countGlyphs(Font f) {

int count = 0;

for (int ii = 0; ii < Character.MAX_CODE_POINT; ii++) {

if (f.canDisplay(ii)) {

count++;

}

}

return count;

}

public static void main(String[] args) {

System.out.println(new Date());

GraphicsEnvironment ge =

GraphicsEnvironment.getLocalGraphicsEnvironment();

String[] fontNameArray = ge.getAvailableFontFamilyNames();

final String[] names = {"Name", "Number Glyphs", "Count Glyphs"};

final Object[][] values =

new Object[fontNameArray.length][names.length];

for (int ii = 0; ii < fontNameArray.length; ii++) {

Font f = new Font(fontNameArray[ii], Font.PLAIN, 16);

values[ii][0] = fontNameArray[ii];

values[ii][1] = new Integer(f.getNumGlyphs());

values[ii][2] = new Integer(countGlyphs(f));

}

System.out.println(new Date());

Runnable r = new Runnable() {

@Override

public void run() {

JPanel gui = new JPanel(new BorderLayout());

DefaultTableModel dtm = new DefaultTableModel(values, names) {

@Override

public Class> getColumnClass(int columnIndex) {

if (columnIndex == 0) {

return String.class;

}

return Integer.class;

}

};

JTable table = new JTable(dtm);

table.setAutoCreateRowSorter(true);

gui.add(new JScrollPane(table));

JOptionPane.showMessageDialog(null, gui);

}

};

// Swing GUIs should be created and updated on the EDT

// http://docs.oracle.com/javase/tutorial/uiswing/concurrency

SwingUtilities.invokeLater(r);

}

}

产量

此输出来自基于Windows 7的PC. GUI表中显示的第一列已拖到最后一列(以更好地对齐列),并且行按getNumGlyphs()值(输出的第一列)以升序排序.

16 33 MS Outlook

41 59 Marlett

46 64 MT Extra

116 131 Bookshelf Symbol 7

192 208 Symbol

204 256 Algerian

208 286 Castellar

211 228 Wingdings 3

220 237 Wingdings 2

226 243 Wingdings

227 243 Webdings

230 250 Elephant

231 190 MS Reference Specialty

232 282 Stencil

241 258 Onyx

242 254 Narkisim

242 254 Miriam

242 254 Levenim MT

242 254 Aharoni

242 261 Modern No. 20

242 261 Footlight MT Light

243 254 Miriam Fixed

243 254 FrankRuehl

243 254 David

243 260 Lucida Handwriting

243 260 Lucida Fax

243 260 Lucida Calligraphy

243 261 Rockwell Extra Bold

243 261 Rockwell

243 261 Palace Script MT

243 261 Gloucester MT Extra Condensed

243 261 Colonna MT

243 261 Centaur

243 261 Brush Script MT

243 261 Broadway

243 261 Bell MT

243 261 Arial Rounded MT Bold

244 256 Rod

244 261 Perpetua Titling MT

244 261 Matura MT Script Capitals

244 261 Imprint MT Shadow

244 261 Engravers MT

244 261 Blackadder ITC

244 261 Bernard MT Condensed

244 262 Poor Richard

244 265 Old English Text MT

244 267 Edwardian Script ITC

245 261 Chiller

245 261 Calisto MT

246 262 Freestyle Script

247 266 Pristina

248 257 Harrington

248 270 Jokerman

249 268 Forte

249 273 Goudy Stout

249 275 Kristen ITC

250 267 Vladimir Script

250 267 Rage Italic

250 267 Kunstler Script

250 267 Eras Medium ITC

250 267 Eras Light ITC

250 267 Eras Demi ITC

250 267 Eras Bold ITC

250 268 Perpetua

251 268 OCR A Extended

251 268 Bodoni MT

251 269 Viner Hand ITC

251 269 Tempus Sans ITC

251 269 Script MT Bold

251 269 Rockwell Condensed

251 269 French Script MT

251 269 Felix Titling

251 269 Curlz MT

251 269 Bradley Hand ITC

252 259 Wide Latin

252 260 Britannic Bold

252 261 Cooper Black

252 268 Bodoni MT Condensed

252 268 Bodoni MT Black

253 261 Copperplate Gothic Light

253 261 Copperplate Gothic Bold

253 268 Gigi

255 262 Parchment

255 262 Papyrus

258 260 Playbill

260 278 Maiandra GD

261 277 Snap ITC

261 277 Juice ITC

261 279 Bodoni MT Poster Compressed

269 261 Baskerville Old Face

269 274 Showcard Gothic

270 260 Vivaldi

270 260 Harlow Solid Italic

270 260 Bauhaus 93

270 261 Goudy Old Style

274 274 Ravie

275 279 Informal Roman

291 274 Magneto

295 315 Gill Sans Ultra Bold

296 315 Gill Sans MT Condensed

297 314 Tw Cen MT Condensed Extra Bold

297 314 Tw Cen MT Condensed

297 314 Tw Cen MT

297 314 Gill Sans Ultra Bold Condensed

297 315 Gill Sans MT Ext Condensed Bold

298 274 Agency FB

300 303 MV Boli

300 315 Gill Sans MT

308 321 Microsoft Tai Le

311 326 Plantagenet Cherokee

317 338 Lao UI

343 350 Microsoft New Tai Lue

350 358 Leelawadee

362 333 LilyUPC

362 333 KodchiangUPC

362 333 JasmineUPC

362 333 IrisUPC

362 333 FreesiaUPC

362 333 EucrosiaUPC

362 333 DilleniaUPC

362 333 CordiaUPC

362 333 Cordia New

362 333 BrowalliaUPC

362 333 Browallia New

362 333 AngsanaUPC

362 333 Angsana New

363 275 Berlin Sans FB

364 274 Berlin Sans FB Demi

381 274 Californian FB

385 274 High Tower Text

395 402 Gisha

397 274 Niagara Solid

397 274 Niagara Engraved

422 321 Vijaya

433 317 Latha

450 370 Estrangelo Edessa

459 326 Raavi

463 348 Kartika

473 484 Simplified Arabic

474 482 Simplified Arabic Fixed

490 402 DokChampa

518 507 Andalus

581 595 Trebuchet MS

587 602 Comic Sans MS

589 574 Traditional Arabic

592 339 Tunga

596 614 Georgia

633 337 Kalinga

634 382 DaunPenh

654 676 Haettenschweiler

660 677 Franklin Gothic Heavy

660 678 Franklin Gothic Book

663 672 Garamond

663 676 Arial Narrow

663 678 Franklin Gothic Medium Cond

663 678 Franklin Gothic Demi Cond

663 681 Franklin Gothic Demi

665 677 Franklin Gothic Medium

666 676 Mistral

666 677 Impact

666 688 Century Gothic

667 664 Lucida Console

669 690 Monotype Corsiva

669 691 Century Schoolbook

669 691 Bookman Old Style

669 691 Book Antiqua

670 406 MoolBoran

670 692 Century

674 680 Arial Black

675 391 Khmer UI

690 687 Segoe Print

706 358 Utsaah

706 358 Kokila

706 358 Aparajita

734 732 Sylfaen

796 724 Gentium Book Basic

796 724 Gentium Basic

816 333 Vrinda

826 352 Iskoola Pota

847 337 Shonar Bangla

864 353 Vani

865 879 Euphemia

872 348 Gautami

885 357 Mangal

951 794 Verdana

1014 1029 OpenSymbol

1028 902 Nyala

1043 709 Microsoft Uighur

1180 780 Candara

1193 1190 MS Reference Sans Serif

1201 780 Corbel

1204 779 Constantia

1326 613 Microsoft PhagsPa

1328 1083 Palatino Linotype

1376 1391 Lucida Sans Typewriter

1402 1415 Lucida Bright

1482 456 Microsoft Himalaya

1484 1286 Ebrima

1491 340 Shruti

1565 1553 Microsoft Yi Baiti

1779 1762 Lucida Sans Unicode

1824 420 Mongolian Baiti

1915 1876 DejaVu Sans Light

1940 627 Segoe Script

2261 989 Sakkal Majalla

2380 2139 Segoe UI Semibold

2380 2139 Segoe UI Light

2584 2307 Arimo

2731 2230 Consolas

2901 2668 Segoe UI

2929 2391 Lucida Sans

2962 1138 Arabic Typesetting

3077 2826 Microsoft Sans Serif

3248 2862 Courier New

3248 87256 Monospaced

3248 87256 DialogInput

3289 3257 DejaVu Sans Mono

3399 3357 DejaVu Serif Condensed

3399 3357 DejaVu Serif

3414 2905 Tahoma

3415 2817 Times New Roman

3415 87191 Serif

3417 2821 Arial

3417 87193 SansSerif

3417 87193 Dialog

3878 2176 Calibri

3983 2176 Calibri Light

3987 3752 Segoe UI Symbol

4517 902 Gabriola

5928 5636 DejaVu Sans Condensed

5928 5636 DejaVu Sans

6991 3240 Cambria

6991 4362 Cambria Math

12747 12639 Malgun Gothic

19321 16059 MS PMincho

19321 16059 MS Mincho

22134 22202 DFKai-SB

22213 16059 MS UI Gothic

22213 16059 MS PGothic

22213 16059 MS Gothic

23942 16946 Meiryo UI

23942 16946 Meiryo

28562 28542 SimHei

28562 28542 KaiTi

28562 28542 FangSong

28762 28735 SimSun

28762 28735 NSimSun

29220 28977 Microsoft JhengHei

29354 29095 Microsoft YaHei

34046 28991 PMingLiU

34046 28991 MingLiU

34046 33877 MingLiU_HKSCS

39680 20626 GungsuhChe

39680 20626 Gungsuh

39680 20626 BatangChe

39680 20626 Batang

40194 20626 GulimChe

40194 20626 Gulim

40194 20626 DotumChe

40194 20626 Dotum

42809 42827 SimSun-ExtB

44875 42953 PMingLiU-ExtB

44875 42953 MingLiU-ExtB

44875 42953 MingLiU_HKSCS-ExtB

50377 38933 Arial Unicode MS

>如果其中有一个Font,两个值相同,那么我还没有注意到.

>尽管大多数计数接近(在canDisplay方法返回的值的10%以内),但有些却截然不同.

 类似资料: