-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpdf_out-fonts.adb
77 lines (70 loc) · 3.17 KB
/
pdf_out-fonts.adb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package body PDF_Out.Fonts is
-- 9.6.2.2 Standard Type 1 Fonts (Standard 14 Fonts)
function Standard_Font_Name (f : Standard_Font_Type) return String is
begin -- Code generation: see pw_work.xls, Fonts (Std)
case f is
when Courier => return "Courier";
when Courier_Bold => return "Courier-Bold";
when Courier_Bold_Oblique => return "Courier-BoldOblique";
when Courier_Oblique => return "Courier-Oblique";
when Helvetica => return "Helvetica";
when Helvetica_Bold => return "Helvetica-Bold";
when Helvetica_Bold_Oblique => return "Helvetica-BoldOblique";
when Helvetica_Oblique => return "Helvetica-Oblique";
when Symbol => return "Symbol";
when Times_Bold => return "Times-Bold";
when Times_Bold_Italic => return "Times-BoldItalic";
when Times_Italic => return "Times-Italic";
when Times_Roman => return "Times-Roman";
when Zapf_Dingbats => return "ZapfDingbats";
end case;
end Standard_Font_Name;
function Font_Dictionary_Name (font_name : String) return String is
begin
return "/Ada_PDF_Font_" & font_name;
end Font_Dictionary_Name;
function Standard_Font_Dictionary_Name (f : Standard_Font_Type) return String is
begin
return "/Ada_PDF_Std_Font_" & Standard_Font_Name (f);
end Standard_Font_Dictionary_Name;
-- 7.8.3 Resource Dictionaries (any resources required by a page).
-- Table 33: Font: A dictionary that maps resource names to font dictionaries.
--
procedure Font_Dictionary (pdf : in out PDF_Out_Stream'Class) is
begin
WL (pdf, " /Font <<"); -- font dictionary
for f in Standard_Font_Type loop
if pdf.std_font_used_in_page (f) then
WL (pdf,
" " &
Standard_Font_Dictionary_Name (f) &
" << /Type /Font /Subtype /Type1 /BaseFont /" &
Standard_Font_Name (f) &
-- 7.9.2.2 Text String Type: "PDFDocEncoding can encode all of
-- the ISO Latin 1 character set and is documented in Annex D."
-- PDFDocEncoding is recognized by the Chrome PDF viewer on Windows but...
-- *isn't* by Adobe Reader X, on Windows! So we resort to another ISO
-- Latin 1 superset: WinAnsiEncoding = Windows Code Page 1252 (Table D.1).
" /Encoding /WinAnsiEncoding " &
" >>");
end if;
end loop;
WL (pdf, " >>");
end Font_Dictionary;
function Current_Font_Name (pdf : PDF_Out_Stream'Class) return String is
begin
if pdf.current_font in Standard_Font_Type then
return Standard_Font_Name (pdf.current_font);
else
return To_String (pdf.ext_font_name);
end if;
end Current_Font_Name;
function Current_Font_Dictionary_Name (pdf : PDF_Out_Stream'Class) return String is
begin
if pdf.current_font in Standard_Font_Type then
return Standard_Font_Dictionary_Name (pdf.current_font);
else
return Font_Dictionary_Name (To_String (pdf.ext_font_name));
end if;
end Current_Font_Dictionary_Name;
end PDF_Out.Fonts;