资源简介
主要采用GDI的GetGlyphOutline进行TrueType字体的提取,参照C++源码的总体处理逻辑。为适应C#编程,一些结构的定义和C++有所不同。

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using TrueTypeText.Drawing;
using TrueTypeText.Outline.Data;
using TrueTypeText.Outline;
namespace TrueTypeText
{
public partial class MainForm : Form
{
private IList wordOutlines;
private Graphics graphics = null;
private float lineWidth = 1f;
public MainForm()
{
InitializeComponent();
wordOutlines = new List();
Font font = new Font(new FontFamily(“宋体“) 100f);
tbFont.Text = font.ToString();
tbFont.Tag = font;
}
private void MainForm_Load(object sender EventArgs e)
{
graphics = this.CreateGraphics();
}
private void MainForm_Paint(object sender PaintEventArgs e)
{
DrawingContext context = new DrawingContext(e.Graphics);
using (Pen p = new Pen(Color.Red lineWidth))
{
context.Pen = p;
//画图
foreach (WordOutlineDrawing outline in wordOutlines)
{
outline.Draw(context);
}
}
}
private void MainForm_MouseMove(object sender MouseEventArgs e)
{
this.Text = string.Format(“({0}{1})“ e.X e.Y);
}
private void tvList_AfterSelect(object sender TreeViewEventArgs e)
{
DrawingContext context = new DrawingContext(graphics);
using (Pen pen = new Pen(Color.Blue lineWidth))
{
context.Pen = pen;
if (e.Node.Nodes.Count > 0)
{//存在子项
pen.Color = Color.Green;
Cursor.Current = Cursors.WaitCursor;
foreach (TreeNode node in e.Node.Nodes)
{
IDrawing drawing = node.Tag as IDrawing;
if (drawing != null)
{
drawing.Draw(context);
}
Thread.Sleep(250);
}
Cursor.Current = Cursors.Default;
}
else
{
IDrawing drawing = e.Node.Tag as IDrawing;
if (drawing != null)
{
drawing.Draw(context);
}
}
}
}
#region FillWordOutlines
///
/// 填充所有字符轮廓
///
private void FillWordOutlines()
{
//清空
wordOutlines.Clear();
tvList.Nodes.Clear();
//填充
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 904 2008-10-16 11:16 Outline\ConvertUtil.cs
文件 727 2008-10-16 11:16 Outline\Data\DLine.cs
文件 996 2008-10-16 13:17 Outline\Data\DOutline.cs
文件 955 2008-10-16 13:17 Outline\Data\DPolygon.cs
文件 666 2008-10-16 11:16 Outline\GdiNativeMethods.cs
文件 2946 2008-10-16 11:16 Outline\StructDefine.cs
文件 5517 2008-10-16 11:16 Outline\WordGraph.cs
文件 9366 2008-10-16 13:20 App.ico
文件 20363 2008-10-16 13:37 MainForm.resx
文件 168 2008-10-16 11:20 TrueTypeText.csproj.user
文件 1175 2008-10-16 13:24 Properties\AssemblyInfo.cs
文件 2880 2008-10-16 11:19 Properties\Resources.Designer.cs
文件 5612 2008-10-16 11:19 Properties\Resources.resx
文件 1097 2008-10-16 11:19 Properties\Settings.Designer.cs
文件 249 2008-10-16 11:19 Properties\Settings.settings
文件 9218 2008-10-16 13:37 MainForm.cs
文件 13718 2008-10-16 13:37 MainForm.Designer.cs
文件 474 2008-10-16 11:19 Program.cs
文件 4193 2008-10-16 13:21 TrueTypeText.csproj
文件 912 2008-10-16 11:19 TrueTypeText.sln
文件 391 2008-10-16 11:17 Drawing\BeelineDrawing.cs
文件 385 2008-10-16 11:17 Drawing\CurvelineDrawing.cs
文件 1125 2008-10-16 11:17 Drawing\DrawingContext.cs
文件 376 2008-10-16 11:17 Drawing\IDrawing.cs
文件 544 2008-10-16 11:17 Drawing\IDrawingContext.cs
文件 667 2008-10-16 11:17 Drawing\LineDrawing.cs
文件 813 2008-10-16 11:17 Drawing\PolygonDrawing.cs
文件 384 2008-10-16 11:17 Drawing\PolylineDrawing.cs
文件 1117 2008-10-16 11:17 Drawing\WordOutlineDrawing.cs
目录 0 2008-10-16 13:17 Outline\Data
............此处省略6个文件信息
相关资源
- ChartCtrl控件库(可在VS2019中使用)
- traceroute路由跟踪
- 俄罗斯方块游戏源码(Tetris)
- Microsoft Visual C++ 2005 Redistributable Pack
- 《Data Structures and Algorithm Analysis in C
- Microsoft Visual C++ 2010 Redistributable Pack
- 自绘CListCtrl聊天列表MFC
- 地铁计费系统C++实现dijkstra算法
- FastReport V6.4.13 VCL Enterprise(安装包源
- 求点介数C++实现 Betweenness Centrality
- MFC Tab control 重绘便签边框和主框 背景
- High-speed Charting ControlMFC绘图控件
- SM4(ECB、CBC、CTR、CFB、OFB)加密算法
- Data Structures and Algorithm Analysis in C++
- plist 文件文本二进制互转
- BCGControlBar Professional v.28 Full Source
- Microsoft Visual C++ 2005 SP1 Redistributable
- Microsoft Visual C++ 2010 SP1 Redistributable
- C++写太阳/月球坐标计算,在地固坐标
- Microsoft Visual C++ 2013 Redistributable X64
-
Data Structures and Other ob
jects Using C++( - Data Structures Using C++(2nd) 无水印原版
- JPL DE405 资源
- Numerical Recipes 3rd英文版,有C++、Fort
- C++ Concurrency in Action (2nd) 无水印
- 最短路径的篇论文及必经节点的遗传
- 最新版AddFlow ActiveX Control矢量图OCX控件
- Microsoft Visual C++ 2013 Redistributable (x
- FastReport_Professtional_5.6.2_Full_Source_for
- Intel_Visual_Fortran应用程序开发
评论
共有 条评论