w32font.h 2.88 KB
Newer Older
1
/* Shared GDI and Uniscribe Font backend declarations for the Windows API.
Paul Eggert's avatar
Paul Eggert committed
2
   Copyright (C) 2007-2019 Free Software Foundation, Inc.
Jason Rumney's avatar
Jason Rumney committed
3 4 5

This file is part of GNU Emacs.

6
GNU Emacs is free software: you can redistribute it and/or modify
Jason Rumney's avatar
Jason Rumney committed
7
it under the terms of the GNU General Public License as published by
8 9
the Free Software Foundation, either version 3 of the License, or (at
your option) any later version.
Jason Rumney's avatar
Jason Rumney committed
10 11 12 13 14 15 16

GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
Paul Eggert's avatar
Paul Eggert committed
17
along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
Jason Rumney's avatar
Jason Rumney committed
18 19 20 21

#ifndef EMACS_W32FONT_H
#define EMACS_W32FONT_H

22
#include "font.h"
Jason Rumney's avatar
Jason Rumney committed
23

Juanma Barranquero's avatar
Juanma Barranquero committed
24 25
/* Bit 17 of ntmFlags in NEWTEXTMETRIC is set for PostScript OpenType fonts,
   bit 18 for TrueType OpenType fonts, bit 20 for Type1 fonts.  */
26 27 28 29 30 31 32 33 34 35 36
#ifndef NTM_PS_OPENTYPE
#define NTM_PS_OPENTYPE 0x00020000
#endif
#ifndef NTM_TT_OPENTYPE
#define NTM_TT_OPENTYPE 0x00040000
#endif
#ifndef NTM_TYPE1
#define NTM_TYPE1 0x00100000
#endif

#define NTMFLAGS_OPENTYPE (NTM_PS_OPENTYPE | NTM_TT_OPENTYPE)
Jason Rumney's avatar
Jason Rumney committed
37

38 39
struct w32_metric_cache
{
40
  short lbearing, rbearing, width, ascent, descent;
41 42 43 44 45 46 47
  unsigned char status;
};

#define W32METRIC_NO_ATTEMPT 0
#define W32METRIC_SUCCESS 1
#define W32METRIC_FAIL 2

Jason Rumney's avatar
Jason Rumney committed
48 49 50 51 52
/* The actual structure for a w32 font, that can be cast to struct font.
   The Uniscribe backend extends this.  */
struct w32font_info
{
  struct font font;
53
  TEXTMETRICW metrics;
54
  unsigned int glyph_idx;
55 56
  struct w32_metric_cache **cached_metrics;
  int n_cache_blocks;
57
  HFONT hfont;
Jason Rumney's avatar
Jason Rumney committed
58 59
};

60 61 62 63
/* Macros for getting OS specific information from a font struct.  */
#define FONT_HANDLE(f) (((struct w32font_info *)(f))->hfont)
#define FONT_TEXTMETRIC(f) (((struct w32font_info *)(f))->metrics)

64 65
#define CACHE_BLOCKSIZE 128

Dmitry Antipov's avatar
Dmitry Antipov committed
66
Lisp_Object w32font_get_cache (struct frame *fe);
Dmitry Antipov's avatar
Dmitry Antipov committed
67
Lisp_Object w32font_list_internal (struct frame *f,
Jan D's avatar
Jan D committed
68
                                   Lisp_Object font_spec,
69
                                   bool opentype_only);
Dmitry Antipov's avatar
Dmitry Antipov committed
70
Lisp_Object w32font_match_internal (struct frame *f,
Jan D's avatar
Jan D committed
71
                                    Lisp_Object font_spec,
72
                                    bool opentype_only);
Dmitry Antipov's avatar
Dmitry Antipov committed
73
int w32font_open_internal (struct frame *f, Lisp_Object font_entity,
Jan D's avatar
Jan D committed
74
                           int pixel_size, Lisp_Object font_object);
75
void w32font_close (struct font *font);
Jan D's avatar
Jan D committed
76
int w32font_has_char (Lisp_Object entity, int c);
77
void w32font_text_extents (struct font *font, const unsigned *code, int nglyphs,
78
			   struct font_metrics *metrics);
Jan D's avatar
Jan D committed
79
int w32font_draw (struct glyph_string *s, int from, int to,
80
                  int x, int y, bool with_background);
Jan D's avatar
Jan D committed
81 82 83 84 85


int uniscribe_check_otf (LOGFONT *font, Lisp_Object otf_spec);

Lisp_Object intern_font_name (char *);
86

87 88
extern void globals_of_w32font (void);

Jason Rumney's avatar
Jason Rumney committed
89
#endif