■ EnumFontFamiliesEx API 함수를 선언하는 방법을 보여준다.
▶ 예제 코드 (C#)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 |
using System; using System.Runtime.InteropServices; #region 폰트 패밀리 열거하기 (확장) - EnumFontFamiliesEx(deviceContextHandle, logFontHandle, enumerateFontDelegate, longParameter, flag) /// <summary> /// 폰트 패밀리 열거하기 (확장) /// </summary> /// <param name="deviceContextHandle">디바이스 컨텍스트 핸들</param> /// <param name="logFontHandle">LOG 폰트 핸들</param> /// <param name="enumerateFontDelegate">폰트 열거하기 대리자</param> /// <param name="longParameter">LONG 매개 변수</param> /// <param name="flag">플래그</param> /// <returns>처리 결과</returns> [DllImport("gdi32", CharSet = CharSet.Auto)] private static extern int EnumFontFamiliesEx ( int deviceContextHandle, [In] IntPtr logFontHandle, EnumerateFontDelegate enumerateFontDelegate, IntPtr longParameter, uint flag ); #endregion /// <summary> /// 폰트 문자 세트 /// </summary> public enum FontCharSet : byte { /// <summary> /// ANSI_CHARSET /// </summary> ANSI_CHARSET = 0, /// <summary> /// DEFAULT_CHARSET /// </summary> DEFAULT_CHARSET = 1, /// <summary> /// SYMBOL_CHARSET /// </summary> SYMBOL_CHARSET = 2, /// <summary> /// MAC_CHARSET /// </summary> MAC_CHARSET = 77, /// <summary> /// SHIFTJIS_CHARSET /// </summary> SHIFTJIS_CHARSET = 128, /// <summary> /// HANGEUL_CHARSET /// </summary> HANGEUL_CHARSET = 129, /// <summary> /// HANGUL_CHARSET /// </summary> HANGUL_CHARSET = 129, /// <summary> /// JOHAB_CHARSET /// </summary> JOHAB_CHARSET = 130, /// <summary> /// GB2312_CHARSET /// </summary> GB2312_CHARSET = 134, /// <summary> /// CHINESEBIG5_CHARSET /// </summary> CHINESEBIG5_CHARSET = 136, /// <summary> /// GREEK_CHARSET /// </summary> GREEK_CHARSET = 161, /// <summary> /// TURKISH_CHARSET /// </summary> TURKISH_CHARSET = 162, /// <summary> /// VIETNAMESE_CHARSET /// </summary> VIETNAMESE_CHARSET = 163, /// <summary> /// HEBREW_CHARSET /// </summary> HEBREW_CHARSET = 177, /// <summary> /// ARABIC_CHARSET /// </summary> ARABIC_CHARSET = 178, /// <summary> /// BALTIC_CHARSET /// </summary> BALTIC_CHARSET = 186, /// <summary> /// RUSSIAN_CHARSET /// </summary> RUSSIAN_CHARSET = 204, /// <summary> /// THAI_CHARSET /// </summary> THAI_CHARSET = 222, /// <summary> /// EASTEUROPE_CHARSET /// </summary> EASTEUROPE_CHARSET = 238, /// <summary> /// OEM_CHARSET /// </summary> OEM_CHARSET = 255 } /// <summary> /// 폰트 클리핑 정밀도 /// </summary> public enum FontClipPrecision : byte { /// <summary> /// CLIP_DEFAULT_PRECIS /// </summary> CLIP_DEFAULT_PRECIS = 0, /// <summary> /// CLIP_CHARACTER_PRECIS /// </summary> CLIP_CHARACTER_PRECIS = 1, /// <summary> /// CLIP_STROKE_PRECIS /// </summary> CLIP_STROKE_PRECIS = 2, /// <summary> /// CLIP_MASK /// </summary> CLIP_MASK = 0xf, /// <summary> /// CLIP_LH_ANGLES /// </summary> CLIP_LH_ANGLES = (1 << 4), /// <summary> /// CLIP_TT_ALWAYS /// </summary> CLIP_TT_ALWAYS = (2 << 4), /// <summary> /// CLIP_DFA_DISABLE /// </summary> CLIP_DFA_DISABLE = (4 << 4), /// <summary> /// CLIP_EMBEDDED /// </summary> CLIP_EMBEDDED = (8 << 4) } /// <summary> /// 폰트 피치 & 패밀리 /// </summary> [Flags] public enum FontPitchAndFamily : byte { /// <summary> /// DEFAULT_PITCH /// </summary> DEFAULT_PITCH = 0, /// <summary> /// FIXED_PITCH /// </summary> FIXED_PITCH = 1, /// <summary> /// VARIABLE_PITCH /// </summary> VARIABLE_PITCH = 2, /// <summary> /// FF_DONTCARE /// </summary> FF_DONTCARE = (0 << 4), /// <summary> /// FF_ROMAN /// </summary> FF_ROMAN = (1 << 4), /// <summary> /// FF_SWISS /// </summary> FF_SWISS = (2 << 4), /// <summary> /// FF_MODERN /// </summary> FF_MODERN = (3 << 4), /// <summary> /// FF_SCRIPT /// </summary> FF_SCRIPT = (4 << 4), /// <summary> /// FF_DECORATIVE /// </summary> FF_DECORATIVE = (5 << 4) } /// <summary> /// 폰트 정밀도 /// </summary> public enum FontPrecision : byte { /// <summary> /// OUT_DEFAULT_PRECIS /// </summary> OUT_DEFAULT_PRECIS = 0, /// <summary> /// OUT_STRING_PRECIS /// </summary> OUT_STRING_PRECIS = 1, /// <summary> /// OUT_CHARACTER_PRECIS /// </summary> OUT_CHARACTER_PRECIS = 2, /// <summary> /// OUT_STROKE_PRECIS /// </summary> OUT_STROKE_PRECIS = 3, /// <summary> /// OUT_TT_PRECIS /// </summary> OUT_TT_PRECIS = 4, /// <summary> /// OUT_DEVICE_PRECIS /// </summary> OUT_DEVICE_PRECIS = 5, /// <summary> /// OUT_RASTER_PRECIS /// </summary> OUT_RASTER_PRECIS = 6, /// <summary> /// OUT_TT_ONLY_PRECIS /// </summary> OUT_TT_ONLY_PRECIS = 7, /// <summary> /// OUT_OUTLINE_PRECIS /// </summary> OUT_OUTLINE_PRECIS = 8, /// <summary> /// OUT_SCREEN_OUTLINE_PRECIS /// </summary> OUT_SCREEN_OUTLINE_PRECIS = 9, /// <summary> /// OUT_PS_ONLY_PRECIS /// </summary> OUT_PS_ONLY_PRECIS = 10 } /// <summary> /// 폰트 품질 /// </summary> public enum FontQuality : byte { /// <summary> /// DEFAULT_QUALITY /// </summary> DEFAULT_QUALITY = 0, /// <summary> /// DRAFT_QUALITY /// </summary> DRAFT_QUALITY = 1, /// <summary> /// PROOF_QUALITY /// </summary> PROOF_QUALITY = 2, /// <summary> /// NONANTIALIASED_QUALITY /// </summary> NONANTIALIASED_QUALITY = 3, /// <summary> /// ANTIALIASED_QUALITY /// </summary> ANTIALIASED_QUALITY = 4, /// <summary> /// CLEARTYPE_QUALITY /// </summary> CLEARTYPE_QUALITY = 5, /// <summary> /// CLEARTYPE_NATURAL_QUALITY /// </summary> CLEARTYPE_NATURAL_QUALITY = 6 } /// <summary> /// 폰트 가중치 /// </summary> public enum FontWeight : int { /// <summary> /// DONT_CARE /// </summary> DONT_CARE = 0, /// <summary> /// THIN /// </summary> THIN = 100, /// <summary> /// EXTRA_LIGHT /// </summary> EXTRA_LIGHT = 200, /// <summary> /// LIGHT /// </summary> LIGHT = 300, /// <summary> /// NORMAL /// </summary> NORMAL = 400, /// <summary> /// MEDIUM /// </summary> MEDIUM = 500, /// <summary> /// SEMI_BOLD /// </summary> SEMI_BOLD = 600, /// <summary> /// BOLD /// </summary> BOLD = 700, /// <summary> /// EXTRA_BOLD /// </summary> EXTRA_BOLD = 800, /// <summary> /// HEAVY /// </summary> HEAVY = 900 } /// <summary> /// LOGFONT /// </summary> [StructLayout(LayoutKind.Sequential, CharSet = System.Runtime.InteropServices.CharSet.Auto)] public struct LOGFONT { //////////////////////////////////////////////////////////////////////////////////////////////////// Field ////////////////////////////////////////////////////////////////////////////////////////// Public #region Field /// <summary> /// 높이 /// </summary> public int Height; /// <summary> /// 너비 /// </summary> public int Width; /// <summary> /// 이스케이프먼트 /// </summary> public int Escapement; /// <summary> /// 방향 /// </summary> public int Orientation; /// <summary> /// 가중치 /// </summary> public FontWeight Weight; /// <summary> /// 이탤릭체 여부 /// </summary> [MarshalAs(UnmanagedType.U1)] public bool Italic; /// <summary> /// 밑줄 여부 /// </summary> [MarshalAs(UnmanagedType.U1)] public bool Underline; /// <summary> /// 스트라이크 아웃 여부 /// </summary> [MarshalAs(UnmanagedType.U1)] public bool StrikeOut; /// <summary> /// 문자 세트 /// </summary> public FontCharSet CharSet; /// <summary> /// 출력 정밀도 /// </summary> public FontPrecision OutPrecision; /// <summary> /// 클리핑 정밀도 /// </summary> public FontClipPrecision ClipPrecision; /// <summary> /// 품질 /// </summary> public FontQuality Quality; /// <summary> /// 피치 & 패밀리 /// </summary> public FontPitchAndFamily PitchAndFamily; /// <summary> /// 폰트명 /// </summary> [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string FaceName; #endregion } /// <summary> /// ENUMLOGFONTEX /// </summary> [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] public struct ENUMLOGFONTEX { //////////////////////////////////////////////////////////////////////////////////////////////////// Field ////////////////////////////////////////////////////////////////////////////////////////// Public #region Field /// <summary> /// LOG 폰트 /// </summary> public LOGFONT LogFont; /// <summary> /// 전체 명칭 /// </summary> [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)] public string FullName; /// <summary> /// 스타일 /// </summary> [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string Style; /// <summary> /// 스크립트 /// </summary> [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string Script; #endregion } /// <summary> /// NEWTEXTMETRIC /// </summary> [StructLayout(LayoutKind.Sequential, CharSet = System.Runtime.InteropServices.CharSet.Auto)] public struct NEWTEXTMETRIC { //////////////////////////////////////////////////////////////////////////////////////////////////// Field #region Field /// <summary> /// 높이 /// </summary> public int Height; /// <summary> /// 상단 높이 /// </summary> public int Ascent; /// <summary> /// 하단 높이 /// </summary> public int Descent; /// <summary> /// 내부 간격 /// </summary> public int InternalLeading; /// <summary> /// 외부 간격 /// </summary> public int ExternalLeading; /// <summary> /// 평균 문자 너비 /// </summary> public int AverageCharacterWidth; /// <summary> /// 최대 문자 너비 /// </summary> public int MaximumCharacterWidth; /// <summary> /// 가중치 /// </summary> public int Weight; /// <summary> /// 오버행 /// </summary> public int Overhang; /// <summary> /// 종횡비 X /// </summary> public int AspectX; /// <summary> /// 종횡비 Y /// </summary> public int AspectY; /// <summary> /// 첫번째 문자 /// </summary> public char FirstCharacter; /// <summary> /// 마지막 문자 /// </summary> public char LastCharacter; /// <summary> /// 디폴트 문자 /// </summary> public char DefaultCharacter; /// <summary> /// BREAK 문자 /// </summary> public char BreakCharacter; /// <summary> /// 이탤릭체 여부 /// </summary> public byte Italic; /// <summary> /// 밑줄 여부 /// </summary> public byte Underlined; /// <summary> /// 스트라이크 아웃 여부 /// </summary> public byte StrikeOut; /// <summary> /// 피치 & 패밀리 /// </summary> public byte PitchAndFamily; /// <summary> /// 문자 세트 여부 /// </summary> public byte CharSet; /// <summary> /// 플래그 /// </summary> public int Flag; /// <summary> /// EM 크기 /// </summary> public int SizeEM; /// <summary> /// 셀 높이 /// </summary> public int CellHeight; /// <summary> /// 평균 너비 /// </summary> public int AverageWidth; #endregion } /// <summary> /// FONTSIGNATURE /// </summary> public struct FONTSIGNATURE { //////////////////////////////////////////////////////////////////////////////////////////////////// Field ////////////////////////////////////////////////////////////////////////////////////////// Public #region Field /// <summary> /// USB /// </summary> [MarshalAs(UnmanagedType.ByValArray)] public int[] USB; /// <summary> /// CSB /// </summary> [MarshalAs(UnmanagedType.ByValArray)] public int[] CSB; #endregion } /// <summary> /// NEWTEXTMETRICEX /// </summary> public struct NEWTEXTMETRICEX { //////////////////////////////////////////////////////////////////////////////////////////////////// Field ////////////////////////////////////////////////////////////////////////////////////////// Public #region Field /// <summary> /// 텍스트 메트릭 /// </summary> public NEWTEXTMETRIC TextMetric; /// <summary> /// 폰트 서명 /// </summary> public FONTSIGNATURE FontSignature; #endregion } #region 폰트 열거하기 대리자 - EnumerateFontDelegate(enumLogFontEx, newTextMetricEx, fontType, longParameter); /// <summary> /// 폰트 열거하기 대리자 /// </summary> /// <param name="enumLogFontEx">ENUMLOGFONTEX</param> /// <param name="newTextMetricEx">NEWTEXTMETRICEX</param> /// <param name="fontType">폰트 타입</param> /// <param name="longParameter">LONG 매개 변수</param> /// <returns>처리 결과</returns> public delegate int EnumerateFontDelegate ( ref ENUMLOGFONTEX enumLogFontEx, ref NEWTEXTMETRICEX newTextMetricEx, int fontType, int longParameter ); #endregion |