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的更多相关文章

  1. CSS3与页面布局学习总结(五)——Web Font与Sprite

    一.web font web font是应用在web中的一种字体技术,在CSS中使用font-face定义新的字体.先了解操作系统中的字体: a).安装好操作系统后,会默认安装一些字体,这些字体文件描 ...

  2. 把UI图里的小图标制作成icon font

    一个交互比较多的UI图里面可能会有很多小图标,一般可用sprites图将多个小图标弄成一张大图,或者其它的办法,各种方法的比较可参见博主的另外一篇博客使用css3新属性clip-path制作小图标,本 ...

  3. [函数] Firemonkey Windows 重新计算 Font Baseline

    计算字型 Baseline 是一个不常用的函数,但如果想要显示不同大小文字下方对齐,就得用它来计算字型的 Baseline 才行,如果计算不准,显示的文字就会高高低低不整齐. 在 Firemonkey ...

  4. Html中<font>标签的使用

    Html中<font>标签的使用 <!doctype html> <html lang="en"> <head> <meta ...

  5. 关于firefox对font awesome本地环境无法加载问题

    问题描述 昨天尝试使用font awesome加载字体图标,直接在本地引入相关文件,测试发现图标在chrome和IE环境支持,但是在firefox上怎么都显示不出来. 解决方法 通过测试发现通过htt ...

  6. CSS3使用Font Awesome字体图标的控件样例(按钮,工具栏,输入框)

    按钮上加入font awesome图标,用原生的input button标签无法实现,查看网上的只能通过<a><li></li></a>实现此功能,通过 ...

  7. CSS 中Font Awesome 图标(附码表)

    HTML中缩放的矢量图标,您可以使用CSS所提供的所有特性对它们进行更改,包括:大小.颜色.阴影或者其它任何支持的效果. Font Awesome 传送门:http://fontawesome.das ...

  8. Font Squirrel

    Font Squirrel FontSquirrel:国外免费字体下载网是一个提供高质量商业字体下载网站,提供海量的英文字体库,用户可以随意下载并应用于各种商业用字,无需考虑其版权问题. 官网地址:h ...

  9. <web Font的使用>

    使用font-face将字体引入web中 先将字体文件复制到项目的font文件夹中,CSS样式如下: @font-face { font-family: 'iconfont'; /*字体名称*/ sr ...

  10. java 引入自定义字体font后出现的硬盘吃光的问题

    有个需求要用美术字体在图片上写字 用自定义的文字有两个方法: 1. Font dynamicFont = Font.createFont(Font.TRUETYPE_FONT, InputStream ...

随机推荐

  1. 如何创建Cookie? (选择1项)

    如何创建Cookie? (选择1项) A. 使用new Cookie语句 B. 调用response.addCookie方法 C. 使用Cookie的setMaxAge方法 D. setCookie方 ...

  2. 【BZOJ】1699: [Usaco2007 Jan]Balanced Lineup排队(rmq/树状数组)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1699 我是用树状数组做的..rmq的st的话我就不敲了.. #include <cstdio& ...

  3. 转载 HTTPS 之fiddler抓包、jmeter请求

    转载自 http://suixiang0923.github.io/2016/01/12/%E6%B5%85%E8%B0%88HTTPS%E4%BB%A5%E5%8F%8AFiddler%E6%8A% ...

  4. hive经常使用命令

    hive经常使用命令 show tables; 列出hive里面全部数据表名 desc userProfile; 显示数据表userProfile的基本表字段及字段type desc extended ...

  5. RabbitMQ OS X下安装及常用命令-1

            RabbitMQ的主页在http://www.rabbitmq.com/ . 1. 安装Erlang RabbitMQ是用Erlang编写的,所以需要先安装Erlang,如果有的话跳过 ...

  6. 编程之美 set 14 小飞的电梯调度算法

    题目 电梯每次上升只停一次, 求问电梯停在哪一楼能够保证乘坐电梯的所有乘客爬楼层的层数之和最小 思路 假设电梯的层数是 m, 乘客人数是 n 1. 枚举, 时间复杂度是 o(mn) 2. 滚动解法. ...

  7. 编程之美 海量数据寻找 K 大数

    1. 使用最小堆, 设置最小堆的大小为K, 仅需遍历一遍即可 2. 寻找最大的 K 个数实质上是寻找第 K 大的数. 通过二分法在区间内不断校正 mid 的值来找到 pivot, 时间复杂度为 o(N ...

  8. Web前端设计模式--制作漂亮的弹出层

    设计场景: Ben最近在负责一个购书网站,在网站的首页上,有一个叫做“最新上架”的板块,板块的内容比较简单,只有书籍名称,作者姓名和上架时间(如图),当初设计的时候并i没有过于丰富的构思... 现在问 ...

  9. Mybatis整理系列(01)————传入参数方式以及#{}与${}的区别

    一.在MyBatis的select.insert.update.delete这些元素中都提到了parameterType这个属性.MyBatis现在可以使用的parameterType有基本数据类型和 ...

  10. tortoiseSVN如何回滚(切换至)某个历史版本?

    tortoiseSVN如何回滚(切换至)某个历史版本? 1.右键需要回滚的项目,tortoiseSVN - >show log 2.右键需要回滚的历史版本,选择revert to this re ...