github.com/unidoc/unidoc@v2.2.0+incompatible/pdf/model/fonts/zapfdingbats.go (about)

     1  /*
     2   * This file is subject to the terms and conditions defined in
     3   * file 'LICENSE.md', which is part of this source code package.
     4   */
     5  /*
     6   * The embedded character metrics specified in this file are distributed under the terms listed in
     7   * ./afms/MustRead.html.
     8   */
     9  
    10  package fonts
    11  
    12  import (
    13  	"github.com/unidoc/unidoc/pdf/core"
    14  	"github.com/unidoc/unidoc/pdf/model/textencoding"
    15  )
    16  
    17  // Font ZapfDingbats.  Implements Font interface.
    18  // This is a built-in font and it is assumed that every reader has access to it.
    19  type fontZapfDingbats struct {
    20  	// By default encoder is not set, which means that we use the font's built in encoding.
    21  	encoder textencoding.TextEncoder
    22  }
    23  
    24  func NewFontZapfDingbats() fontZapfDingbats {
    25  	font := fontZapfDingbats{}
    26  	return font
    27  }
    28  
    29  func (font fontZapfDingbats) SetEncoder(encoder textencoding.TextEncoder) {
    30  	font.encoder = encoder
    31  }
    32  
    33  func (font fontZapfDingbats) GetGlyphCharMetrics(glyph string) (CharMetrics, bool) {
    34  	metrics, has := zapfDingbatsCharMetrics[glyph]
    35  	if !has {
    36  		return metrics, false
    37  	}
    38  
    39  	return metrics, true
    40  }
    41  
    42  func (font fontZapfDingbats) ToPdfObject() core.PdfObject {
    43  	obj := &core.PdfIndirectObject{}
    44  
    45  	fontDict := core.MakeDict()
    46  	fontDict.Set("Type", core.MakeName("Font"))
    47  	fontDict.Set("Subtype", core.MakeName("Type1"))
    48  	fontDict.Set("BaseFont", core.MakeName("ZapfDingbats"))
    49  	if font.encoder != nil {
    50  		fontDict.Set("Encoding", font.encoder.ToPdfObject())
    51  	}
    52  
    53  	obj.PdfObject = fontDict
    54  	return obj
    55  }
    56  
    57  // ZapfDingbats font metics loaded from afms/ZapfDingbats.afm.  See afms/MustRead.html for license information.
    58  var zapfDingbatsCharMetrics map[string]CharMetrics = map[string]CharMetrics{
    59  	"a1":    {GlyphName: "a1", Wx: 974.000000, Wy: 0.000000},
    60  	"a10":   {GlyphName: "a10", Wx: 692.000000, Wy: 0.000000},
    61  	"a100":  {GlyphName: "a100", Wx: 668.000000, Wy: 0.000000},
    62  	"a101":  {GlyphName: "a101", Wx: 732.000000, Wy: 0.000000},
    63  	"a102":  {GlyphName: "a102", Wx: 544.000000, Wy: 0.000000},
    64  	"a103":  {GlyphName: "a103", Wx: 544.000000, Wy: 0.000000},
    65  	"a104":  {GlyphName: "a104", Wx: 910.000000, Wy: 0.000000},
    66  	"a105":  {GlyphName: "a105", Wx: 911.000000, Wy: 0.000000},
    67  	"a106":  {GlyphName: "a106", Wx: 667.000000, Wy: 0.000000},
    68  	"a107":  {GlyphName: "a107", Wx: 760.000000, Wy: 0.000000},
    69  	"a108":  {GlyphName: "a108", Wx: 760.000000, Wy: 0.000000},
    70  	"a109":  {GlyphName: "a109", Wx: 626.000000, Wy: 0.000000},
    71  	"a11":   {GlyphName: "a11", Wx: 960.000000, Wy: 0.000000},
    72  	"a110":  {GlyphName: "a110", Wx: 694.000000, Wy: 0.000000},
    73  	"a111":  {GlyphName: "a111", Wx: 595.000000, Wy: 0.000000},
    74  	"a112":  {GlyphName: "a112", Wx: 776.000000, Wy: 0.000000},
    75  	"a117":  {GlyphName: "a117", Wx: 690.000000, Wy: 0.000000},
    76  	"a118":  {GlyphName: "a118", Wx: 791.000000, Wy: 0.000000},
    77  	"a119":  {GlyphName: "a119", Wx: 790.000000, Wy: 0.000000},
    78  	"a12":   {GlyphName: "a12", Wx: 939.000000, Wy: 0.000000},
    79  	"a120":  {GlyphName: "a120", Wx: 788.000000, Wy: 0.000000},
    80  	"a121":  {GlyphName: "a121", Wx: 788.000000, Wy: 0.000000},
    81  	"a122":  {GlyphName: "a122", Wx: 788.000000, Wy: 0.000000},
    82  	"a123":  {GlyphName: "a123", Wx: 788.000000, Wy: 0.000000},
    83  	"a124":  {GlyphName: "a124", Wx: 788.000000, Wy: 0.000000},
    84  	"a125":  {GlyphName: "a125", Wx: 788.000000, Wy: 0.000000},
    85  	"a126":  {GlyphName: "a126", Wx: 788.000000, Wy: 0.000000},
    86  	"a127":  {GlyphName: "a127", Wx: 788.000000, Wy: 0.000000},
    87  	"a128":  {GlyphName: "a128", Wx: 788.000000, Wy: 0.000000},
    88  	"a129":  {GlyphName: "a129", Wx: 788.000000, Wy: 0.000000},
    89  	"a13":   {GlyphName: "a13", Wx: 549.000000, Wy: 0.000000},
    90  	"a130":  {GlyphName: "a130", Wx: 788.000000, Wy: 0.000000},
    91  	"a131":  {GlyphName: "a131", Wx: 788.000000, Wy: 0.000000},
    92  	"a132":  {GlyphName: "a132", Wx: 788.000000, Wy: 0.000000},
    93  	"a133":  {GlyphName: "a133", Wx: 788.000000, Wy: 0.000000},
    94  	"a134":  {GlyphName: "a134", Wx: 788.000000, Wy: 0.000000},
    95  	"a135":  {GlyphName: "a135", Wx: 788.000000, Wy: 0.000000},
    96  	"a136":  {GlyphName: "a136", Wx: 788.000000, Wy: 0.000000},
    97  	"a137":  {GlyphName: "a137", Wx: 788.000000, Wy: 0.000000},
    98  	"a138":  {GlyphName: "a138", Wx: 788.000000, Wy: 0.000000},
    99  	"a139":  {GlyphName: "a139", Wx: 788.000000, Wy: 0.000000},
   100  	"a14":   {GlyphName: "a14", Wx: 855.000000, Wy: 0.000000},
   101  	"a140":  {GlyphName: "a140", Wx: 788.000000, Wy: 0.000000},
   102  	"a141":  {GlyphName: "a141", Wx: 788.000000, Wy: 0.000000},
   103  	"a142":  {GlyphName: "a142", Wx: 788.000000, Wy: 0.000000},
   104  	"a143":  {GlyphName: "a143", Wx: 788.000000, Wy: 0.000000},
   105  	"a144":  {GlyphName: "a144", Wx: 788.000000, Wy: 0.000000},
   106  	"a145":  {GlyphName: "a145", Wx: 788.000000, Wy: 0.000000},
   107  	"a146":  {GlyphName: "a146", Wx: 788.000000, Wy: 0.000000},
   108  	"a147":  {GlyphName: "a147", Wx: 788.000000, Wy: 0.000000},
   109  	"a148":  {GlyphName: "a148", Wx: 788.000000, Wy: 0.000000},
   110  	"a149":  {GlyphName: "a149", Wx: 788.000000, Wy: 0.000000},
   111  	"a15":   {GlyphName: "a15", Wx: 911.000000, Wy: 0.000000},
   112  	"a150":  {GlyphName: "a150", Wx: 788.000000, Wy: 0.000000},
   113  	"a151":  {GlyphName: "a151", Wx: 788.000000, Wy: 0.000000},
   114  	"a152":  {GlyphName: "a152", Wx: 788.000000, Wy: 0.000000},
   115  	"a153":  {GlyphName: "a153", Wx: 788.000000, Wy: 0.000000},
   116  	"a154":  {GlyphName: "a154", Wx: 788.000000, Wy: 0.000000},
   117  	"a155":  {GlyphName: "a155", Wx: 788.000000, Wy: 0.000000},
   118  	"a156":  {GlyphName: "a156", Wx: 788.000000, Wy: 0.000000},
   119  	"a157":  {GlyphName: "a157", Wx: 788.000000, Wy: 0.000000},
   120  	"a158":  {GlyphName: "a158", Wx: 788.000000, Wy: 0.000000},
   121  	"a159":  {GlyphName: "a159", Wx: 788.000000, Wy: 0.000000},
   122  	"a16":   {GlyphName: "a16", Wx: 933.000000, Wy: 0.000000},
   123  	"a160":  {GlyphName: "a160", Wx: 894.000000, Wy: 0.000000},
   124  	"a161":  {GlyphName: "a161", Wx: 838.000000, Wy: 0.000000},
   125  	"a162":  {GlyphName: "a162", Wx: 924.000000, Wy: 0.000000},
   126  	"a163":  {GlyphName: "a163", Wx: 1016.000000, Wy: 0.000000},
   127  	"a164":  {GlyphName: "a164", Wx: 458.000000, Wy: 0.000000},
   128  	"a165":  {GlyphName: "a165", Wx: 924.000000, Wy: 0.000000},
   129  	"a166":  {GlyphName: "a166", Wx: 918.000000, Wy: 0.000000},
   130  	"a167":  {GlyphName: "a167", Wx: 927.000000, Wy: 0.000000},
   131  	"a168":  {GlyphName: "a168", Wx: 928.000000, Wy: 0.000000},
   132  	"a169":  {GlyphName: "a169", Wx: 928.000000, Wy: 0.000000},
   133  	"a17":   {GlyphName: "a17", Wx: 945.000000, Wy: 0.000000},
   134  	"a170":  {GlyphName: "a170", Wx: 834.000000, Wy: 0.000000},
   135  	"a171":  {GlyphName: "a171", Wx: 873.000000, Wy: 0.000000},
   136  	"a172":  {GlyphName: "a172", Wx: 828.000000, Wy: 0.000000},
   137  	"a173":  {GlyphName: "a173", Wx: 924.000000, Wy: 0.000000},
   138  	"a174":  {GlyphName: "a174", Wx: 917.000000, Wy: 0.000000},
   139  	"a175":  {GlyphName: "a175", Wx: 930.000000, Wy: 0.000000},
   140  	"a176":  {GlyphName: "a176", Wx: 931.000000, Wy: 0.000000},
   141  	"a177":  {GlyphName: "a177", Wx: 463.000000, Wy: 0.000000},
   142  	"a178":  {GlyphName: "a178", Wx: 883.000000, Wy: 0.000000},
   143  	"a179":  {GlyphName: "a179", Wx: 836.000000, Wy: 0.000000},
   144  	"a18":   {GlyphName: "a18", Wx: 974.000000, Wy: 0.000000},
   145  	"a180":  {GlyphName: "a180", Wx: 867.000000, Wy: 0.000000},
   146  	"a181":  {GlyphName: "a181", Wx: 696.000000, Wy: 0.000000},
   147  	"a182":  {GlyphName: "a182", Wx: 874.000000, Wy: 0.000000},
   148  	"a183":  {GlyphName: "a183", Wx: 760.000000, Wy: 0.000000},
   149  	"a184":  {GlyphName: "a184", Wx: 946.000000, Wy: 0.000000},
   150  	"a185":  {GlyphName: "a185", Wx: 865.000000, Wy: 0.000000},
   151  	"a186":  {GlyphName: "a186", Wx: 967.000000, Wy: 0.000000},
   152  	"a187":  {GlyphName: "a187", Wx: 831.000000, Wy: 0.000000},
   153  	"a188":  {GlyphName: "a188", Wx: 873.000000, Wy: 0.000000},
   154  	"a189":  {GlyphName: "a189", Wx: 927.000000, Wy: 0.000000},
   155  	"a19":   {GlyphName: "a19", Wx: 755.000000, Wy: 0.000000},
   156  	"a190":  {GlyphName: "a190", Wx: 970.000000, Wy: 0.000000},
   157  	"a191":  {GlyphName: "a191", Wx: 918.000000, Wy: 0.000000},
   158  	"a192":  {GlyphName: "a192", Wx: 748.000000, Wy: 0.000000},
   159  	"a193":  {GlyphName: "a193", Wx: 836.000000, Wy: 0.000000},
   160  	"a194":  {GlyphName: "a194", Wx: 771.000000, Wy: 0.000000},
   161  	"a195":  {GlyphName: "a195", Wx: 888.000000, Wy: 0.000000},
   162  	"a196":  {GlyphName: "a196", Wx: 748.000000, Wy: 0.000000},
   163  	"a197":  {GlyphName: "a197", Wx: 771.000000, Wy: 0.000000},
   164  	"a198":  {GlyphName: "a198", Wx: 888.000000, Wy: 0.000000},
   165  	"a199":  {GlyphName: "a199", Wx: 867.000000, Wy: 0.000000},
   166  	"a2":    {GlyphName: "a2", Wx: 961.000000, Wy: 0.000000},
   167  	"a20":   {GlyphName: "a20", Wx: 846.000000, Wy: 0.000000},
   168  	"a200":  {GlyphName: "a200", Wx: 696.000000, Wy: 0.000000},
   169  	"a201":  {GlyphName: "a201", Wx: 874.000000, Wy: 0.000000},
   170  	"a202":  {GlyphName: "a202", Wx: 974.000000, Wy: 0.000000},
   171  	"a203":  {GlyphName: "a203", Wx: 762.000000, Wy: 0.000000},
   172  	"a204":  {GlyphName: "a204", Wx: 759.000000, Wy: 0.000000},
   173  	"a205":  {GlyphName: "a205", Wx: 509.000000, Wy: 0.000000},
   174  	"a206":  {GlyphName: "a206", Wx: 410.000000, Wy: 0.000000},
   175  	"a21":   {GlyphName: "a21", Wx: 762.000000, Wy: 0.000000},
   176  	"a22":   {GlyphName: "a22", Wx: 761.000000, Wy: 0.000000},
   177  	"a23":   {GlyphName: "a23", Wx: 571.000000, Wy: 0.000000},
   178  	"a24":   {GlyphName: "a24", Wx: 677.000000, Wy: 0.000000},
   179  	"a25":   {GlyphName: "a25", Wx: 763.000000, Wy: 0.000000},
   180  	"a26":   {GlyphName: "a26", Wx: 760.000000, Wy: 0.000000},
   181  	"a27":   {GlyphName: "a27", Wx: 759.000000, Wy: 0.000000},
   182  	"a28":   {GlyphName: "a28", Wx: 754.000000, Wy: 0.000000},
   183  	"a29":   {GlyphName: "a29", Wx: 786.000000, Wy: 0.000000},
   184  	"a3":    {GlyphName: "a3", Wx: 980.000000, Wy: 0.000000},
   185  	"a30":   {GlyphName: "a30", Wx: 788.000000, Wy: 0.000000},
   186  	"a31":   {GlyphName: "a31", Wx: 788.000000, Wy: 0.000000},
   187  	"a32":   {GlyphName: "a32", Wx: 790.000000, Wy: 0.000000},
   188  	"a33":   {GlyphName: "a33", Wx: 793.000000, Wy: 0.000000},
   189  	"a34":   {GlyphName: "a34", Wx: 794.000000, Wy: 0.000000},
   190  	"a35":   {GlyphName: "a35", Wx: 816.000000, Wy: 0.000000},
   191  	"a36":   {GlyphName: "a36", Wx: 823.000000, Wy: 0.000000},
   192  	"a37":   {GlyphName: "a37", Wx: 789.000000, Wy: 0.000000},
   193  	"a38":   {GlyphName: "a38", Wx: 841.000000, Wy: 0.000000},
   194  	"a39":   {GlyphName: "a39", Wx: 823.000000, Wy: 0.000000},
   195  	"a4":    {GlyphName: "a4", Wx: 719.000000, Wy: 0.000000},
   196  	"a40":   {GlyphName: "a40", Wx: 833.000000, Wy: 0.000000},
   197  	"a41":   {GlyphName: "a41", Wx: 816.000000, Wy: 0.000000},
   198  	"a42":   {GlyphName: "a42", Wx: 831.000000, Wy: 0.000000},
   199  	"a43":   {GlyphName: "a43", Wx: 923.000000, Wy: 0.000000},
   200  	"a44":   {GlyphName: "a44", Wx: 744.000000, Wy: 0.000000},
   201  	"a45":   {GlyphName: "a45", Wx: 723.000000, Wy: 0.000000},
   202  	"a46":   {GlyphName: "a46", Wx: 749.000000, Wy: 0.000000},
   203  	"a47":   {GlyphName: "a47", Wx: 790.000000, Wy: 0.000000},
   204  	"a48":   {GlyphName: "a48", Wx: 792.000000, Wy: 0.000000},
   205  	"a49":   {GlyphName: "a49", Wx: 695.000000, Wy: 0.000000},
   206  	"a5":    {GlyphName: "a5", Wx: 789.000000, Wy: 0.000000},
   207  	"a50":   {GlyphName: "a50", Wx: 776.000000, Wy: 0.000000},
   208  	"a51":   {GlyphName: "a51", Wx: 768.000000, Wy: 0.000000},
   209  	"a52":   {GlyphName: "a52", Wx: 792.000000, Wy: 0.000000},
   210  	"a53":   {GlyphName: "a53", Wx: 759.000000, Wy: 0.000000},
   211  	"a54":   {GlyphName: "a54", Wx: 707.000000, Wy: 0.000000},
   212  	"a55":   {GlyphName: "a55", Wx: 708.000000, Wy: 0.000000},
   213  	"a56":   {GlyphName: "a56", Wx: 682.000000, Wy: 0.000000},
   214  	"a57":   {GlyphName: "a57", Wx: 701.000000, Wy: 0.000000},
   215  	"a58":   {GlyphName: "a58", Wx: 826.000000, Wy: 0.000000},
   216  	"a59":   {GlyphName: "a59", Wx: 815.000000, Wy: 0.000000},
   217  	"a6":    {GlyphName: "a6", Wx: 494.000000, Wy: 0.000000},
   218  	"a60":   {GlyphName: "a60", Wx: 789.000000, Wy: 0.000000},
   219  	"a61":   {GlyphName: "a61", Wx: 789.000000, Wy: 0.000000},
   220  	"a62":   {GlyphName: "a62", Wx: 707.000000, Wy: 0.000000},
   221  	"a63":   {GlyphName: "a63", Wx: 687.000000, Wy: 0.000000},
   222  	"a64":   {GlyphName: "a64", Wx: 696.000000, Wy: 0.000000},
   223  	"a65":   {GlyphName: "a65", Wx: 689.000000, Wy: 0.000000},
   224  	"a66":   {GlyphName: "a66", Wx: 786.000000, Wy: 0.000000},
   225  	"a67":   {GlyphName: "a67", Wx: 787.000000, Wy: 0.000000},
   226  	"a68":   {GlyphName: "a68", Wx: 713.000000, Wy: 0.000000},
   227  	"a69":   {GlyphName: "a69", Wx: 791.000000, Wy: 0.000000},
   228  	"a7":    {GlyphName: "a7", Wx: 552.000000, Wy: 0.000000},
   229  	"a70":   {GlyphName: "a70", Wx: 785.000000, Wy: 0.000000},
   230  	"a71":   {GlyphName: "a71", Wx: 791.000000, Wy: 0.000000},
   231  	"a72":   {GlyphName: "a72", Wx: 873.000000, Wy: 0.000000},
   232  	"a73":   {GlyphName: "a73", Wx: 761.000000, Wy: 0.000000},
   233  	"a74":   {GlyphName: "a74", Wx: 762.000000, Wy: 0.000000},
   234  	"a75":   {GlyphName: "a75", Wx: 759.000000, Wy: 0.000000},
   235  	"a76":   {GlyphName: "a76", Wx: 892.000000, Wy: 0.000000},
   236  	"a77":   {GlyphName: "a77", Wx: 892.000000, Wy: 0.000000},
   237  	"a78":   {GlyphName: "a78", Wx: 788.000000, Wy: 0.000000},
   238  	"a79":   {GlyphName: "a79", Wx: 784.000000, Wy: 0.000000},
   239  	"a8":    {GlyphName: "a8", Wx: 537.000000, Wy: 0.000000},
   240  	"a81":   {GlyphName: "a81", Wx: 438.000000, Wy: 0.000000},
   241  	"a82":   {GlyphName: "a82", Wx: 138.000000, Wy: 0.000000},
   242  	"a83":   {GlyphName: "a83", Wx: 277.000000, Wy: 0.000000},
   243  	"a84":   {GlyphName: "a84", Wx: 415.000000, Wy: 0.000000},
   244  	"a85":   {GlyphName: "a85", Wx: 509.000000, Wy: 0.000000},
   245  	"a86":   {GlyphName: "a86", Wx: 410.000000, Wy: 0.000000},
   246  	"a87":   {GlyphName: "a87", Wx: 234.000000, Wy: 0.000000},
   247  	"a88":   {GlyphName: "a88", Wx: 234.000000, Wy: 0.000000},
   248  	"a89":   {GlyphName: "a89", Wx: 390.000000, Wy: 0.000000},
   249  	"a9":    {GlyphName: "a9", Wx: 577.000000, Wy: 0.000000},
   250  	"a90":   {GlyphName: "a90", Wx: 390.000000, Wy: 0.000000},
   251  	"a91":   {GlyphName: "a91", Wx: 276.000000, Wy: 0.000000},
   252  	"a92":   {GlyphName: "a92", Wx: 276.000000, Wy: 0.000000},
   253  	"a93":   {GlyphName: "a93", Wx: 317.000000, Wy: 0.000000},
   254  	"a94":   {GlyphName: "a94", Wx: 317.000000, Wy: 0.000000},
   255  	"a95":   {GlyphName: "a95", Wx: 334.000000, Wy: 0.000000},
   256  	"a96":   {GlyphName: "a96", Wx: 334.000000, Wy: 0.000000},
   257  	"a97":   {GlyphName: "a97", Wx: 392.000000, Wy: 0.000000},
   258  	"a98":   {GlyphName: "a98", Wx: 392.000000, Wy: 0.000000},
   259  	"a99":   {GlyphName: "a99", Wx: 668.000000, Wy: 0.000000},
   260  	"space": {GlyphName: "space", Wx: 278.000000, Wy: 0.000000},
   261  }