2 * PostScript driver downloadable font functions
4 * Copyright 2002 Huw D M Davies for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include "wine/debug.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
33 /****************************************************************************
36 static void get_download_name(PSDRV_PDEVICE *physDev, LPOUTLINETEXTMETRICA
41 len = strlen((char*)potm + (ptrdiff_t)potm->otmpFullName) + 1;
42 *str = HeapAlloc(GetProcessHeap(),0,len);
43 strcpy(*str, (char*)potm + (ptrdiff_t)potm->otmpFullName);
46 while((p = strchr(p, ' ')))
52 /****************************************************************************
55 static DOWNLOAD *is_font_downloaded(PSDRV_PDEVICE *physDev, char *ps_name)
59 for(pdl = physDev->downloaded_fonts; pdl; pdl = pdl->next)
60 if(!strcmp(pdl->ps_name, ps_name))
65 /****************************************************************************
66 * PSDRV_SelectDownloadFont
68 * Set up physDev->font for a downloadable font
71 BOOL PSDRV_SelectDownloadFont(PSDRV_PDEVICE *physDev)
74 LPOUTLINETEXTMETRICA potm;
75 DWORD len = GetOutlineTextMetricsA(physDev->hdc, 0, NULL);
77 potm = HeapAlloc(GetProcessHeap(), 0, len);
78 GetOutlineTextMetricsA(physDev->hdc, len, potm);
79 get_download_name(physDev, potm, &ps_name);
81 physDev->font.fontloc = Download;
82 physDev->font.fontinfo.Download = is_font_downloaded(physDev, ps_name);
84 physDev->font.size = INTERNAL_YWSTODS(physDev->dc, /* ppem */
85 potm->otmTextMetrics.tmAscent +
86 potm->otmTextMetrics.tmDescent -
87 potm->otmTextMetrics.tmInternalLeading);
88 physDev->font.underlineThickness = potm->otmsUnderscoreSize;
89 physDev->font.underlinePosition = potm->otmsUnderscorePosition;
90 physDev->font.strikeoutThickness = potm->otmsStrikeoutSize;
91 physDev->font.strikeoutPosition = potm->otmsStrikeoutPosition;
93 HeapFree(GetProcessHeap(), 0, ps_name);
94 HeapFree(GetProcessHeap(), 0, potm);
98 /****************************************************************************
99 * PSDRV_WriteSetDownloadFont
101 * Write setfont for download font.
104 BOOL PSDRV_WriteSetDownloadFont(PSDRV_PDEVICE *physDev)
107 LPOUTLINETEXTMETRICA potm;
108 DWORD len = GetOutlineTextMetricsA(physDev->hdc, 0, NULL);
111 assert(physDev->font.fontloc == Download);
113 potm = HeapAlloc(GetProcessHeap(), 0, len);
114 GetOutlineTextMetricsA(physDev->hdc, len, potm);
116 get_download_name(physDev, potm, &ps_name);
118 if(physDev->font.fontinfo.Download == NULL) {
119 pdl = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pdl));
120 pdl->ps_name = HeapAlloc(GetProcessHeap(), 0, strlen(ps_name)+1);
121 strcpy(pdl->ps_name, ps_name);
124 if(physDev->pi->ppd->TTRasterizer == RO_Type42) {
125 pdl->typeinfo.Type42 = T42_download_header(physDev, potm,
129 pdl->typeinfo.Type1 = T1_download_header(physDev, potm, ps_name);
133 pdl->next = physDev->downloaded_fonts;
134 physDev->downloaded_fonts = pdl;
136 physDev->font.fontinfo.Download = pdl;
140 PSDRV_WriteSetFont(physDev, ps_name, physDev->font.size,
141 physDev->font.escapement);
143 HeapFree(GetProcessHeap(), 0, ps_name);
144 HeapFree(GetProcessHeap(), 0, potm);
148 void get_glyph_name(HDC hdc, WORD index, char *name)
151 sprintf(name, "g%04x", index);
155 /****************************************************************************
156 * PSDRV_WriteDownloadGlyphShow
158 * Download and write out a number of glyphs
161 BOOL PSDRV_WriteDownloadGlyphShow(PSDRV_PDEVICE *physDev, WORD *glyphs,
165 char g_name[MAX_G_NAME + 1];
166 assert(physDev->font.fontloc == Download);
168 switch(physDev->font.fontinfo.Download->type) {
170 for(i = 0; i < count; i++) {
171 get_glyph_name(physDev->hdc, glyphs[i], g_name);
172 T42_download_glyph(physDev, physDev->font.fontinfo.Download,
174 PSDRV_WriteGlyphShow(physDev, g_name);
179 for(i = 0; i < count; i++) {
180 get_glyph_name(physDev->hdc, glyphs[i], g_name);
181 T1_download_glyph(physDev, physDev->font.fontinfo.Download,
183 PSDRV_WriteGlyphShow(physDev, g_name);
188 ERR("Type = %d\n", physDev->font.fontinfo.Download->type);
194 /****************************************************************************
195 * PSDRV_EmptyDownloadList
197 * Clear the list of downloaded fonts
200 BOOL PSDRV_EmptyDownloadList(PSDRV_PDEVICE *physDev)
203 if(physDev->font.fontloc == Download) {
204 physDev->font.set = FALSE;
205 physDev->font.fontinfo.Download = NULL;
208 pdl = physDev->downloaded_fonts;
209 physDev->downloaded_fonts = NULL;
213 T42_free(pdl->typeinfo.Type42);
217 T1_free(pdl->typeinfo.Type1);
221 ERR("Type = %d\n", pdl->type);
225 HeapFree(GetProcessHeap(), 0, pdl->ps_name);
228 HeapFree(GetProcessHeap(), 0, old);