From 1a1c8e71fcd14858f595029f089b2d4a00202b32 Mon Sep 17 00:00:00 2001
From: ogi <Administrator@S-OGI-PC>
Date: Fri, 05 Dec 2025 09:24:16 +0900
Subject: [PATCH] プロジェクトファイルを追加。

---
 HotelPms.Share.Windows/Report/TrueFontFactory.cs | 1084 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 1,084 insertions(+), 0 deletions(-)

diff --git a/HotelPms.Share.Windows/Report/TrueFontFactory.cs b/HotelPms.Share.Windows/Report/TrueFontFactory.cs
new file mode 100644
index 0000000..ac1be8e
--- /dev/null
+++ b/HotelPms.Share.Windows/Report/TrueFontFactory.cs
@@ -0,0 +1,1084 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace HotelPms.Share.Windows.Report
+{
+#pragma warning disable CS0649
+    public class TrueFontFactory
+    {
+        [StructLayout(LayoutKind.Sequential, Pack = 0x1)]
+        struct TT_OFFSET_TABLE
+        {
+            public ushort uMajorVersion;
+            public ushort uMinorVersion;
+            public ushort uNumOfTables;
+            public ushort uSearchRange;
+            public ushort uEntrySelector;
+            public ushort uRangeShift;
+        }
+        [StructLayout(LayoutKind.Sequential, Pack = 0x1)]
+        struct TT_TABLE_DIRECTORY
+        {
+            public char szTag1;
+            public char szTag2;
+            public char szTag3;
+            public char szTag4;
+            public uint uCheckSum; //Check sum        
+            public uint uOffset; //Offset from beginning of file        
+            public uint uLength; //length of the table in bytes    
+        }
+        [StructLayout(LayoutKind.Sequential, Pack = 0x1)]
+        struct TT_NAME_TABLE_HEADER
+        {
+            public ushort uFSelector;
+            public ushort uNRCount;
+            public ushort uStorageOffset;
+        }
+        [StructLayout(LayoutKind.Sequential, Pack = 0x1)]
+        struct TT_NAME_RECORD
+        {
+            public ushort uPlatformID;
+            public ushort uEncodingID;
+            public ushort uLanguageID;
+            public ushort uNameID;
+            public ushort uStringLength;
+            public ushort uStringOffset;
+        }
+
+        private static TT_OFFSET_TABLE ttOffsetTable;
+        private static TT_TABLE_DIRECTORY tblDir;
+        private static TT_NAME_TABLE_HEADER ttNTHeader;
+        private static TT_NAME_RECORD ttNMRecord;
+
+        public static string GetEngName(string fontName)
+        {
+            ////InstalledFontCollectionオブジェクトの取得
+            //System.Drawing.Text.InstalledFontCollection InstalledFont = new System.Drawing.Text.InstalledFontCollection();
+
+            ////インストール済みフォントを取得してコンボボックスに表示する
+            //FontFamily[] FontFamilies = InstalledFont.Families;
+            //foreach (FontFamily f in FontFamilies)
+            //{
+            //    string fontName = f.GetName(CultureInfo.GetCultureInfo("en-us").LCID);
+            //    string aa = fontName + ".ttf";
+            //    System.Diagnostics.Debug.WriteLine(f.Name + ":" + aa);
+            //}
+
+            FontFamily msp = new FontFamily(fontName);
+            return msp.GetName(CultureInfo.GetCultureInfo("en-us").LCID);
+        }
+
+        /// <summary>
+        /// 例:MS UI Gothic ⇒ C:\\WINDOWS\\Fonts\\msgothic.ttc,1
+        /// </summary>
+        /// <param name="fontName"></param>
+        /// <returns>filename,index</returns>
+        public static string GetFontFile(string fontName)
+        {
+            string root = Environment.GetFolderPath(Environment.SpecialFolder.Fonts);
+            string item = string.Empty;
+            string engName = GetEngName(fontName);
+
+            #region FontName(English) ⇒ FileName,Index
+
+            switch (engName)
+            {
+                case "Agency FB":
+                    item = "AGENCYB.TTF,0";
+                    break;
+                case "Algerian":
+                    item = "ALGER.TTF,0";
+                    break;
+                case "Book Antiqua":
+                    item = "ANTQUAB.TTF,0";
+                    break;
+                case "Arial":
+                    item = "arial.ttf,0";
+                    break;
+                case "Arial Narrow":
+                    item = "ARIALN.TTF,0";
+                    break;
+                case "Arial Unicode MS":
+                    item = "ARIALUNI.TTF,0";
+                    break;
+                case "Arial Black":
+                    item = "ariblk.ttf,0";
+                    break;
+                case "Arial Rounded MT Bold":
+                    item = "ARLRDBD.TTF,0";
+                    break;
+                case "Baskerville Old Face":
+                    item = "BASKVILL.TTF,0";
+                    break;
+                case "Bauhaus 93":
+                    item = "BAUHS93.TTF,0";
+                    break;
+                case "Bell MT":
+                    item = "BELL.TTF,0";
+                    break;
+                case "Bernard MT Condensed":
+                    item = "BERNHC.TTF,0";
+                    break;
+                case "Bodoni MT":
+                    item = "BOD_B.TTF,0";
+                    break;
+                case "Bodoni MT Black":
+                    item = "BOD_BLAI.TTF,0";
+                    break;
+                case "Bodoni MT Condensed":
+                    item = "BOD_CB.TTF,0";
+                    break;
+                case "Bodoni MT Poster Compressed":
+                    item = "BOD_PSTC.TTF,0";
+                    break;
+                case "Bookman Old Style":
+                    item = "BOOKOS.TTF,0";
+                    break;
+                case "Bradley Hand ITC":
+                    item = "BRADHITC.TTF,0";
+                    break;
+                case "Britannic Bold":
+                    item = "BRITANIC.TTF,0";
+                    break;
+                case "Berlin Sans FB":
+                    item = "BRLNSB.TTF,0";
+                    break;
+                case "Berlin Sans FB Demi":
+                    item = "BRLNSDB.TTF,0";
+                    break;
+                case "Broadway":
+                    item = "BROADW.TTF,0";
+                    break;
+                case "Brush Script MT":
+                    item = "BRUSHSCI.TTF,0";
+                    break;
+                case "Bookshelf Symbol 7":
+                    item = "BSSYM7.TTF,0";
+                    break;
+                case "Buxton Sketch":
+                    item = "BuxtonSketch.ttf,0";
+                    break;
+                case "Calibri":
+                    item = "calibri.ttf,0";
+                    break;
+                case "Calibri Light":
+                    item = "calibril.ttf,0";
+                    break;
+                case "Californian FB":
+                    item = "CALIFB.TTF,0";
+                    break;
+                case "Calisto MT":
+                    item = "CALIST.TTF,0";
+                    break;
+                case "Cambria":
+                    item = "cambria.ttc,0";
+                    break;
+                case "Cambria Math":
+                    item = "cambria.ttc,1";
+                    break;
+                case "Candara":
+                    item = "Candara.ttf,0";
+                    break;
+                case "Castellar":
+                    item = "CASTELAR.TTF,0";
+                    break;
+                case "Century Schoolbook":
+                    item = "CENSCBK.TTF,0";
+                    break;
+                case "Centaur":
+                    item = "CENTAUR.TTF,0";
+                    break;
+                case "Century":
+                    item = "CENTURY.TTF,0";
+                    break;
+                case "Chiller":
+                    item = "CHILLER.TTF,0";
+                    break;
+                case "Colonna MT":
+                    item = "COLONNA.TTF,0";
+                    break;
+                case "Comic Sans MS":
+                    item = "comic.ttf,0";
+                    break;
+                case "Consolas":
+                    item = "consola.ttf,0";
+                    break;
+                case "Constantia":
+                    item = "constan.ttf,0";
+                    break;
+                case "Cooper Black":
+                    item = "COOPBL.TTF,0";
+                    break;
+                case "Copperplate Gothic Bold":
+                    item = "COPRGTB.TTF,0";
+                    break;
+                case "Copperplate Gothic Light":
+                    item = "COPRGTL.TTF,0";
+                    break;
+                case "Corbel":
+                    item = "corbel.ttf,0";
+                    break;
+                case "Courier New":
+                    item = "cour.ttf,0";
+                    break;
+                case "Curlz MT":
+                    item = "CURLZ___.TTF,0";
+                    break;
+                case "DengXian":
+                    item = "Deng.ttf,0";
+                    break;
+                case "DengXian Light":
+                    item = "Dengl.ttf,0";
+                    break;
+                case "Ebrima":
+                    item = "ebrima.ttf,0";
+                    break;
+                case "Elephant":
+                    item = "ELEPHNT.TTF,0";
+                    break;
+                case "Engravers MT":
+                    item = "ENGR.TTF,0";
+                    break;
+                case "Eras Bold ITC":
+                    item = "ERASBD.TTF,0";
+                    break;
+                case "Eras Demi ITC":
+                    item = "ERASDEMI.TTF,0";
+                    break;
+                case "Eras Light ITC":
+                    item = "ERASLGHT.TTF,0";
+                    break;
+                case "Eras Medium ITC":
+                    item = "ERASMD.TTF,0";
+                    break;
+                case "Felix Titling":
+                    item = "FELIXTI.TTF,0";
+                    break;
+                case "Forte":
+                    item = "FORTE.TTF,0";
+                    break;
+                case "Franklin Gothic Book":
+                    item = "FRABK.TTF,0";
+                    break;
+                case "Franklin Gothic Demi":
+                    item = "FRADM.TTF,0";
+                    break;
+                case "Franklin Gothic Demi Cond":
+                    item = "FRADMCN.TTF,0";
+                    break;
+                case "Franklin Gothic Heavy":
+                    item = "FRAHV.TTF,0";
+                    break;
+                case "Franklin Gothic Medium":
+                    item = "framd.ttf,0";
+                    break;
+                case "Franklin Gothic Medium Cond":
+                    item = "FRAMDCN.TTF,0";
+                    break;
+                case "Freestyle Script":
+                    item = "FREESCPT.TTF,0";
+                    break;
+                case "French Script MT":
+                    item = "FRSCRIPT.TTF,0";
+                    break;
+                case "Footlight MT Light":
+                    item = "FTLTLT.TTF,0";
+                    break;
+                case "FZLanTingHeiS-UL-GB":
+                    item = "FZLTCXHJW.TTF,0";
+                    break;
+                case "Gabriola":
+                    item = "Gabriola.ttf,0";
+                    break;
+                case "Gadugi":
+                    item = "gadugi.ttf,0";
+                    break;
+                case "Garamond":
+                    item = "GARA.TTF,0";
+                    break;
+                case "Georgia":
+                    item = "georgia.ttf,0";
+                    break;
+                case "Gigi":
+                    item = "GIGI.TTF,0";
+                    break;
+                case "Gill Sans MT":
+                    item = "GILBI___.TTF,0";
+                    break;
+                case "Gill Sans MT Condensed":
+                    item = "GILC____.TTF,0";
+                    break;
+                case "Gill Sans Ultra Bold Condensed":
+                    item = "GILLUBCD.TTF,0";
+                    break;
+                case "Gill Sans Ultra Bold":
+                    item = "GILSANUB.TTF,0";
+                    break;
+                case "Gloucester MT Extra Condensed":
+                    item = "GLECB.TTF,0";
+                    break;
+                case "Gill Sans MT Ext Condensed Bold":
+                    item = "GLSNECB.TTF,0";
+                    break;
+                case "Century Gothic":
+                    item = "GOTHIC.TTF,0";
+                    break;
+                case "Goudy Old Style":
+                    item = "GOUDOS.TTF,0";
+                    break;
+                case "Goudy Stout":
+                    item = "GOUDYSTO.TTF,0";
+                    break;
+                case "Harlow Solid Italic":
+                    item = "HARLOWSI.TTF,0";
+                    break;
+                case "Harrington":
+                    item = "HARNGTON.TTF,0";
+                    break;
+                case "Haettenschweiler":
+                    item = "HATTEN.TTF,0";
+                    break;
+                case "HGGothicE":
+                    item = "HGRGE.TTC,0";
+                    break;
+                case "HGPGothicE":
+                    item = "HGRGE.TTC,1";
+                    break;
+                case "HGSGothicE":
+                    item = "HGRGE.TTC,2";
+                    break;
+                case "HGGothicM":
+                    item = "HGRGM.TTC,0";
+                    break;
+                case "HGPGothicM":
+                    item = "HGRGM.TTC,1";
+                    break;
+                case "HGSGothicM":
+                    item = "HGRGM.TTC,2";
+                    break;
+                case "HGGyoshotai":
+                    item = "HGRGY.TTC,0";
+                    break;
+                case "HGPGyoshotai":
+                    item = "HGRGY.TTC,1";
+                    break;
+                case "HGSGyoshotai":
+                    item = "HGRGY.TTC,2";
+                    break;
+                case "HGKyokashotai":
+                    item = "HGRKK.TTC,0";
+                    break;
+                case "HGPKyokashotai":
+                    item = "HGRKK.TTC,1";
+                    break;
+                case "HGSKyokashotai":
+                    item = "HGRKK.TTC,2";
+                    break;
+                case "HGMinchoB":
+                    item = "HGRMB.TTC,0";
+                    break;
+                case "HGPMinchoB":
+                    item = "HGRMB.TTC,1";
+                    break;
+                case "HGSMinchoB":
+                    item = "HGRMB.TTC,2";
+                    break;
+                case "HGMinchoE":
+                    item = "HGRME.TTC,0";
+                    break;
+                case "HGPMinchoE":
+                    item = "HGRME.TTC,1";
+                    break;
+                case "HGSMinchoE":
+                    item = "HGRME.TTC,2";
+                    break;
+                case "HGSoeiKakupoptai":
+                    item = "HGRPP1.TTC,0";
+                    break;
+                case "HGPSoeiKakupoptai":
+                    item = "HGRPP1.TTC,1";
+                    break;
+                case "HGSSoeiKakupoptai":
+                    item = "HGRPP1.TTC,2";
+                    break;
+                case "HGSoeiPresenceEB":
+                    item = "HGRPRE.TTC,0";
+                    break;
+                case "HGPSoeiPresenceEB":
+                    item = "HGRPRE.TTC,1";
+                    break;
+                case "HGSSoeiPresenceEB":
+                    item = "HGRPRE.TTC,2";
+                    break;
+                case "HGSoeiKakugothicUB":
+                    item = "HGRSGU.TTC,0";
+                    break;
+                case "HGPSoeiKakugothicUB":
+                    item = "HGRSGU.TTC,1";
+                    break;
+                case "HGSSoeiKakugothicUB":
+                    item = "HGRSGU.TTC,2";
+                    break;
+                case "HGSeikaishotaiPRO":
+                    item = "HGRSKP.TTF,0";
+                    break;
+                case "HGMaruGothicMPRO":
+                    item = "HGRSMP.TTF,0";
+                    break;
+                case "Microsoft Himalaya":
+                    item = "himalaya.ttf,0";
+                    break;
+                case "High Tower Text":
+                    item = "HTOWERT.TTF,0";
+                    break;
+                case "Impact":
+                    item = "impact.ttf,0";
+                    break;
+                case "Imprint MT Shadow":
+                    item = "IMPRISHA.TTF,0";
+                    break;
+                case "Informal Roman":
+                    item = "INFROMAN.TTF,0";
+                    break;
+                case "Blackadder ITC":
+                    item = "ITCBLKAD.TTF,0";
+                    break;
+                case "Edwardian Script ITC":
+                    item = "ITCEDSCR.TTF,0";
+                    break;
+                case "Kristen ITC":
+                    item = "ITCKRIST.TTF,0";
+                    break;
+                case "Javanese Text":
+                    item = "javatext.ttf,0";
+                    break;
+                case "Jokerman":
+                    item = "JOKERMAN.TTF,0";
+                    break;
+                case "Juice ITC":
+                    item = "JUICE___.TTF,0";
+                    break;
+                case "Kunstler Script":
+                    item = "KUNSTLER.TTF,0";
+                    break;
+                case "Wide Latin":
+                    item = "LATINWD.TTF,0";
+                    break;
+                case "Lucida Bright":
+                    item = "LBRITE.TTF,0";
+                    break;
+                case "Lucida Calligraphy":
+                    item = "LCALLIG.TTF,0";
+                    break;
+                case "Leelawadee UI":
+                    item = "LeelaUIb.ttf,0";
+                    break;
+                case "Leelawadee UI Semilight":
+                    item = "LeelUIsl.ttf,0";
+                    break;
+                case "Lucida Fax":
+                    item = "LFAX.TTF,0";
+                    break;
+                case "Lucida Handwriting":
+                    item = "LHANDW.TTF,0";
+                    break;
+                case "Lucida Sans":
+                    item = "LSANS.TTF,0";
+                    break;
+                case "Lucida Sans Typewriter":
+                    item = "LTYPE.TTF,0";
+                    break;
+                case "Lucida Console":
+                    item = "lucon.ttf,0";
+                    break;
+                case "Lucida Sans Unicode":
+                    item = "l_10646.ttf,0";
+                    break;
+                case "Magneto":
+                    item = "MAGNETOB.TTF,0";
+                    break;
+                case "Maiandra GD":
+                    item = "MAIAN.TTF,0";
+                    break;
+                case "Malgun Gothic":
+                    item = "malgun.ttf,0";
+                    break;
+                case "Malgun Gothic Semilight":
+                    item = "malgunsl.ttf,0";
+                    break;
+                case "Marlett":
+                    item = "marlett.ttf,0";
+                    break;
+                case "Matura MT Script Capitals":
+                    item = "MATURASC.TTF,0";
+                    break;
+                case "Meiryo":
+                    item = "meiryo.ttc,0";
+                    break;
+                case "Meiryo UI":
+                    item = "meiryo.ttc,2";
+                    break;
+                case "Microsoft Sans Serif":
+                    item = "micross.ttf,0";
+                    break;
+                case "MingLiU-ExtB":
+                    item = "mingliub.ttc,0";
+                    break;
+                case "PMingLiU-ExtB":
+                    item = "mingliub.ttc,1";
+                    break;
+                case "MingLiU_HKSCS-ExtB":
+                    item = "mingliub.ttc,2";
+                    break;
+                case "Mistral":
+                    item = "MISTRAL.TTF,0";
+                    break;
+                case "Myanmar Text":
+                    item = "mmrtext.ttf,0";
+                    break;
+                case "Modern No. 20":
+                    item = "MOD20.TTF,0";
+                    break;
+                case "Mongolian Baiti":
+                    item = "monbaiti.ttf,0";
+                    break;
+                case "MS Gothic":
+                    item = "msgothic.ttc,0";
+                    break;
+                case "MS UI Gothic":
+                    item = "msgothic.ttc,1";
+                    break;
+                case "MS PGothic":
+                    item = "msgothic.ttc,2";
+                    break;
+                case "微軟正黑體":
+                    item = "msjh.ttc,0";
+                    break;
+                case "Microsoft JhengHei UI":
+                    item = "msjh.ttc,1";
+                    break;
+                case "微軟正黑體 Light":
+                    item = "msjhl.ttc,0";
+                    break;
+                case "Microsoft JhengHei UI Light":
+                    item = "msjhl.ttc,1";
+                    break;
+                case "Microsoft MHei":
+                    item = "MSMHei-Bold.ttf,0";
+                    break;
+                case "MS Mincho":
+                    item = "msmincho.ttc,0";
+                    break;
+                case "MS PMincho":
+                    item = "msmincho.ttc,1";
+                    break;
+                case "Microsoft NeoGothic":
+                    item = "MSNeoGothic-Bold.ttf,0";
+                    break;
+                case "Microsoft YaHei":
+                    item = "msyh.ttc,0";
+                    break;
+                case "Microsoft YaHei UI":
+                    item = "msyh.ttc,1";
+                    break;
+                case "Microsoft YaHei Light":
+                    item = "msyhl.ttc,0";
+                    break;
+                case "Microsoft YaHei UI Light":
+                    item = "msyhl.ttc,1";
+                    break;
+                case "Microsoft Yi Baiti":
+                    item = "msyi.ttf,0";
+                    break;
+                case "Monotype Corsiva":
+                    item = "MTCORSVA.TTF,0";
+                    break;
+                case "MV Boli":
+                    item = "mvboli.ttf,0";
+                    break;
+                case "Niagara Engraved":
+                    item = "NIAGENG.TTF,0";
+                    break;
+                case "Niagara Solid":
+                    item = "NIAGSOL.TTF,0";
+                    break;
+                case "Nina":
+                    item = "nina.ttf,0";
+                    break;
+                case "Nirmala UI":
+                    item = "Nirmala.ttf,0";
+                    break;
+                case "Nirmala UI Semilight":
+                    item = "NirmalaS.ttf,0";
+                    break;
+                case "Microsoft New Tai Lue":
+                    item = "ntailu.ttf,0";
+                    break;
+                case "OCR A Extended":
+                    item = "OCRAEXT.TTF,0";
+                    break;
+                case "OCRB":
+                    item = "OCRB.TTF,0";
+                    break;
+                case "OCR-B-10 BT":
+                    item = "OCRB10N.TTF,0";
+                    break;
+                case "Old English Text MT":
+                    item = "OLDENGL.TTF,0";
+                    break;
+                case "Onyx":
+                    item = "ONYX.TTF,0";
+                    break;
+                case "MS Outlook":
+                    item = "OUTLOOK.TTF,0";
+                    break;
+                case "Palatino Linotype":
+                    item = "pala.ttf,0";
+                    break;
+                case "Palace Script MT":
+                    item = "PALSCRI.TTF,0";
+                    break;
+                case "Papyrus":
+                    item = "PAPYRUS.TTF,0";
+                    break;
+                case "Parchment":
+                    item = "PARCHM.TTF,0";
+                    break;
+                case "Perpetua":
+                    item = "PERBI___.TTF,0";
+                    break;
+                case "Perpetua Titling MT":
+                    item = "PERTIBD.TTF,0";
+                    break;
+                case "Microsoft PhagsPa":
+                    item = "phagspa.ttf,0";
+                    break;
+                case "Playbill":
+                    item = "PLAYBILL.TTF,0";
+                    break;
+                case "Poor Richard":
+                    item = "POORICH.TTF,0";
+                    break;
+                case "Pristina":
+                    item = "PRISTINA.TTF,0";
+                    break;
+                case "Rage Italic":
+                    item = "RAGE.TTF,0";
+                    break;
+                case "Ravie":
+                    item = "RAVIE.TTF,0";
+                    break;
+                case "MS Reference Sans Serif":
+                    item = "REFSAN.TTF,0";
+                    break;
+                case "MS Reference Specialty":
+                    item = "REFSPCL.TTF,0";
+                    break;
+                case "Rockwell Condensed":
+                    item = "ROCCB___.TTF,0";
+                    break;
+                case "Rockwell":
+                    item = "ROCK.TTF,0";
+                    break;
+                case "Rockwell Extra Bold":
+                    item = "ROCKEB.TTF,0";
+                    break;
+                case "Script MT Bold":
+                    item = "SCRIPTBL.TTF,0";
+                    break;
+                case "Segoe MDL2 Assets":
+                    item = "segmdl2.ttf,0";
+                    break;
+                case "Segoe Marker":
+                    item = "SegoeMarker.ttf,0";
+                    break;
+                case "Segoe Print":
+                    item = "segoepr.ttf,0";
+                    break;
+                case "Segoe Script":
+                    item = "segoesc.ttf,0";
+                    break;
+                case "Segoe UI":
+                    item = "segoeui.ttf,0";
+                    break;
+                case "Segoe UI Light":
+                    item = "segoeuil.ttf,0";
+                    break;
+                case "Segoe UI Semilight":
+                    item = "segoeuisl.ttf,0";
+                    break;
+                case "Segoe WP Black":
+                    item = "SegoeWP-Black.ttf,0";
+                    break;
+                case "Segoe WP":
+                    item = "SegoeWP-Bold.ttf,0";
+                    break;
+                case "Segoe WP Light":
+                    item = "SegoeWP-Light.ttf,0";
+                    break;
+                case "Segoe WP Semibold":
+                    item = "SegoeWP-Semibold.ttf,0";
+                    break;
+                case "Segoe WP SemiLight":
+                    item = "SegoeWP-Semilight.ttf,0";
+                    break;
+                case "Segoe UI Black":
+                    item = "seguibl.ttf,0";
+                    break;
+                case "Segoe UI Emoji":
+                    item = "seguiemj.ttf,0";
+                    break;
+                case "Segoe UI Historic":
+                    item = "seguihis.ttf,0";
+                    break;
+                case "Segoe UI Semibold":
+                    item = "seguisb.ttf,0";
+                    break;
+                case "Segoe UI Symbol":
+                    item = "seguisym.ttf,0";
+                    break;
+                case "Showcard Gothic":
+                    item = "SHOWG.TTF,0";
+                    break;
+                case "FangSong":
+                    item = "simfang.ttf,0";
+                    break;
+                case "SimHei":
+                    item = "simhei.ttf,0";
+                    break;
+                case "KaiTi":
+                    item = "simkai.ttf,0";
+                    break;
+                case "SimSun":
+                    item = "simsun.ttc,0";
+                    break;
+                case "NSimSun":
+                    item = "simsun.ttc,1";
+                    break;
+                case "SimSun-ExtB":
+                    item = "simsunb.ttf,0";
+                    break;
+                case "Sitka Small":
+                    item = "Sitka.ttc,0";
+                    break;
+                case "Sitka Text":
+                    item = "Sitka.ttc,1";
+                    break;
+                case "Sitka Subheading":
+                    item = "Sitka.ttc,2";
+                    break;
+                case "Sitka Heading":
+                    item = "Sitka.ttc,3";
+                    break;
+                case "Sitka Display":
+                    item = "Sitka.ttc,4";
+                    break;
+                case "Sitka Banner":
+                    item = "Sitka.ttc,5";
+                    break;
+                case "SketchFlow Print":
+                    item = "SketchFlow Print.ttf,0";
+                    break;
+                case "Snap ITC":
+                    item = "SNAP____.TTF,0";
+                    break;
+                case "Stencil":
+                    item = "STENCIL.TTF,0";
+                    break;
+                case "Sylfaen":
+                    item = "sylfaen.ttf,0";
+                    break;
+                case "Symbol":
+                    item = "symbol.ttf,0";
+                    break;
+                case "Tahoma":
+                    item = "tahoma.ttf,0";
+                    break;
+                case "Microsoft Tai Le":
+                    item = "taile.ttf,0";
+                    break;
+                case "Tw Cen MT":
+                    item = "TCBI____.TTF,0";
+                    break;
+                case "Tw Cen MT Condensed":
+                    item = "TCCB____.TTF,0";
+                    break;
+                case "Tw Cen MT Condensed Extra Bold":
+                    item = "TCCEB.TTF,0";
+                    break;
+                case "Tempus Sans ITC":
+                    item = "TEMPSITC.TTF,0";
+                    break;
+                case "Times New Roman":
+                    item = "times.ttf,0";
+                    break;
+                case "Trebuchet MS":
+                    item = "trebuc.ttf,0";
+                    break;
+                case "Verdana":
+                    item = "verdana.ttf,0";
+                    break;
+                case "Viner Hand ITC":
+                    item = "VINERITC.TTF,0";
+                    break;
+                case "Vivaldi":
+                    item = "VIVALDII.TTF,0";
+                    break;
+                case "Vladimir Script":
+                    item = "VLADIMIR.TTF,0";
+                    break;
+                case "Webdings":
+                    item = "webdings.ttf,0";
+                    break;
+                case "Wingdings":
+                    item = "wingding.ttf,0";
+                    break;
+                case "Wingdings 2":
+                    item = "WINGDNG2.TTF,0";
+                    break;
+                case "Wingdings 3":
+                    item = "WINGDNG3.TTF,0";
+                    break;
+                case "Yu Gothic":
+                    item = "YuGothB.ttc,0";
+                    break;
+                case "Yu Gothic UI":
+                    item = "YuGothB.ttc,1";
+                    break;
+                case "Yu Gothic UI Semibold":
+                    item = "YuGothB.ttc,2";
+                    break;
+                case "Yu Gothic Light":
+                    item = "YuGothL.ttc,0";
+                    break;
+                case "Yu Gothic UI Light":
+                    item = "YuGothL.ttc,1";
+                    break;
+                case "Yu Gothic Medium":
+                    item = "YuGothM.ttc,0";
+                    break;
+                case "Yu Gothic UI Semilight":
+                    item = "YuGothR.ttc,1";
+                    break;
+                case "Yu Mincho":
+                    item = "yumin.ttf,0";
+                    break;
+                case "Yu Mincho Demibold":
+                    item = "yumindb.ttf,0";
+                    break;
+                case "Yu Mincho Light":
+                    item = "yuminl.ttf,0";
+                    break;
+            }
+
+            #endregion
+
+            return root + Path.DirectorySeparatorChar + item;
+        }
+
+
+        /// <summary>
+        /// FontName(English) ⇒ FileName,Index
+        /// </summary>
+        /// <returns></returns>
+        public static Dictionary<string, string> GetFontFileDict()
+        {
+            Dictionary<string, string> dict = new Dictionary<string, string>();
+            string root = Environment.GetFolderPath(Environment.SpecialFolder.Fonts);
+            string[] files = Directory.GetFiles(root);
+            foreach(string item in files)
+            {
+                if ((item.ToLower(System.Globalization.CultureInfo.InvariantCulture).EndsWith(".ttf") || item.ToLower(System.Globalization.CultureInfo.InvariantCulture).EndsWith(".otf") || item.ToLower(System.Globalization.CultureInfo.InvariantCulture).EndsWith(".ttc")))
+                {
+                    List<string> list = GetFontName(item);
+                    if (list == null) { continue; }
+                    for (int i = 0; i < list.Count; i++)
+                    {
+                        if (dict.ContainsKey(list[i])) { continue; }
+                        dict.Add(list[i], string.Format("{0},{1}", item, i));
+                        //System.Diagnostics.Debug.WriteLine("case \"" + list[i] + "\":");
+                        //System.Diagnostics.Debug.WriteLine("    item = \"" + string.Format("{0},{1}", Path.GetFileName(item), i) + "\";");
+                        //System.Diagnostics.Debug.WriteLine("    break;");
+                    }
+                }
+            }
+            return dict;
+        }
+
+
+        public static List<string> GetFontName(string file)
+        {
+            try
+            {
+                List<string> list = new List<string>();
+                bool isMulti = false;
+                if (file.ToLower(System.Globalization.CultureInfo.InvariantCulture).EndsWith(".ttc")) { isMulti = true; }
+
+                using (FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read))
+                {
+                    using (BinaryReader r = new BinaryReader(fs))
+                    {
+                        List<int> offsetList = new List<int>();
+
+                        if (isMulti)
+                        {
+                            byte[] buffH = r.ReadBytes(4); //ttcf
+                            buffH = r.ReadBytes(4);  //Skip
+                            int dirCount = ReadInt(r.ReadBytes(4));
+                            for (int i = 0; i < dirCount; i++)
+                            {
+                                offsetList.Add(ReadInt(r.ReadBytes(4)));
+                            }
+                        }
+                        else
+                        {
+                            offsetList.Add(0);
+                        }
+
+                        foreach (int directoryOffset in offsetList)
+                        {
+                            if (isMulti) { fs.Seek(directoryOffset, SeekOrigin.Begin); }
+
+                            byte[] buff = r.ReadBytes(Marshal.SizeOf(ttOffsetTable));
+                            buff = BigEndian(buff);
+                            IntPtr ptr = Marshal.AllocHGlobal(buff.Length);
+                            Marshal.Copy(buff, 0x0, ptr, buff.Length);
+                            TT_OFFSET_TABLE ttResult = (TT_OFFSET_TABLE)Marshal.PtrToStructure(ptr, typeof(TT_OFFSET_TABLE));
+                            Marshal.FreeHGlobal(ptr);
+                            //Must be maj =1 minor = 0            
+                            if (ttResult.uMajorVersion != 1 || ttResult.uMinorVersion != 0) { return null; }
+
+                            bool bFound = false;
+                            TT_TABLE_DIRECTORY tbName = new TT_TABLE_DIRECTORY();
+                            for (int i = 0; i < ttResult.uNumOfTables; i++)
+                            {
+                                byte[] bNameTable = r.ReadBytes(Marshal.SizeOf(tblDir));
+                                IntPtr ptrName = Marshal.AllocHGlobal(bNameTable.Length);
+                                Marshal.Copy(bNameTable, 0x0, ptrName, bNameTable.Length);
+                                tbName = (TT_TABLE_DIRECTORY)Marshal.PtrToStructure(ptrName, typeof(TT_TABLE_DIRECTORY));
+                                Marshal.FreeHGlobal(ptrName);
+                                string szName = tbName.szTag1.ToString() + tbName.szTag2.ToString() + tbName.szTag3.ToString() + tbName.szTag4.ToString();
+                                if (szName == null) { continue; }
+                                if (szName.ToString() != "name") { continue; }
+
+                                bFound = true;
+                                byte[] btLength = BitConverter.GetBytes(tbName.uLength);
+                                byte[] btOffset = BitConverter.GetBytes(tbName.uOffset);
+                                Array.Reverse(btLength);
+                                Array.Reverse(btOffset);
+                                tbName.uLength = BitConverter.ToUInt32(btLength, 0);
+                                tbName.uOffset = BitConverter.ToUInt32(btOffset, 0);
+                                break;
+                            }
+
+                            //名称取得
+                            if (bFound) { AddName(list, fs, r, ref tbName); }
+                        }
+                    }
+                }
+                return list;
+            }
+            catch
+            {
+                return null;
+            }
+        }
+
+        private static void AddName(List<string> list, FileStream fs, BinaryReader r, ref TT_TABLE_DIRECTORY tbName)
+        {
+            fs.Position = tbName.uOffset;
+            byte[] btNTHeader = r.ReadBytes(Marshal.SizeOf(ttNTHeader));
+            btNTHeader = BigEndian(btNTHeader);
+            IntPtr ptrNTHeader = Marshal.AllocHGlobal(btNTHeader.Length);
+            Marshal.Copy(btNTHeader, 0x0, ptrNTHeader, btNTHeader.Length);
+            TT_NAME_TABLE_HEADER ttNTResult = (TT_NAME_TABLE_HEADER)Marshal.PtrToStructure(ptrNTHeader, typeof(TT_NAME_TABLE_HEADER));
+            Marshal.FreeHGlobal(ptrNTHeader);
+            for (int i = 0; i < ttNTResult.uNRCount; i++)
+            {
+                byte[] btNMRecord = r.ReadBytes(Marshal.SizeOf(ttNMRecord));
+                btNMRecord = BigEndian(btNMRecord);
+                IntPtr ptrNMRecord = Marshal.AllocHGlobal(btNMRecord.Length);
+                Marshal.Copy(btNMRecord, 0x0, ptrNMRecord, btNMRecord.Length);
+                TT_NAME_RECORD ttNMResult = (TT_NAME_RECORD)Marshal.PtrToStructure(ptrNMRecord, typeof(TT_NAME_RECORD));
+                Marshal.FreeHGlobal(ptrNMRecord);
+                if (ttNMResult.uNameID == 1)
+                {
+                    long fPos = fs.Position;
+                    fs.Position = tbName.uOffset + ttNMResult.uStringOffset + ttNTResult.uStorageOffset;
+                    byte[] szResult = r.ReadBytes(ttNMResult.uStringLength);
+                    if (szResult.Length != 0)
+                    {
+                        string name;
+                        if (ttNMResult.uPlatformID == 0 || ttNMResult.uPlatformID == 3 || (ttNMResult.uPlatformID == 2 && ttNMResult.uEncodingID == 1))
+                        {
+                            name = ReadUnicodeString(szResult);
+                        }
+                        else
+                        {
+                            name = System.Text.Encoding.Default.GetString(szResult);
+                        }
+                        list.Add(name);
+                    }
+                }
+            }
+        }
+
+        /// <summary>
+        /// 反転
+        /// </summary>
+        /// <param name="bLittle"></param>
+        /// <returns></returns>
+        private static byte[] BigEndian(byte[] bLittle)
+        {
+            byte[] bBig = new byte[bLittle.Length];
+            for (int y = 0; y < (bLittle.Length - 1); y += 2)
+            {
+                byte b1, b2;
+                b1 = bLittle[y];
+                b2 = bLittle[y + 1];
+                bBig[y] = b2;
+                bBig[y + 1] = b1;
+            }
+            return bBig;
+        }
+
+        private static int ReadInt(byte[] buff)
+        {
+            int ch1 = buff[0];
+            int ch2 = buff[1];
+            int ch3 = buff[2];
+            int ch4 = buff[3];
+            if ((ch1 | ch2 | ch3 | ch4) < 0)
+                throw new EndOfStreamException();
+            return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + ch4);
+        }
+
+        private static char ReadChar(byte[] buff)
+        {
+            int ch1 = buff[0];
+            int ch2 = buff[1];
+            if ((ch1 | ch2) < 0)
+                throw new EndOfStreamException();
+            return (char)((ch1 << 8) + ch2);
+        }
+
+        private static string ReadUnicodeString(byte[] buff)
+        {
+            StringBuilder buf = new StringBuilder();
+            int length = buff.Length / 2;
+            for (int k = 0; k < length; ++k)
+            {
+                byte[] item = new byte[2];
+                Array.Copy(buff, k * 2, item, 0, 2);
+                buf.Append(ReadChar(item));
+            }
+            return buf.ToString();
+        }
+    }
+}

--
Gitblit v1.10.0