|
Packit Service |
e3b512 |
/* Copyright (C) 2008 Jonathon Jongsma
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* This library is free software; you can redistribute it and/or
|
|
Packit Service |
e3b512 |
* modify it under the terms of the GNU Library General Public
|
|
Packit Service |
e3b512 |
* License as published by the Free Software Foundation; either
|
|
Packit Service |
e3b512 |
* version 2 of the License, or (at your option) any later version.
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* This library is distributed in the hope that it will be useful,
|
|
Packit Service |
e3b512 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
e3b512 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
e3b512 |
* Library General Public License for more details.
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* You should have received a copy of the GNU Library General Public
|
|
Packit Service |
e3b512 |
* License along with this library; if not, write to the Free Software
|
|
Packit Service |
e3b512 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
Packit Service |
e3b512 |
* 02110-1301, USA.
|
|
Packit Service |
e3b512 |
*/
|
|
Packit Service |
e3b512 |
#ifndef __CAIROMM_WIN32_FONT_H
|
|
Packit Service |
e3b512 |
#define __CAIROMM_WIN32_FONT_H
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
#include <cairo-features.h>
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
#ifdef CAIRO_HAS_WIN32_FONT
|
|
Packit Service |
e3b512 |
#include <cairo-win32.h>
|
|
Packit Service |
e3b512 |
#include <cairomm/fontface.h>
|
|
Packit Service |
e3b512 |
#include <cairomm/scaledfont.h>
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
namespace Cairo
|
|
Packit Service |
e3b512 |
{
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
/** Font support for Microsoft Windows.
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* @since 1.8
|
|
Packit Service |
e3b512 |
*/
|
|
Packit Service |
e3b512 |
class Win32FontFace : public FontFace
|
|
Packit Service |
e3b512 |
{
|
|
Packit Service |
e3b512 |
public:
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
/** Creates a new font for the Win32 font backend based on a LOGFONT. This
|
|
Packit Service |
e3b512 |
* font can then be used with Context::set_font_face() or
|
|
Packit Service |
e3b512 |
* Win32ScaledFont::create().
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* @param logfont A LOGFONTW structure specifying the font to use. The
|
|
Packit Service |
e3b512 |
* lfHeight, lfWidth, lfOrientation and lfEscapement fields of this structure
|
|
Packit Service |
e3b512 |
* are ignored.
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* @since 1.8
|
|
Packit Service |
e3b512 |
*/
|
|
Packit Service |
e3b512 |
static RefPtr<Win32FontFace> create(LOGFONTW* logfont);
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
/** Creates a new font for the Win32 font backend based on a HFONT. This font
|
|
Packit Service |
e3b512 |
* can then be used with Context::set_font_face() or Win32ScaledFont::create().
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* @param font An HFONT structure specifying the font to use.
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* @since 1.8
|
|
Packit Service |
e3b512 |
*/
|
|
Packit Service |
e3b512 |
static RefPtr<Win32FontFace> create(HFONT font);
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
/** Creates a new font for the Win32 font backend based on a LOGFONT. This
|
|
Packit Service |
e3b512 |
* font can then be used with Context::set_font_face() or
|
|
Packit Service |
e3b512 |
* Win32ScaledFont::create().
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* @param logfont A LOGFONTW structure specifying the font to use. If hfont is
|
|
Packit Service |
e3b512 |
* null then the lfHeight, lfWidth, lfOrientation and lfEscapement fields of
|
|
Packit Service |
e3b512 |
* this structure are ignored. Otherwise lfWidth, lfOrientation and
|
|
Packit Service |
e3b512 |
* lfEscapement must be zero.
|
|
Packit Service |
e3b512 |
* @param font An HFONT that can be used when the font matrix is a scale by
|
|
Packit Service |
e3b512 |
* -lfHeight and the CTM is identity.
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* @since 1.8
|
|
Packit Service |
e3b512 |
*/
|
|
Packit Service |
e3b512 |
static RefPtr<Win32FontFace> create(LOGFONTW* logfont, HFONT font);
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
protected:
|
|
Packit Service |
e3b512 |
Win32FontFace(LOGFONTW* logfont);
|
|
Packit Service |
e3b512 |
Win32FontFace(HFONT font);
|
|
Packit Service |
e3b512 |
Win32FontFace(LOGFONTW* logfont, HFONT font);
|
|
Packit Service |
e3b512 |
};
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
/** Scaled Font implementation for Microsoft Windows fonts.
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* @since 1.8
|
|
Packit Service |
e3b512 |
*/
|
|
Packit Service |
e3b512 |
class Win32ScaledFont : public ScaledFont
|
|
Packit Service |
e3b512 |
{
|
|
Packit Service |
e3b512 |
public:
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
/** Creates a scaled font for the given Win32FontFace.
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* @since 1.8
|
|
Packit Service |
e3b512 |
*/
|
|
Packit Service |
e3b512 |
static RefPtr<Win32ScaledFont> create(const RefPtr<Win32FontFace>& font_face,
|
|
Packit Service |
e3b512 |
const Matrix& font_matrix,
|
|
Packit Service |
e3b512 |
const Matrix& ctm,
|
|
Packit Service |
e3b512 |
const FontOptions& options = FontOptions());
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
/** Selects the font into the given device context and changes the map mode
|
|
Packit Service |
e3b512 |
* and world transformation of the device context to match that of the font.
|
|
Packit Service |
e3b512 |
* This function is intended for use when using layout APIs such as Uniscribe
|
|
Packit Service |
e3b512 |
* to do text layout with the cairo font. After finishing using the device
|
|
Packit Service |
e3b512 |
* context, you must call done_font() to release any resources allocated by
|
|
Packit Service |
e3b512 |
* this function.
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* See get_metrics_factor() for converting logical coordinates from the device
|
|
Packit Service |
e3b512 |
* context to font space.
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* Normally, calls to SaveDC() and RestoreDC() would be made around the use of
|
|
Packit Service |
e3b512 |
* this function to preserve the original graphics state.
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* @param scaled_font A cairo_scaled_font_t from the Win32 font backend. Such
|
|
Packit Service |
e3b512 |
* an object can be created with Win32FontFace::create_for_logfontw().
|
|
Packit Service |
e3b512 |
* @param hdc a device context
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* @since 1.8
|
|
Packit Service |
e3b512 |
*/
|
|
Packit Service |
e3b512 |
void select_font(HDC hdc);
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
/** Releases any resources allocated by select_font()
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* @since 1.8
|
|
Packit Service |
e3b512 |
*/
|
|
Packit Service |
e3b512 |
void done_font();
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
/** Gets a scale factor between logical coordinates in the coordinate space
|
|
Packit Service |
e3b512 |
* used by select_font() (that is, the coordinate system used by the Windows
|
|
Packit Service |
e3b512 |
* functions to return metrics) and font space coordinates.
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* @return factor to multiply logical units by to get font space coordinates.
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* @since 1.8
|
|
Packit Service |
e3b512 |
*/
|
|
Packit Service |
e3b512 |
double get_metrics_factor() const;
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
/** Gets the transformation mapping the logical space used by this scaled font
|
|
Packit Service |
e3b512 |
* to device space.
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* @param logical_to_device matrix to return
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* @since 1.8
|
|
Packit Service |
e3b512 |
*/
|
|
Packit Service |
e3b512 |
void get_logical_to_device(Matrix& logical_to_device) const;
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
/** Gets the transformation mapping device space to the logical space used by
|
|
Packit Service |
e3b512 |
* this scaled font.
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* @param device_to_logical matrix to return
|
|
Packit Service |
e3b512 |
*
|
|
Packit Service |
e3b512 |
* @since 1.8
|
|
Packit Service |
e3b512 |
*/
|
|
Packit Service |
e3b512 |
void get_device_to_logical(Matrix& device_to_logical) const;
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
protected:
|
|
Packit Service |
e3b512 |
Win32ScaledFont(const RefPtr<Win32FontFace>& font_face,
|
|
Packit Service |
e3b512 |
const Matrix& font_matrix,
|
|
Packit Service |
e3b512 |
const Matrix& ctm,
|
|
Packit Service |
e3b512 |
const FontOptions& options = FontOptions());
|
|
Packit Service |
e3b512 |
};
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
}
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
#endif // CAIRO_HAS_WIN32_FONT
|
|
Packit Service |
e3b512 |
|
|
Packit Service |
e3b512 |
#endif // __CAIROMM_WIN32_FONT_H
|