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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
#! /usr/bin/env ruby
# -*- encoding: utf-8 mode: ruby -*-
# fontpackages.rb
# Copyright (C) 2009-2010 Red Hat, Inc.
# Authors:
# Akira TAGOH <tagoh@redhat.com>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program 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
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
begin
require 'fontpackages/comps'
rescue LoadError
require File.join(File.dirname(__FILE__), '..', 'fontpackages', 'comps')
end
module FontPackages
=begin rdoc
== FontPackages::FontPackages
=end
class FontPackages
def initialize(comps)
@comps = Comps::Root.new(comps)
end # def initialize
def fontpackages(mode = :all)
grps = @comps.groups(:langonly)
grps << @comps.group("fonts")
grps << @comps.group("legacy-fonts")
grps.map do |grp|
case mode
when :all
grp.packages
when :default
grp.packages(:default)
else
STDERR.printf("W: unknown query mode: %s\n", mode)
[]
end.map do |pkg|
pkg.name =~ /-fonts\Z/ ? pkg : nil
end.compact
end.flatten
end # def fontpackages
def supported_languages(package)
retval = []
@comps.groups.each do |grp|
if grp.has_package?(package) then
if grp.name !~ /fonts/ && (grp.lang.nil? || grp.lang.empty?) then
# assuming it may be "en"
retval << "en"
else
retval << grp.lang if !grp.lang.nil? && !grp.lang.empty?
end
end
end
retval
end # def supported_languages
def is_lgc_font?(package)
lang = supported_languages(package)
ll = []
# Latin-1
ll[1] = ['af', 'sq', 'br', 'ca', 'da', 'en', 'en_GB', 'gl', 'de', 'is', 'ga', 'it', 'ku', 'la', 'lb', 'nb', 'oc', 'pt_BR', 'pt', 'es', 'sw', 'sv', 'wa', 'eu'] # XXX: Faroese, Leonese, Rhaeto-Romanic, Scottish Gaelic
# Latin-2
ll[2] = ['bs', 'hr', 'cs', 'de', 'hu', 'pl', 'ro', 'sr', 'sk', 'sl', 'hsb'] # XXX: Lower Sorbian
# Latin-3
ll[3] = ['tr', 'mt', 'eo']
# Latin-4
ll[4] = ['et', 'lv', 'lt'] # XXX: Greenlandic, Sami
# Latin/Cyrillic
ll[5] = ['bg', 'be', 'ru', 'sr', 'mk']
# Latin/Arabic
#ll[6] = ['ar']
# Latin/Greek
ll[7] = ['el', 'ka']
# Latin/Hebrew
#ll[8] = ['he']
# Latin-5
ll[9] = ['tr']
# Latin-6
ll[10] = ['is', 'nb', 'da', 'sv'] # XXX: Faroese
# Latin/Thai
#ll[11] = ['th']
# Latin/Devanagari
# ll12: for Devanagari
# Latin-7
#ll[13] = [] # XXX: Western Baltic, Eastern Baltic
# Latin-8
ll[14] = ['gd', 'cy', 'br']
# Latin-9
ll[15] = ['af', 'sq', 'br', 'ca', 'da', 'nl', 'en', 'en_GB', 'et', 'fi', 'fr', 'gl', 'de', 'is', 'ga', 'it', 'ku', 'la', 'lb', 'ms', 'nb', 'oc', 'pt_BR', 'pt', 'es', 'sw', 'tl', 'wa'] # XXX: Faroese, Rhaeto-Romanic, Scottish Gaelic, Scots
# Latin-10
ll[16] = ['sq', 'hr', 'hu', 'pl', 'ro', 'sl', 'fr', 'de', 'it', 'ga']
retval = false
ll.flatten.compact.sort.uniq.each do |l|
retval ||= lang.include?(l)
break if retval
end
retval
end # def is_lgc_font?
def is_cijk_font?(package)
lang = supported_languages(package)
indic = ['as', 'bn', 'hne', 'gu', 'hi', 'kn', 'ks', 'kok', 'mai', 'ml', 'mr', 'ne', 'or', 'pa', 'sa', 'sd', 'si', 'ta', 'te']
cjk = ['zh', 'ja', 'ko']
retval = false
(cjk + indic).each do |ll|
retval ||= lang.include?(ll)
break if retval
end
retval
end # def is_cijk_font?
end # class FontPackages
end # module FontPackages
|