src/metric.c

/* [<][>]
[^][v][top][bottom][index][help] */

FUNCTIONS

This source file includes following functions.
  1. VF_FreeMetric1
  2. VF_FreeMetric2
  3. vf_alloc_metric1
  4. vf_alloc_metric2
  5. vf_metric1_to_metric2
  6. vf_dump_metric1
  7. vf_dump_metric2

   1 /*
   2  * metric.c - font metrics
   3  * by Hirotsugu Kakugawa
   4  */
   5 /*
   6  * Copyright (C) 1996-1998 Hirotsugu Kakugawa. 
   7  * All rights reserved.
   8  *
   9  * This file is part of the VFlib Library.  This library is free
  10  * software; you can redistribute it and/or modify it under the terms of
  11  * the GNU Library General Public License as published by the Free
  12  * Software Foundation; either version 2 of the License, or (at your
  13  * option) any later version.  This library is distributed in the hope
  14  * that it will be useful, but WITHOUT ANY WARRANTY; without even the
  15  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  16  * PURPOSE.  See the GNU Library General Public License for more details.
  17  * You should have received a copy of the GNU Library General Public
  18  * License along with this library; if not, write to the Free Software
  19  * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20  */
  21 
  22 #include "config.h"
  23 #include <stdio.h>
  24 #include <stdlib.h>
  25 #include <ctype.h>
  26 #ifdef HAVE_UNISTD_H
  27 #  include <unistd.h>
  28 #endif
  29 #include <sys/types.h>
  30 #include <sys/param.h>
  31 
  32 #include "VFlib-3_6.h"
  33 #include "VFsys.h"
  34 #include "consts.h"
  35 
  36 
  37 
  38 /**
  39  **   VF_FreeMetric1
  40  **/
  41 Public void
  42 VF_FreeMetric1(VF_METRIC1 metric1)
     /* [<][>][^][v][top][bottom][index][help] */
  43 {
  44   vf_error = 0;
  45   vf_free(metric1);
  46 }
  47 
  48 
  49 /**
  50  **   VF_FreeMetric2
  51  **/
  52 Public void
  53 VF_FreeMetric2(VF_METRIC2 metric2)
     /* [<][>][^][v][top][bottom][index][help] */
  54 {
  55   vf_error = 0;
  56   vf_free(metric2);
  57 }
  58 
  59 
  60 Glocal VF_METRIC1
  61 vf_alloc_metric1(void)
     /* [<][>][^][v][top][bottom][index][help] */
  62 {
  63   VF_METRIC1 metric;
  64   
  65   ALLOC_IF_ERR(metric, struct vf_s_metric1)
  66     return NULL;
  67   metric->bbx_width  = 0;
  68   metric->bbx_height = 0;
  69   metric->off_x      = 0;
  70   metric->off_y      = 0;
  71   metric->mv_x       = 0;
  72   metric->mv_y       = 0;
  73   return metric;
  74 }
  75 
  76 Glocal VF_METRIC2
  77 vf_alloc_metric2(void)
     /* [<][>][^][v][top][bottom][index][help] */
  78 {
  79   VF_METRIC2 metric;
  80   
  81   ALLOC_IF_ERR(metric, struct vf_s_metric2)
  82     return NULL;
  83   metric->bbx_width  = 0;
  84   metric->bbx_height = 0;
  85   metric->off_x      = 0;
  86   metric->off_y      = 0;
  87   metric->mv_x       = 0;
  88   metric->mv_y       = 0;
  89   return metric;
  90 }
  91 
  92 
  93 Glocal void
  94 vf_metric1_to_metric2(VF_METRIC1 met1, double dpi, VF_METRIC2 met2)
     /* [<][>][^][v][top][bottom][index][help] */
  95 {
  96   if ((met1 == NULL) || (met2 == NULL))
  97     return;
  98   met2->bbx_width  = (int)(met1->bbx_width * (dpi / 72.27) + 0.5);
  99   met2->bbx_height = (int)(met1->bbx_height * (dpi / 72.27) + 0.5);
 100   met2->off_x      = (int)(met1->off_x * (dpi / 72.27) + 0.5);
 101   met2->off_y      = (int)(met1->off_y * (dpi / 72.27) + 0.5);
 102   met2->mv_x       = (int)(met1->mv_x * (dpi / 72.27) + 0.5);
 103   met2->mv_y       = (int)(met1->mv_y * (dpi / 72.27) + 0.5);
 104 }
 105 
 106 
 107 Glocal void
 108 vf_dump_metric1(VF_METRIC1 met)
     /* [<][>][^][v][top][bottom][index][help] */
 109 {
 110   printf("Metric1: \n");
 111   printf("   bbx (%fx%f)\n", met->bbx_width, met->bbx_height);
 112   printf("   off (%f,%f)\n", met->off_x, met->off_y);
 113   printf("   mv  (%f,%f)\n", met->mv_x, met->mv_y);
 114 }
 115 
 116 Glocal void
 117 vf_dump_metric2(VF_METRIC2 met)
     /* [<][>][^][v][top][bottom][index][help] */
 118 {
 119   printf("Metric2: \n");
 120   printf("   bbx (%dx%d)\n", met->bbx_width, met->bbx_height);
 121   printf("   off (%d,%d)\n", met->off_x, met->off_y);
 122   printf("   mv  (%d,%d)\n", met->mv_x, met->mv_y);
 123 }
 124 
 125 /*EOF*/

/* [<][>][^][v][top][bottom][index][help] */