Font: a C++ class
Font: a C++ class
This class is used in
Fractal Generator.
Avi Examples
The header file
Font.h
/*
Font.h
Copyright (C) 2002-2005 René Nyffenegger
This source code is provided 'as-is', without any express or implied
warranty. In no event will the author be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this source code must not be misrepresented; you must not
claim that you wrote the original source code. If you use this source code
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original source code.
3. This notice may not be removed or altered from any source distribution.
René Nyffenegger rene.nyffenegger@adp-gmbh.ch
*/
#ifndef FONT_H_
#define FONT_H_
#include <string>
#include <sstream>
#include <windows.h>
#include "STD_STR.h"
class Font {
public:
Font(STD_STR const& name, int size=12, bool bold=false, bool italic=false, bool underlined=false);
~Font();
protected:
friend class DC;
Font(HFONT f) : font_(f){};
operator HFONT() const {return font_;};
private:
HFONT font_;
};
#endif
The implementation file
Font.cpp
/*
Font.cpp
Copyright (C) 2002-2004 René Nyffenegger
This source code is provided 'as-is', without any express or implied
warranty. In no event will the author be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this source code must not be misrepresented; you must not
claim that you wrote the original source code. If you use this source code
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original source code.
3. This notice may not be removed or altered from any source distribution.
René Nyffenegger rene.nyffenegger@adp-gmbh.ch
*/
#include "Font.h"
Font::Font(STD_STR const& name, int size, bool bold, bool italic, bool underlined) {
font_ = ::CreateFont(size, 0, 0, 0, bold? FW_BOLD : FW_NORMAL, italic, underlined, false,
DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
FF_DONTCARE,
name.c_str());
if (!font_) {
throw "Couldn't create font";
}
}
Font::~Font() {
::DeleteObject(font_);
}
Font: a C++ class的更多相关文章
- CSS3与页面布局学习总结(五)——Web Font与Sprite
一.web font web font是应用在web中的一种字体技术,在CSS中使用font-face定义新的字体.先了解操作系统中的字体: a).安装好操作系统后,会默认安装一些字体,这些字体文件描 ...
- 把UI图里的小图标制作成icon font
一个交互比较多的UI图里面可能会有很多小图标,一般可用sprites图将多个小图标弄成一张大图,或者其它的办法,各种方法的比较可参见博主的另外一篇博客使用css3新属性clip-path制作小图标,本 ...
- [函数] Firemonkey Windows 重新计算 Font Baseline
计算字型 Baseline 是一个不常用的函数,但如果想要显示不同大小文字下方对齐,就得用它来计算字型的 Baseline 才行,如果计算不准,显示的文字就会高高低低不整齐. 在 Firemonkey ...
- Html中<font>标签的使用
Html中<font>标签的使用 <!doctype html> <html lang="en"> <head> <meta ...
- 关于firefox对font awesome本地环境无法加载问题
问题描述 昨天尝试使用font awesome加载字体图标,直接在本地引入相关文件,测试发现图标在chrome和IE环境支持,但是在firefox上怎么都显示不出来. 解决方法 通过测试发现通过htt ...
- CSS3使用Font Awesome字体图标的控件样例(按钮,工具栏,输入框)
按钮上加入font awesome图标,用原生的input button标签无法实现,查看网上的只能通过<a><li></li></a>实现此功能,通过 ...
- CSS 中Font Awesome 图标(附码表)
HTML中缩放的矢量图标,您可以使用CSS所提供的所有特性对它们进行更改,包括:大小.颜色.阴影或者其它任何支持的效果. Font Awesome 传送门:http://fontawesome.das ...
- Font Squirrel
Font Squirrel FontSquirrel:国外免费字体下载网是一个提供高质量商业字体下载网站,提供海量的英文字体库,用户可以随意下载并应用于各种商业用字,无需考虑其版权问题. 官网地址:h ...
- <web Font的使用>
使用font-face将字体引入web中 先将字体文件复制到项目的font文件夹中,CSS样式如下: @font-face { font-family: 'iconfont'; /*字体名称*/ sr ...
- java 引入自定义字体font后出现的硬盘吃光的问题
有个需求要用美术字体在图片上写字 用自定义的文字有两个方法: 1. Font dynamicFont = Font.createFont(Font.TRUETYPE_FONT, InputStream ...
随机推荐
- java.util下有一个Comparator(比较器)
java.util下有一个Comparator(比较器) 它拥有compare(),用来比较两个方法. 要生成比较器,则用Sort中Sort(List,List(Compate)) 第二种方法更灵活, ...
- TPS和事务响应时间的关系
例子:一个高速路有10个入口,每个入口每秒钟只能进1辆车 1.请问1秒钟最多能进几辆车? TPS=10 2.每辆车需要多长时间进行响应? reponse time = 1 3.改成20辆车 ...
- Linux网卡命名enp3s0说明
用了很多年Linux的我在升级Ubuntu 16.04之后竟然发现我的以太网卡的名字竟然不是eth0,变成了enp3s0,每次想要修改什么配置,都要先ifconfig查一下网卡名,真是让我很郁闷! 去 ...
- Linux环境下Apache配置多个虚拟主机挂载多站点同时运行
博客地址: http://blog.csdn.net/ClydeKuo/article/details/69569474 这篇博客讲的很详细,很详细.
- 编程之美 最长递增子序列 LIS
1. O(N*logN) 解法 先对序列排序, 然后寻找两个序列的最长公共子序列 2. O(N*N) 的动态规划解法 令 LIST[i] 表示以 i 为结尾的最长子序列的长度, 那么 LIST[J] ...
- php 快速读取文件夹下文件列表
在读取某个文件夹下的内容的时候 以前是使用 opendir readdir结合while循环过滤 . ..当前文件夹和父文件夹来操作的. 代码如下: 然后偶然发现了有scandir函数 可以扫描文件夹 ...
- iOS开发之--NSNotificationCenter的使用
NSNotification是IOS中一个调度消息通知的类,采用单例模式设计,在程序中实现传值.回调等地方应用很广 iOS中通知中心NSNotificationCenter应用总结 一.了解几个相关的 ...
- Myeclipse创建Maven项目
1.右击new创建一个Maven Project: 点击Next 继续Next Finish 2.项目成功创建后,项目目录主要有:主代码目录.主资源目录.测试代码目录.测试资源目录.输出目录(代码编译 ...
- 很好用的canvas
一.基本用法 1.要使用canvas元素,需要先给定其width和height来设置绘图区域的大小.canvas中间的文本会在浏览器不支持canvas的情况下显示出来. <canvas widt ...
- Spring-AOP的五种通知和切面的优先级、通知变量声明
SpringAOP的通知分为以下五种: 1前置通知(@before)在连接点执行之前执行的代码 2后置通知(@after)在连接点执行之后执行的代码,不管连接点执行后是否出现异常,后置通知都会执行,但 ...