⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 type1fontdata.cs

📁 在网页上显示pdf文件的类库,可以将pdf文件显示的网页上面
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Collections;
using System.Diagnostics;
using System.Globalization;
using System.IO;
 
// Creation date: 11.10.2002
// Checked: xx.05.2002
// Author: Otto Mayer (mot@root.ch)
// Version: 1.01

// Report.NET copyright 2002-2004 root-software ag, B黵glen Switzerland - O. Mayer, S. Spirig, R. Gartenmann, all rights reserved
// This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation, version 2.1 of the License.
// This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You
// should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA www.opensource.org/licenses/lgpl-license.html

namespace Root.Reports {
  /// <summary>Type 1 Font Data</summary>
  /// <remarks>This class is based on the "Adobe Font Metrics File Format Specification" <see href="http://partners.adobe.com/asn/developer/pdfs/tn/5004.AFM_Spec.pdf"/></remarks>
  public class Type1FontData : FontData {
    //----------------------------------------------------------------------------------------------------x
    #region AFM Font Information
    //----------------------------------------------------------------------------------------------------x

    /// <summary>Font metrics version</summary>
    /// <example><code>StartFontMetrics 4.1</code></example>
    internal readonly String sFontMetricsVersion;

    /// <summary>Metric sets</summary>
    /// <example><code>MetricsSets 0</code></example>
    internal readonly Int32 iMetricsSets = 0;

    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -x
    // Global Font Information

    /// <summary>Font name</summary>
    /// <example><code>FontName Times-Roman</code></example>
    internal readonly String sFontName;

    /// <summary>Full name</summary>
    /// <example><code></code>FullName Times Roman</example>
    internal readonly String sFullName;

    /// <summary>Family name</summary>
    /// <example><code>FamilyName Times</code></example>
    internal readonly String sFamilyName;

    /// <summary>Weight</summary>
    /// <example><code>Weight Roman</code></example>
    internal readonly String sWeight;

    /// <summary>Font box</summary>
    /// <example><code>FontBBox -168 -218 1000 898</code></example>
    internal readonly Single fFontBBox_llx = Single.NaN;
    internal readonly Single fFontBBox_lly = Single.NaN;
    internal readonly Single fFontBBox_urx = Single.NaN;
    internal readonly Single fFontBBox_ury = Single.NaN;

    /// <summary>Version</summary>
    /// <example><code>Version 002.000</code></example>
    internal readonly String sVersion;

    /// <summary>Notice</summary>
    /// <example><code>Notice Copyright (c) 1985, 1987, 1989, 1990, 1993, 1997 Adobe Systems Incorporated ...</code></example>
    internal readonly String sNotice;

    /// <summary>Encoding scheme</summary>
    /// <remarks>
    /// The encoding is 'StandardEncoding' or 'AdobeStandardEncoding' for a font that can be totally encoded according to the characters names.
    /// For all other names the font is treated as symbolic.
    /// </remarks>
    /// <example><code>EncodingScheme AdobeStandardEncoding</code></example>
    internal readonly String sEncodingScheme;

    // internal readonly Int32 iMappingScheme;  // not present with base fonts

    // internal readonly Int32 iEscChar;  // only for MappingScheme 3

    /// <summary>Character set</summary>
    /// <example><code>CharacterSet ExtendedRoman</code></example>
    internal readonly String sCharacterSet;

    // internal readonly Int32 iCharacters;

    /// <summary>Base font flag</summary>
    /// <example><code>IsBaseFont true</code></example>
    internal readonly Boolean bIsBaseFont = true;

    // internal readonly Single fVVector_Origin0;  // only for MetricsSets 2

    // internal readonly Single fVVector_Origin1;  // only for MetricsSets 2

    // internal readonly Boolean bIsFixedV;  // only for MetricsSets 2

    /// <summary>Cap height</summary>
    /// <example><code>CapHeight 662</code></example>
    internal readonly Single fCapHeight = Single.NaN;

    /// <summary>X height</summary>
    /// <example><code>XHeight 450</code></example>
    internal readonly Single fXHeight = Single.NaN;
    
    /// <summary>Ascender</summary>
    /// <example><code>Ascender 683</code></example>
    internal readonly Single fAscender = Single.NaN;
    
    /// <summary>Descender</summary>
    /// <example><code>Descender -217</code></example>
    internal readonly Single fDescender = Single.NaN;
    
    /// <summary>Standard horizontal width</summary>
    /// <example><code>StdHW 28</code></example>
    internal readonly Single fStdHW = Single.NaN;
    
    /// <summary>Standard vertical width</summary>
    /// <example><code>StdVW 84</code></example>
    internal readonly Single fStdVW = Single.NaN;

    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -x
    // Writing Direction Information

    // internal readonly Int32 iStartDirection;

    /// <summary>Underline position</summary>
    /// <example><code>UnderlinePosition -100</code></example>
    internal readonly Single fUnderlinePosition = Single.NaN;

    /// <summary>Underline thickness</summary>
    /// <example><code>UnderlineThickness 50</code></example>
    internal readonly Single fUnderlineThickness = Single.NaN;

    /// <summary>Italic angle</summary>
    /// <example><code>ItalicAngle 0</code></example>
    internal readonly Single fItalicAngle = Single.NaN;
    
    // internal readonly Single fCharWidth_x;
    
    // internal readonly Single fCharWidth_y;
    
    /// <summary><see langword="true"/> if all the characters have the same width.</summary>
    /// <example><code>IsFixedPitch false</code></example>
    internal readonly Boolean bIsFixedPitch = false;

    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -x
    // Individual Character Metrics

    /// <summary>Number of character metrics entries</summary>
    internal readonly Int32 iCharMetricsCount;

    /// <summary>Character metrics definition array</summary>
    private readonly CharMetrics[] aCharMetrics;

    //internal readonly Int32 iKernDataCount;

    //internal readonly Int32 iCompositesCount;
    #endregion

    //----------------------------------------------------------------------------------------------------x
    internal static readonly Char[] acDelimiterSemicolon = {';'};

    private static readonly Char[] acDelimiterToken = {' ', '\t'};

    //----------------------------------------------------------------------------------------------------x
    /// <summary>Creates the type 1 font data object</summary>
    /// <param name="stream">AFM definition stream</param>
    /// <param name="style"></param>
    internal Type1FontData(Stream stream, Style style /*, Encoding encoding, Boolean bEmbedded*/ /*, byte ttfAfm[], byte pfb[]*/)
      : base(style, FontData.Encoding.Cp1252, true/*encoding, bEmbedded, bCached*/) {
      //Boolean bBuiltinFont14 = bIsBuiltinFont14();
      StreamReader streamReader = new StreamReader(stream);
      try {
        // Header
        String sLine = streamReader.ReadLine();
        if (sLine == null || !sLine.StartsWith("StartFontMetrics")) {
          throw new ReportException("Token [StartFontMetrics] expected in AFM file");
        }

        // general information
        do {
          if (sLine.StartsWith("Comment")) {
            goto NextLine;
          }
          String[] asToken = sLine.Split(acDelimiterToken, 5);
          if (asToken.Length == 0) {
            goto NextLine;
          }
          switch (asToken[0]) {
            case "StartFontMetrics": { sFontMetricsVersion = asToken[1];  break; }
            case "MetricsSets": { iMetricsSets = Int32.Parse(asToken[1]);  break; }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -