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. 敏捷软件开发实践-Code Review Process(转)

    介绍: 在敏捷软件开发中,从代码的产生速度上来看,要比 传统Waterfall产生速度高很多.因为我们把时间安排的更加紧凑了.那么这么多的代码,如何能保证这些代码质量呢?很多人可能直接想到静态代码检测 ...

  2. 去掉if

    修改前 namespace CleanCSharp.Methods.Dirty {     class BooleanSwitchingArgumentsExample     {         p ...

  3. typecho篇

    百度百科的介绍: Typecho是由type和echo两个词合成的,来自于开发团队的头脑风暴. Typecho基于PHP5开发,支持多种数据库,是一款内核强健﹑扩展 方便﹑体验友好﹑运行流畅的轻量级开 ...

  4. 【Debian】时间设置

    http://blog.linuxphp.org/archives/567/ http://www.dedecms.com/knowledge/servers/linux-bsd/2012/0819/ ...

  5. 织梦dedecms整合discuz论坛的操作方法

    织梦dedecms和discuz论坛整合主要用途,是让两个系统共享用户数据,同一个用户可以在两个网站都可以登录.在我们制作织梦cms模板的时候,有时需要整合discuz里的东细.本文主要讲解一下ded ...

  6. Spring_day04--SSH框架整合过程

    SSH框架整合过程 第一步 导入jar包 第二步 搭建struts2环境 (1)创建action,创建struts.xml配置文件,配置action (2)配置struts2的过滤器 第三步 搭建hi ...

  7. mysql触发器小实验

    今天实验了一下mysql的触发器 mysql> use test; Database changed mysql> desc time; +-------+---------------- ...

  8. phpcms v9表单实现问答咨询功能

    本文转自别人 phpcms v9的留言板插件可以安装留言板,做问答咨询,那样的话有很多东西需要修改,也有人发现phpcms v9有个表单向导功能,只能留言,不能回复,今天仿站网:新源网络工作室告诉大家 ...

  9. poj_3259 负权和环

    题目大意 N个点,M条双向路径,W条单向路径.从双向路径的一端到另一端所花费时间为正值,从单向路径的源点到终点所花时间为负值.问是否存在一条从A出发,再回到A的回路,满足回到A的时间小于出发时间. 题 ...

  10. Git详解之二 Git细节拾遗

    git知识点详解 文件状态 现在我们手上已经有了一个真实项目的 Git 仓库,并从这个仓库中取出了所有文件的工作拷贝.接下来,对这些文件作些修改,在完成了一个阶段的目标之后,提交本次更新到仓库. 请记 ...