Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file dvicairo.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116(**************************************************************************)(* *)(* Copyright (C) Johannes Kanig, Stephane Lescuyer *)(* Jean-Christophe Filliatre, Romain Bardou and Francois Bobot *)(* *)(* This software is free software; you can redistribute it and/or *)(* modify it under the terms of the GNU Library General Public *)(* License version 2.1, with the special exception on linking *)(* described in file LICENSE. *)(* *)(* This software 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. *)(* *)(**************************************************************************)openFormatopenDviinterptypemulti_page_pic={pic:Cairo.context;x_origin:float;y_origin:float;}letconversion=0.3937*.72.letpoint_of_cmcm=conversion*.cmletfonts_known=Hashtbl.create30letfind_fontfont=letfont_name=font.Fonts.glyphs_tagintryHashtbl.findfonts_knownfont_namewithNot_found->ifDefaults.get_debug()thenprintf"Cairo : Loading font@.";letface=font.Fonts.glyphs_ftinletf=Cairo.Ft.create_for_ft_facefaceinHashtbl.addfonts_knownfont_namef;fletset_source_colorpic=function|RGB(red,green,blue)->ifDefaults.get_debug()thenprintf"Use color RGB (%f,%f,%f)@."redgreenblue;Cairo.set_source_rgbpicredgreenblue|Grayg->ifDefaults.get_debug()thenprintf"Use color Gray (%f)@."g;Cairo.set_source_rgbpicggg|CMYK_->failwith"dvicairo : I don't know how to convert CMYKto RGB and cairo doesn't \
support it"|HSB_->failwith"dvicairo : I'm lazy I haven't written this conversion"(* http://en.wikipedia.org/wiki/HSL_and_HSV#Conversion_from_HSV_to_RGB
and in color.ml*)letfill_rectsdinfox1y1wh=letx1=point_of_cmx1+.s.x_originandy1=point_of_cmy1+.s.y_originandw=point_of_cmwandh=point_of_cmhinifDefaults.get_debug()thenprintf"Draw a rectangle in (%f,%f) with w=%f h=%f@."x1y1wh;Cairo.saves.pic;set_source_colors.picdinfo.Dviinterp.color;Cairo.rectangles.picx1y1~w~h;Cairo.fills.pic;Cairo.restores.picletdraw_type1stext_type1=letdinfo=text_type1.c_infoinletfont=text_type1.c_fontinletchar=text_type1.c_glyphinletx,y=text_type1.c_posinletf=find_fontfontinletchar=font.Fonts.glyphs_enc(Int32.to_intchar)andx=point_of_cmx+.s.x_originandy=point_of_cmy+.s.y_originandratio=point_of_cmfont.Fonts.glyphs_ratio_cmin(ifDefaults.get_debug()thentryprintf"Draw the char %i(%c) in (%f,%f) x%f@."char(Char.chrchar)xyratiowith_->printf"Draw the char %i in (%f,%f) x%f@."charxyratio);Cairo.saves.pic;set_source_colors.picdinfo.Dviinterp.color;Cairo.Font_face.sets.picf;Cairo.set_font_sizes.picratio;(* slant and extend *)(matchfont.Fonts.slantwith|SomeawhenDefaults.get_verbosity()->printf"slant of %f not used@."a|Some_|None->());(matchfont.Fonts.extendwith|SomeawhenDefaults.get_debug()->printf"extend of %f not used@."a|Some_|None->());Cairo.Glyph.shows.pic[|{Cairo.Glyph.index=char;Cairo.Glyph.x;Cairo.Glyph.y}|];Cairo.strokes.pic;Cairo.restores.piclet_specials_s_infoxxxxy=ifDefaults.get_debug()thenprintf"specials : \"%s\" at (%f,%f)@."xxxxyletrecdraw_stringstext=draw_commandss(decompose_texttext)anddraw_commands=function|Fill_rect(info,x,y,w,h)->fill_rectsinfoxywh|Draw_texttext->draw_stringstext|Specials(info,xxx,x,y)->_specialssinfoxxxxy|Draw_text_type1text_type1->draw_type1stext_type1anddraw_commandss=List.iter(draw_commands)letdraw=draw_commands