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

📄 uttf2vct.int

📁 windows TTF 字型的delphi reader
💻 INT
字号:
{
  UTTF2Vct.pas       (was UTTFToVector.pas; changed for 8.3 compatibility )

  TTF to Vector converter
  Copyright (c) 1996 by Marco Cocco. All rights reseved.
  Copyright (c) 1996 by D3K Artisan Of Ware. All rights reseved.

  Please send comments to d3k@hotmail.com

  History
  ------------------------------------------------------------------
  17/Dec/1996  v1.00 Start of implementation
  17/Dec/1996  v1.00 End of implementation & testing !
  19/Dec/1996  v1.01 Added some sparse comments
  20/Dec/1996  v1.02 Added support for Delphi 1.0/Win3.x
  20/Dec/1996  v2.00 Converterd from pure class to component
  20/Dev/1996  v2.01 Added support for UNICODE (Delphi 2.0 only)
}

unit UTTF2Vct;

interface

uses
  {$IFDEF WIN32}
  Windows,
  {$ELSE}
  WinTypes, WinProcs,
  {$ENDIF}
  Classes, Graphics, SysUtils;

type
  { Font stroke: a Font Stroke is the "basic" element of a character glyph,
                that is a glyph is a sequence of connected strokes (lines).
                First point of first stroke connects to last point of last stroke.
                All strokes with equal GlyphNumber value come from the same glyph.
                Strokes of the same glyph are stored sequentially, i.e. stroke 0,
                stroke 1, ... stoke n-1. }
  PFontStroke = ^TFontStroke;
  TFontStroke = record
                  GlyphNumber: integer;
                  Pt1, Pt2: TPoint;          { Note: Strokes[i].Pt2=Strokes[i+1].Pt1
                                                    (also Strokes[i].Pt1=Strokes[i-1].Pt2)
                                                    when Strokes[i].GlyphNumber = Strokes[i+1].GlyphNumber }
                end;

  TEnumStrokesCallback = function( Idx: integer; const Stroke: TFontStroke ): boolean of object;

  TStrokeCollection = class( TList )
    private
    protected
      function GetNumGlyphs: integer;
      function GetFontStroke( Idx: integer ): TFontStroke;
      procedure FreeStrokes;
      function GetBounds: TRect;
    public
      constructor Create; virtual;
      destructor Destroy; override;

      { Returns the index of the first stroke for the glyph number GlyphNumber }
      function StartOfGlyph( GlyphNumber: integer ): integer;
      { Returns the count of strokes for the glyph number GlyphNumber. }
      function GlyphNumStrokes( GlyphNumber: integer ): integer;
      { Enumerates all strokes of all glyphs }
      procedure EnumStrokes( Callback: TEnumStrokesCallback );

      { Returns the number of glyphs }
      property NumGlyphs: integer read GetNumGlyphs;
      { Returns the stroke number Idx. Use StrartOfGlyph to determine
        the index of the first stroke for a given glyph.
        Use GlyphNumStrokes to determine the number of strokes a glyph is. }
      property Stroke[Idx:integer]: TFontStroke read GetFontStroke;
      { Returns the smallest rectangle that completely bounds all glyphs }
      property Bounds: TRect read GetBounds;
  end;

  TTTFToVectorConverter = class( TComponent )
    private
      FFont: TFont;
      FSplinePrecision: integer;
      FUNICODE: boolean;
    protected
      procedure SetFont( Value: TFont ); virtual;
      procedure SetSplinePrecision( Value: integer );
    public
      constructor Create( Owner: TComponent ); override;
      destructor Destroy; override;

      function GetCharacterGlyphs( CharCode: integer ): TStrokeCollection;

    published
      property Font: TFont read FFont write SetFont;
      property Precision: integer read FSplinePrecision write SetSplinePrecision default 5;
      {$IFDEF WIN32}
      { Set to TRUE if you wish retrieve outlines for UNICODE fonts }
      property UNICODE: boolean read FUNICODE write FUNICODE default false;
      {$ENDIF}
  end;

procedure Register;

implementation

⌨️ 快捷键说明

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