1#*************************************************************************
2#
3# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4#
5# Copyright 2000, 2010 Oracle and/or its affiliates.
6#
7# OpenOffice.org - a multi-platform office productivity suite
8#
9# This file is part of OpenOffice.org.
10#
11# OpenOffice.org is free software: you can redistribute it and/or modify
12# it under the terms of the GNU Lesser General Public License version 3
13# only, as published by the Free Software Foundation.
14#
15# OpenOffice.org is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18# GNU Lesser General Public License version 3 for more details
19# (a copy is included in the LICENSE file that accompanied this code).
20#
21# You should have received a copy of the GNU Lesser General Public License
22# version 3 along with OpenOffice.org.  If not, see
23# <http://www.openoffice.org/license.html>
24# for a copy of the LGPLv3 License.
25#
26#*************************************************************************
27
28package installer::windows::font;
29
30use installer::files;
31use installer::globals;
32use installer::windows::idtglobal;
33
34
35#################################################################################
36# Creating the file Font.idt dynamically
37# Content:
38# File_ FontTitle
39#################################################################################
40
41sub create_font_table
42{
43	my ($filesref, $basedir) = @_;
44
45	my @fonttable = ();
46
47	installer::windows::idtglobal::write_idt_header(\@fonttable, "font");
48
49	for ( my $i = 0; $i <= $#{$filesref}; $i++ )
50	{
51		my $onefile = ${$filesref}[$i];
52		my $styles = "";
53
54		if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; }
55
56		if ( $styles =~ /\bFONT\b/ )
57		{
58			my %font = ();
59
60			$font{'File_'} = $onefile->{'uniquename'};
61			# $font{'FontTitle'} = $onefile->{'FontName'};	# results in a warning during validation
62			$font{'FontTitle'} = "";
63
64			my $oneline = $font{'File_'} . "\t" . $font{'FontTitle'} . "\n";
65
66			push(@fonttable, $oneline);
67		}
68	}
69
70	# Saving the file
71
72	my $fonttablename = $basedir . $installer::globals::separator . "Font.idt";
73	installer::files::save_file($fonttablename ,\@fonttable);
74	my $infoline = "Created idt file: $fonttablename\n";
75	push(@installer::globals::logfileinfo, $infoline);
76
77}
78
79#################################################################################
80# Reading the Font version from the ttf file, to avoid installation
81# of older files over newer files.
82#################################################################################
83
84sub get_font_version
85{
86	my ( $fontfile ) = @_;
87
88	if ( ! -f $fontfile ) { installer::exiter::exit_program("ERROR: Font file does not exist: \"$fontfile\"", "get_font_version"); }
89
90	my $fontversion = 0;
91	my $infoline = "";
92
93	my $onefile = installer::files::read_binary_file($fontfile);
94
95	if ( $onefile =~ /Version\s+(\d+\.\d+\.*\d*)/ )
96	{
97		$fontversion = $1;
98		$infoline = "FONT: Font \"$fontfile\" version: $fontversion\n";
99		push(@installer::globals::logfileinfo, $infoline);
100	}
101	else
102	{
103		$infoline = "FONT: Could not determine font version: \"$fontfile\"\n";
104		push(@installer::globals::logfileinfo, $infoline);
105	}
106
107	return $fontversion;
108}
109
1101;
111