[bglug] Nuovo post: calendario 2009 pdf per scuole, automatico con imagemagick, inkscape e gimp
k|b|s
kbs@bglug.it
Ven 12 Dic 2008 18:15:29 CET
"Angelo Gelmi [Web3king]" <iwm@web3king.com> writes:
> Angelo
E il vecchio calendario del lug?
ps2pdf bglugcal.ps
--------------------bglugcal.ps----------------------
%!PS-Adobe-1.0
%%Title: bglugcal-1.1.ps
%%Modified by: k|b|s (`echo ti.gulgb@sbk|'rev'`)
%%CreationDate: December 27, 2002
%%License: public domain
%%EndComments
% User definable stuff
% Modify this variable to reflect the year you want to print
% Modifica anche l'intestazione pił sotto
/year 2009 def
% The following are font related and language related.
/day_names [ (Do) (Lu) (Ma) (Me) (Gi) (Ve) (Sa) ] def
/month_names [ (Gennaio) (Febbraio) (Marzo) (Aprile) (Maggio) (Giugno) (Luglio)
(Agosto) (Settembre) (Ottobre) (Novembre) (Dicembre) ] def
/year_font /Times-Bold findfont def
/year_font.scale 48 def
/year_spacing 36 def
/month_font /Helvetica findfont def
/month_font.scale 14 def
%/day_font /Times findfont def
%/day_font.scale 14 def
/day_font /Hevetica findfont def
/day_font.scale 14 def
/footer_font /Hevetica findfont def
/footer_font.scale 10 def
/footer_spacing 18 def
% end of user definable stuff
% Margins for 8.5X11 page
/left_margin 72 def % 1 inch
/right_margin 540 def % 1 inch
/top_margin 756 def % 0.5 inch
/bottom_margin 72 def % 1 inch
% Center justified text
/centered_text { % x1 y x2 str => -
dup stringwidth pop 2 div % Get string width and store just strlen/2
5 2 roll % Move string towards bottom of stack
2 index sub % Use copy of x1 to find width of line
2 div % Find center of two margins
4 -1 roll sub % Subtract half strlen to find start location
3 -1 roll add % Add offset to start location
exch moveto % Move to this location
show % Show string
} def
% Right justified text
/right_text { % x y str => -
dup stringwidth pop % Get string width
4 -1 roll exch sub % Backtrack from right x location
3 -1 roll moveto show % Move to this location and show string
} def
/year_string year 4 string cvs def
year_font year_font.scale scalefont setfont
/bottom_header {
756 year_font.scale sub
year_spacing sub % make bottom half an inch down
} def
/top_footer 72 def
% Modifica l'intestazione del calendario :)
left_margin bottom_header year_spacing add right_margin (2.09k) centered_text
footer_font footer_font.scale scalefont setfont
% Modifica anche il footer, se vuoi
right_margin top_footer footer_spacing sub (Bergamo Linux User Group) right_text
/page_width right_margin left_margin sub def
/page_length bottom_header top_footer sub def
/months_per_line 3 def
/rows_per_page 12 months_per_line idiv def
/month_width page_width months_per_line div def
/month_length page_length rows_per_page div def
/black {0 0 0 setrgbcolor} def
/dow_string { % dow_num -> dow_string
% Number passed in needs to be 0-6 based.
1 sub % Make 0-6 based
day_names exch get % Swap array and dow num and get string
} def
/month_string { % month_num -> month_string
1 sub % Convert to 0-11
month_names exch get % Swap array and month num and get string
} def
/leap_year { % year -> true/false
dup 1752 le
{
4 mod 0 eq
}
{
dup 4 mod 0 eq
1 index 100 mod 0 ne and
1 index 400 mod 0 eq or
} ifelse
exch pop % Return boolean value
} def
/days_in_month { % month year -> daysinmonth
1 index 2 eq % See if we are testing febuary
{
2 -1 roll pop % Don't need month any more
leap_year {29} {28} ifelse
}
{
pop % Don't need year any more
dup 4 eq % Compare month number with 4
1 index 6 eq or % Compare month number with 6 and OR previous test
1 index 9 eq or % Compare month number with 9 and OR previous test
exch 11 eq or % Consume month number and compare with 11
{30} {31} ifelse % Tested months have 30 days, else 31
} ifelse
} def
/days_in_year { % day, month, year -> julian-style day
0 % This will be julian-style day that is returned
1 1 4 index 1 sub % Set up loop for each month before this month
{
2 index days_in_month % Find out how many days in this month
add % Add it to counter created outside loop
} for
exch pop % Get rid of year
3 -1 roll add % Add days of this month into total
exch pop % Get read of year
} def
/FIRST_MISSING_DAY 639799 def
/NUMBER_MISSING_DAYS 11 def
/day_of_week { % day month year -> 0-6
3 copy days_in_year % Return the julian date of this year
1 index 1 sub % Store last year to count previous leap years
dup 4 idiv % Find how many leap years happened during past years
1 index 1700 gt
{ %ifelse
1 index 100 idiv 17 sub % After 1700, skip leap year every 100 years
}
{ %else
0 % Invalid leap years were counted before 1700
} ifelse
sub % Subtract non-valid leap years.
1 index 1600 gt
{ %ifelse
1 index 1600 sub 400 idiv % Quad centries are valid leap years
}
{ %else
0 % Before 1600 will be counted by 4 idiv
} ifelse
add % and back in vaid quad-century leap years
exch 365 mul % Find out how many days have past in past years
add % Add extra leap years that last step missed
add % Add in this years days. Now we have days since 1 jan 1
4 1 roll pop pop pop % Get rid of everything but days
dup FIRST_MISSING_DAY lt % if before reformation on 3 Sep 1752
{ % elseif
1 sub 6 add % 1 Jan 1 was a saturday so add 6 to force this
7 mod % Comput 0-6 value for day of week
}
{ %else
dup FIRST_MISSING_DAY NUMBER_MISSING_DAYS add ge
{ %elseif
1 sub 6 add
NUMBER_MISSING_DAYS sub % Same math but removing missing days
7 mod
}
{ %else
pop 4 % Force to a thursday... This is an invalid request though
} ifelse
} ifelse
} def
/day_width month_width 8 div def % 7 days + 1 space
/day_length month_length 8 div def % 6 lines for days + day string + blank line
/show_month { % month year -> -
month_font month_font.scale scalefont setfont
0 % start x location for month string
7 day_length mul % y location of month string
month_width day_width sub % Remove whitespace included at end of month
4 index month_string % Create month string
centered_text
day_font day_font.scale scalefont setfont
1 1 7 { %for
dup day_width mul % compute right justified x offset
6 day_length mul % Compute y offset
3 -1 roll % Move day number to front of stack
dow_string
right_text
} for
/counter 1 def
1 1 3 index 3 index days_in_month % Setup for loop for each day in month
{ %for
dup 3 index 3 index day_of_week % Find which dow this day is
dup 1 add day_width mul % Convert it into right-justified column offset
6 counter sub % Inverse counter to find row
day_length mul % Compute y offset
4 -1 roll 2 string cvs % Create string from day number
right_text % Display day number
6 eq % Increment row counter if end of week
{ %if
counter 1 add /counter exch def %
} if
} for
pop pop % Remove month and year
} def
left_margin top_footer translate
1 1 12 { gsave
dup 1 sub % duplicate current loop value and subtract 1 (0-11)
months_per_line mod % see which column we are at
month_width mul % Compute x offset
1 index 1 sub % duplicate current loop value and subtract 1 (0-11)
months_per_line idiv % Find which row we are currently on (0 based)
rows_per_page 1 sub % Make 0 based version of rows.
exch sub % invert meanings since origin is at bottom
month_length mul % Compute y offset
translate % Move origin to these x,y positions.
year show_month
grestore
} for
showpage
------------------------------end-----------------------------------
--
mailto: ʇı̣˙ɓnƮɓq@sqʞ
Maggiori informazioni sulla lista
bglug